Commit 037f9aae authored by Varun Patil's avatar Varun Patil

Refactor dark theme follow button code

parent 3ad05091
......@@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
......@@ -17,6 +18,7 @@ import android.support.v4.app.FragmentTransaction;
import android.util.TypedValue;
import android.view.View;
import android.webkit.CookieManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
......@@ -259,6 +261,20 @@ public final class Utils {
return typedValue.data;
}
public static void setupFollowButton(Context context, Button view, boolean follows) {
// Get background colors
final int themeColor = Utils.getAttrColor(context, R.attr.themeColor);
final int accent = context.getResources().getColor(R.color.colorAccent);
// Get font colors
final int themeColorInverse = Utils.getAttrColor(context, R.attr.themeColorInverse);
final int black = Color.BLACK;
// Set background and foreground colors
view.setBackgroundColor(follows ? accent : themeColor);
view.setTextColor(follows ? black : themeColorInverse);
}
@RequiresApi(21)
public static void clearCookies(Context context) {
CookieManager.getInstance().removeAllCookies(null);
......
......@@ -276,7 +276,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
goingButton.setOnClickListener(getUESOnClickListener(2));
setFollowButtonColors(event.getEventUserUes());
setFollowButtons(event.getEventUserUes());
if (!event.getEventVenues().isEmpty()) {
if (event.getEventVenues().get(0).getVenueLatitude() == 0) {
......@@ -356,22 +356,10 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
}
/** Setup button colors depending on status */
void setFollowButtonColors(int status) {
// Get background colors
final int themeColor = Utils.getAttrColor(getContext(), R.attr.themeColor);
final int accent = getResources().getColor(R.color.colorAccent);
// Get font colors
final int themeColorInverse = Utils.getAttrColor(getContext(), R.attr.themeColorInverse);
final int black = Color.BLACK;
// Set background colors
interestedButton.setBackgroundColor(status == Constants.STATUS_INTERESTED ? accent : themeColor);
goingButton.setBackgroundColor(status == Constants.STATUS_GOING ? accent : themeColor);
// Set font colors
interestedButton.setTextColor(status == Constants.STATUS_INTERESTED ? black : themeColorInverse);
goingButton.setTextColor(status == Constants.STATUS_GOING ? black : themeColorInverse);
void setFollowButtons(int status) {
// Set colors
Utils.setupFollowButton(getContext(), interestedButton, status == Constants.STATUS_INTERESTED);
Utils.setupFollowButton(getContext(), goingButton, status == Constants.STATUS_GOING);
// Show badges
interestedButton.setText(getCountBadgeSpannable("INTERESTED", event.getEventInterestedCount()));
......@@ -413,7 +401,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
}
event.setEventUserUes(endStatus);
setFollowButtonColors(endStatus);
setFollowButtons(endStatus);
// Update global memory cache
Utils.eventCache.updateCache(event);
......
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