Comply with Checkstyle rules
This commit is contained in:
parent
ac5571a363
commit
53b3bda909
13 changed files with 75 additions and 49 deletions
|
@ -11,7 +11,6 @@ import android.preference.PreferenceManager;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -35,7 +34,6 @@ import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
import org.schabi.newpipe.util.StateSaver;
|
import org.schabi.newpipe.util.StateSaver;
|
||||||
import org.schabi.newpipe.util.StreamDialogEntry;
|
import org.schabi.newpipe.util.StreamDialogEntry;
|
||||||
import org.schabi.newpipe.views.NewPipeRecyclerView;
|
|
||||||
import org.schabi.newpipe.views.SuperScrollLayoutManager;
|
import org.schabi.newpipe.views.SuperScrollLayoutManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -166,13 +164,15 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
||||||
restoreFocus((Integer) savedObjects.poll());
|
restoreFocus((Integer) savedObjects.poll());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreFocus(Integer position) {
|
private void restoreFocus(final Integer position) {
|
||||||
if (position == null || position < 0) {
|
if (position == null || position < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemsList.post(() -> {
|
itemsList.post(() -> {
|
||||||
RecyclerView.ViewHolder focusedHolder = itemsList.findViewHolderForAdapterPosition(position);
|
RecyclerView.ViewHolder focusedHolder =
|
||||||
|
itemsList.findViewHolderForAdapterPosition(position);
|
||||||
|
|
||||||
if (focusedHolder != null) {
|
if (focusedHolder != null) {
|
||||||
focusedHolder.itemView.requestFocus();
|
focusedHolder.itemView.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ import icepick.State;
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
public abstract class BaseListInfoFragment<I extends ListInfo>
|
public abstract class BaseListInfoFragment<I extends ListInfo>
|
||||||
|
|
|
@ -511,7 +511,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
if (isSuggestionsEnabled && errorPanelRoot.getVisibility() != View.VISIBLE) {
|
if (isSuggestionsEnabled && errorPanelRoot.getVisibility() != View.VISIBLE) {
|
||||||
showSuggestionsPanel();
|
showSuggestionsPanel();
|
||||||
}
|
}
|
||||||
if(AndroidTvUtils.isTv()){
|
if (AndroidTvUtils.isTv()) {
|
||||||
showKeyboardSearch();
|
showKeyboardSearch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,10 +78,8 @@ import org.schabi.newpipe.util.SerializedCache;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.disposables.SerialDisposable;
|
import io.reactivex.disposables.SerialDisposable;
|
||||||
|
@ -90,6 +88,8 @@ import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_INTERNAL
|
||||||
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_PERIOD_TRANSITION;
|
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_PERIOD_TRANSITION;
|
||||||
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK;
|
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK;
|
||||||
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT;
|
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT;
|
||||||
|
import static io.reactivex.android.schedulers.AndroidSchedulers.mainThread;
|
||||||
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base for the players, joining the common properties.
|
* Base for the players, joining the common properties.
|
||||||
|
@ -304,7 +304,7 @@ public abstract class BasePlayer implements
|
||||||
final PlayQueueItem item = queue.getItem();
|
final PlayQueueItem item = queue.getItem();
|
||||||
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
||||||
stateLoader = recordManager.loadStreamState(item)
|
stateLoader = recordManager.loadStreamState(item)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(mainThread())
|
||||||
.doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed,
|
.doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed,
|
||||||
playbackPitch, playbackSkipSilence, true, isMuted))
|
playbackPitch, playbackSkipSilence, true, isMuted))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -655,8 +655,8 @@ public abstract class BasePlayer implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private Disposable getProgressReactor() {
|
private Disposable getProgressReactor() {
|
||||||
return Observable.interval(PROGRESS_LOOP_INTERVAL_MILLIS, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
return Observable.interval(PROGRESS_LOOP_INTERVAL_MILLIS, MILLISECONDS, mainThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(mainThread())
|
||||||
.subscribe(ignored -> triggerProgressUpdate(),
|
.subscribe(ignored -> triggerProgressUpdate(),
|
||||||
error -> Log.e(TAG, "Progress update failure: ", error));
|
error -> Log.e(TAG, "Progress update failure: ", error));
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,7 @@ public abstract class BasePlayer implements
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
|
if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
|
||||||
final Disposable stateSaver = recordManager.saveStreamState(info, progress)
|
final Disposable stateSaver = recordManager.saveStreamState(info, progress)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(mainThread())
|
||||||
.doOnError((e) -> {
|
.doOnError((e) -> {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1281,7 +1281,7 @@ public abstract class BasePlayer implements
|
||||||
if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
|
if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
|
||||||
final Disposable stateSaver = queueItem.getStream()
|
final Disposable stateSaver = queueItem.getStream()
|
||||||
.flatMapCompletable(info -> recordManager.saveStreamState(info, 0))
|
.flatMapCompletable(info -> recordManager.saveStreamState(info, 0))
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(mainThread())
|
||||||
.doOnError((e) -> {
|
.doOnError((e) -> {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -176,8 +176,10 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
public void onChange(final boolean selfChange) {
|
public void onChange(final boolean selfChange) {
|
||||||
super.onChange(selfChange);
|
super.onChange(selfChange);
|
||||||
if (globalScreenOrientationLocked()) {
|
if (globalScreenOrientationLocked()) {
|
||||||
|
final String orientKey = getString(R.string.last_orientation_landscape_key);
|
||||||
|
|
||||||
final boolean lastOrientationWasLandscape = defaultPreferences
|
final boolean lastOrientationWasLandscape = defaultPreferences
|
||||||
.getBoolean(getString(R.string.last_orientation_landscape_key), AndroidTvUtils.isTv());
|
.getBoolean(orientKey, AndroidTvUtils.isTv());
|
||||||
setLandscape(lastOrientationWasLandscape);
|
setLandscape(lastOrientationWasLandscape);
|
||||||
} else {
|
} else {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
|
@ -216,7 +218,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
||||||
switch (event.getKeyCode()) {
|
switch (event.getKeyCode()) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -258,8 +260,10 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (globalScreenOrientationLocked()) {
|
if (globalScreenOrientationLocked()) {
|
||||||
|
final String orientKey = getString(R.string.last_orientation_landscape_key);
|
||||||
|
|
||||||
boolean lastOrientationWasLandscape = defaultPreferences
|
boolean lastOrientationWasLandscape = defaultPreferences
|
||||||
.getBoolean(getString(R.string.last_orientation_landscape_key), AndroidTvUtils.isTv());
|
.getBoolean(orientKey, AndroidTvUtils.isTv());
|
||||||
setLandscape(lastOrientationWasLandscape);
|
setLandscape(lastOrientationWasLandscape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,7 +1081,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void safeHideControls(long duration, final long delay) {
|
public void safeHideControls(final long duration, final long delay) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "safeHideControls() called with: delay = [" + delay + "]");
|
Log.d(TAG, "safeHideControls() called with: delay = [" + delay + "]");
|
||||||
}
|
}
|
||||||
|
@ -1085,8 +1089,9 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
View controlsRoot = getControlsRoot();
|
View controlsRoot = getControlsRoot();
|
||||||
if (controlsRoot.isInTouchMode()) {
|
if (controlsRoot.isInTouchMode()) {
|
||||||
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
||||||
getControlsVisibilityHandler().postDelayed(
|
getControlsVisibilityHandler().postDelayed(() ->
|
||||||
() -> animateView(controlsRoot, false, duration, 0, MainVideoPlayer.this::hideSystemUi), delay);
|
animateView(controlsRoot, false, duration, 0,
|
||||||
|
MainVideoPlayer.this::hideSystemUi), delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -969,7 +969,9 @@ public abstract class VideoPlayer extends BasePlayer
|
||||||
Log.d(TAG, "showControlsThenHide() called");
|
Log.d(TAG, "showControlsThenHide() called");
|
||||||
}
|
}
|
||||||
|
|
||||||
final int hideTime = controlsRoot.isInTouchMode() ? DEFAULT_CONTROLS_HIDE_TIME : DPAD_CONTROLS_HIDE_TIME;
|
final int hideTime = controlsRoot.isInTouchMode()
|
||||||
|
? DEFAULT_CONTROLS_HIDE_TIME
|
||||||
|
: DPAD_CONTROLS_HIDE_TIME;
|
||||||
|
|
||||||
animateView(controlsRoot, true, DEFAULT_CONTROLS_DURATION, 0,
|
animateView(controlsRoot, true, DEFAULT_CONTROLS_DURATION, 0,
|
||||||
() -> hideControls(DEFAULT_CONTROLS_DURATION, hideTime));
|
() -> hideControls(DEFAULT_CONTROLS_DURATION, hideTime));
|
||||||
|
|
|
@ -7,12 +7,12 @@ import android.view.KeyEvent;
|
||||||
import org.schabi.newpipe.App;
|
import org.schabi.newpipe.App;
|
||||||
|
|
||||||
public final class AndroidTvUtils {
|
public final class AndroidTvUtils {
|
||||||
|
private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
|
||||||
|
|
||||||
private AndroidTvUtils() { }
|
private AndroidTvUtils() { }
|
||||||
|
|
||||||
@SuppressLint("InlinedApi")
|
@SuppressLint("InlinedApi")
|
||||||
public static boolean isTv(){
|
public static boolean isTv() {
|
||||||
final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
|
|
||||||
|
|
||||||
PackageManager pm = App.getApp().getPackageManager();
|
PackageManager pm = App.getApp().getPackageManager();
|
||||||
|
|
||||||
return pm.hasSystemFeature(AMAZON_FEATURE_FIRE_TV)
|
return pm.hasSystemFeature(AMAZON_FEATURE_FIRE_TV)
|
||||||
|
|
|
@ -34,11 +34,13 @@ public final class FocusAwareCoordinator extends CoordinatorLayout {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FocusAwareCoordinator(@NonNull final Context context, @Nullable final AttributeSet attrs) {
|
public FocusAwareCoordinator(@NonNull final Context context,
|
||||||
|
@Nullable final AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FocusAwareCoordinator(@NonNull final Context context, @Nullable final AttributeSet attrs, final int defStyleAttr) {
|
public FocusAwareCoordinator(@NonNull final Context context,
|
||||||
|
@Nullable final AttributeSet attrs, final int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +56,8 @@ public final class FocusAwareCoordinator extends CoordinatorLayout {
|
||||||
} else {
|
} else {
|
||||||
focused.getHitRect(childFocus);
|
focused.getHitRect(childFocus);
|
||||||
|
|
||||||
((ViewGroup) child).offsetDescendantRectToMyCoords((View) focused.getParent(), childFocus);
|
((ViewGroup) child).offsetDescendantRectToMyCoords((View) focused.getParent(),
|
||||||
|
childFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestChildRectangleOnScreen(child, childFocus, false);
|
requestChildRectangleOnScreen(child, childFocus, false);
|
||||||
|
|
|
@ -37,18 +37,23 @@ public final class FocusAwareDrawerLayout extends DrawerLayout {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FocusAwareDrawerLayout(@NonNull final Context context, @Nullable final AttributeSet attrs) {
|
public FocusAwareDrawerLayout(@NonNull final Context context,
|
||||||
|
@Nullable final AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FocusAwareDrawerLayout(@NonNull final Context context, @Nullable final AttributeSet attrs, final int defStyle) {
|
public FocusAwareDrawerLayout(@NonNull final Context context,
|
||||||
|
@Nullable final AttributeSet attrs,
|
||||||
|
final int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onRequestFocusInDescendants(final int direction, final Rect previouslyFocusedRect) {
|
protected boolean onRequestFocusInDescendants(final int direction,
|
||||||
// SDK implementation of this method picks whatever visible View takes the focus first without regard to addFocusables
|
final Rect previouslyFocusedRect) {
|
||||||
// if the open drawer is temporarily empty, the focus escapes outside of it, which can be confusing
|
// SDK implementation of this method picks whatever visible View takes the focus first
|
||||||
|
// without regard to addFocusables. If the open drawer is temporarily empty, the focus
|
||||||
|
// escapes outside of it, which can be confusing
|
||||||
|
|
||||||
boolean hasOpenPanels = false;
|
boolean hasOpenPanels = false;
|
||||||
|
|
||||||
|
@ -74,7 +79,8 @@ public final class FocusAwareDrawerLayout extends DrawerLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFocusables(final ArrayList<View> views, final int direction, final int focusableMode) {
|
public void addFocusables(final ArrayList<View> views, final int direction,
|
||||||
|
final int focusableMode) {
|
||||||
boolean hasOpenPanels = false;
|
boolean hasOpenPanels = false;
|
||||||
View content = null;
|
View content = null;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,8 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FocusAwareSeekBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
|
public FocusAwareSeekBar(final Context context, final AttributeSet attrs,
|
||||||
|
final int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +67,8 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFocusChanged(final boolean gainFocus, final int direction, final Rect previouslyFocusedRect) {
|
protected void onFocusChanged(final boolean gainFocus, final int direction,
|
||||||
|
final Rect previouslyFocusedRect) {
|
||||||
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
|
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
|
||||||
|
|
||||||
if (!isInTouchMode() && !gainFocus) {
|
if (!isInTouchMode() && !gainFocus) {
|
||||||
|
@ -116,7 +118,8 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
|
public void onProgressChanged(final SeekBar seekBar, final int progress,
|
||||||
|
final boolean fromUser) {
|
||||||
if (!seekBar.isInTouchMode() && !isSeeking && fromUser) {
|
if (!seekBar.isInTouchMode() && !isSeeking && fromUser) {
|
||||||
isSeeking = true;
|
isSeeking = true;
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,15 @@ public class NewPipeRecyclerView extends RecyclerView {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewPipeRecyclerView(@NonNull final Context context, @Nullable final AttributeSet attrs) {
|
public NewPipeRecyclerView(@NonNull final Context context,
|
||||||
|
@Nullable final AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewPipeRecyclerView(@NonNull final Context context, @Nullable final AttributeSet attrs, final int defStyle) {
|
public NewPipeRecyclerView(@NonNull final Context context,
|
||||||
|
@Nullable final AttributeSet attrs, final int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
@ -90,9 +92,9 @@ public class NewPipeRecyclerView extends RecyclerView {
|
||||||
super.removeDetachedView(child, animate);
|
super.removeDetachedView(child, animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we override focusSearch to always return null, so all moves moves lead to dispatchUnhandledMove()
|
// we override focusSearch to always return null, so all moves moves lead to
|
||||||
// as added advantage, we can fully swallow some kinds of moves (such as downward movement, that
|
// dispatchUnhandledMove(). As added advantage, we can fully swallow some kinds of moves
|
||||||
// happens when loading additional contents is in progress
|
// (such as downward movement, that happens when loading additional contents is in progress
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchUnhandledMove(final View focused, final int direction) {
|
public boolean dispatchUnhandledMove(final View focused, final int direction) {
|
||||||
|
@ -116,8 +118,9 @@ public class NewPipeRecyclerView extends RecyclerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arrowScroll(direction)) {
|
if (arrowScroll(direction)) {
|
||||||
// if RecyclerView can not yield focus, but there is still some scrolling space in indicated,
|
// if RecyclerView can not yield focus, but there is still some scrolling space in
|
||||||
// direction, scroll some fixed amount in that direction (the same logic in ScrollView)
|
// indicated, direction, scroll some fixed amount in that direction
|
||||||
|
// (the same logic in ScrollView)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +143,8 @@ public class NewPipeRecyclerView extends RecyclerView {
|
||||||
|
|
||||||
private boolean tryFocusFinder(final int direction) {
|
private boolean tryFocusFinder(final int direction) {
|
||||||
if (Build.VERSION.SDK_INT >= 28) {
|
if (Build.VERSION.SDK_INT >= 28) {
|
||||||
// Android 9 implemented bunch of handy changes to focus, that render code below less useful, and
|
// Android 9 implemented bunch of handy changes to focus, that render code below less
|
||||||
// also broke findNextFocusFromRect in way, that render this hack useless
|
// useful, and also broke findNextFocusFromRect in way, that render this hack useless
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,11 @@ public final class SuperScrollLayoutManager extends LinearLayoutManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requestChildRectangleOnScreen(@NonNull final RecyclerView parent, @NonNull final View child, @NonNull final Rect rect, final boolean immediate, final boolean focusedChildVisible) {
|
public boolean requestChildRectangleOnScreen(@NonNull final RecyclerView parent,
|
||||||
|
@NonNull final View child,
|
||||||
|
@NonNull final Rect rect,
|
||||||
|
final boolean immediate,
|
||||||
|
final boolean focusedChildVisible) {
|
||||||
if (!parent.isInTouchMode()) {
|
if (!parent.isInTouchMode()) {
|
||||||
// only activate when in directional navigation mode (Android TV etc) — fine grained
|
// only activate when in directional navigation mode (Android TV etc) — fine grained
|
||||||
// touch scrolling is better served by nested scroll system
|
// touch scrolling is better served by nested scroll system
|
||||||
|
@ -53,7 +57,8 @@ public final class SuperScrollLayoutManager extends LinearLayoutManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.requestChildRectangleOnScreen(parent, child, rect, immediate, focusedChildVisible);
|
return super.requestChildRectangleOnScreen(parent, child, rect, immediate,
|
||||||
|
focusedChildVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -90,7 +95,9 @@ public final class SuperScrollLayoutManager extends LinearLayoutManager {
|
||||||
|
|
||||||
focusables.clear();
|
focusables.clear();
|
||||||
|
|
||||||
recycler.addFocusables(focusables, direction, recycler.isInTouchMode() ? View.FOCUSABLES_TOUCH_MODE : View.FOCUSABLES_ALL);
|
recycler.addFocusables(focusables, direction, recycler.isInTouchMode()
|
||||||
|
? View.FOCUSABLES_TOUCH_MODE
|
||||||
|
: View.FOCUSABLES_ALL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (View view : focusables) {
|
for (View view : focusables) {
|
||||||
|
|
Loading…
Reference in a new issue