go back to yearly view on pressing Back from month view

This commit is contained in:
tibbi 2016-10-19 23:33:57 +02:00
parent 7dc9cc73f7
commit d7502ec277
1 changed files with 12 additions and 0 deletions

View File

@ -22,6 +22,8 @@ class MainActivity : SimpleActivity(), NavigationListener {
private val PREFILLED_MONTHS = 73
private val PREFILLED_YEARS = 21
private var mIsMonthSelected = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
@ -71,7 +73,16 @@ class MainActivity : SimpleActivity(), NavigationListener {
}
}
override fun onBackPressed() {
if (mIsMonthSelected && mConfig.view == Constants.YEARLY_VIEW) {
updateView(Constants.YEARLY_VIEW)
} else {
super.onBackPressed()
}
}
private fun updateView(view: Int) {
mIsMonthSelected = view == Constants.MONTHLY_VIEW
mConfig.view = view
updateViewPager()
Handler().postDelayed({ invalidateOptionsMenu() }, 500)
@ -152,5 +163,6 @@ class MainActivity : SimpleActivity(), NavigationListener {
override fun goToDateTime(dateTime: DateTime) {
fillMonthlyViewPager(Formatter.getDayCodeFromDateTime(dateTime))
mIsMonthSelected = true
}
}