mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-05-01 10:30:16 -05:00
player: update properly reset ui position in touch mode
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user