Skip to content

Commit

Permalink
HW-4 bindingAdapter - bind prefix 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
mtjin committed Mar 25, 2020
1 parent 055f20d commit 88f5031
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Expand Up @@ -10,7 +10,7 @@ import com.bumptech.glide.Glide
import com.mtjin.androidarchitecturestudy.R


@BindingAdapter("bind:htmlText")
@BindingAdapter("htmlText")
fun setHtmlText(textView: TextView, html: String) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
textView.text = Html.fromHtml(html, Html.FROM_HTML_MODE_COMPACT)
Expand All @@ -19,14 +19,14 @@ fun setHtmlText(textView: TextView, html: String) {
}
}

@BindingAdapter("bind:urlImage")
@BindingAdapter("urlImage")
fun setUrlImage(imageView: ImageView, url: String) {
Glide.with(imageView.context).load(url)
.placeholder(R.drawable.ic_default)
.into(imageView)
}

@BindingAdapter("bind:movieRating")
@BindingAdapter("movieRating")
fun setMovieRating(ratingBar: RatingBar, score: String) {
ratingBar.rating = (score.toFloatOrNull() ?: 0f) / 2
}
Expand Down
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/tools">
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<data>

Expand All @@ -18,11 +17,11 @@

<ImageView
android:id="@+id/iv_poster"
urlImage="@{movie.image}"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:scaleType="fitXY"
bind:urlImage="@{movie.image}" />
android:scaleType="fitXY" />

<LinearLayout
android:layout_width="0dp"
Expand All @@ -33,23 +32,23 @@

<TextView
android:id="@+id/tv_title"
htmlText="@{movie.title}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"
bind:htmlText="@{movie.title}" />
android:textStyle="bold" />

<RatingBar
android:id="@+id/rb_rating"
style="@style/Widget.AppCompat.RatingBar.Small"
movieRating="@{movie.userRating}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:isIndicator="true"
android:max="10"
android:numStars="5"
android:stepSize="0.1"
bind:movieRating="@{movie.userRating}" />
android:stepSize="0.1" />

<TextView
android:id="@+id/tv_release_date"
Expand Down

0 comments on commit 88f5031

Please sign in to comment.