From 7a365c1a54859ca87c75a26cf194445308a74869 Mon Sep 17 00:00:00 2001 From: Prem Nirmal Date: Fri, 8 Oct 2021 11:06:20 +0100 Subject: [PATCH] Only fetch release notes and news when splash activity launches, and update colour --- .../com/github/premnirmal/ticker/StocksApp.kt | 13 ------------- .../premnirmal/ticker/home/HomeFragment.kt | 13 ++++++------- .../premnirmal/ticker/home/SplashActivity.kt | 17 +++++++++++++++++ app/src/main/res/values/colors.xml | 2 +- app/version.properties | 4 ++-- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/StocksApp.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/StocksApp.kt index d5142fa4..b6c603b1 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/StocksApp.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/StocksApp.kt @@ -11,7 +11,6 @@ import com.github.premnirmal.ticker.components.LoggingTree import com.github.premnirmal.ticker.network.CommitsProvider import com.github.premnirmal.ticker.network.NewsProvider import com.github.premnirmal.ticker.notifications.NotificationsHandler -import com.github.premnirmal.tickerwidget.BuildConfig import com.github.premnirmal.tickerwidget.R import com.jakewharton.threetenabp.AndroidThreeTen import io.github.inflationx.calligraphy3.CalligraphyConfig @@ -52,9 +51,7 @@ open class StocksApp : MultiDexApplication() { Injector.appComponent.inject(holder) AppCompatDelegate.setDefaultNightMode(holder.appPreferences.nightMode) initAnalytics() - initCommitCache() initNotificationHandler() - initNewsCache() } protected open fun initNotificationHandler() { @@ -78,14 +75,4 @@ open class StocksApp : MultiDexApplication() { protected open fun initAnalytics() { holder.analytics.initialize(this) } - - protected open fun initNewsCache() { - holder.newsProvider.initCache() - } - - protected open fun initCommitCache() { - if (holder.appPreferences.getLastSavedVersionCode() < BuildConfig.VERSION_CODE) { - holder.commitsProvider.initCache() - } - } } \ No newline at end of file diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/home/HomeFragment.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/home/HomeFragment.kt index 95f551e4..8a464150 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/home/HomeFragment.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/home/HomeFragment.kt @@ -21,8 +21,11 @@ import com.github.premnirmal.ticker.isNetworkOnline import com.github.premnirmal.ticker.portfolio.PortfolioFragment import com.github.premnirmal.ticker.widget.WidgetDataProvider import com.github.premnirmal.tickerwidget.R -import com.github.premnirmal.tickerwidget.R.layout -import kotlinx.android.synthetic.main.fragment_home.* +import kotlinx.android.synthetic.main.fragment_home.subtitle +import kotlinx.android.synthetic.main.fragment_home.swipe_container +import kotlinx.android.synthetic.main.fragment_home.tabs +import kotlinx.android.synthetic.main.fragment_home.toolbar +import kotlinx.android.synthetic.main.fragment_home.view_pager import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import javax.inject.Inject @@ -85,10 +88,6 @@ class HomeFragment : BaseFragment(), ChildFragment, PortfolioFragment.Parent { ) { super.onViewCreated(view, savedInstanceState) (toolbar.layoutParams as MarginLayoutParams).topMargin = requireContext().getStatusBarHeight() - swipe_container.setColorSchemeResources( - R.color.color_primary_dark, R.color.spicy_salmon, - R.color.sea - ) swipe_container.setOnRefreshListener { fetch() } adapter = HomePagerAdapter(childFragmentManager) view_pager.adapter = adapter @@ -107,7 +106,7 @@ class HomeFragment : BaseFragment(), ChildFragment, PortfolioFragment.Parent { private fun showTotalHoldingsPopup() { val popupWindow = PopupWindow(requireContext(), null) val popupView = LayoutInflater.from(requireContext()) - .inflate(layout.layout_holdings_popup, null) + .inflate(R.layout.layout_holdings_popup, null) popupWindow.contentView = popupView popupWindow.isOutsideTouchable = true popupWindow.setBackgroundDrawable(resources.getDrawable(R.drawable.card_bg)) diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/home/SplashActivity.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/home/SplashActivity.kt index 7dd54b18..f7652fd1 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/home/SplashActivity.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/home/SplashActivity.kt @@ -8,19 +8,28 @@ import android.view.View import android.view.WindowInsets import android.view.WindowManager.LayoutParams import androidx.lifecycle.lifecycleScope +import com.github.premnirmal.ticker.AppPreferences import com.github.premnirmal.ticker.base.BaseActivity import com.github.premnirmal.ticker.components.Injector +import com.github.premnirmal.ticker.network.CommitsProvider +import com.github.premnirmal.ticker.network.NewsProvider +import com.github.premnirmal.tickerwidget.BuildConfig import com.github.premnirmal.tickerwidget.R import kotlinx.android.synthetic.main.activity_splash.touch_interceptor import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import javax.inject.Inject class SplashActivity : BaseActivity() { override val simpleName: String = "SplashActivity" override val subscribeToErrorEvents = false private var openJob: Job? = null + @Inject internal lateinit var appPreferences: AppPreferences + @Inject internal lateinit var newsProvider: NewsProvider + @Inject internal lateinit var commitsProvider: CommitsProvider + override fun onCreate(savedInstanceState: Bundle?) { Injector.appComponent.inject(this) super.onCreate(savedInstanceState) @@ -39,6 +48,7 @@ class SplashActivity : BaseActivity() { } else { window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN } + initCaches() openJob = lifecycleScope.launch { delay(800) openApp() @@ -65,4 +75,11 @@ class SplashActivity : BaseActivity() { finish() } } + + protected fun initCaches() { + newsProvider.initCache() + if (appPreferences.getLastSavedVersionCode() < BuildConfig.VERSION_CODE) { + commitsProvider.initCache() + } + } } \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index e93fef66..fd150a75 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,7 +6,7 @@ #ffffff #be6663 - #D5FFD9 + #c5f5f0 #dad8d9 #d19391 #cdaca1 diff --git a/app/version.properties b/app/version.properties index 5f3ca0d7..5f2472c8 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,2 +1,2 @@ -versionName=3.9.750 -versionCode=300900750 \ No newline at end of file +versionName=3.9.751 +versionCode=300900751 \ No newline at end of file