minor cleanup

This commit is contained in:
tibbi 2016-10-22 12:19:14 +02:00
parent 8a64933652
commit caae2d65e5
5 changed files with 8 additions and 9 deletions

View File

@ -4,14 +4,13 @@ import android.content.Context
import com.simplemobiletools.calendar.models.Event
import org.joda.time.DateTime
class YearlyCalendarImpl(callback: YearlyCalendar, context: Context) : DBHelper.GetEventsListener {
val mContext = context
class YearlyCalendarImpl(val callback: YearlyCalendar, val context: Context) : DBHelper.GetEventsListener {
fun getEvents(year: Int) {
val startDateTime = DateTime().withTime(0, 0, 0, 0).withDate(year, 1, 1)
val startTS = (startDateTime.millis / 1000).toInt()
val endTS = (startDateTime.plusYears(1).minusSeconds(1).millis / 1000).toInt()
DBHelper(mContext).getEvents(startTS, endTS, this)
DBHelper(context).getEvents(startTS, endTS, this)
}
override fun gotEvents(events: MutableList<Event>) {

View File

@ -303,10 +303,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventsListener {
private fun dateSet(year: Int, month: Int, day: Int, isStart: Boolean) {
if (isStart) {
mEventStartDateTime = mEventStartDateTime.withYear(year).withMonthOfYear(month + 1).withDayOfMonth(day)
mEventStartDateTime = mEventStartDateTime.withDate(year, month + 1, day)
updateStartDate()
} else {
mEventEndDateTime = mEventEndDateTime.withYear(year).withMonthOfYear(month + 1).withDayOfMonth(day)
mEventEndDateTime = mEventEndDateTime.withDate(year, month + 1, day)
updateEndDate()
mWasEndDateSet = true
}

View File

@ -108,7 +108,7 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
val month = datePicker.month + 1
val year = datePicker.year
val day = datePicker.dayOfMonth
val newDateTime = dateTime.withDayOfMonth(day).withMonthOfYear(month).withYear(year)
val newDateTime = dateTime.withDate(year, month, day)
mListener?.goToDateTime(newDateTime)
}

View File

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

View File

@ -39,7 +39,7 @@ class YearFragment : Fragment(), YearlyCalendar {
}
fun setupMonths() {
val dateTime = DateTime().withYear(mYear).withDayOfMonth(1).withMonthOfYear(2).withHourOfDay(12)
val dateTime = DateTime().withDate(mYear, 2, 1).withHourOfDay(12)
val days = dateTime.dayOfMonth().maximumValue
mView.month_2.setDays(days)
@ -52,7 +52,7 @@ class YearFragment : Fragment(), YearlyCalendar {
monthView.setFirstDay(dayOfWeek)
monthView.setOnClickListener {
mListener?.goToDateTime(DateTime().withDayOfMonth(1).withMonthOfYear(i).withYear(mYear))
mListener?.goToDateTime(DateTime().withDate(mYear, i, 1)
}
}
}