aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-03-02 17:51:28 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-03-02 17:51:28 +0000
commitce7981534699aa7fef1a321a76b67be73c45210b (patch)
tree98257a4d9c53b9c34328701497c8bcab6506fc37 /app/src
parent28acf9933dd3f5eedfae857155306b6140fab0b5 (diff)
downloadinfinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.tar
infinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.tar.gz
infinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.tar.bz2
infinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.tar.lz
infinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.tar.xz
infinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.tar.zst
infinity-for-reddit-ce7981534699aa7fef1a321a76b67be73c45210b.zip
Fix NullPointerException in when loading fallback video.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java43
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java42
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java4
4 files changed, 59 insertions, 44 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
index 8c538e47..863d4484 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
@@ -25,7 +25,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.content.res.AppCompatResources;
import androidx.constraintlayout.widget.Barrier;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
@@ -3323,12 +3322,14 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
- post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
- post.setVideoUrl(post.getVideoFallBackDirectUrl());
- post.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (post.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
+ post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
+ post.setVideoUrl(post.getVideoFallBackDirectUrl());
+ post.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
@@ -4978,12 +4979,14 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
- post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
- post.setVideoUrl(post.getVideoFallBackDirectUrl());
- post.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (post.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
+ post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
+ post.setVideoUrl(post.getVideoFallBackDirectUrl());
+ post.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
@@ -5972,12 +5975,14 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
- post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
- post.setVideoUrl(post.getVideoFallBackDirectUrl());
- post.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (post.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
+ post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
+ post.setVideoUrl(post.getVideoFallBackDirectUrl());
+ post.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index 7e08d604..c46091fa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -1785,12 +1785,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(mPost.getVideoFallBackDirectUrl());
- mPost.setVideoDownloadUrl(mPost.getVideoFallBackDirectUrl());
- mPost.setVideoUrl(mPost.getVideoFallBackDirectUrl());
- mPost.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (mPost.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(mPost.getVideoFallBackDirectUrl());
+ mPost.setVideoDownloadUrl(mPost.getVideoFallBackDirectUrl());
+ mPost.setVideoUrl(mPost.getVideoFallBackDirectUrl());
+ mPost.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index a1cb9447..4f5dcdb7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -3485,12 +3485,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
- post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
- post.setVideoUrl(post.getVideoFallBackDirectUrl());
- post.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (post.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
+ post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
+ post.setVideoUrl(post.getVideoFallBackDirectUrl());
+ post.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
@@ -5208,12 +5210,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
- post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
- post.setVideoUrl(post.getVideoFallBackDirectUrl());
- post.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (post.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
+ post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
+ post.setVideoUrl(post.getVideoFallBackDirectUrl());
+ post.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
@@ -6238,12 +6242,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void loadFallbackDirectVideo() {
- mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
- post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
- post.setVideoUrl(post.getVideoFallBackDirectUrl());
- post.setLoadRedgifsOrStreamableVideoSuccess(true);
- if (container != null) {
- container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ if (post.getVideoFallBackDirectUrl() != null) {
+ mediaUri = Uri.parse(post.getVideoFallBackDirectUrl());
+ post.setVideoDownloadUrl(post.getVideoFallBackDirectUrl());
+ post.setVideoUrl(post.getVideoFallBackDirectUrl());
+ post.setLoadRedgifsOrStreamableVideoSuccess(true);
+ if (container != null) {
+ container.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
index d15c6f7e..52c1bf22 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
@@ -43,6 +43,7 @@ public class Post implements Parcelable {
private String url;
private String videoUrl;
private String videoDownloadUrl;
+ @Nullable
private String videoFallBackDirectUrl;
private String redgifsId;
private String streamableShortCode;
@@ -330,11 +331,12 @@ public class Post implements Parcelable {
this.videoDownloadUrl = videoDownloadUrl;
}
+ @Nullable
public String getVideoFallBackDirectUrl() {
return videoFallBackDirectUrl;
}
- public void setVideoFallBackDirectUrl(String videoFallBackDirectUrl) {
+ public void setVideoFallBackDirectUrl(@Nullable String videoFallBackDirectUrl) {
this.videoFallBackDirectUrl = videoFallBackDirectUrl;
}