mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 12:57:12 +01: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:
parent
979ff84f46
commit
4a67e02639
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user