From 2669ba944d7573c991ad89c9a1005b47e12412f6 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 18:54:27 -0500 Subject: [PATCH] Correct some other small lints --- .../main/java/org/schabi/newpipe/MainActivity.java | 3 +-- .../main/java/org/schabi/newpipe/RouterActivity.java | 4 ++-- .../newpipe/fragments/detail/VideoDetailFragment.java | 11 +++++------ .../java/org/schabi/newpipe/player/BasePlayer.java | 3 +-- .../org/schabi/newpipe/player/VideoPlayerImpl.java | 2 +- .../java/org/schabi/newpipe/report/ErrorActivity.java | 6 +++--- .../newpipe/settings/ContentSettingsFragment.java | 9 ++++----- .../java/org/schabi/newpipe/settings/tabs/Tab.java | 2 +- .../main/java/org/schabi/newpipe/util/KoreUtil.java | 5 ++--- 9 files changed, 20 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 9bcbe4ff1..f51ecf2d3 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -139,8 +139,7 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - if (getSupportFragmentManager() != null - && getSupportFragmentManager().getBackStackEntryCount() == 0) { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) { initFragments(); } diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index f650d882e..e14eeeba6 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -519,7 +519,7 @@ public class RouterActivity extends AppCompatActivity { disposables.add(ExtractorHelper.getStreamInfo(currentServiceId, currentUrl, true) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull StreamInfo result) -> { + .subscribe(result -> { final List sortedVideoStreams = ListHelper .getSortedStreamVideosList(this, result.getVideoStreams(), result.getVideoOnlyStreams(), false); @@ -534,7 +534,7 @@ public class RouterActivity extends AppCompatActivity { downloadDialog.show(fm, "downloadDialog"); fm.executePendingTransactions(); downloadDialog.requireDialog().setOnDismissListener(dialog -> finish()); - }, (@NonNull Throwable throwable) -> + }, throwable -> showUnsupportedUrlDialog(currentUrl))); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 8e445572d..772a291b1 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -19,7 +19,6 @@ import android.view.ViewTreeObserver; import androidx.core.text.HtmlCompat; import androidx.preference.PreferenceManager; import android.provider.Settings; -import android.text.Spanned; import android.text.TextUtils; import android.text.util.Linkify; import android.util.DisplayMetrics; @@ -731,7 +730,7 @@ public final class VideoDetailFragment } private View.OnTouchListener getOnControlsTouchListener() { - return (View view, MotionEvent motionEvent) -> { + return (view, motionEvent) -> { if (!PreferenceManager.getDefaultSharedPreferences(activity) .getBoolean(getString(R.string.show_hold_to_append_key), true)) { return false; @@ -948,7 +947,7 @@ public final class VideoDetailFragment currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull final StreamInfo result) -> { + .subscribe(result -> { isLoading.set(false); hideMainPlayer(); if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( @@ -969,7 +968,7 @@ public final class VideoDetailFragment openVideoPlayer(); } } - }, (@NonNull final Throwable throwable) -> { + }, throwable -> { isLoading.set(false); onError(throwable); }); @@ -1224,12 +1223,12 @@ public final class VideoDetailFragment if (description.getType() == Description.HTML) { disposables.add(Single.just(description.getContent()) - .map((@NonNull final String descriptionText) -> + .map(descriptionText -> HtmlCompat.fromHtml(descriptionText, HtmlCompat.FROM_HTML_MODE_LEGACY)) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull final Spanned spanned) -> { + .subscribe(spanned -> { videoDescriptionView.setText(spanned); videoDescriptionView.setVisibility(View.VISIBLE); })); diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 1355f4285..4790dc029 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -1545,8 +1545,7 @@ public abstract class BasePlayer implements if (simpleExoPlayer == null) { return PlaybackParameters.DEFAULT; } - final PlaybackParameters parameters = simpleExoPlayer.getPlaybackParameters(); - return parameters == null ? PlaybackParameters.DEFAULT : parameters; + return simpleExoPlayer.getPlaybackParameters(); } /** diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 5b4b987a4..e25ec90c4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -337,7 +337,7 @@ public class VideoPlayerImpl extends VideoPlayer view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX, (float) minimumLength / captionRatioInverse); } - view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT)); + view.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT); view.setStyle(captionStyle); } diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 3b7ae1d64..259dff44d 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -216,15 +216,15 @@ public class ErrorActivity extends AppCompatActivity { addGuruMeditation(); currentTimeStamp = getCurrentTimeStamp(); - reportEmailButton.setOnClickListener((View v) -> + reportEmailButton.setOnClickListener(v -> openPrivacyPolicyDialog(this, "EMAIL")); - copyButton.setOnClickListener((View v) -> { + copyButton.setOnClickListener(v -> { ShareUtils.copyToClipboard(this, buildMarkdown()); Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show(); }); - reportGithubButton.setOnClickListener((View v) -> + reportGithubButton.setOnClickListener(v -> openPrivacyPolicyDialog(this, "GITHUB")); diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 37431fa58..3fba6890a 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.settings; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -134,7 +133,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { addPreferencesFromResource(R.xml.content_settings); final Preference importDataPreference = findPreference(getString(R.string.import_data)); - importDataPreference.setOnPreferenceClickListener((Preference p) -> { + importDataPreference.setOnPreferenceClickListener(p -> { final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false) @@ -145,7 +144,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { }); final Preference exportDataPreference = findPreference(getString(R.string.export_data)); - exportDataPreference.setOnPreferenceClickListener((Preference p) -> { + exportDataPreference.setOnPreferenceClickListener(p -> { final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true) @@ -199,9 +198,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.override_current_data) .setPositiveButton(getString(R.string.finish), - (DialogInterface d, int id) -> importDatabase(path)) + (d, id) -> importDatabase(path)) .setNegativeButton(android.R.string.cancel, - (DialogInterface d, int id) -> d.cancel()); + (d, id) -> d.cancel()); builder.create().show(); } } diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java index ac07392cd..aaac03232 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java @@ -116,7 +116,7 @@ public abstract class Tab { return true; } - return obj instanceof Tab && obj.getClass().equals(this.getClass()) + return obj instanceof Tab && obj.getClass() == this.getClass() && ((Tab) obj).getTabId() == this.getTabId(); } diff --git a/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java b/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java index 983fe689b..7d37b25c4 100644 --- a/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java +++ b/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java @@ -2,7 +2,6 @@ package org.schabi.newpipe.util; import android.content.Context; -import android.content.DialogInterface; import androidx.appcompat.app.AlertDialog; @@ -20,9 +19,9 @@ public final class KoreUtil { public static void showInstallKoreDialog(final Context context) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(R.string.kore_not_found) - .setPositiveButton(R.string.install, (DialogInterface dialog, int which) -> + .setPositiveButton(R.string.install, (dialog, which) -> NavigationHelper.installKore(context)) - .setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> { + .setNegativeButton(R.string.cancel, (dialog, which) -> { }); builder.create().show(); }