Commit 72bb881e authored by Varun Patil's avatar Varun Patil

Show following count of body in badge

parent 3ea4a573
...@@ -173,6 +173,7 @@ public class BodyFragment extends Fragment { ...@@ -173,6 +173,7 @@ public class BodyFragment extends Fragment {
/* Check if user is already following /* Check if user is already following
* Initialize follow button */ * Initialize follow button */
followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite)); followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite));
followButton.setText(EventFragment.getCountBadgeSpannable("Follow", body.getBodyFollowersCount()));
followButton.setOnClickListener(new View.OnClickListener() { followButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
......
...@@ -207,12 +207,18 @@ public class EventFragment extends BaseFragment { ...@@ -207,12 +207,18 @@ public class EventFragment extends BaseFragment {
* @param count integer count to show in the badge * @param count integer count to show in the badge
* @return spannable to be used as view.setText(spannable) * @return spannable to be used as view.setText(spannable)
*/ */
static Spannable getCountBadgeSpannable(String text, int count) { static Spannable getCountBadgeSpannable(String text, Integer count) {
// Check for nulls
if (count == null) return new SpannableString(text);
// Make a spannable
String countString = Integer.toString(count); String countString = Integer.toString(count);
Spannable spannable = new SpannableString(text + " " + countString); Spannable spannable = new SpannableString(text + " " + countString);
spannable.setSpan(new StyleSpan(Typeface.NORMAL), 0, text.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
// Set font face and color of badge
spannable.setSpan(new RelativeSizeSpan(0.75f), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); spannable.setSpan(new RelativeSizeSpan(0.75f), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(Color.DKGRAY), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); spannable.setSpan(new ForegroundColorSpan(Color.DKGRAY), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return spannable; return spannable;
} }
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
android:layout_margin="0dp" android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="Follow" android:text="Follow"
android:textColor="@color/colorGray" /> android:textColor="@color/secondaryTextColor" />
</LinearLayout> </LinearLayout>
<View <View
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment