This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="presenter" | |
type="com.example.MyPresenter"/> | |
<variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter("progressColor") | |
public static void setProgressBarColor(ProgressBar loader, int color) { | |
if (loader != null) { | |
loader.getIndeterminateDrawable() | |
.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ProgressBar | |
style="?android:attr/progressBarStyleLarge" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:indeterminate="true" | |
bind:progressColor="@{@android:color/holo_green_dark}" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bind Glide with an ImageView. | |
* | |
* @param view the ImageView to bind to Glide. | |
* @param src The URL of the image to load. | |
* @param placeholder The placeholder icon. | |
* @param error The error icon. | |
* @param blurValue The blur radius value between 1 and 25. | |
* @param cropCircle Crop the image in a circle of not. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ImageView | |
android:layout_width="@dimen/logo_size" | |
android:layout_height="@dimen/logo_size" | |
android:contentDescription="@null" | |
bind:src="@{logoURL}" | |
bind:blur="@{20}" | |
bind:cropCircle="@{true}" | |
bind:error="@{@drawable/ic_error_black_24dp}" | |
bind:placeholder="@{@drawable/ic_rowing_black_24dp}" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter("onKeyDone") | |
public static void onKeyDone(EditText editText, final OnKeyPressedListener action) { | |
if (editText != null) { | |
editText.setOnKeyListener(new View.OnKeyListener() { | |
@Override | |
public boolean onKey(View v, int keyCode, KeyEvent event) { | |
boolean handled = false; | |
if (keyCode == KeyEvent.KEYCODE_ENTER | |
&& event.getAction() == KeyEvent.ACTION_DOWN) { | |
action.onKeyPressed(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:imeOptions="actionSend" | |
app:onKeyDone="@{()-> model.doLogin()}" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enable a TextView to handle HTML links. | |
* @param view The TextView where the link will be located. | |
* @param linkRes The resource id that contains the HTML link. | |
*/ | |
@SuppressWarnings("deprecation") | |
@android.databinding.BindingAdapter("link") | |
public static void addLinkToTextView(TextView view, @StringRes int linkRes) { | |
if (view != null) { | |
Resources resources = view.getContext().getResources(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Underline a portion of the text. | |
* | |
* @param view The TextView containing the text to underline. | |
* @param spanSize an array that contain the start index and the end index. | |
*/ | |
@android.databinding.BindingAdapter("underline") | |
public static void underlineText(TextView view, @NonNull int[] spanSize) { | |
if (view != null && spanSize.length == 2) { | |
SpannableString content = new SpannableString(view.getText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@android.databinding.BindingAdapter("showKeyboard") | |
public static void showKeyBoard(final EditText editText, final boolean showFlag) { | |
editText.post(new Runnable() { | |
@Override | |
public void run() { | |
if (showFlag) { | |
KeyboardUtils.showKeyboard(editText); | |
} else { | |
editText.clearFocus(); | |
+ KeyboardUtils.hideKeyboard(editText.getContext(), editText); |