From a1831f7ce10f2556cd6d26ba03b4c911d42e29b8 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 12 Mar 2021 21:07:37 +0800 Subject: Handle v.redd.it videos loading failed. --- .../infinityforreddit/activities/ViewVideoActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index df24e15b..094657b9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -424,7 +424,7 @@ public class ViewVideoActivity extends AppCompatActivity { public void onResponse(@NonNull Call call, @NonNull Response response) { Uri redirectUri = Uri.parse(response.raw().request().url().toString()); String redirectPath = redirectUri.getPath(); - if (redirectPath.matches("/r/\\w+/comments/\\w+/?\\w+/?") || redirectPath.matches("/user/\\w+/comments/\\w+/?\\w+/?")) { + if (redirectPath != null && (redirectPath.matches("/r/\\w+/comments/\\w+/?\\w+/?") || redirectPath.matches("/user/\\w+/comments/\\w+/?\\w+/?"))) { List segments = redirectUri.getPathSegments(); int commentsIndex = segments.lastIndexOf("comments"); String postId = segments.get(commentsIndex + 1); @@ -473,17 +473,17 @@ public class ViewVideoActivity extends AppCompatActivity { @Override public void fetchPostFailed() { - + Toast.makeText(ViewVideoActivity.this, R.string.error_fetching_v_redd_it_video_cannot_get_post, Toast.LENGTH_LONG).show(); } }); } else { - + Toast.makeText(ViewVideoActivity.this, R.string.error_fetching_v_redd_it_video_cannot_get_post_id, Toast.LENGTH_LONG).show(); } } @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { - + Toast.makeText(ViewVideoActivity.this, R.string.error_fetching_v_redd_it_video_cannot_get_redirect_url, Toast.LENGTH_LONG).show(); } }); } -- cgit v1.2.3