Skip to content

Commit 4d51ebc

Browse files
committed
Fix a few SonarLint warnings
1 parent 433c6dc commit 4d51ebc

6 files changed

Lines changed: 16 additions & 9 deletions

File tree

app/src/main/java/org/schabi/newpipe/BaseFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public abstract class BaseFragment extends Fragment {
1818
protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
19-
protected final boolean DEBUG = MainActivity.DEBUG;
19+
protected static final boolean DEBUG = MainActivity.DEBUG;
2020
protected AppCompatActivity activity;
2121
//These values are used for controlling fragments when they are part of the frontpage
2222
@State

app/src/main/java/org/schabi/newpipe/error/ReCaptchaActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.error;
22

3+
import android.annotation.SuppressLint;
34
import android.content.Intent;
45
import android.content.SharedPreferences;
56
import android.os.Build;
@@ -66,6 +67,7 @@ public static String sanitizeRecaptchaUrl(@Nullable final String url) {
6667
private ActivityRecaptchaBinding recaptchaBinding;
6768
private String foundCookies = "";
6869

70+
@SuppressLint("SetJavaScriptEnabled")
6971
@Override
7072
protected void onCreate(final Bundle savedInstanceState) {
7173
ThemeHelper.setTheme(this);

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public void handleIntent(@NonNull final Intent intent) {
614614
playQueue.append(newQueue.getStreams());
615615

616616
if ((intent.getBooleanExtra(SELECT_ON_APPEND, false)
617-
|| currentState == STATE_COMPLETED) && newQueue.getStreams().size() > 0) {
617+
|| currentState == STATE_COMPLETED) && !newQueue.getStreams().isEmpty()) {
618618
playQueue.setIndex(sizeBeforeAppend);
619619
}
620620

@@ -2326,7 +2326,7 @@ public void onRepeatModeChanged(@RepeatMode final int repeatMode) {
23262326
Log.d(TAG, "ExoPlayer - onRepeatModeChanged() called with: "
23272327
+ "repeatMode = [" + repeatMode + "]");
23282328
}
2329-
setRepeatModeButton(((AppCompatImageButton) binding.repeatButton), repeatMode);
2329+
setRepeatModeButton(binding.repeatButton, repeatMode);
23302330
onShuffleOrRepeatModeChanged();
23312331
}
23322332

@@ -3189,7 +3189,7 @@ public void onScrolledDown(final RecyclerView recyclerView) {
31893189
private StreamSegmentAdapter.StreamSegmentListener getStreamSegmentListener() {
31903190
return (item, seconds) -> {
31913191
segmentAdapter.selectSegment(item);
3192-
seekTo(seconds * 1000);
3192+
seekTo(seconds * 1000L);
31933193
triggerProgressUpdate();
31943194
};
31953195
}
@@ -3199,7 +3199,7 @@ private int getNearestStreamSegmentPosition(final long playbackPosition) {
31993199
final List<StreamSegment> segments = currentMetadata.getMetadata().getStreamSegments();
32003200

32013201
for (int i = 0; i < segments.size(); i++) {
3202-
if (segments.get(i).getStartTimeSeconds() * 1000 > playbackPosition) {
3202+
if (segments.get(i).getStartTimeSeconds() * 1000L > playbackPosition) {
32033203
break;
32043204
}
32053205
nearestPosition++;

app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public static void openVideoDetailFragment(@NonNull final Context context,
360360
autoPlay = false;
361361
}
362362

363-
final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = (detailFragment) -> {
363+
final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = detailFragment -> {
364364
expandMainPlayer(detailFragment.requireActivity());
365365
detailFragment.setAutoPlay(autoPlay);
366366
if (switchingPlayers) {

app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static boolean checkSystemAlertWindowPermission(final Context context) {
119119

120120
public static boolean isPopupEnabled(final Context context) {
121121
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
122-
|| PermissionHelper.checkSystemAlertWindowPermission(context);
122+
|| checkSystemAlertWindowPermission(context);
123123
}
124124

125125
public static void showPopupEnablementToast(final Context context) {

app/src/main/java/org/schabi/newpipe/util/external_communication/InternalUrlsHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ private static boolean handleUrl(final Context context,
101101
return false;
102102
}
103103
final String matchedUrl = matcher.group(1);
104-
final int seconds = Integer.parseInt(matcher.group(2));
104+
final int seconds;
105+
if (matcher.group(2) == null) {
106+
seconds = -1;
107+
} else {
108+
seconds = Integer.parseInt(matcher.group(2));
109+
}
105110

106111
final StreamingService service;
107112
final StreamingService.LinkType linkType;
@@ -154,7 +159,7 @@ public static boolean playOnPopup(final Context context,
154159
.observeOn(AndroidSchedulers.mainThread())
155160
.subscribe(info -> {
156161
final PlayQueue playQueue
157-
= new SinglePlayQueue(info, seconds * 1000);
162+
= new SinglePlayQueue(info, seconds * 1000L);
158163
NavigationHelper.playOnPopupPlayer(context, playQueue, false);
159164
}, throwable -> {
160165
if (DEBUG) {

0 commit comments

Comments
 (0)