Skip to content

Commit

Permalink
Navigation tweaks, and check market state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
premnirmal committed Jul 21, 2022
1 parent 5662b3f commit 937f856
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AlertDialog.Builder
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.github.premnirmal.ticker.AppPreferences
import com.github.premnirmal.ticker.analytics.Analytics
Expand Down Expand Up @@ -78,7 +77,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), BottomNavigationView.O
val fragment = HomeFragment()
supportFragmentManager.beginTransaction()
.add(R.id.fragment_container, fragment, fragment.javaClass.name)
.show(fragment)
.commit()
fragment
} else {
Expand All @@ -101,13 +99,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), BottomNavigationView.O
}

override fun onBackPressed() {
val eaten = onNavigationItemSelected(binding.bottomNavigation.menu.findItem(R.id.action_portfolio))
if (eaten) {
if (binding.bottomNavigation.selectedItemId == R.id.action_portfolio) {
if (!maybeAskToRate()) {
super.onBackPressed()
}
} else {
binding.bottomNavigation.selectedItemId = R.id.action_portfolio
}
if (!eaten && !maybeAskToRate()) {
super.onBackPressed()
}
}

override fun onSaveInstanceState(outState: Bundle) {
Expand Down Expand Up @@ -165,25 +163,18 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), BottomNavigationView.O
throw IllegalStateException("Unknown bottom nav itemId: $itemId - ${item.title}")
}
}
supportFragmentManager.beginTransaction()
.add(R.id.fragment_container, fragment, fragment::class.java.name)
.hide(fragment)
.show(currentChild as Fragment)
.commitNowAllowingStateLoss()
}
if (fragment.isHidden) {
supportFragmentManager.beginTransaction()
.hide(currentChild as Fragment)
.show(fragment)
if (fragment != currentChild) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment, fragment::class.java.name)
.commit()
currentChild = fragment as ChildFragment
analytics.trackClickEvent(
ClickEvent("BottomNavClick")
.addProperty("NavItem", item.title.toString())
)
return true
} else return false
}
return false
currentChild = fragment as ChildFragment
analytics.trackClickEvent(
ClickEvent("BottomNavClick")
.addProperty("NavItem", item.title.toString())
)
return true
}

// BottomNavigationView.OnNavigationItemReselectedListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ data class Quote constructor(
}

val isMarketOpen: Boolean
get() = "CLOSED" != marketState.uppercase()
get() = "REGULAR" == marketState.uppercase()

override operator fun compareTo(other: Quote): Int =
other.changeInPercent.compareTo(changeInPercent)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-v31/color_palette.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="accent_fallback">@android:color/system_accent1_400</color>
<color name="accent_fallback">@android:color/system_accent1_600</color>
</resources>

0 comments on commit 937f856

Please sign in to comment.