mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-05 21:39:50 +02:00
Maybe fixed a lot of bugs in DownloadRedditVideoService, DownloadMediaService and GlideImageGetter. Fix gfycat video not playing when opening in compact layout.
This commit is contained in:
@@ -365,7 +365,7 @@
|
|||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="ml.docilealligator.infinityforreddit.provider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
|
@@ -2507,10 +2507,19 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
case Post.VIDEO_TYPE: {
|
case Post.VIDEO_TYPE: {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
|
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.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
||||||
|
}
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
|
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
break;
|
break;
|
||||||
|
@@ -516,12 +516,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilterList)).get(PostViewModel.class);
|
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilterList)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
FetchSubredditFilters.fetchSubredditFilters(mRedditDataRoomDatabase, subredditFilters -> {
|
FetchSubredditFilters.fetchSubredditFilters(mRedditDataRoomDatabase, subredditFilters -> {
|
||||||
|
if (activity != null) {
|
||||||
subredditFilterList = subredditFilters;
|
subredditFilterList = subredditFilters;
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, getResources().getConfiguration().locale, mSharedPreferences,
|
accountName, getResources().getConfiguration().locale, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilters)).get(PostViewModel.class);
|
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilters)).get(PostViewModel.class);
|
||||||
|
|
||||||
bindPostViewModel();
|
bindPostViewModel();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -284,7 +284,8 @@ public class DownloadMediaService extends Service {
|
|||||||
downloadFinished(null, ERROR_FILE_CANNOT_DOWNLOAD);
|
downloadFinished(null, ERROR_FILE_CANNOT_DOWNLOAD);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return super.onStartCommand(intent, flags, startId);
|
|
||||||
|
return START_NOT_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Notification createNotification(String fileName) {
|
private Notification createNotification(String fileName) {
|
||||||
|
@@ -568,7 +568,7 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
|
|
||||||
muxer.stop();
|
muxer.stop();
|
||||||
muxer.release();
|
muxer.release();
|
||||||
} catch (IllegalStateException ignore) {
|
} catch (IllegalArgumentException ignore) {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Utils;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
@@ -56,7 +57,7 @@ public class GlideImageGetter implements Html.ImageGetter {
|
|||||||
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
|
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
|
||||||
|
|
||||||
Context context = container.get().getContext();
|
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)
|
container.get().post(() -> Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(source)
|
.load(source)
|
||||||
@@ -119,7 +120,13 @@ public class GlideImageGetter implements Html.ImageGetter {
|
|||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
|
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
|
||||||
if (container != null) {
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user