aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-03-12 13:07:37 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-03-12 13:07:37 +0000
commita1831f7ce10f2556cd6d26ba03b4c911d42e29b8 (patch)
treea9971ebd44f0fa0427157ffca4674dfe33b70831 /app/src/main/java/ml
parent6beb4485401a4da1a22a86f062f359d2c01bf3ef (diff)
downloadinfinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.tar
infinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.tar.gz
infinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.tar.bz2
infinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.tar.lz
infinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.tar.xz
infinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.tar.zst
infinity-for-reddit-a1831f7ce10f2556cd6d26ba03b4c911d42e29b8.zip
Handle v.redd.it videos loading failed.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java8
1 files changed, 4 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();
}
});
}