player: update properly reset ui position in touch mode

This commit is contained in:
Yuriy Liskov
2025-01-14 02:41:27 +02:00
parent d570e05846
commit bd90aebb56
2 changed files with 13 additions and 3 deletions
@@ -723,7 +723,7 @@ public class PlaybackSupportFragment extends Fragment {
} else {
// MOD: properly reset ui position in touch mode (see BaseGridView.dispatchKeyEvent)
if (getVerticalGridView() != null) {
getVerticalGridView().setFocusScrollStrategy(VerticalGridView.FOCUS_SCROLL_ALIGNED);
getVerticalGridView().fixTouchLayout();
}
reverseFirstOrStartSecond(mBgFadeInAnimator, mBgFadeOutAnimator, animation);
@@ -1022,7 +1022,16 @@ public abstract class BaseGridView extends RecyclerView {
return mOnUnhandledKeyListener != null && mOnUnhandledKeyListener.onUnhandledKey(event);
}
private int mPrevAction;
private int mPrevAction; // Enable clicks on cards
private boolean mSkipFirstTouch = true; // Fix ui position before real touches
/**
* MOD: Properly reset ui position in touch mode (see BaseGridView.dispatchKeyEvent)
*/
public void fixTouchLayout() {
mSkipFirstTouch = true;
setFocusScrollStrategy(FOCUS_SCROLL_ALIGNED);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
@@ -1030,8 +1039,9 @@ public abstract class BaseGridView extends RecyclerView {
// Force enable touch mode (FOCUS_SCROLL_PAGE)
// Also, exclude clicks to avoid miss focus.
boolean isClick = event.getAction() == MotionEvent.ACTION_UP && mPrevAction == MotionEvent.ACTION_DOWN;
mLayoutManager.setFocusScrollStrategy(isClick ? BaseGridView.FOCUS_SCROLL_ALIGNED : BaseGridView.FOCUS_SCROLL_PAGE);
mLayoutManager.setFocusScrollStrategy(isClick || mSkipFirstTouch ? FOCUS_SCROLL_ALIGNED : FOCUS_SCROLL_PAGE);
mPrevAction = event.getAction();
mSkipFirstTouch = false;
if (mOnTouchInterceptListener != null) {
if (mOnTouchInterceptListener.onInterceptTouchEvent(event)) {