diff options
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
2 files changed, 13 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java index d296688f..21d5c5d6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -266,6 +266,12 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee isSpoiler = savedInstanceState.getBoolean(IS_SPOILER_STATE); isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE); redditGalleryImageInfoList = savedInstanceState.getParcelableArrayList(REDDIT_GALLERY_IMAGE_INFO_STATE); + if (redditGalleryImageInfoList != null && !redditGalleryImageInfoList.isEmpty()) { + if (redditGalleryImageInfoList.get(redditGalleryImageInfoList.size() - 1).payload == null) { + imageUri = Uri.parse(redditGalleryImageInfoList.get(redditGalleryImageInfoList.size() - 1).imageUrlString); + uploadImage(); + } + } adapter.setRedditGalleryImageInfoList(redditGalleryImageInfoList); if (subredditName != null) { @@ -461,12 +467,14 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); handler.post(() -> { + adapter.removeFailedToUploadImage(); Snackbar.make(coordinatorLayout, R.string.get_image_bitmap_failed, Snackbar.LENGTH_LONG).show(); isUploading = false; }); } catch (XmlPullParserException | JSONException | IOException e) { e.printStackTrace(); handler.post(() -> { + adapter.removeFailedToUploadImage(); Snackbar.make(coordinatorLayout, R.string.error_processing_image, Snackbar.LENGTH_LONG).show(); isUploading = false; }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java index 005e65f4..80b4d1e4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java @@ -136,6 +136,11 @@ public class RedditGallerySubmissionRecyclerViewAdapter extends RecyclerView.Ada notifyItemChanged(redditGalleryImageInfoList.size() - 1); } + public void removeFailedToUploadImage() { + redditGalleryImageInfoList.remove(redditGalleryImageInfoList.size() - 1); + notifyItemRemoved(redditGalleryImageInfoList.size()); + } + class ImageViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.aspect_ratio_gif_image_view_item_reddit_gallery_submission_image) AspectRatioGifImageView imageView; |