diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-04 01:20:36 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-04 01:20:36 +0000 |
commit | 91ae3f9610cb97407bc23c2742fd4a991b681524 (patch) | |
tree | 3ff5e0074ab2739a71cc8ae3ee54fa5500b3d83f /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | f33dfd288a4a6535bc8357765d1ffe98299100ba (diff) | |
download | infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.tar infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.tar.gz infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.tar.bz2 infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.tar.lz infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.tar.xz infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.tar.zst infinity-for-reddit-91ae3f9610cb97407bc23c2742fd4a991b681524.zip |
Add an option in MarkdownBottomBarRecyclerViewAdapter to upload images.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
5 files changed, 65 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java index 30811e2f..8bfd09dc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java @@ -236,8 +236,18 @@ public class CommentActivity extends BaseActivity { setSupportActionBar(toolbar); - MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(mCustomThemeWrapper, item -> { - MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(this, commentEditText, item); + MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter( + mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() { + @Override + public void onClick(int item) { + MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener( + CommentActivity.this, commentEditText, item); + } + + @Override + public void onUploadImage() { + + } }); markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManager(this, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java index 07c0c2af..8cd3d646 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java @@ -32,12 +32,12 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.apis.RedditAPI; +import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter; +import ml.docilealligator.infinityforreddit.apis.RedditAPI; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; -import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -109,8 +109,18 @@ public class EditCommentActivity extends BaseActivity { mCommentContent = getIntent().getStringExtra(EXTRA_CONTENT); contentEditText.setText(mCommentContent); - MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(mCustomThemeWrapper, item -> { - MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(this, contentEditText, item); + MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter( + mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() { + @Override + public void onClick(int item) { + MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener( + EditCommentActivity.this, contentEditText, item); + } + + @Override + public void onUploadImage() { + + } }); markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManager(this, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java index 5c8ea02f..f6573507 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java @@ -117,8 +117,18 @@ public class EditPostActivity extends BaseActivity { mPostContent = getIntent().getStringExtra(EXTRA_CONTENT); contentEditText.setText(mPostContent); - MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(mCustomThemeWrapper, item -> { - MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(this, contentEditText, item); + MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter( + mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() { + @Override + public void onClick(int item) { + MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener( + EditPostActivity.this, contentEditText, item); + } + + @Override + public void onUploadImage() { + + } }); markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManager(this, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java index 7d93fef7..1d256f00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java @@ -310,8 +310,18 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr } }); - MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(mCustomThemeWrapper, item -> { - MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(this, contentEditText, item); + MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter( + mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() { + @Override + public void onClick(int item) { + MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener( + PostTextActivity.this, contentEditText, item); + } + + @Override + public void onUploadImage() { + + } }); markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManager(this, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java index b7057106..fec4d3c2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java @@ -29,14 +29,16 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R public static final int SPOILER = 7; public static final int QUOTE = 8; public static final int CODE_BLOCK = 9; + public static final int UPLOAD_IMAGE = 10; - private static final int ITEM_COUNT = 10; + private static final int ITEM_COUNT = 11; private CustomThemeWrapper customThemeWrapper; private ItemClickListener itemClickListener; public interface ItemClickListener { void onClick(int item); + void onUploadImage(); } public MarkdownBottomBarRecyclerViewAdapter(CustomThemeWrapper customThemeWrapper, @@ -85,6 +87,9 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R case CODE_BLOCK: ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_code_24dp); break; + case UPLOAD_IMAGE: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_image_24dp); + break; } } } @@ -289,7 +294,14 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R public MarkdownBottomBarItemViewHolder(@NonNull View itemView) { super(itemView); imageView = (ImageView) itemView; - itemView.setOnClickListener(view -> itemClickListener.onClick(getAdapterPosition())); + itemView.setOnClickListener(view -> { + int position = getBindingAdapterPosition(); + if (position == UPLOAD_IMAGE) { + itemClickListener.onUploadImage(); + } else { + itemClickListener.onClick(position); + } + }); imageView.setColorFilter(customThemeWrapper.getPrimaryIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); } |