Correct some other small lints

This commit is contained in:
TacoTheDank 2020-11-19 18:54:27 -05:00
parent 04cb6ba3d0
commit 2669ba944d
9 changed files with 20 additions and 25 deletions

View file

@ -139,8 +139,7 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
if (getSupportFragmentManager() != null if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
&& getSupportFragmentManager().getBackStackEntryCount() == 0) {
initFragments(); initFragments();
} }

View file

@ -519,7 +519,7 @@ public class RouterActivity extends AppCompatActivity {
disposables.add(ExtractorHelper.getStreamInfo(currentServiceId, currentUrl, true) disposables.add(ExtractorHelper.getStreamInfo(currentServiceId, currentUrl, true)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe((@NonNull StreamInfo result) -> { .subscribe(result -> {
final List<VideoStream> sortedVideoStreams = ListHelper final List<VideoStream> sortedVideoStreams = ListHelper
.getSortedStreamVideosList(this, result.getVideoStreams(), .getSortedStreamVideosList(this, result.getVideoStreams(),
result.getVideoOnlyStreams(), false); result.getVideoOnlyStreams(), false);
@ -534,7 +534,7 @@ public class RouterActivity extends AppCompatActivity {
downloadDialog.show(fm, "downloadDialog"); downloadDialog.show(fm, "downloadDialog");
fm.executePendingTransactions(); fm.executePendingTransactions();
downloadDialog.requireDialog().setOnDismissListener(dialog -> finish()); downloadDialog.requireDialog().setOnDismissListener(dialog -> finish());
}, (@NonNull Throwable throwable) -> }, throwable ->
showUnsupportedUrlDialog(currentUrl))); showUnsupportedUrlDialog(currentUrl)));
} }

View file

