aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-11-05 13:25:30 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-11-05 13:25:30 +0000
commitb62ab6f4430a7a0a3b7aaa915849487306473781 (patch)
treea25ff4aec3ef380448a6051c452a707799b39610 /app/src/main/java
parenteae6c24868be52b48b5e593f51e0488bf9263ef6 (diff)
downloadinfinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.tar
infinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.tar.gz
infinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.tar.bz2
infinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.tar.lz
infinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.tar.xz
infinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.tar.zst
infinity-for-reddit-b62ab6f4430a7a0a3b7aaa915849487306473781.zip
Fixed IllegalStateException in SubredditSelectionActivity. Downgrade material library to fix the bugs introduced in the last update.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java98
2 files changed, 67 insertions, 63 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
index 160fa136..ffd882d6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
@@ -145,11 +145,13 @@ public class SubredditSelectionActivity extends BaseActivity {
mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
mAccountProfileImageUrl = savedInstanceState.getString(ACCOUNT_PROFILE_IMAGE_URL);
+ mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
+
if (!mNullAccessToken && mAccountName == null) {
getCurrentAccountAndBindView();
} else {
- mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
- getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
+ bindView(false);
}
}
}
@@ -168,24 +170,26 @@ public class SubredditSelectionActivity extends BaseActivity {
mAccountName = account.getUsername();
mAccountProfileImageUrl = account.getProfileImageUrl();
}
- bindView();
+ bindView(true);
}).execute();
}
- private void bindView() {
+ private void bindView(boolean initializeFragment) {
loadSubscriptions();
- mFragment = new SubscribedSubredditsListingFragment();
- Bundle bundle = new Bundle();
- bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, mAccountProfileImageUrl);
- bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
- if (getIntent().hasExtra(EXTRA_EXTRA_CLEAR_SELECTION)) {
- bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_EXTRA_CLEAR_SELECTION,
- getIntent().getExtras().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION));
+ if (initializeFragment) {
+ mFragment = new SubscribedSubredditsListingFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, mAccountProfileImageUrl);
+ bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
+ if (getIntent().hasExtra(EXTRA_EXTRA_CLEAR_SELECTION)) {
+ bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_EXTRA_CLEAR_SELECTION,
+ getIntent().getExtras().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION));
+ }
+ mFragment.setArguments(bundle);
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
}
- mFragment.setArguments(bundle);
- getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
}
private void loadSubscriptions() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index 12f06260..50454381 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -890,6 +890,55 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
});
}
});
+
+ ((CommentViewHolder) holder).authorTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
+ if (mIsSingleCommentThreadMode) {
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mVisibleComments.get(holder.getAdapterPosition() - 2).getAuthor());
+ } else {
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mVisibleComments.get(holder.getAdapterPosition() - 1).getAuthor());
+ }
+ mActivity.startActivity(intent);
+ });
+
+ ((CommentViewHolder) holder).shareButton.setOnClickListener(view -> {
+ try {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ String extraText = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2).getPermalink()
+ : mVisibleComments.get(holder.getAdapterPosition() - 1).getPermalink();
+ intent.putExtra(Intent.EXTRA_TEXT, extraText);
+ mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.share)));
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(mActivity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ ((CommentViewHolder) holder).expandButton.setOnClickListener(view -> {
+ if (((CommentViewHolder) holder).expandButton.getVisibility() == View.VISIBLE) {
+ int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
+ if(commentPosition < mVisibleComments.size()) {
+ if (mVisibleComments.get(commentPosition).isExpanded()) {
+ collapseChildren(commentPosition);
+ ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
+ } else {
+ expandChildren(commentPosition);
+ mVisibleComments.get(commentPosition).setExpanded(true);
+ ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
+ }
+ }
+ }
+ });
+
+ ((CommentViewHolder) holder).commentMarkdownView.setOnLongClickListener(view -> {
+ ((CommentViewHolder) holder).expandButton.performClick();
+ return true;
+ });
+
+ ((CommentViewHolder) holder).itemView.setOnLongClickListener(view -> {
+ ((CommentViewHolder) holder).expandButton.performClick();
+ return true;
+ });
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
CommentData placeholder;
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
@@ -1730,55 +1779,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
super(itemView);
ButterKnife.bind(this, itemView);
- authorTextView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
- if (mIsSingleCommentThreadMode) {
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mVisibleComments.get(getAdapterPosition() - 2).getAuthor());
- } else {
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mVisibleComments.get(getAdapterPosition() - 1).getAuthor());
- }
- mActivity.startActivity(intent);
- });
-
- shareButton.setOnClickListener(view -> {
- try {
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType("text/plain");
- String extraText = mIsSingleCommentThreadMode ? mVisibleComments.get(getAdapterPosition() - 2).getPermalink()
- : mVisibleComments.get(getAdapterPosition() - 1).getPermalink();
- intent.putExtra(Intent.EXTRA_TEXT, extraText);
- mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.share)));
- } catch (ActivityNotFoundException e) {
- Toast.makeText(mActivity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
- }
- });
-
- expandButton.setOnClickListener(view -> {
- if (expandButton.getVisibility() == View.VISIBLE) {
- int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
- if(commentPosition < mVisibleComments.size()) {
- if (mVisibleComments.get(commentPosition).isExpanded()) {
- collapseChildren(commentPosition);
- expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
- } else {
- expandChildren(commentPosition);
- mVisibleComments.get(commentPosition).setExpanded(true);
- expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
- }
- }
- }
- });
-
- commentMarkdownView.setOnLongClickListener(view -> {
- expandButton.performClick();
- return true;
- });
-
- itemView.setOnLongClickListener(view -> {
- expandButton.performClick();
- return true;
- });
-
if (mVoteButtonsOnTheRight) {
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(bottomConstraintLayout);