Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
037f9aae
Commit
037f9aae
authored
Feb 04, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor dark theme follow button code
parent
3ad05091
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+16
-0
app/src/main/java/app/insti/fragment/EventFragment.java
app/src/main/java/app/insti/fragment/EventFragment.java
+6
-18
No files found.
app/src/main/java/app/insti/Utils.java
View file @
037f9aae
...
...
@@ -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
);
...
...
app/src/main/java/app/insti/fragment/EventFragment.java
View file @
037f9aae
...
...
@@ -276,7 +276,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
goingButton
.
setOnClickListener
(
getUESOnClickListener
(
2
));
setFollowButton
Color
s
(
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
);
setFollowButton
Color
s
(
endStatus
);
setFollowButtons
(
endStatus
);
// Update global memory cache
Utils
.
eventCache
.
updateCache
(
event
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment