Skip to content

Commit

Permalink
Fix a few SonarLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Sep 5, 2021
1 parent 433c6dc commit 4d51ebc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public abstract class BaseFragment extends Fragment {
protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
protected final boolean DEBUG = MainActivity.DEBUG;
protected static final boolean DEBUG = MainActivity.DEBUG;
protected AppCompatActivity activity;
//These values are used for controlling fragments when they are part of the frontpage
@State
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.schabi.newpipe.error;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
Expand Down Expand Up @@ -66,6 +67,7 @@ public static String sanitizeRecaptchaUrl(@Nullable final String url) {
private ActivityRecaptchaBinding recaptchaBinding;
private String foundCookies = "";

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(final Bundle savedInstanceState) {
ThemeHelper.setTheme(this);
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public void handleIntent(@NonNull final Intent intent) {
playQueue.append(newQueue.getStreams());

if ((intent.getBooleanExtra(SELECT_ON_APPEND, false)
|| currentState == STATE_COMPLETED) && newQueue.getStreams().size() > 0) {
|| currentState == STATE_COMPLETED) && !newQueue.getStreams().isEmpty()) {
playQueue.setIndex(sizeBeforeAppend);
}

Expand Down Expand Up @@ -2326,7 +2326,7 @@ public void onRepeatModeChanged(@RepeatMode final int repeatMode) {
Log.d(TAG, "ExoPlayer - onRepeatModeChanged() called with: "
+ "repeatMode = [" + repeatMode + "]");
}
setRepeatModeButton(((AppCompatImageButton) binding.repeatButton), repeatMode);
setRepeatModeButton(binding.repeatButton, repeatMode);
onShuffleOrRepeatModeChanged();
}

Expand Down Expand Up @@ -3189,7 +3189,7 @@ public void onScrolledDown(final RecyclerView recyclerView) {
private StreamSegmentAdapter.StreamSegmentListener getStreamSegmentListener() {
return (item, seconds) -> {
segmentAdapter.selectSegment(item);
seekTo(seconds * 1000);
seekTo(seconds * 1000L);
triggerProgressUpdate();
};
}
Expand All @@ -3199,7 +3199,7 @@ private int getNearestStreamSegmentPosition(final long playbackPosition) {
final List<StreamSegment> segments = currentMetadata.getMetadata().getStreamSegments();

for (int i = 0; i < segments.size(); i++) {
if (segments.get(i).getStartTimeSeconds() * 1000 > playbackPosition) {
if (segments.get(i).getStartTimeSeconds() * 1000L > playbackPosition) {
break;
}
nearestPosition++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public static void openVideoDetailFragment(@NonNull final Context context,
autoPlay = false;
}

final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = (detailFragment) -> {
final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = detailFragment -> {
expandMainPlayer(detailFragment.requireActivity());
detailFragment.setAutoPlay(autoPlay);
if (switchingPlayers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static boolean checkSystemAlertWindowPermission(final Context context) {

public static boolean isPopupEnabled(final Context context) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| PermissionHelper.checkSystemAlertWindowPermission(context);
|| checkSystemAlertWindowPermission(context);
}

public static void showPopupEnablementToast(final Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ private static boolean handleUrl(final Context context,
return false;
}
final String matchedUrl = matcher.group(1);
final int seconds = Integer.parseInt(matcher.group(2));
final int seconds;
if (matcher.group(2) == null) {
seconds = -1;
} else {
seconds = Integer.parseInt(matcher.group(2));
}

final StreamingService service;
final StreamingService.LinkType linkType;
Expand Down Expand Up @@ -154,7 +159,7 @@ public static boolean playOnPopup(final Context context,
.observeOn(AndroidSchedulers.mainThread())
.subscribe(info -> {
final PlayQueue playQueue
= new SinglePlayQueue(info, seconds * 1000);
= new SinglePlayQueue(info, seconds * 1000L);
NavigationHelper.playOnPopupPlayer(context, playQueue, false);
}, throwable -> {
if (DEBUG) {
Expand Down

0 comments on commit 4d51ebc

Please sign in to comment.