1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-06-27 15:43:07 +00:00

Fix Checkstyle & remove unused fields

This commit is contained in:
Profpatsch 2025-05-06 09:58:41 +02:00
parent a9153c6dd9
commit 3dba719d9f
5 changed files with 12 additions and 30 deletions

View File

@ -464,7 +464,8 @@ public final class Player implements PlaybackListener, Listener {
new AlertDialog.Builder(context)
.setTitle(R.string.player_stream_failure)
.setMessage(
ErrorPanelHelper.Companion.getExceptionDescription(throwable))
ErrorPanelHelper.Companion.getExceptionDescription(
throwable))
.setPositiveButton(R.string.ok, null)
.show();
}));

View File

@ -6,7 +6,6 @@ import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -18,15 +17,11 @@ import org.schabi.newpipe.util.NavigationHelper;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.reactivex.rxjava3.disposables.CompositeDisposable;
public final class InternalUrlsHandler {
private static final String TAG = InternalUrlsHandler.class.getSimpleName();
private static final boolean DEBUG = MainActivity.DEBUG;
private static final Pattern AMPERSAND_TIMESTAMP_PATTERN = Pattern.compile("(.*)&t=(\\d+)");
private static final Pattern HASHTAG_TIMESTAMP_PATTERN =
Pattern.compile("(.*)#timestamp=(\\d+)");
private InternalUrlsHandler() {
}
/**
* Handle a YouTube timestamp description URL in NewPipe.
@ -36,14 +31,11 @@ public final class InternalUrlsHandler {
* player will be opened when the user will click on the timestamp in the video description,
* at the time and for the video indicated in the timestamp.
*
* @param disposables a field of the Activity/Fragment class that calls this method
* @param context the context to use
* @param url the URL to check if it can be handled
* @return true if the URL can be handled by NewPipe, false if it cannot
*/
public static boolean handleUrlDescriptionTimestamp(@NonNull final CompositeDisposable
disposables,
final Context context,
public static boolean handleUrlDescriptionTimestamp(final Context context,
@NonNull final String url) {
final Matcher matcher = AMPERSAND_TIMESTAMP_PATTERN.matcher(url);
if (!matcher.matches()) {
@ -70,7 +62,7 @@ public final class InternalUrlsHandler {
}
if (linkType == StreamingService.LinkType.STREAM && seconds != -1) {
return playOnPopup(context, matchedUrl, service, seconds, disposables);
return playOnPopup(context, matchedUrl, service, seconds);
} else {
NavigationHelper.openRouterActivity(context, matchedUrl);
return true;
@ -84,15 +76,12 @@ public final class InternalUrlsHandler {
* @param url the URL of the content
* @param service the service of the content
* @param seconds the position in seconds at which the floating player will start
* @param disposables disposables created by the method are added here and their lifecycle
* should be handled by the calling class
* @return true if the playback of the content has successfully started or false if not
*/
public static boolean playOnPopup(final Context context,
final String url,
@NonNull final StreamingService service,
final int seconds,
@NonNull final CompositeDisposable disposables) {
final int seconds) {
final LinkHandlerFactory factory = service.getStreamLHFactory();
final String cleanUrl;

View File

@ -192,7 +192,7 @@ public final class TextLinkifier {
* <p>
* Instead of using an {@link android.content.Intent#ACTION_VIEW} intent in the description of
* a content, this method will parse the {@link CharSequence} and replace all current web links
* with {@link ShareUtils#openUrlInBrowser(Context, String, boolean)}.
* with {@link ShareUtils#openUrlInBrowser(Context, String)}.
* </p>
*
* <p>
@ -240,7 +240,7 @@ public final class TextLinkifier {
for (final URLSpan span : urls) {
final String url = span.getURL();
final LongPressClickableSpan longPressClickableSpan =
new UrlLongPressClickableSpan(context, disposables, url);
new UrlLongPressClickableSpan(context, url);
textBlockLinked.setSpan(longPressClickableSpan,
textBlockLinked.getSpanStart(span),

View File

@ -45,8 +45,7 @@ final class TimestampLongPressClickableSpan extends LongPressClickableSpan {
@Override
public void onClick(@NonNull final View view) {
playOnPopup(context, relatedStreamUrl, relatedInfoService,
timestampMatchDTO.seconds(), disposables);
playOnPopup(context, relatedStreamUrl, relatedInfoService, timestampMatchDTO.seconds());
}
@Override

View File

@ -7,29 +7,22 @@ import androidx.annotation.NonNull;
import org.schabi.newpipe.util.external_communication.ShareUtils;
import io.reactivex.rxjava3.disposables.CompositeDisposable;
final class UrlLongPressClickableSpan extends LongPressClickableSpan {
@NonNull
private final Context context;
@NonNull
private final CompositeDisposable disposables;
@NonNull
private final String url;
UrlLongPressClickableSpan(@NonNull final Context context,
@NonNull final CompositeDisposable disposables,
@NonNull final String url) {
this.context = context;
this.disposables = disposables;
this.url = url;
}
@Override
public void onClick(@NonNull final View view) {
if (!InternalUrlsHandler.handleUrlDescriptionTimestamp(
disposables, context, url)) {
if (!InternalUrlsHandler.handleUrlDescriptionTimestamp(context, url)) {
ShareUtils.openUrlInApp(context, url);
}
}