Skip to content

Commit

Permalink
Only fetch release notes and news when splash activity launches, and …
Browse files Browse the repository at this point in the history
…update colour
  • Loading branch information
premnirmal committed Oct 8, 2021
1 parent 2c418e0 commit 7a365c1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
13 changes: 0 additions & 13 deletions app/src/main/kotlin/com/github/premnirmal/ticker/StocksApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -65,4 +75,11 @@ class SplashActivity : BaseActivity() {
finish()
}
}

protected fun initCaches() {
newsProvider.initCache()
if (appPreferences.getLastSavedVersionCode() < BuildConfig.VERSION_CODE) {
commitsProvider.initCache()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<color name="white">#ffffff</color>

<color name="color_accent">#be6663</color>
<color name="color_primary">#D5FFD9</color>
<color name="color_primary">#c5f5f0</color>
<color name="color_primary_dark">#dad8d9</color>
<color name="button_pressed">#d19391</color>
<color name="button_disabled">#cdaca1</color>
Expand Down
4 changes: 2 additions & 2 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=3.9.750
versionCode=300900750
versionName=3.9.751
versionCode=300900751

0 comments on commit 7a365c1

Please sign in to comment.