Browse Source

Fix for Topic's RecyclerView mixing views

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
c6afc057bc
  1. 30
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

30
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -259,9 +259,26 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
holder.postFooter.removeAllViews(); holder.postFooter.removeAllViews();
} }
String mSpecialRank, mRank, mGender, mNumberOfPosts, mPersonalText;
int mNumberOfStars, mUserColor;
if (!currentPost.isDeleted()) { //Sets user's extra info if (!currentPost.isDeleted()) { //Sets user's extra info
String mSpecialRank = currentPost.getSpecialRank(), mRank = currentPost.getRank(), mGender = currentPost.getGender(), mNumberOfPosts = currentPost.getNumberOfPosts(), mPersonalText = currentPost.getPersonalText(); mSpecialRank = currentPost.getSpecialRank();
int mNumberOfStars = currentPost.getNumberOfStars(), mUserColor = currentPost.getUserColor(); mRank = currentPost.getRank();
mGender = currentPost.getGender();
mNumberOfPosts = currentPost.getNumberOfPosts();
mPersonalText = currentPost.getPersonalText();
mNumberOfStars = currentPost.getNumberOfStars();
mUserColor = currentPost.getUserColor();
} else {
mSpecialRank = null;
mRank = null;
mGender = null;
mNumberOfPosts = null;
mPersonalText = null;
mNumberOfStars = 0;
mUserColor = 0;
}
if (!Objects.equals(mSpecialRank, "") && mSpecialRank != null) { if (!Objects.equals(mSpecialRank, "") && mSpecialRank != null) {
holder.specialRank.setText(mSpecialRank); holder.specialRank.setText(mSpecialRank);
@ -313,13 +330,14 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
} else holder.cardChildLinear.setBackground(null); } else holder.cardChildLinear.setBackground(null);
//Avoid's view's visibility recycling //Avoid's view's visibility recycling
if (viewProperties.get(position)[isUserExtraInfoVisibile]) { if (!currentPost.isDeleted() && viewProperties.get(position)[isUserExtraInfoVisibile]) {
holder.userExtraInfo.setVisibility(View.VISIBLE); holder.userExtraInfo.setVisibility(View.VISIBLE);
holder.userExtraInfo.setAlpha(1.0f); holder.userExtraInfo.setAlpha(1.0f);
} else { } else {
holder.userExtraInfo.setVisibility(View.GONE); holder.userExtraInfo.setVisibility(View.GONE);
holder.userExtraInfo.setAlpha(0.0f); holder.userExtraInfo.setAlpha(0.0f);
} }
if (!currentPost.isDeleted()) {
//Sets graphics behavior //Sets graphics behavior
holder.header.setOnClickListener(new View.OnClickListener() { holder.header.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -356,7 +374,11 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
TopicAnimations.animateUserExtraInfoVisibility(v); TopicAnimations.animateUserExtraInfoVisibility(v);
} }
}); });
}//End of deleted profiles } else {
holder.header.setOnClickListener(null);
holder.userExtraInfo.setOnClickListener(null);
}
//Avoid's view's visibility recycling //Avoid's view's visibility recycling
if (viewProperties.get(position)[isPostDateAndNumberVisibile]) { //Expanded if (viewProperties.get(position)[isPostDateAndNumberVisibile]) { //Expanded
holder.postDateAndNumberExp.setVisibility(View.VISIBLE); holder.postDateAndNumberExp.setVisibility(View.VISIBLE);

Loading…
Cancel
Save