Skip to content

Instantly share code, notes, and snippets.

@eyeahs
Last active July 26, 2017 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyeahs/570a3f835981761d4f667d6adfa71647 to your computer and use it in GitHub Desktop.
Save eyeahs/570a3f835981761d4f667d6adfa71647 to your computer and use it in GitHub Desktop.
<android.support.v7.widget.RecyclerView
android:id="@+id/results_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_wrapper"
android:scrollbars="vertical"
app:itemView="@{listViewModel.itemView}"
app:items="@{listViewModel.films}"
app:layoutManager="@{LayoutManagers.linear()}"
app:onItemSelected="@{listViewModel.onItemSelected}"
/>
@BindingAdapter("app:onItemSelected")
public static void OnItemSelected(RecyclerView recyclerView, final OnItemSelected listener) {
final RecyclerView.OnItemTouchListener onItemTouch = new RecyclerItemClickListener(recyclerView.getContext(), (view, position) -> listener.onItemSelected(position));
recyclerView.addOnItemTouchListener(onItemTouch);
}
//////
<ImageView
android:id="@+id/film_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:url="@{detailViewModel.film.largePosterUrl}"
/>
@BindingAdapter("app:url")
public static void setImageUrl(ImageView view, String url) {
Picasso.with(view.getContext())
.load(url)
.into(view);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment