Browse Source

TopicAdapter fixes, Color suggestion.

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
ba55784253
  1. 4
      app/src/main/assets/style.css
  2. 87
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  3. 7
      app/src/main/res/layout/activity_topic_post_row.xml
  4. 2
      app/src/main/res/layout/fragment_recent.xml
  5. 6
      app/src/main/res/layout/fragment_recent_row.xml
  6. 30
      app/src/main/res/values/colors.xml

4
app/src/main/assets/style.css

@ -319,8 +319,8 @@ a img
width: 100%;
overflow: auto;
line-height: 1.3em;
/*color: white;
background: #333333 !important;*/
color: white;
background: #3C3F41 !important;
}
/* All the signatures used in the forum. If your forum users use Mozilla, Opera, or Safari, you might add max-height here ;). */

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

@ -11,6 +11,7 @@ import android.os.Handler;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@ -28,6 +29,7 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -50,6 +52,10 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
private final Context context;
private final List<Post> postsList;
private boolean foundPostFocus = false;
private ArrayList<boolean[]> viewProperties = new ArrayList<>();
private static final int isPostDateAndNumberVisibile = 0;
private static final int isUserExtraInfoVisibile = 1;
private static final int isQuoteButtonChecked = 2;
class MyViewHolder extends RecyclerView.ViewHolder {
final CardView cardView;
@ -102,6 +108,10 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
this.postsList = postsList;
THUMBNAIL_SIZE = (int) context.getResources().getDimension(R.dimen.thumbnail_size);
for (int i = 0; i < postsList.size(); ++i) {
//Initialize properties, array's values will be false by default
viewProperties.add(new boolean[3]);
}
}
@Override
@ -132,7 +142,7 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
//noinspection ConstantConditions
Picasso.with(context)
.load(currentPost.getThumbnailUrl())
.resize(THUMBNAIL_SIZE,THUMBNAIL_SIZE)
.resize(THUMBNAIL_SIZE, THUMBNAIL_SIZE)
.centerCrop()
.error(ResourcesCompat.getDrawable(context.getResources()
, R.drawable.ic_default_user_thumbnail, null))
@ -180,46 +190,36 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
//If user is not deleted then we have more to do
if (!currentPost.isDeleted()) { //Set extra info
//Variables with content
String c_specialRank = currentPost.getSpecialRank()
, c_rank = currentPost.getRank()
, c_gender = currentPost.getGender()
, c_numberOfPosts = currentPost.getNumberOfPosts()
, c_personalText = currentPost.getPersonalText();
int c_numberOfStars = currentPost.getNumberOfStars()
,c_userColor = currentPost.getUserColor();
String c_specialRank = currentPost.getSpecialRank(), c_rank = currentPost.getRank(), c_gender = currentPost.getGender(), c_numberOfPosts = currentPost.getNumberOfPosts(), c_personalText = currentPost.getPersonalText();
int c_numberOfStars = currentPost.getNumberOfStars(), c_userColor = currentPost.getUserColor();
if (!Objects.equals(c_specialRank, "") && c_specialRank != null) {
holder.specialRank.setText(c_specialRank);
holder.specialRank.setVisibility(View.VISIBLE);
}
else
} else
holder.specialRank.setVisibility(View.GONE);
if (!Objects.equals(c_rank, "") && c_rank != null) {
holder.rank.setText(c_rank);
holder.rank.setVisibility(View.VISIBLE);
}
else
} else
holder.rank.setVisibility(View.GONE);
if (!Objects.equals(c_gender, "") && c_gender != null) {
holder.gender.setText(c_gender);
holder.gender.setVisibility(View.VISIBLE);
}
else
} else
holder.gender.setVisibility(View.GONE);
if (!Objects.equals(c_numberOfPosts, "") && c_numberOfPosts != null) {
holder.numberOfPosts.setText(c_numberOfPosts);
holder.numberOfPosts.setVisibility(View.VISIBLE);
}
else
} else
holder.numberOfPosts.setVisibility(View.GONE);
if (!Objects.equals(c_personalText, "") && c_personalText != null) {
holder.personalText.setText("\"" + c_personalText + "\"");
holder.personalText.setVisibility(View.VISIBLE);
}
else
} else
holder.personalText.setVisibility(View.GONE);
if(c_numberOfStars != 0) {
if (c_numberOfStars != 0) {
holder.stars.setTypeface(FontManager.getTypeface(context, FONTAWESOME));
String aStar = context.getResources().getString(R.string.fa_icon_star);
@ -230,15 +230,25 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
holder.stars.setText(usersStars);
holder.stars.setTextColor(c_userColor);
holder.stars.setVisibility(View.VISIBLE);
}
else
} else
holder.stars.setVisibility(View.GONE);
/* --Header expand/collapse functionality-- */
/* --Header expand/collapse functionality-- */
//Check if current post's header is expanded
if (viewProperties.get(position)[isUserExtraInfoVisibile]) //Expanded
holder.userExtraInfo.setVisibility(View.VISIBLE);
else //Collapsed
holder.userExtraInfo.setVisibility(View.GONE);
holder.header.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Change post's viewProperties accordingly
boolean[] tmp = viewProperties.get(holder.getAdapterPosition());
tmp[isUserExtraInfoVisibile] = !tmp[isUserExtraInfoVisibile];
viewProperties.set(holder.getAdapterPosition(), tmp);
TopicAnimations.animateUserExtraInfoVisibility(holder.userExtraInfo);
}
});
@ -247,18 +257,49 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
holder.userExtraInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Change post's viewProperties accordingly
boolean[] tmp = viewProperties.get(holder.getAdapterPosition());
tmp[1] = false;
viewProperties.set(holder.getAdapterPosition(), tmp);
TopicAnimations.animateUserExtraInfoVisibility(v);
}
});
/* --Header expand/collapse functionality end-- */
/* --Header expand/collapse functionality end-- */
}
/* --Card expand/collapse functionality-- */
//Check if current post is expanded
if (viewProperties.get(position)[isPostDateAndNumberVisibile]) { //Expanded
holder.postDateAndNumberExp.setVisibility(View.VISIBLE);
holder.username.setMaxLines(Integer.MAX_VALUE);
holder.username.setEllipsize(null);
holder.subject.setTextColor(Color.parseColor("#000000"));
holder.subject.setMaxLines(Integer.MAX_VALUE);
holder.subject.setEllipsize(null);
} else { //Collapsed
holder.postDateAndNumberExp.setVisibility(View.GONE);
holder.username.setMaxLines(1);
holder.username.setEllipsize(TextUtils.TruncateAt.END);
holder.subject.setTextColor(Color.parseColor("#757575"));
holder.subject.setMaxLines(1);
holder.subject.setEllipsize(TextUtils.TruncateAt.END);
}
//Should expand/collapse when card is touched
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Change post's viewProperties accordingly
boolean[] tmp = viewProperties.get(holder.getAdapterPosition());
tmp[isPostDateAndNumberVisibile] = !tmp[isPostDateAndNumberVisibile];
viewProperties.set(holder.getAdapterPosition(), tmp);
TopicAnimations.animatePostExtraInfoVisibility(holder.postDateAndNumberExp
, holder.username, holder.subject
, Color.parseColor("#000000")

7
app/src/main/res/layout/activity_topic_post_row.xml

@ -36,7 +36,6 @@
android:text=""
android:textColor="@color/card_expand_text_color"
android:textSize="8sp"
/>
</FrameLayout>
@ -47,7 +46,7 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="@color/white"
card_view:cardBackgroundColor="@color/card_background"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="true"
@ -102,7 +101,7 @@
android:ellipsize="end"
android:maxLines="1"
android:text="@string/username"
android:textColor="@color/black"
android:textColor="@color/primary_text"
android:textStyle="bold"/>
<TextView
@ -213,7 +212,7 @@
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@color/white"
android:background="@color/card_background"
android:clickable="true"
android:text="@string/post"
/>

2
app/src/main/res/layout/fragment_recent.xml

@ -17,7 +17,7 @@
class="gr.thmmy.mthmmy.utils.CustomRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:background="@color/background"
android:clipToPadding="false"
android:paddingBottom="4dp"
android:paddingTop="4dp"

6
app/src/main/res/layout/fragment_recent_row.xml

@ -34,7 +34,7 @@
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/md_grey_850"/>
android:textColor="@color/primary_text"/>
<Space
android:id="@+id/spacer"
@ -49,7 +49,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/spacer"/>
android:layout_below="@+id/spacer"
android:textColor="@color/secondary_text"/>
<TextView
android:id="@+id/lastUser"
@ -58,6 +59,7 @@
android:layout_alignBaseline="@+id/dateTime"
android:layout_alignBottom="@+id/dateTime"
android:layout_alignParentEnd="true"
android:textColor="@color/secondary_text"
android:textStyle="italic"/>
</RelativeLayout>
</android.support.v7.widget.CardView>

30
app/src/main/res/values/colors.xml

@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
When changing the colors be sure to also change lines 322 & 323
in the style.css file!
-->
<!--Indigo-->
<color name="primary">#3F51B5</color>
<!--<color name="primary">#3F51B5</color>
<color name="primary_dark">#303F9F</color>
<color name="primary_light">#C5CAE9</color>
<color name="accent">#009688</color>
<color name="primary_text">#E7E7E7</color>
<color name="primary_text">#000000</color>
<color name="secondary_text">#757575</color>
<color name="card_background">#FFFFFF</color>
<color name="divider">#8B8B8B</color>
@ -16,5 +21,24 @@
<color name="iron">#CCCCCC</color>
<color name="card_expand_text_color">#464646</color>
<color name="background">#D3D3D3</color>
<color name="dialog_bg_semi_transparent">#80212c6f</color>
<color name="dialog_bg_semi_transparent">#80212c6f</color>-->
<!--Dark-->
<color name="primary">#2B2B2B</color>
<color name="primary_dark">#333333</color>
<color name="primary_light">#3C3F41</color>
<color name="accent">#BF4040</color>
<!--<color name="accent">#6797BB</color>-->
<color name="primary_text">#E7E7E7</color>
<color name="secondary_text">#757575</color>
<color name="background">#303234</color>
<color name="card_background">#3C3F41</color>
<color name="divider">#8B8B8B</color>
<color name="transparent">#00000000</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="iron">#CCCCCC</color>
<color name="card_expand_text_color">#E7E7E7</color>
<color name="dialog_bg_semi_transparent">#80BF4040</color>
</resources>

Loading…
Cancel
Save