[Android] Fix some focus issues and clean some code
Nicolas Pomepuy
git at videolan.org
Tue Jul 2 11:03:40 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Jul 2 10:49:40 2019 +0200| [f326356659f59ad4f1624db0492e534a0608409f] | committer: Nicolas Pomepuy
Fix some focus issues and clean some code
> https://code.videolan.org/videolan/vlc-android/commit/f326356659f59ad4f1624db0492e534a0608409f
---
vlc-android/res/layout/player.xml | 6 ++++--
vlc-android/res/layout/playlist_item.xml | 4 +---
.../src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt | 19 +++++++++----------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 3784bd0e0..286d81450 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -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"
diff --git a/vlc-android/res/layout/playlist_item.xml b/vlc-android/res/layout/playlist_item.xml
index 68e37a1a5..b6dc44d2e 100644
--- a/vlc-android/res/layout/playlist_item.xml
+++ b/vlc-android/res/layout/playlist_item.xml
@@ -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"/>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
index ffeeb07d1..2dd1a6418 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
@@ -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)
More information about the Android
mailing list