mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-06-27 07:32:54 +00:00
Fix Checkstyle & remove unused fields
This commit is contained in:
parent
a9153c6dd9
commit
3dba719d9f
@ -464,7 +464,8 @@ public final class Player implements PlaybackListener, Listener {
|
|||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(R.string.player_stream_failure)
|
.setTitle(R.string.player_stream_failure)
|
||||||
.setMessage(
|
.setMessage(
|
||||||
ErrorPanelHelper.Companion.getExceptionDescription(throwable))
|
ErrorPanelHelper.Companion.getExceptionDescription(
|
||||||
|
throwable))
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.show();
|
.show();
|
||||||
}));
|
}));
|
||||||
|
@ -6,7 +6,6 @@ import android.content.Intent;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import org.schabi.newpipe.MainActivity;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
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.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
|
||||||
|
|
||||||
public final class InternalUrlsHandler {
|
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 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.
|
* 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,
|
* 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.
|
* 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 context the context to use
|
||||||
* @param url the URL to check if it can be handled
|
* @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
|
* @return true if the URL can be handled by NewPipe, false if it cannot
|
||||||
*/
|
*/
|
||||||
public static boolean handleUrlDescriptionTimestamp(@NonNull final CompositeDisposable
|
public static boolean handleUrlDescriptionTimestamp(final Context context,
|
||||||
disposables,
|
|
||||||
final Context context,
|
|
||||||
@NonNull final String url) {
|
@NonNull final String url) {
|
||||||
final Matcher matcher = AMPERSAND_TIMESTAMP_PATTERN.matcher(url);
|
final Matcher matcher = AMPERSAND_TIMESTAMP_PATTERN.matcher(url);
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
@ -70,7 +62,7 @@ public final class InternalUrlsHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (linkType == StreamingService.LinkType.STREAM && seconds != -1) {
|
if (linkType == StreamingService.LinkType.STREAM && seconds != -1) {
|
||||||
return playOnPopup(context, matchedUrl, service, seconds, disposables);
|
return playOnPopup(context, matchedUrl, service, seconds);
|
||||||
} else {
|
} else {
|
||||||
NavigationHelper.openRouterActivity(context, matchedUrl);
|
NavigationHelper.openRouterActivity(context, matchedUrl);
|
||||||
return true;
|
return true;
|
||||||
@ -84,15 +76,12 @@ public final class InternalUrlsHandler {
|
|||||||
* @param url the URL of the content
|
* @param url the URL of the content
|
||||||
* @param service the service of the content
|
* @param service the service of the content
|
||||||
* @param seconds the position in seconds at which the floating player will start
|
* @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
|
* @return true if the playback of the content has successfully started or false if not
|
||||||
*/
|
*/
|
||||||
public static boolean playOnPopup(final Context context,
|
public static boolean playOnPopup(final Context context,
|
||||||
final String url,
|
final String url,
|
||||||
@NonNull final StreamingService service,
|
@NonNull final StreamingService service,
|
||||||
final int seconds,
|
final int seconds) {
|
||||||
@NonNull final CompositeDisposable disposables) {
|
|
||||||
final LinkHandlerFactory factory = service.getStreamLHFactory();
|
final LinkHandlerFactory factory = service.getStreamLHFactory();
|
||||||
final String cleanUrl;
|
final String cleanUrl;
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public final class TextLinkifier {
|
|||||||
* <p>
|
* <p>
|
||||||
* Instead of using an {@link android.content.Intent#ACTION_VIEW} intent in the description of
|
* 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
|
* 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>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
@ -240,7 +240,7 @@ public final class TextLinkifier {
|
|||||||
for (final URLSpan span : urls) {
|
for (final URLSpan span : urls) {
|
||||||
final String url = span.getURL();
|
final String url = span.getURL();
|
||||||
final LongPressClickableSpan longPressClickableSpan =
|
final LongPressClickableSpan longPressClickableSpan =
|
||||||
new UrlLongPressClickableSpan(context, disposables, url);
|
new UrlLongPressClickableSpan(context, url);
|
||||||
|
|
||||||
textBlockLinked.setSpan(longPressClickableSpan,
|
textBlockLinked.setSpan(longPressClickableSpan,
|
||||||
textBlockLinked.getSpanStart(span),
|
textBlockLinked.getSpanStart(span),
|
||||||
|
@ -45,8 +45,7 @@ final class TimestampLongPressClickableSpan extends LongPressClickableSpan {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(@NonNull final View view) {
|
public void onClick(@NonNull final View view) {
|
||||||
playOnPopup(context, relatedStreamUrl, relatedInfoService,
|
playOnPopup(context, relatedStreamUrl, relatedInfoService, timestampMatchDTO.seconds());
|
||||||
timestampMatchDTO.seconds(), disposables);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,29 +7,22 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
|
||||||
|
|
||||||
final class UrlLongPressClickableSpan extends LongPressClickableSpan {
|
final class UrlLongPressClickableSpan extends LongPressClickableSpan {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final CompositeDisposable disposables;
|
|
||||||
@NonNull
|
|
||||||
private final String url;
|
private final String url;
|
||||||
|
|
||||||
UrlLongPressClickableSpan(@NonNull final Context context,
|
UrlLongPressClickableSpan(@NonNull final Context context,
|
||||||
@NonNull final CompositeDisposable disposables,
|
|
||||||
@NonNull final String url) {
|
@NonNull final String url) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.disposables = disposables;
|
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(@NonNull final View view) {
|
public void onClick(@NonNull final View view) {
|
||||||
if (!InternalUrlsHandler.handleUrlDescriptionTimestamp(
|
if (!InternalUrlsHandler.handleUrlDescriptionTimestamp(context, url)) {
|
||||||
disposables, context, url)) {
|
|
||||||
ShareUtils.openUrlInApp(context, url);
|
ShareUtils.openUrlInApp(context, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user