aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadMediaService.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java11
6 files changed, 33 insertions, 14 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d636665f..b174ee0e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -365,7 +365,7 @@
<provider
android:name="androidx.core.content.FileProvider"
- android:authorities="${applicationId}.provider"
+ android:authorities="ml.docilealligator.infinityforreddit.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index ac223d3d..73d7bb8d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -2507,10 +2507,19 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
case Post.VIDEO_TYPE: {
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
- intent.setData(Uri.parse(post.getVideoUrl()));
- intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
- intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
- intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ if (post.isGfycat()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
+ } else if (post.isRedgifs()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
+ } else {
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ }
+ intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
mActivity.startActivity(intent);
break;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 553df57f..49da464a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -516,12 +516,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilterList)).get(PostViewModel.class);
} else {
FetchSubredditFilters.fetchSubredditFilters(mRedditDataRoomDatabase, subredditFilters -> {
- subredditFilterList = subredditFilters;
- mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
- accountName, getResources().getConfiguration().locale, mSharedPreferences,
- postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilters)).get(PostViewModel.class);
+ if (activity != null) {
+ subredditFilterList = subredditFilters;
+ mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
+ accountName, getResources().getConfiguration().locale, mSharedPreferences,
+ postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilters)).get(PostViewModel.class);
- bindPostViewModel();
+ bindPostViewModel();
+ }
});
}
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadMediaService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadMediaService.java
index 30dfd001..49182903 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadMediaService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadMediaService.java
@@ -284,7 +284,8 @@ public class DownloadMediaService extends Service {
downloadFinished(null, ERROR_FILE_CANNOT_DOWNLOAD);
}
});
- return super.onStartCommand(intent, flags, startId);
+
+ return START_NOT_STICKY;
}
private Notification createNotification(String fileName) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
index 440441c7..575a0868 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
@@ -568,7 +568,7 @@ public class DownloadRedditVideoService extends Service {
muxer.stop();
muxer.release();
- } catch (IllegalStateException ignore) {
+ } catch (IllegalArgumentException ignore) {
} catch (IOException e) {
e.printStackTrace();
return false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
index f3cef706..bd100469 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Utils;
import android.app.Activity;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
@@ -56,7 +57,7 @@ public class GlideImageGetter implements Html.ImageGetter {
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
Context context = container.get().getContext();
- if (!(context instanceof Activity && ((Activity) context).isDestroyed())) {
+ if (!(context instanceof Activity && (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()))) {
container.get().post(() -> Glide.with(context)
.asBitmap()
.load(source)
@@ -119,7 +120,13 @@ public class GlideImageGetter implements Html.ImageGetter {
@Override
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
if (container != null) {
- setDrawable(new BitmapDrawable(container.get().getResources(), bitmap));
+ TextView textView = container.get();
+ if (textView != null) {
+ Resources resources = textView.getResources();
+ if (resources != null) {
+ setDrawable(new BitmapDrawable(resources, bitmap));
+ }
+ }
}
}