Last active
October 11, 2016 23:00
-
-
Save fnk0/d1f2550101ca7e9e66bf18aff0b4daba to your computer and use it in GitHub Desktop.
MovieCardView
This file contains hidden or 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"?> | |
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="180dp" | |
android:layout_height="280dp" | |
android:orientation="vertical"> | |
<ImageView | |
android:id="@+id/poster_iv" | |
android:layout_width="match_parent" | |
android:scaleType="centerCrop" | |
android:layout_height="0dp" | |
android:layout_weight="1"/> | |
<TextView | |
android:id="@+id/popularity" | |
android:padding="8dp" | |
android:gravity="end|center_vertical" | |
android:drawablePadding="8dp" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:textSize="16sp" | |
android:drawableEnd="@drawable/ic_star" | |
tools:text="4.0"/> | |
</LinearLayout> |
This file contains hidden or 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
public class MovieCardView extends BindableCardView<Movie> { | |
@BindView(R.id.poster_iv) | |
ImageView mPosterIV; | |
@BindView(R.id.vote_average_tv) | |
TextView mVoteAverageTV; | |
public MovieCardView(Context context) { | |
super(context); | |
ButterKnife.bind(this); | |
} | |
@Override | |
protected void bind(Movie data) { | |
Glide.with(getContext()) | |
.load(HttpClientModule.POSTER_URL + data.getPosterPath()) | |
.diskCacheStrategy(DiskCacheStrategy.ALL) | |
.into(mPosterIV); | |
mVoteAverageTV.setText(String.format(Locale.getDefault(), "%.2f", data.getVoteAverage())); | |
} | |
public ImageView getPosterIV() { | |
return mPosterIV; | |
} | |
@Override | |
protected int getLayoutResource() { | |
return R.layout.card_movie; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment