Comply with Checkstyle rules

This commit is contained in:
Alexander-- 2020-04-11 09:02:22 +06:59
parent 08459b3a90
commit a5e28105ac
13 changed files with 75 additions and 49 deletions

View file

@ -34,11 +34,13 @@ public final class FocusAwareCoordinator extends CoordinatorLayout {
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);
}
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);
}
@ -54,7 +56,8 @@ public final class FocusAwareCoordinator extends CoordinatorLayout {
} else {
focused.getHitRect(childFocus);
((ViewGroup) child).offsetDescendantRectToMyCoords((View) focused.getParent(), childFocus);
((ViewGroup) child).offsetDescendantRectToMyCoords((View) focused.getParent(),
childFocus);
}
requestChildRectangleOnScreen(child, childFocus, false);

View file

@ -37,18 +37,23 @@ public final class FocusAwareDrawerLayout extends DrawerLayout {
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);
}
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);
}
@Override
protected boolean onRequestFocusInDescendants(final int direction, final Rect previouslyFocusedRect) {
// 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
protected boolean onRequestFocusInDescendants(final int direction,
final Rect previouslyFocusedRect) {
// 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;
@ -74,7 +79,8 @@ public final class FocusAwareDrawerLayout extends DrawerLayout {
}
@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;
View content = null;

View file

@ -45,7 +45,8 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
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);
}
@ -66,7 +67,8 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
}
@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);
if (!isInTouchMode() && !gainFocus) {
@ -116,7 +118,8 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
}
@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) {
isSeeking = true;

View file

@ -44,13 +44,15 @@ public class NewPipeRecyclerView extends RecyclerView {
init();
}
public NewPipeRecyclerView(@NonNull final Context context, @Nullable final AttributeSet attrs) {
public NewPipeRecyclerView(@NonNull final Context context,
@Nullable final AttributeSet attrs) {
super(context, attrs);
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);
init();
@ -90,9 +92,9 @@ public class NewPipeRecyclerView extends RecyclerView {
super.removeDetachedView(child, animate);
}
// we override focusSearch to always return null, so all moves moves lead to dispatchUnhandledMove()
// as added advantage, we can fully swallow some kinds of moves (such as downward movement, that
// happens when loading additional contents is in progress
// we override focusSearch to always return null, so all moves moves lead to
// dispatchUnhandledMove(). As added advantage, we can fully swallow some kinds of moves
// (such as downward movement, that happens when loading additional contents is in progress
@Override
public boolean dispatchUnhandledMove(final View focused, final int direction) {
@ -116,8 +118,9 @@ public class NewPipeRecyclerView extends RecyclerView {
}
if (arrowScroll(direction)) {
// if RecyclerView can not yield focus, but there is still some scrolling space in indicated,
// direction, scroll some fixed amount in that direction (the same logic in ScrollView)
// if RecyclerView can not yield focus, but there is still some scrolling space in
// indicated, direction, scroll some fixed amount in that direction
// (the same logic in ScrollView)
return true;
}
@ -140,8 +143,8 @@ public class NewPipeRecyclerView extends RecyclerView {
private boolean tryFocusFinder(final int direction) {
if (Build.VERSION.SDK_INT >= 28) {
// Android 9 implemented bunch of handy changes to focus, that render code below less useful, and
// also broke findNextFocusFromRect in way, that render this hack useless
// Android 9 implemented bunch of handy changes to focus, that render code below less
// useful, and also broke findNextFocusFromRect in way, that render this hack useless
return false;
}

View file

@ -39,7 +39,11 @@ public final class SuperScrollLayoutManager extends LinearLayoutManager {
}
@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()) {
// only activate when in directional navigation mode (Android TV etc) fine grained
// 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
@ -90,7 +95,9 @@ public final class SuperScrollLayoutManager extends LinearLayoutManager {
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 {
for (View view : focusables) {