open the picked month on click

This commit is contained in:
tibbi 2016-10-19 22:26:26 +02:00
parent 8016391989
commit 53761776e3
6 changed files with 14 additions and 6 deletions

View File

@ -7,5 +7,5 @@ interface NavigationListener {
fun goRight()
fun goToDateTime(dateTime: DateTime)
fun goToDateTime(dateTime: DateTime, switchedFromYearly: Boolean)
}

View File

@ -111,7 +111,7 @@ class DayActivity : SimpleActivity(), DayFragment.DeleteListener, ViewPager.OnPa
view_pager.currentItem = view_pager.currentItem + 1
}
override fun goToDateTime(dateTime: DateTime) {
override fun goToDateTime(dateTime: DateTime, switchedFromYearly: Boolean) {
checkDeleteEvents()
fillViewPager(Formatter.getDayCodeFromDateTime(dateTime))
}

View File

@ -150,7 +150,12 @@ class MainActivity : SimpleActivity(), NavigationListener {
view_pager.currentItem = view_pager.currentItem + 1
}
override fun goToDateTime(dateTime: DateTime) {
override fun goToDateTime(dateTime: DateTime, switchedFromYearly: Boolean) {
fillMonthlyViewPager(Formatter.getDayCodeFromDateTime(dateTime))
if (switchedFromYearly) {
mConfig.view = Constants.MONTHLY_VIEW
invalidateOptionsMenu()
}
}
}

View File

@ -109,7 +109,7 @@ class DayFragment : Fragment(), DBHelper.DBOperationsListener, AdapterView.OnIte
val year = datePicker.year
val day = datePicker.dayOfMonth
val newDateTime = dateTime.withDayOfMonth(day).withMonthOfYear(month).withYear(year)
mListener?.goToDateTime(newDateTime)
mListener?.goToDateTime(newDateTime, false)
}
show()

View File

@ -126,8 +126,8 @@ class MonthFragment : Fragment(), Calendar {
setPositiveButton(R.string.ok) { dialog, id ->
val month = datePicker.month + 1
val year = datePicker.year
val newDateTime = dateTime.withMonthOfYear(month).withYear(year)
mListener?.goToDateTime(newDateTime)
val newDateTime = dateTime.withDayOfMonth(1).withMonthOfYear(month).withYear(year)
mListener?.goToDateTime(newDateTime, false)
}
show()

View File

@ -48,6 +48,9 @@ class YearFragment : Fragment() {
dayOfWeek--
monthView.setFirstDay(dayOfWeek)
monthView.setOnClickListener {
mListener?.goToDateTime(DateTime().withDayOfMonth(1).withMonthOfYear(i).withYear(mYear), true)
}
}
}