aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-08-29 12:43:50 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-08-29 12:43:50 +0000
commit01304ee7dc56ffafbf69b953aa3c541935e581bf (patch)
tree7079673fb6be6b6ea91598abb6d9cf799b04bbf1 /app/src/main
parent78deab34b70ff8fad90ea3587cf52559c73c93c5 (diff)
downloadinfinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.tar
infinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.tar.gz
infinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.tar.bz2
infinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.tar.lz
infinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.tar.xz
infinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.tar.zst
infinity-for-reddit-01304ee7dc56ffafbf69b953aa3c541935e581bf.zip
Null check when fetching v.redd.it in ViewVideoActivity.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java32
-rw-r--r--app/src/main/res/values/strings.xml1
2 files changed, 19 insertions, 14 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 7362e892..a9e366ca 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -553,20 +553,24 @@ public class ViewVideoActivity extends AppCompatActivity {
loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, savedInstanceState, false);
} else {
progressBar.setVisibility(View.INVISIBLE);
- mVideoUri = Uri.parse(post.getVideoUrl());
- subredditName = post.getSubredditName();
- id = post.getId();
- videoDownloadUrl = post.getVideoDownloadUrl();
-
- videoFileName = subredditName + "-" + id + ".mp4";
- // Produces DataSource instances through which media data is loaded.
- dataSourceFactory = new CacheDataSourceFactory(mSimpleCache,
- new DefaultHttpDataSourceFactory(
- Util.getUserAgent(ViewVideoActivity.this,
- "Infinity")));
- // Prepare the player with the source.
- player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
- preparePlayer(savedInstanceState);
+ if (post.getVideoUrl() != null) {
+ mVideoUri = Uri.parse(post.getVideoUrl());
+ subredditName = post.getSubredditName();
+ id = post.getId();
+ videoDownloadUrl = post.getVideoDownloadUrl();
+
+ videoFileName = subredditName + "-" + id + ".mp4";
+ // Produces DataSource instances through which media data is loaded.
+ dataSourceFactory = new CacheDataSourceFactory(mSimpleCache,
+ new DefaultHttpDataSourceFactory(
+ Util.getUserAgent(ViewVideoActivity.this,
+ "Infinity")));
+ // Prepare the player with the source.
+ player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
+ preparePlayer(savedInstanceState);
+ } else {
+ Toast.makeText(ViewVideoActivity.this, R.string.error_fetching_v_redd_it_video_cannot_get_video_url, Toast.LENGTH_LONG).show();
+ }
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a286248c..1ad095d0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1114,6 +1114,7 @@
<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>
+ <string name="error_fetching_v_redd_it_video_cannot_get_video_url">Error fetching v.redd.it video: Cannot get the video url</string>
<string name="always_on">Always On</string>
<string name="only_on_wifi">Only on Wifi</string>