diff options
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java | 8 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 4 |
2 files changed, 8 insertions, 4 deletions
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<String> call, @NonNull Response<String> 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<String> 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<String> call, @NonNull Throwable t) { - + Toast.makeText(ViewVideoActivity.this, R.string.error_fetching_v_redd_it_video_cannot_get_redirect_url, Toast.LENGTH_LONG).show(); } }); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9b530ab3..414087ae 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1055,4 +1055,8 @@ <string name="do_not_show_this_again">Don\'t show this again</string> <string name="continue_suicide_prevention_activity">Continue</string> + <string name="error_fetching_v_redd_it_video_cannot_get_redirect_url">Error fetching v.redd.it video: Cannot get the redirect url</string> + <string name="error_fetching_v_redd_it_video_cannot_get_post">Error fetching v.redd.it video: Cannot get the post</string> + <string name="error_fetching_v_redd_it_video_cannot_get_post_id">Error fetching v.redd.it video: Cannot get the post id</string> + </resources> |