From a610be7d16316a17d4c6910027d135ceda09f2ed Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 16 Jul 2021 08:44:51 +0800 Subject: Select or capture image in PostGalleryActivity. --- .../infinityforreddit/activities/PostGalleryActivity.java | 5 ++++- .../adapters/RedditGallerySubmissionRecyclerViewAdapter.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/ml/docilealligator') 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 9b80db16..50109df3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -378,7 +378,10 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee } public void selectImage() { - + Intent intent = new Intent(); + intent.setType("image/*"); + intent.setAction(Intent.ACTION_GET_CONTENT); + startActivityForResult(Intent.createChooser(intent, resources.getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE); } public void captureImage() { 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 a03d28ec..b81f235b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RedditGallerySubmissionRecyclerViewAdapter.java @@ -121,6 +121,9 @@ public class RedditGallerySubmissionRecyclerViewAdapter extends RecyclerView.Ada } public void addImage(String imageUrl) { + if (redditGalleryImageInfoList == null) { + redditGalleryImageInfoList = new ArrayList<>(); + } redditGalleryImageInfoList.add(new RedditGalleryImageInfo(imageUrl)); notifyItemInserted(redditGalleryImageInfoList.size() - 1); } -- cgit v1.2.3