@ -19,7 +19,6 @@ import android.view.ViewTreeObserver;
import androidx.core.text.HtmlCompat; import androidx.core.text.HtmlCompat;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -731,7 +730,7 @@ public final class VideoDetailFragment
} }
private View.OnTouchListener getOnControlsTouchListener() { private View.OnTouchListener getOnControlsTouchListener() {
return (View view, MotionEvent motionEvent) -> { return (view, motionEvent) -> {
if (!PreferenceManager.getDefaultSharedPreferences(activity) if (!PreferenceManager.getDefaultSharedPreferences(activity)
.getBoolean(getString(R.string.show_hold_to_append_key), true)) { .getBoolean(getString(R.string.show_hold_to_append_key), true)) {
return false; return false;
@ -948,7 +947,7 @@ public final class VideoDetailFragment
currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe((@NonNull final StreamInfo result) -> { .subscribe(result -> {
isLoading.set(false); isLoading.set(false);
hideMainPlayer(); hideMainPlayer();
if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean(
@ -969,7 +968,7 @@ public final class VideoDetailFragment
openVideoPlayer(); openVideoPlayer();
} }
} }
}, (@NonNull final Throwable throwable) -> { }, throwable -> {
isLoading.set(false); isLoading.set(false);
onError(throwable); onError(throwable);
}); });
@ -1224,12 +1223,12 @@ public final class VideoDetailFragment
if (description.getType() == Description.HTML) { if (description.getType() == Description.HTML) {
disposables.add(Single.just(description.getContent()) disposables.add(Single.just(description.getContent())
.map((@NonNull final String descriptionText) -> .map(descriptionText ->
HtmlCompat.fromHtml(descriptionText, HtmlCompat.fromHtml(descriptionText,
HtmlCompat.FROM_HTML_MODE_LEGACY)) HtmlCompat.FROM_HTML_MODE_LEGACY))
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe((@NonNull final Spanned spanned) -> { .subscribe(spanned -> {
videoDescriptionView.setText(spanned); videoDescriptionView.setText(spanned);
videoDescriptionView.setVisibility(View.VISIBLE); videoDescriptionView.setVisibility(View.VISIBLE);
})); }));

View file

@ -1545,8 +1545,7 @@ public abstract class BasePlayer implements
if (simpleExoPlayer == null) { if (simpleExoPlayer == null) {
return PlaybackParameters.DEFAULT; return PlaybackParameters.DEFAULT;
} }
final PlaybackParameters parameters = simpleExoPlayer.getPlaybackParameters(); return simpleExoPlayer.getPlaybackParameters();
return parameters == null ? PlaybackParameters.DEFAULT : parameters;
} }
/** /**

View file

@ -337,7 +337,7 @@ public class VideoPlayerImpl extends VideoPlayer
view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX, view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX,
(float) minimumLength / captionRatioInverse); (float) minimumLength / captionRatioInverse);
} }
view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT)); view.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT);
view.setStyle(captionStyle); view.setStyle(captionStyle);
} }

View file

@ -216,15 +216,15 @@ public class ErrorActivity extends AppCompatActivity {
addGuruMeditation(); addGuruMeditation();
currentTimeStamp = getCurrentTimeStamp(); currentTimeStamp = getCurrentTimeStamp();
reportEmailButton.setOnClickListener((View v) -> reportEmailButton.setOnClickListener(v ->
openPrivacyPolicyDialog(this, "EMAIL")); openPrivacyPolicyDialog(this, "EMAIL"));
copyButton.setOnClickListener((View v) -> { copyButton.setOnClickListener(v -> {
ShareUtils.copyToClipboard(this, buildMarkdown()); ShareUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show();
}); });
reportGithubButton.setOnClickListener((View v) -> reportGithubButton.setOnClickListener(v ->
openPrivacyPolicyDialog(this, "GITHUB")); openPrivacyPolicyDialog(this, "GITHUB"));

View file

@ -3,7 +3,6 @@ package org.schabi.newpipe.settings;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
@ -134,7 +133,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
addPreferencesFromResource(R.xml.content_settings); addPreferencesFromResource(R.xml.content_settings);
final Preference importDataPreference = findPreference(getString(R.string.import_data)); final Preference importDataPreference = findPreference(getString(R.string.import_data));
importDataPreference.setOnPreferenceClickListener((Preference p) -> { importDataPreference.setOnPreferenceClickListener(p -> {
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class) final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, 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)); final Preference exportDataPreference = findPreference(getString(R.string.export_data));
exportDataPreference.setOnPreferenceClickListener((Preference p) -> { exportDataPreference.setOnPreferenceClickListener(p -> {
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class) final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true)
@ -199,9 +198,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.override_current_data) builder.setMessage(R.string.override_current_data)
.setPositiveButton(getString(R.string.finish), .setPositiveButton(getString(R.string.finish),
(DialogInterface d, int id) -> importDatabase(path)) (d, id) -> importDatabase(path))
.setNegativeButton(android.R.string.cancel, .setNegativeButton(android.R.string.cancel,
(DialogInterface d, int id) -> d.cancel()); (d, id) -> d.cancel());
builder.create().show(); builder.create().show();
} }
} }

View file

@ -116,7 +116,7 @@ public abstract class Tab {
return true; return true;
} }
return obj instanceof Tab && obj.getClass().equals(this.getClass()) return obj instanceof Tab && obj.getClass() == this.getClass()
&& ((Tab) obj).getTabId() == this.getTabId(); && ((Tab) obj).getTabId() == this.getTabId();
} }

View file

@ -2,7 +2,6 @@ package org.schabi.newpipe.util;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -20,9 +19,9 @@ public final class KoreUtil {
public static void showInstallKoreDialog(final Context context) { public static void showInstallKoreDialog(final Context context) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context); final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.kore_not_found) builder.setMessage(R.string.kore_not_found)
.setPositiveButton(R.string.install, (DialogInterface dialog, int which) -> .setPositiveButton(R.string.install, (dialog, which) ->
NavigationHelper.installKore(context)) NavigationHelper.installKore(context))
.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> { .setNegativeButton(R.string.cancel, (dialog, which) -> {
}); });
builder.create().show(); builder.create().show();
} }