Skip to content
Snippets Groups Projects
Commit 837f3c72 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Mitigate the d-pad fast scroll issue

parent b4d20b71
No related branches found
No related tags found
1 merge request!53AudioBrowserAdapter refactor
......@@ -35,7 +35,7 @@
type="org.videolan.vlc.gui.audio.AudioBrowserAdapter.MediaItemTVViewHolder" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
<org.videolan.vlc.gui.tv.FocusableConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/tv_card_background"
......@@ -104,5 +104,5 @@
vlc:placeholder="@{item}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</org.videolan.vlc.gui.tv.FocusableConstraintLayout>
</layout>
\ No newline at end of file
......@@ -165,6 +165,7 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
@Override
public void onViewRecycled(@NonNull AbstractMediaItemViewHolder h) {
h.recycle();
super.onViewRecycled(h);
}
private boolean isPositionValid(int position) {
......
package org.videolan.vlc.gui.tv
import android.content.Context
import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
class FocusableConstraintLayout : ConstraintLayout {
constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun clearFocus() {
if (parent != null)
super.clearFocus()
}
}
\ No newline at end of file
......@@ -31,8 +31,7 @@ import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.util.Log
import android.view.KeyEvent.KEYCODE_BACK
import android.view.KeyEvent.KEYCODE_MENU
import android.view.KeyEvent.*
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
......@@ -478,19 +477,35 @@ class AudioBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEventsHand
}
private var lastDpadEventTime = 0L
override fun onKeyPressed(keyCode: Int): Boolean {
if (keyCode == KEYCODE_MENU) {
fabSettings.requestFocusFromTouch()
expandExtendedFAB()
return true
}
if (keyCode == KEYCODE_BACK) {
if (headerListContainer.visibility == View.VISIBLE) {
hideHeaderSelectionScreen()
when (keyCode) {
KEYCODE_MENU -> {
fabSettings.requestFocusFromTouch()
expandExtendedFAB()
return true
}
KEYCODE_BACK -> {
if (headerListContainer.visibility == View.VISIBLE) {
hideHeaderSelectionScreen()
return true
}
}
/**
* mitigate the perf issue when scrolling fast with d-pad
*/
KEYCODE_DPAD_DOWN, KEYCODE_DPAD_LEFT, KEYCODE_DPAD_RIGHT, KEYCODE_DPAD_UP -> {
val now = System.currentTimeMillis()
if (now - lastDpadEventTime > 200) {
lastDpadEventTime = now
if (BuildConfig.DEBUG) Log.d("keydown", "Keydown propagated");
return false
}
return true
}
}
return false
}
}
......
......@@ -110,7 +110,6 @@ public class VerticalGridActivity extends BaseTvActivity implements BrowserActiv
}
@Override
public void showProgress(final boolean show){
runOnUiThread(new Runnable() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment