move the months FAB code to a separate function

This commit is contained in:
tibbi 2016-09-19 22:26:00 +02:00
parent 711736cbeb
commit ee508de5d1
1 changed files with 8 additions and 6 deletions

View File

@ -22,12 +22,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
val today = DateTime().toString(Formatter.DAYCODE_PATTERN)
fillViewPager(today)
calendar_fab.setOnClickListener {
val intent = Intent(applicationContext, EventActivity::class.java)
val tomorrowCode = Formatter.getDayCodeFromDateTime(DateTime(DateTimeZone.getDefault()).plusDays(1))
intent.putExtra(Constants.DAY_CODE, tomorrowCode)
startActivity(intent)
}
calendar_fab.setOnClickListener { addNewEvent() }
}
override fun onDestroy() {
@ -54,6 +49,13 @@ class MainActivity : SimpleActivity(), NavigationListener {
}
}
private fun addNewEvent() {
val intent = Intent(applicationContext, EventActivity::class.java)
val tomorrowCode = Formatter.getDayCodeFromDateTime(DateTime(DateTimeZone.getDefault()).plusDays(1))
intent.putExtra(Constants.DAY_CODE, tomorrowCode)
startActivity(intent)
}
private fun fillViewPager(targetMonth: String) {
val codes = getMonths(targetMonth)
val adapter = MyMonthPagerAdapter(supportFragmentManager, codes, this)