Skip to content

Commit

Permalink
remove self star
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed May 3, 2019
1 parent 6f6969e commit 942aad3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ class EpisodeAdapter(data: MutableList<SelectableSectionEntity<Episode>>? = null
else -> android.R.attr.textColorSecondary
}))
helper.itemView.item_badge.text = item.t.progress?.status?.cn_name?:""
helper.itemView.backgroundTintList = ColorStateList.valueOf(color)
helper.itemView.alpha = if((item.t.status?:"") in listOf("Air"))1f else 0.6f
helper.itemView.ep_box.backgroundTintList = ColorStateList.valueOf(color)
helper.itemView.ep_box.alpha = if((item.t.status?:"") in listOf("Air"))1f else 0.6f
helper.addOnClickListener(R.id.ep_box)
helper.addOnLongClickListener(R.id.ep_box)

if(itemHeight == 0){
helper.itemView.measure(0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ class SubjectPresenter(private val context: SubjectActivity){
context.item_ep_title.text = "${context.getText(R.string.episodes)}${if(eps.isEmpty()) "" else "(${eps.size})"}"
}

subjectView.episodeDetailAdapter.setOnItemLongClickListener { _, _, position ->
subjectView.episodeDetailAdapter.setOnItemChildLongClickListener { _, _, position ->
val eps = subjectView.episodeDetailAdapter.data.subList(0, position + 1).filter { !it.isHeader }.map { it.t }
if(eps.last().type == Episode.TYPE_MUSIC)
subjectView.episodeDetailAdapter.data[position]?.t?.let{ openEpisode(it, subject, eps)
true }?:false
else subjectView.episodeDetailAdapter.longClickListener(position)
}

subjectView.episodeDetailAdapter.setOnItemClickListener { _, _, position ->
subjectView.episodeDetailAdapter.setOnItemChildClickListener { _, _, position ->
val eps = subjectView.episodeDetailAdapter.data.subList(0, position + 1).filter { !it.isHeader }.map { it.t }
if(eps.last().type == Episode.TYPE_MUSIC || subjectView.episodeDetailAdapter.clickListener(position))
subjectView.episodeDetailAdapter.data[position]?.t?.let{ openEpisode(it, subject, eps) }
Expand Down Expand Up @@ -374,9 +374,6 @@ class SubjectPresenter(private val context: SubjectActivity){
if(status?.id in listOf(1, 2, 3, 4)) R.drawable.ic_heart else R.drawable.ic_heart_outline, context.theme))
context.item_collect_info.text = status?.name?:context.getString(R.string.collect)

context.item_self_rating.visibility = if(body.rating == 0)View.GONE else View.VISIBLE
context.item_self_rating.rating = body.rating / 2f

context.item_collect.setOnClickListener{
if(context.formhash.isEmpty()) return@setOnClickListener
val popupMenu = PopupMenu(context, context.item_collect)
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/soko/ekibun/bangumi/ui/subject/SubjectView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class SubjectView(private val context: SubjectActivity){
val marginEnd = (context.item_buttons.layoutParams as CollapsingToolbarLayout.LayoutParams).marginEnd
(context.title_expand.layoutParams as ConstraintLayout.LayoutParams).marginEnd = 3 * marginEnd

context.item_self_rating.measure(0,0)
val selfRatingWidth = context.item_self_rating.measuredWidth
context.app_bar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener{ appBarLayout, verticalOffset ->
if(appBarOffset == verticalOffset) return@OnOffsetChangedListener
val ratio = Math.abs(verticalOffset.toFloat() / appBarLayout.totalScrollRange)
Expand All @@ -88,12 +86,6 @@ class SubjectView(private val context: SubjectActivity){
context.item_buttons.translationX = -2.2f * marginEnd * ratio
context.app_bar.elevation = Math.max(0f, 12 * (ratio - 0.95f)/ 0.05f)

context.item_self_rating.layoutParams.let {
it.width = (selfRatingWidth * (1-ratio)).toInt()
context.item_self_rating.layoutParams = it
}
context.item_self_rating.alpha = 1-ratio

context.episode_detail_list.invalidate()
})

Expand Down Expand Up @@ -205,7 +197,7 @@ class SubjectView(private val context: SubjectActivity){
context.title_expand.text = context.title_collapse.text
context.title_expand.post {
val layoutParams = (context.title_collapse.layoutParams as ConstraintLayout.LayoutParams)
layoutParams.marginEnd = 3 * (context.item_buttons.layoutParams as CollapsingToolbarLayout.LayoutParams).marginEnd + context.item_buttons.width - context.item_self_rating.width
layoutParams.marginEnd = 3 * (context.item_buttons.layoutParams as CollapsingToolbarLayout.LayoutParams).marginEnd + context.item_buttons.width
context.title_collapse.layoutParams = layoutParams
(context.item_subject.layoutParams as CollapsingToolbarLayout.LayoutParams).topMargin = context.toolbar_container.height
}
Expand Down
62 changes: 32 additions & 30 deletions app/src/main/res/layout/item_episode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,41 @@
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="9dp"
android:clickable="true"
android:backgroundTint="?colorAccent"
android:backgroundTintMode="src_in"
android:background="@drawable/bg_episode_outline"
android:focusable="true">
<TextView
android:id="@+id/item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
tools:text="第 1 话"
android:layout_marginBottom="9dp">
<LinearLayout
android:clickable="true"
android:backgroundTint="?colorAccent"
android:backgroundTintMode="src_in"
android:background="@drawable/bg_episode_outline"
android:focusable="true"
android:id="@+id/ep_box"
android:padding="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:textSize="@dimen/textSizeSmall"/>

<TextView
android:id="@+id/item_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textSizeMedium"
android:ellipsize="end"
android:paddingTop="4dp"
tools:text="Episode Name"
app:layout_constraintTop_toBottomOf="@+id/item_title"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:maxLines="1"/>
android:orientation="vertical">
<TextView
android:id="@+id/item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
tools:text="第 1 话"
app:layout_constraintTop_toTopOf="parent"
android:textSize="@dimen/textSizeSmall"/>

<TextView
android:id="@+id/item_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textSizeMedium"
android:ellipsize="end"
android:paddingTop="4dp"
tools:text="Episode Name"
app:layout_constraintTop_toBottomOf="@+id/item_title"
app:layout_constraintBottom_toBottomOf="parent"
android:maxLines="1"/>
</LinearLayout>
<TextView
android:id="@+id/item_badge"
android:layout_width="wrap_content"
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/res/layout/subject_buttons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,5 @@
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RatingBar
android:id="@+id/item_self_rating"
android:visibility="gone"
android:layout_marginStart="2dp"
android:layout_width="wrap_content"
style="?android:attr/ratingBarStyleSmall"
android:progressTint="@android:color/white"
tools:rating="2.5"
tools:visibility="visible"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>

0 comments on commit 942aad3

Please sign in to comment.