@@ -5,12 +5,10 @@ import android.content.Context
55import android.content.Intent
66import android.content.res.Resources
77import android.os.Bundle
8- import android.support.annotation.AttrRes
98import android.support.annotation.ColorInt
109import android.support.transition.Fade
1110import android.support.transition.TransitionManager
1211import android.support.v7.app.AppCompatActivity
13- import android.util.TypedValue
1412import android.view.View
1513import androidx.view.isInvisible
1614import androidx.view.isVisible
@@ -22,6 +20,7 @@ import net.squanchy.home.deeplink.HomeActivityDeepLinkCreator
2220import net.squanchy.home.deeplink.HomeActivityIntentParser
2321import net.squanchy.navigation.Navigator
2422import net.squanchy.signin.SignInOrigin
23+ import net.squanchy.support.content.res.getColorFromAttribute
2524import net.squanchy.support.widget.InterceptingBottomNavigationView
2625
2726class HomeActivity : AppCompatActivity () {
@@ -108,8 +107,8 @@ class HomeActivity : AppCompatActivity() {
108107 bottomNavigationView.selectItemAt(section.ordinal)
109108
110109 val theme = getThemeFor(section)
111- bottomNavigationView.setBackgroundColor(getColorFromTheme( theme, android.support.design.R .attr.colorPrimary))
112- window.statusBarColor = getColorFromTheme( theme, android.R .attr.statusBarColor)
110+ bottomNavigationView.setBackgroundColor(theme.getColorFromAttribute( android.support.design.R .attr.colorPrimary))
111+ window.statusBarColor = theme.getColorFromAttribute( android.R .attr.statusBarColor)
113112
114113 currentSection = section
115114 }
@@ -125,8 +124,8 @@ class HomeActivity : AppCompatActivity() {
125124 swapPageTo(section)
126125
127126 val theme = getThemeFor(section)
128- animateStatusBarColorTo(getColorFromTheme( theme, android.R .attr.statusBarColor))
129- bottomNavigationView.colorProvider = { getColorFromTheme( theme, android.support.design.R .attr.colorPrimary) }
127+ animateStatusBarColorTo(theme.getColorFromAttribute( android.R .attr.statusBarColor))
128+ bottomNavigationView.colorProvider = { theme.getColorFromAttribute( android.support.design.R .attr.colorPrimary) }
130129
131130 currentSection = section
132131
@@ -147,13 +146,6 @@ class HomeActivity : AppCompatActivity() {
147146 }
148147 }
149148
150- @ColorInt
151- private fun getColorFromTheme (theme : Resources .Theme , @AttrRes attributeId : Int ): Int {
152- val typedValue = TypedValue ()
153- theme.resolveAttribute(attributeId, typedValue, true )
154- return typedValue.data
155- }
156-
157149 private fun animateStatusBarColorTo (@ColorInt color : Int ) {
158150 val currentStatusBarColor = window.statusBarColor
159151
0 commit comments