Skip to content

Commit

Permalink
Fix recurrence error
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinMoskala committed Dec 16, 2017
1 parent 0111340 commit 789e92c
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

fun Activity.bindToClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { findViewById(viewId) }
= bindToClickP { findViewById(viewId) }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { view.findViewById(viewId) }
= bindToClickP { view.findViewById(viewId) }

fun android.support.v4.app.Fragment.bindToClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { view!!.findViewById(viewId) }
= bindToClickP { view!!.findViewById(viewId) }

fun FrameLayout.bindToClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { findViewById(viewId) }
= bindToClickP { findViewById(viewId) }

fun Activity.bindToClick(viewProvider: ()->View): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { viewProvider() }
= bindToClickP { viewProvider() }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToClick(viewProvider: ()->View): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { viewProvider() }
= bindToClickP { viewProvider() }

fun android.support.v4.app.Fragment.bindToClick(viewProvider: ()->View): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { viewProvider() }
= bindToClickP { viewProvider() }

fun View.bindToClick(): ReadWriteProperty<Any?, () -> Unit>
= bindToClick { this }
= bindToClickP { this }

private fun bindToClick(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
private fun bindToClickP(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
= OnClickBinding(lazy(viewProvider))

private class OnClickBinding(viewProvider: Lazy<View>) : ReadWriteProperty<Any?, () -> Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

fun Activity.bindToEditText(@IdRes editTextId: Int): ReadWriteProperty<Any?, String>
= bindToEditText { findViewById(editTextId) as EditText }
= bindToEditTextP { findViewById(editTextId) as EditText }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToEditText(@IdRes viewId: Int): ReadWriteProperty<Any?, String>
= bindToEditText { view.findViewById(viewId) as EditText }
= bindToEditTextP { view.findViewById(viewId) as EditText }

fun android.support.v4.app.Fragment.bindToEditText(@IdRes viewId: Int): ReadWriteProperty<Any?, String>
= bindToEditText { view!!.findViewById(viewId) as EditText }
= bindToEditTextP { view!!.findViewById(viewId) as EditText }

fun FrameLayout.bindToEditText(@IdRes viewId: Int): ReadWriteProperty<Any?, String>
= bindToEditText { findViewById(viewId) as EditText }
= bindToEditTextP { findViewById(viewId) as EditText }

fun EditText.bindToEditText(): ReadWriteProperty<Any?, String>
= bindToEditText { this }
= bindToEditTextP { this }

fun Activity.bindToEditText(viewProvider: () -> EditText): ReadWriteProperty<Any?, String>
= bindToEditText { viewProvider() }
= bindToEditTextP { viewProvider() }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToEditText(viewProvider: () -> EditText): ReadWriteProperty<Any?, String>
= bindToEditText { viewProvider() }
= bindToEditTextP { viewProvider() }

fun android.support.v4.app.Fragment.bindToEditText(viewProvider: () -> EditText): ReadWriteProperty<Any?, String>
= bindToEditText { viewProvider() }
= bindToEditTextP { viewProvider() }

private fun bindToEditText(viewProvider: () -> EditText): ReadWriteProperty<Any?, String>
private fun bindToEditTextP(viewProvider: () -> EditText): ReadWriteProperty<Any?, String>
= EditTextViewTextBinding(lazy(viewProvider))

private class EditTextViewTextBinding(lazyViewProvider: Lazy<EditText>) : ReadWriteProperty<Any?, String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

fun Activity.bindToEditorActions(@IdRes editTextId: Int, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate, { findViewById(editTextId) as EditText })
= bindToEditorActionsP(predicate, { findViewById(editTextId) as EditText })

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToEditorActions(@IdRes viewId: Int, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate) { view.findViewById(viewId) as EditText }
= bindToEditorActionsP(predicate) { view.findViewById(viewId) as EditText }

fun android.support.v4.app.Fragment.bindToEditorActions(@IdRes viewId: Int, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate) { view!!.findViewById(viewId) as EditText }
= bindToEditorActionsP(predicate) { view!!.findViewById(viewId) as EditText }

fun FrameLayout.bindToEditorActions(@IdRes viewId: Int, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate) { findViewById(viewId) as EditText }
= bindToEditorActionsP(predicate) { findViewById(viewId) as EditText }

fun Activity.bindToEditorActions(viewProvider: ()->EditText, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate, { viewProvider() })
fun Activity.bindToEditorActions(viewProvider: () -> EditText, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActionsP(predicate, { viewProvider() })

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToEditorActions(viewProvider: ()->EditText, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate) { viewProvider() }
fun Fragment.bindToEditorActions(viewProvider: () -> EditText, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActionsP(predicate) { viewProvider() }

fun android.support.v4.app.Fragment.bindToEditorActions(viewProvider: ()->EditText, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate) { viewProvider() }
fun android.support.v4.app.Fragment.bindToEditorActions(viewProvider: () -> EditText, predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActionsP(predicate) { viewProvider() }

fun EditText.bindToEditorActions(predicate: (Int?, Int?) -> Boolean): ReadWriteProperty<Any?, () -> Unit>
= bindToEditorActions(predicate) { this }
= bindToEditorActionsP(predicate) { this }

private fun bindToEditorActions(predicate: (Int?, Int?) -> Boolean, viewProvider: () -> EditText): ReadWriteProperty<Any?, () -> Unit>
private fun bindToEditorActionsP(predicate: (Int?, Int?) -> Boolean, viewProvider: () -> EditText): ReadWriteProperty<Any?, () -> Unit>
= OnEditorActionBinding(predicate, lazy(viewProvider))

private class OnEditorActionBinding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

fun Activity.bindToErrorId(@IdRes editTextId: Int): ReadWriteProperty<Any?, Int?>
= bindToErrorId { findViewById(editTextId) as EditText }
= bindToErrorIdP { findViewById(editTextId) as EditText }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToErrorId(@IdRes viewId: Int): ReadWriteProperty<Any?, Int?>
= bindToErrorId { view.findViewById(viewId) as EditText }
= bindToErrorIdP { view.findViewById(viewId) as EditText }

fun android.support.v4.app.Fragment.bindToErrorId(@IdRes viewId: Int): ReadWriteProperty<Any?, Int?>
= bindToErrorId { view!!.findViewById(viewId) as EditText }
= bindToErrorIdP { view!!.findViewById(viewId) as EditText }

fun FrameLayout.bindToErrorId(@IdRes viewId: Int): ReadWriteProperty<Any?, Int?>
= bindToErrorId { findViewById(viewId) as EditText }
= bindToErrorIdP { findViewById(viewId) as EditText }

fun Activity.bindToErrorId(viewProvider: () -> EditText): ReadWriteProperty<Any?, Int?>
= bindToErrorId { viewProvider() }
= bindToErrorIdP { viewProvider() }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToErrorId(viewProvider: () -> EditText): ReadWriteProperty<Any?, Int?>
= bindToErrorId { viewProvider() }
= bindToErrorIdP { viewProvider() }

fun android.support.v4.app.Fragment.bindToErrorId(viewProvider: () -> EditText): ReadWriteProperty<Any?, Int?>
= bindToErrorId { viewProvider() }
= bindToErrorIdP { viewProvider() }

fun EditText.bindToErrorId(): ReadWriteProperty<Any?, Int?>
= bindToErrorId { this }
= bindToErrorIdP { this }

private fun bindToErrorId(viewProvider: () -> EditText): ReadWriteProperty<Any?, Int?>
private fun bindToErrorIdP(viewProvider: () -> EditText): ReadWriteProperty<Any?, Int?>
= EditTextViewErrorIdBinding(lazy(viewProvider))

private class EditTextViewErrorIdBinding(lazyViewProvider: Lazy<EditText>) : ReadWriteProperty<Any?, Int?> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlin.reflect.KProperty
fun Activity.bindToLoading(
@IdRes progressViewId: Int,
@IdRes restViewHolderId: Int
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { findViewById(progressViewId) },
restViewHolderProvider = { findViewById(restViewHolderId) }
)
Expand All @@ -23,7 +23,7 @@ fun Activity.bindToLoading(
fun Fragment.bindToLoading(
@IdRes progressViewId: Int,
@IdRes restViewHolderId: Int
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { view.findViewById(progressViewId) },
restViewHolderProvider = { view.findViewById(restViewHolderId) }
)
Expand All @@ -32,23 +32,23 @@ fun Fragment.bindToLoading(
fun android.support.v4.app.Fragment.bindToLoading(
@IdRes progressViewId: Int,
@IdRes restViewHolderId: Int
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { view!!.findViewById(progressViewId) },
restViewHolderProvider = { view!!.findViewById(restViewHolderId) }
)

fun FrameLayout.bindToLoading(
@IdRes progressViewId: Int,
@IdRes restViewHolderId: Int
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { findViewById(progressViewId) },
restViewHolderProvider = { findViewById(restViewHolderId) }
)

fun Activity.bindToLoading(
progressViewProvider: () -> View,
restViewProvider: () -> View
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { progressViewProvider() },
restViewHolderProvider = { restViewProvider() }
)
Expand All @@ -57,7 +57,7 @@ fun Activity.bindToLoading(
fun Fragment.bindToLoading(
progressViewProvider: () -> View,
restViewProvider: () -> View
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { progressViewProvider() },
restViewHolderProvider = { restViewProvider() }
)
Expand All @@ -66,17 +66,17 @@ fun Fragment.bindToLoading(
fun android.support.v4.app.Fragment.bindToLoading(
progressViewProvider: () -> View,
restViewProvider: () -> View
): ReadWriteProperty<Any?, Boolean> = bindToLoading(
): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { progressViewProvider() },
restViewHolderProvider = { restViewProvider() }
)

fun Pair<View, View>.bindToLoading(): ReadWriteProperty<Any?, Boolean> = bindToLoading(
fun Pair<View, View>.bindToLoading(): ReadWriteProperty<Any?, Boolean> = bindToLoadingP(
progressViewProvider = { first },
restViewHolderProvider = { second }
)

private fun bindToLoading(
private fun bindToLoadingP(
progressViewProvider: () -> View,
restViewHolderProvider: () -> View
): ReadWriteProperty<Any?, Boolean> = LoadingBinding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

fun Activity.bindToLongClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { findViewById(viewId) }
= bindToLongClickP { findViewById(viewId) }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToLongClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { view.findViewById(viewId) }
= bindToLongClickP { view.findViewById(viewId) }

fun android.support.v4.app.Fragment.bindToLongClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { view!!.findViewById(viewId) }
= bindToLongClickP { view!!.findViewById(viewId) }

fun FrameLayout.bindToLongClick(@IdRes viewId: Int): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { findViewById(viewId) }
= bindToLongClickP { findViewById(viewId) }

fun Activity.bindToLongClick(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { viewProvider() }
= bindToLongClickP { viewProvider() }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToLongClick(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { viewProvider() }
= bindToLongClickP { viewProvider() }

fun android.support.v4.app.Fragment.bindToLongClick(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { viewProvider() }
= bindToLongClickP { viewProvider() }

fun View.bindToLongClick(): ReadWriteProperty<Any?, () -> Unit>
= bindToLongClick { this }
= bindToLongClickP { this }

private fun bindToLongClick(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
private fun bindToLongClickP(viewProvider: () -> View): ReadWriteProperty<Any?, () -> Unit>
= OnLongClickBinding(lazy(viewProvider))

private class OnLongClickBinding(viewProvider: Lazy<View>) : ReadWriteProperty<Any?, () -> Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty

fun Activity.bindToRequestFocus(@IdRes editViewId: Int): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { findViewById(editViewId) }
= bindToRequestFocusP { findViewById(editViewId) }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToRequestFocus(@IdRes editViewId: Int): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { view.findViewById(editViewId) }
= bindToRequestFocusP { view.findViewById(editViewId) }

fun android.support.v4.app.Fragment.bindToRequestFocus(@IdRes editViewId: Int): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { view!!.findViewById(editViewId) }
= bindToRequestFocusP { view!!.findViewById(editViewId) }

fun FrameLayout.bindToRequestFocus(@IdRes editViewId: Int): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { findViewById(editViewId) }
= bindToRequestFocusP { findViewById(editViewId) }

fun Activity.bindToRequestFocus(viewProvider: () -> View): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { viewProvider() }
= bindToRequestFocusP { viewProvider() }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToRequestFocus(viewProvider: () -> View): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { viewProvider() }
= bindToRequestFocusP { viewProvider() }

fun android.support.v4.app.Fragment.bindToRequestFocus(viewProvider: () -> View): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { viewProvider() }
= bindToRequestFocusP { viewProvider() }

fun View.bindToRequestFocus(): ReadOnlyProperty<Any?, () -> Unit>
= bindToRequestFocus { this }
= bindToRequestFocusP { this }

private fun bindToRequestFocus(viewProvider: () -> View): ReadOnlyProperty<Any?, () -> Unit>
private fun bindToRequestFocusP(viewProvider: () -> View): ReadOnlyProperty<Any?, () -> Unit>
= RequestFocusBinding(lazy(viewProvider))

private class RequestFocusBinding(viewProvider: Lazy<View>) : ReadOnlyProperty<Any?, () -> Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

fun Activity.bindToSwipeRefresh(@IdRes swipeRefreshLayoutId: Int): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }
= bindToSwipeRefreshP { findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToSwipeRefresh(@IdRes swipeRefreshLayoutId: Int): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { view.findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }
= bindToSwipeRefreshP { view.findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }

fun android.support.v4.app.Fragment.bindToSwipeRefresh(@IdRes swipeRefreshLayoutId: Int): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { view!!.findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }
= bindToSwipeRefreshP { view!!.findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }

fun FrameLayout.bindToSwipeRefresh(@IdRes swipeRefreshLayoutId: Int): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }
= bindToSwipeRefreshP { findViewById(swipeRefreshLayoutId) as SwipeRefreshLayout }

fun Activity.bindToSwipeRefresh(swipeRefreshLayoutProvider: ()->SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { swipeRefreshLayoutProvider() }
fun Activity.bindToSwipeRefresh(swipeRefreshLayoutProvider: () -> SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefreshP { swipeRefreshLayoutProvider() }

@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
fun Fragment.bindToSwipeRefresh(viewProvider: ()->SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { viewProvider() }
fun Fragment.bindToSwipeRefresh(viewProvider: () -> SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefreshP { viewProvider() }

fun android.support.v4.app.Fragment.bindToSwipeRefresh(viewProvider: ()->SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { viewProvider() }
fun android.support.v4.app.Fragment.bindToSwipeRefresh(viewProvider: () -> SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefreshP { viewProvider() }

fun SwipeRefreshLayout.bindToSwipeRefresh(): ReadWriteProperty<Any?, Boolean>
= bindToSwipeRefresh { this }
= bindToSwipeRefreshP { this }

private fun bindToSwipeRefresh(viewProvider: () -> SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
private fun bindToSwipeRefreshP(viewProvider: () -> SwipeRefreshLayout): ReadWriteProperty<Any?, Boolean>
= SwipeRefreshBinding(lazy(viewProvider))

private class SwipeRefreshBinding(viewProvider: Lazy<SwipeRefreshLayout>) : ReadWriteProperty<Any?, Boolean> {
Expand Down
Loading

0 comments on commit 789e92c

Please sign in to comment.