Commit 3692fd0d authored by Varun Patil's avatar Varun Patil

Fix body follow button for dark theme

parent 037f9aae
package app.insti.utils; package app.insti.utils;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -39,6 +40,11 @@ public class BodyHeadViewHolder extends RecyclerView.ViewHolder { ...@@ -39,6 +40,11 @@ public class BodyHeadViewHolder extends RecyclerView.ViewHolder {
followButton = itemView.findViewById(R.id.follow_button); followButton = itemView.findViewById(R.id.follow_button);
} }
private void setupFollowButton(Context context, Body body) {
Utils.setupFollowButton(context, followButton, body.getBodyUserFollows());
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()));
}
public void bindView(final Body body, final Fragment fragment) { public void bindView(final Body body, final Fragment fragment) {
/* Set body information */ /* Set body information */
bodyName.setText(body.getBodyName()); bodyName.setText(body.getBodyName());
...@@ -53,8 +59,7 @@ public class BodyHeadViewHolder extends RecyclerView.ViewHolder { ...@@ -53,8 +59,7 @@ public class BodyHeadViewHolder extends RecyclerView.ViewHolder {
/* Check if user is already following /* Check if user is already following
* Initialize follow button */ * Initialize follow button */
followButton.setBackgroundColor(fragment.getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite)); setupFollowButton(fragment.getContext(), body);
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()));
followButton.setOnClickListener(new View.OnClickListener() { followButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
...@@ -65,8 +70,7 @@ public class BodyHeadViewHolder extends RecyclerView.ViewHolder { ...@@ -65,8 +70,7 @@ public class BodyHeadViewHolder extends RecyclerView.ViewHolder {
if (response.isSuccessful()) { if (response.isSuccessful()) {
body.setBodyUserFollows(!body.getBodyUserFollows()); body.setBodyUserFollows(!body.getBodyUserFollows());
body.setBodyFollowersCount(body.getBodyUserFollows()? body.getBodyFollowersCount()+1:body.getBodyFollowersCount()-1); body.setBodyFollowersCount(body.getBodyUserFollows()? body.getBodyFollowersCount()+1:body.getBodyFollowersCount()-1);
followButton.setBackgroundColor(fragment.getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite)); setupFollowButton(fragment.getContext(), body);
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()));
} }
} }
......
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