From 87646f7eb15c4139074feeb5ccd014601a3f77fc Mon Sep 17 00:00:00 2001 From: Apostolof Date: Fri, 6 Jan 2017 20:18:48 +0200 Subject: [PATCH] Member of the month cardView pink border --- .../mthmmy/activities/topic/TopicAdapter.java | 20 ++++++++++++++----- .../mthmmy/activities/topic/TopicParser.java | 2 +- .../res/drawable/member_of_the_month_card.xml | 13 ++++++++++++ .../layout-v21/activity_topic_post_row.xml | 5 +++-- .../res/layout/activity_topic_post_row.xml | 5 +++-- app/src/main/res/values/colors.xml | 1 + 6 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/drawable/member_of_the_month_card.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index c9f265d9..cb4616f4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -99,6 +99,7 @@ class TopicAdapter extends RecyclerView.Adapter { */ class MyViewHolder extends RecyclerView.ViewHolder { final CardView cardView; + final LinearLayout cardChildLinear; final FrameLayout postDateAndNumberExp; final TextView postDate, postNum, username, subject; final ImageView thumbnail; @@ -116,6 +117,7 @@ class TopicAdapter extends RecyclerView.Adapter { //Initializes layout's graphic elements //Standard stuff cardView = (CardView) view.findViewById(R.id.card_view); + cardChildLinear = (LinearLayout) view.findViewById(R.id.card_child_linear); postDateAndNumberExp = (FrameLayout) view.findViewById(R.id.post_date_and_number_exp); postDate = (TextView) view.findViewById(R.id.post_date); postNum = (TextView) view.findViewById(R.id.post_number); @@ -220,7 +222,7 @@ class TopicAdapter extends RecyclerView.Adapter { if (currentPost.getAttachedFiles().size() != 0) { holder.bodyFooterDivider.setVisibility(View.VISIBLE); int filesTextColor; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { filesTextColor = context.getResources().getColor(R.color.accent, null); } else //noinspection deprecation filesTextColor = context.getResources().getColor(R.color.accent); @@ -294,6 +296,14 @@ class TopicAdapter extends RecyclerView.Adapter { holder.stars.setVisibility(View.VISIBLE); } else holder.stars.setVisibility(View.GONE); + if (mUserColor == TopicParser.USER_COLOR_PINK) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + holder.cardChildLinear.setBackground(context.getResources(). + getDrawable(R.drawable.member_of_the_month_card, null)); + } else //noinspection deprecation + holder.cardChildLinear.setBackground(context.getResources(). + getDrawable(R.drawable.member_of_the_month_card)); + } else holder.cardChildLinear.setBackground(null); //Avoid's view's visibility recycling if (viewProperties.get(position)[isUserExtraInfoVisibile]) { @@ -313,7 +323,7 @@ class TopicAdapter extends RecyclerView.Adapter { Intent intent = new Intent(context, ProfileActivity.class); Bundle extras = new Bundle(); extras.putString(BUNDLE_PROFILE_URL, currentPost.getProfileURL()); - if(currentPost.getThumbnailUrl() == null) + if (currentPost.getThumbnailUrl() == null) extras.putString(BUNDLE_THUMBNAIL_URL, ""); else extras.putString(BUNDLE_THUMBNAIL_URL, currentPost.getThumbnailUrl()); @@ -365,7 +375,7 @@ class TopicAdapter extends RecyclerView.Adapter { holder.subject.setMaxLines(1); holder.subject.setEllipsize(TextUtils.TruncateAt.END); } - if(viewProperties.get(position)[isQuoteButtonChecked]) + if (viewProperties.get(position)[isQuoteButtonChecked]) holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); else holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); @@ -381,8 +391,8 @@ class TopicAdapter extends RecyclerView.Adapter { Log.d(TAG, "GOT1"); } else Log.d(TAG, "GOT2"); - //Report.i(TAG, "An error occurred while trying to exclude post from" + - // "toQuoteList, post wasn't there!"); + //Report.i(TAG, "An error occurred while trying to exclude post from" + + // "toQuoteList, post wasn't there!"); holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); } else { Log.d(TAG, "GOT3"); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java index 93641cd4..787fe1d0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java @@ -42,7 +42,7 @@ class TopicParser { private static final int USER_COLOR_RED = Color.parseColor("#F44336"); private static final int USER_COLOR_GREEN = Color.parseColor("#4CAF50"); private static final int USER_COLOR_BLUE = Color.parseColor("#536DFE"); - private static final int USER_COLOR_PINK = Color.parseColor("#FF4081"); + static final int USER_COLOR_PINK = Color.parseColor("#FF4081"); private static final int USER_COLOR_YELLOW = Color.parseColor("#FFEB3B"); /** diff --git a/app/src/main/res/drawable/member_of_the_month_card.xml b/app/src/main/res/drawable/member_of_the_month_card.xml new file mode 100644 index 00000000..2e277278 --- /dev/null +++ b/app/src/main/res/drawable/member_of_the_month_card.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index 983090c5..36d7638d 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/app/src/main/res/layout-v21/activity_topic_post_row.xml @@ -49,12 +49,13 @@ android:layout_gravity="center" android:foreground="?android:attr/selectableItemBackground" card_view:cardBackgroundColor="@color/card_background" - card_view:cardCornerRadius="0dp" + card_view:cardCornerRadius="5dp" card_view:cardElevation="2dp" - card_view:cardPreventCornerOverlap="true" + card_view:cardPreventCornerOverlap="false" card_view:cardUseCompatPadding="true"> diff --git a/app/src/main/res/layout/activity_topic_post_row.xml b/app/src/main/res/layout/activity_topic_post_row.xml index 7b1ab60c..db0179e2 100644 --- a/app/src/main/res/layout/activity_topic_post_row.xml +++ b/app/src/main/res/layout/activity_topic_post_row.xml @@ -48,12 +48,13 @@ android:layout_gravity="center" android:foreground="?android:attr/selectableItemBackground" card_view:cardBackgroundColor="@color/card_background" - card_view:cardCornerRadius="0dp" + card_view:cardCornerRadius="5dp" card_view:cardElevation="2dp" - card_view:cardPreventCornerOverlap="true" + card_view:cardPreventCornerOverlap="false" card_view:cardUseCompatPadding="true"> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1afb6d89..45d9efda 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -21,4 +21,5 @@ #CCCCCC #E7E7E7 #D926A69A + #E91E63