aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-07-16 13:43:43 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-07-16 13:43:43 +0000
commit19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4 (patch)
tree7d9555ee16deff9ce75539ef33c3fef04b620cb3 /app
parent5a12266c6fa3a0bb2a976080e9f52226a689d104 (diff)
downloadinfinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.tar
infinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.tar.gz
infinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.tar.bz2
infinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.tar.lz
infinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.tar.xz
infinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.tar.zst
infinity-for-reddit-19a94f7e0a4b4bbcd0b928cab53dc1e110e7e7c4.zip
Automatically remove images that are not uploaded in PostGalleryActivity.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java5
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;