Commit f3263566 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix some focus issues and clean some code

parent a66aa5b6
......@@ -101,8 +101,6 @@
android:id="@+id/playlist_search_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:focusable="true"
android:nextFocusDown="@+id/video_playlist"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -115,6 +113,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:focusable="true"
android:nextFocusDown="@+id/video_playlist"
android:id="@+id/playlist_search_edittext"
android:imeOptions="actionSearch"
android:inputType="textFilter"/>
</com.google.android.material.textfield.TextInputLayout>
......@@ -125,6 +126,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:focusable="true"
android:nextFocusUp="@+id/playlist_search_edittext"
android:descendantFocusability="afterDescendants"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -24,7 +24,6 @@
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="40dp">
......@@ -102,7 +101,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/playing"/>
<ImageView
<ImageButton
android:id="@+id/item_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -114,7 +113,6 @@
android:layout_marginRight="4dp"
app:srcCompat="@drawable/ic_more_player"
android:onClick="@{holder::onMoreClick}"
android:clickable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
......
......@@ -89,12 +89,12 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<AbstractMed
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val ctx = holder.itemView.context
val media = getItem(position)
holder.binding!!.media = media
holder.binding!!.subTitle = MediaUtils.getMediaSubtitle(media)
holder.binding.media = media
holder.binding.subTitle = MediaUtils.getMediaSubtitle(media)
val drawableNowPlaying = AnimatedVectorDrawableCompat.create(ctx, R.drawable.anim_now_playing)!!
if (currentIndex == position) {
holder.binding!!.playing.setImageDrawable(drawableNowPlaying)
holder.binding.playing.setImageDrawable(drawableNowPlaying)
drawableNowPlaying.start()
drawableNowPlaying.registerAnimationCallback(object : Animatable2Compat.AnimationCallback() {
override fun onAnimationEnd(drawable: Drawable?) {
......@@ -102,13 +102,13 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<AbstractMed
drawableNowPlaying.start()
}
})
holder.binding!!.playing.visibility = View.VISIBLE
holder.binding.playing.visibility = View.VISIBLE
} else {
holder.binding!!.playing.setImageDrawable(drawableNowPlaying)
holder.binding!!.playing.visibility = View.INVISIBLE
holder.binding.playing.setImageDrawable(drawableNowPlaying)
holder.binding.playing.visibility = View.INVISIBLE
}
holder.binding!!.executePendingBindings()
holder.binding.executePendingBindings()
}
override fun getItemCount(): Int {
......@@ -162,11 +162,10 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<AbstractMed
inner class ViewHolder @TargetApi(Build.VERSION_CODES.M)
constructor(v: View) : RecyclerView.ViewHolder(v) {
internal var binding: PlaylistItemBinding? = null
var binding: PlaylistItemBinding = DataBindingUtil.bind(v)!!
init {
binding = DataBindingUtil.bind(v)
binding!!.holder = this
binding.holder = this
if (AndroidUtil.isMarshMallowOrLater)
itemView.setOnContextClickListener { v ->
onMoreClick(v)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment