@InverseBindingAdapter(attribute = "android:text", event = "android:textAttrChanged") public static Integer getIntegerText(TextView view) { CharSequence text = view.getText(); if (text != null && text.length() > 0) { return Integer.valueOf(text.toString()); } return null; }
@InverseBindingAdapter(attribute = "android:text") public static float getText(TextInputEditText dimView) { try { String dimString = dimView.getText().toString(); float dimVal = Float.parseFloat(dimString); return dimVal; } catch (NumberFormatException e) { // Return 0 for now return 0; } }
@InverseBindingAdapter(attribute = "scrollPosition") public static int getScrollPosition(RecyclerView recyclerView) { if (recyclerView.getChildCount() == 0) { return 0; } return recyclerView.getChildAdapterPosition(recyclerView.getChildAt(0)); }
@InverseBindingAdapter(attribute = "selectedValue", event = "selectedValueAttrChanged") public static String captureSelectedValue(AppCompatSpinner pAppCompatSpinner) { return (String) pAppCompatSpinner.getSelectedItem(); }
@InverseBindingAdapter(attribute = "bind:selectedValue", event = "bind:selectedValueAttrChanged") public static String captureSelectedValue(Spinner pSpinner) { return (String) pSpinner.getSelectedItem(); }
@InverseBindingAdapter(attribute = "selectedItemPosition") public Integer getSelectedItemPosition(AppCompatSpinner spinner) { return spinner.getSelectedItemPosition(); }
@InverseBindingAdapter(attribute = "app:text", event = "android:textAttrChanged") public static String getTextString(TextView view) { return view.getText().toString(); }
@InverseBindingAdapter(attribute = "refreshing",event = "refreshingAttrChanged") public static boolean isRefreshing(SwipeRefreshLayout view) { return view.isRefreshing(); }
@InverseBindingAdapter(attribute = "page") public static int getPage(ViewPager pager) { return pager.getCurrentItem(); }
@InverseBindingAdapter(attribute = "android:checked", event = "android:checked") public static boolean getViewChecked(CheckBox view) { return view.isChecked(); }