Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class ErrorInfoTest {

@Test
public void errorInfoTestParcelable() {
ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
final ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
R.string.general_error);
// Obtain a Parcel object and write the parcelable object to it:
Parcel parcel = Parcel.obtain();
final Parcel parcel = Parcel.obtain();
info.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);
final ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);

assertEquals(UserAction.USER_REPORT, infoFromParcel.userAction);
assertEquals("youtube", infoFromParcel.serviceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public Object instantiateItem(@NonNull final ViewGroup container, final int posi
// from its saved state, where the fragment manager has already
// taken care of restoring the fragments we previously had instantiated.
if (mFragments.size() > position) {
Fragment f = mFragments.get(position);
final Fragment f = mFragments.get(position);
if (f != null) {
return f;
}
Expand All @@ -160,12 +160,12 @@ public Object instantiateItem(@NonNull final ViewGroup container, final int posi
mCurTransaction = mFragmentManager.beginTransaction();
}

Fragment fragment = getItem(position);
final Fragment fragment = getItem(position);
if (DEBUG) {
Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
}
if (mSavedState.size() > position) {
Fragment.SavedState fss = mSavedState.get(position);
final Fragment.SavedState fss = mSavedState.get(position);
if (fss != null) {
fragment.setInitialSavedState(fss);
}
Expand All @@ -191,7 +191,7 @@ public Object instantiateItem(@NonNull final ViewGroup container, final int posi
@Override
public void destroyItem(@NonNull final ViewGroup container, final int position,
@NonNull final Object object) {
Fragment fragment = (Fragment) object;
final Fragment fragment = (Fragment) object;

if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
Expand All @@ -217,7 +217,7 @@ public void destroyItem(@NonNull final ViewGroup container, final int position,
@SuppressWarnings({"ReferenceEquality", "deprecation"})
public void setPrimaryItem(@NonNull final ViewGroup container, final int position,
@NonNull final Object object) {
Fragment fragment = (Fragment) object;
final Fragment fragment = (Fragment) object;
if (fragment != mCurrentPrimaryItem) {
if (mCurrentPrimaryItem != null) {
mCurrentPrimaryItem.setMenuVisibility(false);
Expand Down Expand Up @@ -267,17 +267,17 @@ public Parcelable saveState() {
Bundle state = null;
if (mSavedState.size() > 0) {
state = new Bundle();
Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
final Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i = 0; i < mFragments.size(); i++) {
Fragment f = mFragments.get(i);
final Fragment f = mFragments.get(i);
if (f != null && f.isAdded()) {
if (state == null) {
state = new Bundle();
}
String key = "f" + i;
final String key = "f" + i;
mFragmentManager.putFragment(state, key, f);

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -294,21 +294,21 @@ public Parcelable saveState() {
@Override
public void restoreState(@Nullable final Parcelable state, @Nullable final ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
final Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
Parcelable[] fss = bundle.getParcelableArray("states");
final Parcelable[] fss = bundle.getParcelableArray("states");
mSavedState.clear();
mFragments.clear();
if (fss != null) {
for (int i = 0; i < fss.length; i++) {
mSavedState.add((Fragment.SavedState) fss[i]);
}
}
Iterable<String> keys = bundle.keySet();
for (String key: keys) {
final Iterable<String> keys = bundle.keySet();
for (final String key : keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
final int index = Integer.parseInt(key.substring(1));
final Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ public FlingBehavior(final Context context, final AttributeSet attrs) {
public boolean onRequestChildRectangleOnScreen(
@NonNull final CoordinatorLayout coordinatorLayout, @NonNull final AppBarLayout child,
@NonNull final Rect rectangle, final boolean immediate) {

focusScrollRect.set(rectangle);

coordinatorLayout.offsetDescendantRectToMyCoords(child, focusScrollRect);

int height = coordinatorLayout.getHeight();
final int height = coordinatorLayout.getHeight();

if (focusScrollRect.top <= 0 && focusScrollRect.bottom >= height) {
// the child is too big to fit inside ourselves completely, ignore request
return false;
}

int dy;
final int dy;

if (focusScrollRect.bottom > height) {
dy = focusScrollRect.top;
Expand All @@ -54,7 +53,7 @@ public boolean onRequestChildRectangleOnScreen(
return false;
}

int consumed = scroll(coordinatorLayout, child, dy, getMaxDragOffset(child), 0);
final int consumed = scroll(coordinatorLayout, child, dy, getMaxDragOffset(child), 0);

return consumed == dy;
}
Expand Down Expand Up @@ -106,14 +105,14 @@ public boolean onNestedFling(@NonNull final CoordinatorLayout coordinatorLayout,
@Nullable
private OverScroller getScrollerField() {
try {
Class<?> headerBehaviorType = this.getClass()
final Class<?> headerBehaviorType = this.getClass()
.getSuperclass().getSuperclass().getSuperclass();
if (headerBehaviorType != null) {
Field field = headerBehaviorType.getDeclaredField("scroller");
final Field field = headerBehaviorType.getDeclaredField("scroller");
field.setAccessible(true);
return ((OverScroller) field.get(this));
}
} catch (NoSuchFieldException | IllegalAccessException e) {
} catch (final NoSuchFieldException | IllegalAccessException e) {
// ?
}
return null;
Expand All @@ -122,34 +121,35 @@ private OverScroller getScrollerField() {
@Nullable
private Field getLastNestedScrollingChildRefField() {
try {
Class<?> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
final Class<?> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
if (headerBehaviorType != null) {
Field field = headerBehaviorType.getDeclaredField("lastNestedScrollingChildRef");
final Field field
= headerBehaviorType.getDeclaredField("lastNestedScrollingChildRef");
field.setAccessible(true);
return field;
}
} catch (NoSuchFieldException e) {
} catch (final NoSuchFieldException e) {
// ?
}
return null;
}

private void resetNestedScrollingChild() {
Field field = getLastNestedScrollingChildRefField();
final Field field = getLastNestedScrollingChildRefField();
if (field != null) {
try {
Object value = field.get(this);
final Object value = field.get(this);
if (value != null) {
field.set(this, null);
}
} catch (IllegalAccessException e) {
} catch (final IllegalAccessException e) {
// ?
}
}
}

private void stopAppBarLayoutFling() {
OverScroller scroller = getScrollerField();
final OverScroller scroller = getScrollerField();
if (scroller != null) {
scroller.forceFinished(true);
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void onCreate() {
}

protected Downloader getDownloader() {
DownloaderImpl downloader = DownloaderImpl.init(null);
final DownloaderImpl downloader = DownloaderImpl.init(null);
setCookiesToDownloader(downloader);
return downloader;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ protected void initACRA() {
.setBuildConfigClass(BuildConfig.class)
.build();
ACRA.init(this, acraConfig);
} catch (ACRAConfigurationException ace) {
} catch (final ACRAConfigurationException ace) {
ace.printStackTrace();
ErrorActivity.reportError(this,
ace,
Expand All @@ -231,10 +231,10 @@ public void initNotificationChannel() {
// Keep this below DEFAULT to avoid making noise on every notification update
final int importance = NotificationManager.IMPORTANCE_LOW;

NotificationChannel mChannel = new NotificationChannel(id, name, importance);
final NotificationChannel mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription(description);

NotificationManager mNotificationManager =
final NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(mChannel);

Expand All @@ -255,11 +255,11 @@ private void setUpUpdateNotificationChannel(final int importance) {
final String appUpdateDescription
= getString(R.string.app_update_notification_channel_description);

NotificationChannel appUpdateChannel
final NotificationChannel appUpdateChannel
= new NotificationChannel(appUpdateId, appUpdateName, importance);
appUpdateChannel.setDescription(appUpdateDescription);

NotificationManager appUpdateNotificationManager
final NotificationManager appUpdateNotificationManager
= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
appUpdateNotificationManager.createNotificationChannel(appUpdateChannel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static String getCertificateSHA1Fingerprint() {

try {
packageInfo = pm.getPackageInfo(packageName, flags);
} catch (PackageManager.NameNotFoundException e) {
} catch (final PackageManager.NameNotFoundException e) {
ErrorActivity.reportError(APP, e, null, null,
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
"Could not find package info", R.string.app_ui_crash));
Expand All @@ -77,7 +77,7 @@ private static String getCertificateSHA1Fingerprint() {
try {
final CertificateFactory cf = CertificateFactory.getInstance("X509");
c = (X509Certificate) cf.generateCertificate(input);
} catch (CertificateException e) {
} catch (final CertificateException e) {
ErrorActivity.reportError(APP, e, null, null,
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
"Certificate error", R.string.app_ui_crash));
Expand All @@ -86,7 +86,7 @@ private static String getCertificateSHA1Fingerprint() {
String hexString = null;

try {
MessageDigest md = MessageDigest.getInstance("SHA1");
final MessageDigest md = MessageDigest.getInstance("SHA1");
final byte[] publicKey = md.digest(c.getEncoded());
hexString = byte2HexFormatted(publicKey);
} catch (NoSuchAlgorithmException | CertificateEncodingException e) {
Expand Down Expand Up @@ -167,7 +167,7 @@ protected void onPostExecute(final String response) {

compareAppVersionAndShowNotification(versionName, apkLocationUrl, versionCode);

} catch (JsonParserException e) {
} catch (final JsonParserException e) {
// connectivity problems, do not alarm user and fail silently
if (DEBUG) {
Log.w(TAG, Log.getStackTraceString(e));
Expand All @@ -187,7 +187,7 @@ protected void onPostExecute(final String response) {
private void compareAppVersionAndShowNotification(final String versionName,
final String apkLocationUrl,
final int versionCode) {
int notificationId = 2000;
final int notificationId = 2000;

if (BuildConfig.VERSION_CODE < versionCode) {

Expand Down
Loading