Shrink the vertical block in comments tree. Temporarily disable the splash screen to see if android.view.DisplayListCanvas.throwIfCannotDraw exception will be gone. Minor bugs fixed.

This commit is contained in:
Alex Ning 2019-09-16 21:25:41 +08:00
parent 8b366c0961
commit 7e96130d20
4 changed files with 34 additions and 13 deletions

View File

@ -193,7 +193,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme.Launcher"> android:theme="@style/AppTheme.NoActionBarWithTransparentStatusBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -511,9 +511,12 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
mMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentContent()); mMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentContent());
((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore() + comment.getVoteType())); ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore() + comment.getVoteType()));
ViewGroup.LayoutParams params = ((CommentViewHolder) holder).verticalBlock.getLayoutParams(); ((CommentViewHolder) holder).itemView.setPadding(comment.getDepth() * 16, 0, 0, 0);
params.width = comment.getDepth() * 16; if(comment.getDepth() > 0) {
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params); ViewGroup.LayoutParams params = ((CommentViewHolder) holder).verticalBlock.getLayoutParams();
params.width = 16;
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
}
if(!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) { if(!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
((CommentViewHolder) holder).moreButton.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).moreButton.setVisibility(View.VISIBLE);
@ -717,9 +720,12 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2) placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
: mVisibleComments.get(holder.getAdapterPosition() - 1); : mVisibleComments.get(holder.getAdapterPosition() - 1);
ViewGroup.LayoutParams params = ((LoadMoreChildCommentsViewHolder) holder).verticalBlock.getLayoutParams(); ((LoadMoreChildCommentsViewHolder) holder).itemView.setPadding(placeholder.getDepth() * 16, 0, 0, 0);
params.width = placeholder.getDepth() * 16; if(placeholder.getDepth() > 0) {
((LoadMoreChildCommentsViewHolder) holder).verticalBlock.setLayoutParams(params); ViewGroup.LayoutParams params = ((LoadMoreChildCommentsViewHolder) holder).verticalBlock.getLayoutParams();
params.width = 16;
((LoadMoreChildCommentsViewHolder) holder).verticalBlock.setLayoutParams(params);
}
if(placeholder.isLoadingMoreChildren()) { if(placeholder.isLoadingMoreChildren()) {
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.loading); ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.loading);
@ -770,6 +776,10 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
} }
private int getParentPosition(int position) { private int getParentPosition(int position) {
if(position >= mVisibleComments.size()) {
return -1;
}
int childDepth = mVisibleComments.get(position).getDepth(); int childDepth = mVisibleComments.get(position).getDepth();
for(int i = position; i >= 0; i--) { for(int i = position; i >= 0; i--) {
if(mVisibleComments.get(i).getDepth() < childDepth) { if(mVisibleComments.get(i).getDepth() < childDepth) {
@ -977,6 +987,10 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor)); ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.defaultTextColor));
((CommentViewHolder) holder).downVoteButton.clearColorFilter(); ((CommentViewHolder) holder).downVoteButton.clearColorFilter();
((CommentViewHolder) holder).replyButton.clearColorFilter(); ((CommentViewHolder) holder).replyButton.clearColorFilter();
ViewGroup.LayoutParams params = ((CommentViewHolder) holder).verticalBlock.getLayoutParams();
params.width = 0;
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
((CommentViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
((CommentViewHolder) holder).itemView.setBackgroundColor( ((CommentViewHolder) holder).itemView.setBackgroundColor(
mActivity.getResources().getColor(R.color.cardViewBackgroundColor)); mActivity.getResources().getColor(R.color.cardViewBackgroundColor));
} else if(holder instanceof PostDetailViewHolder) { } else if(holder instanceof PostDetailViewHolder) {
@ -987,6 +1001,11 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
((PostDetailViewHolder) holder).flairTextView.setVisibility(View.GONE); ((PostDetailViewHolder) holder).flairTextView.setVisibility(View.GONE);
((PostDetailViewHolder) holder).spoilerTextView.setVisibility(View.GONE); ((PostDetailViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
((PostDetailViewHolder) holder).mNSFWChip.setVisibility(View.GONE); ((PostDetailViewHolder) holder).mNSFWChip.setVisibility(View.GONE);
} else if(holder instanceof LoadMoreChildCommentsViewHolder) {
((LoadMoreChildCommentsViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
ViewGroup.LayoutParams params = ((LoadMoreChildCommentsViewHolder) holder).verticalBlock.getLayoutParams();
params.width = 0;
((LoadMoreChildCommentsViewHolder) holder).verticalBlock.setLayoutParams(params);
} }
} }
@ -1413,7 +1432,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
if(mVisibleComments.get(parentPosition).isExpanded()) { if(mVisibleComments.get(parentPosition).isExpanded()) {
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1; int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
int placeholderPosition = commentPosition; int placeholderPosition = commentPosition;
if(!mVisibleComments.get(commentPosition).getFullName().equals(parentComment.getFullName())) { if(commentPosition >= mVisibleComments.size() || !mVisibleComments.get(commentPosition).getFullName().equals(parentComment.getFullName())) {
for(int i = parentPosition + 1; i < mVisibleComments.size(); i++) { for(int i = parentPosition + 1; i < mVisibleComments.size(); i++) {
if(mVisibleComments.get(i).getFullName().equals(parentComment.getFullName())) { if(mVisibleComments.get(i).getFullName().equals(parentComment.getFullName())) {
placeholderPosition = i; placeholderPosition = i;

View File

@ -157,8 +157,6 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);

View File

@ -165,7 +165,11 @@ public class SubredditSelectionActivity extends AppCompatActivity {
getCurrentAccountAndBindView(); getCurrentAccountAndBindView();
} else { } else {
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit(); if(mFragment == null) {
bindView();
} else {
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
}
} }
} }
} }
@ -262,8 +266,8 @@ public class SubredditSelectionActivity extends AppCompatActivity {
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if(requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) { if(requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
if(resultCode == RESULT_OK) { if(resultCode == RESULT_OK) {
String name = data.getExtras().getString(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME); String name = data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME);
String iconUrl = data.getExtras().getString(SearchActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL); String iconUrl = data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
Intent returnIntent = new Intent(); Intent returnIntent = new Intent();
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name); returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl); returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);