From 6cb16be5dfad60d0d5333d6b789affdd524a73af Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:56:26 -0400 Subject: [PATCH] Use enhanced 'for' loops --- .../FragmentStatePagerAdapterMenuWorkaround.java | 4 ++-- .../newpipe/views/LargeTextMovementMethod.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java index 5840b0f7e..471360c60 100644 --- a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java +++ b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java @@ -300,8 +300,8 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt mSavedState.clear(); mFragments.clear(); if (fss != null) { - for (int i = 0; i < fss.length; i++) { - mSavedState.add((Fragment.SavedState) fss[i]); + for (final Parcelable parcelable : fss) { + mSavedState.add((Fragment.SavedState) parcelable); } } final Iterable keys = bundle.keySet(); diff --git a/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java b/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java index 36e0eabb0..1219304e1 100644 --- a/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java +++ b/app/src/main/java/org/schabi/newpipe/views/LargeTextMovementMethod.java @@ -155,13 +155,13 @@ public class LargeTextMovementMethod extends LinkMovementMethod { int bestStart = -1; int bestEnd = -1; - for (int i = 0; i < candidates.length; i++) { - final int start = buffer.getSpanStart(candidates[i]); - final int end = buffer.getSpanEnd(candidates[i]); + for (final ClickableSpan candidate : candidates) { + final int start = buffer.getSpanStart(candidate); + final int end = buffer.getSpanEnd(candidate); if ((end < selEnd || selStart == selEnd) && start >= visibleStart) { if (end > bestEnd) { - bestStart = buffer.getSpanStart(candidates[i]); + bestStart = buffer.getSpanStart(candidate); bestEnd = end; } } @@ -224,14 +224,14 @@ public class LargeTextMovementMethod extends LinkMovementMethod { int bestStart = Integer.MAX_VALUE; int bestEnd = Integer.MAX_VALUE; - for (int i = 0; i < candidates.length; i++) { - final int start = buffer.getSpanStart(candidates[i]); - final int end = buffer.getSpanEnd(candidates[i]); + for (final ClickableSpan candidate : candidates) { + final int start = buffer.getSpanStart(candidate); + final int end = buffer.getSpanEnd(candidate); if ((start > selStart || selStart == selEnd) && end <= visibleEnd) { if (start < bestStart) { bestStart = start; - bestEnd = buffer.getSpanEnd(candidates[i]); + bestEnd = buffer.getSpanEnd(candidate); } } }