reordering some functions

This commit is contained in:
tibbi 2017-10-21 16:24:37 +02:00
parent 7524360fea
commit 3cef66f2bf
2 changed files with 12 additions and 12 deletions

View File

@ -124,7 +124,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
override fun onResume() {
super.onResume()
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor
|| mStoredDayCode != getCurrentDayCode()) {
|| mStoredDayCode != Formatter.getTodayCode()) {
updateViewPager()
}
@ -199,11 +199,9 @@ class MainActivity : SimpleActivity(), NavigationListener {
mStoredTextColor = config.textColor
mStoredPrimaryColor = config.primaryColor
mStoredBackgroundColor = config.backgroundColor
mStoredDayCode = getCurrentDayCode()
mStoredDayCode = Formatter.getTodayCode()
}
private fun getCurrentDayCode() = Formatter.getDayCodeFromTS((System.currentTimeMillis() / 1000).toInt())
private fun showViewDialog() {
val res = resources
val items = arrayListOf(
@ -304,6 +302,14 @@ class MainActivity : SimpleActivity(), NavigationListener {
}
}
private fun handleParseResult(result: IcsImporter.ImportResult) {
toast(when (result) {
IcsImporter.ImportResult.IMPORT_OK -> R.string.holidays_imported_successfully
IcsImporter.ImportResult.IMPORT_PARTIAL -> R.string.importing_some_holidays_failed
else -> R.string.importing_holidays_failed
}, Toast.LENGTH_LONG)
}
private fun addBirthdays() {
val birthdays = getString(R.string.birthdays)
var eventTypeId = dbHelper.getEventTypeIdWithTitle(birthdays)
@ -355,14 +361,6 @@ class MainActivity : SimpleActivity(), NavigationListener {
}
}
private fun handleParseResult(result: IcsImporter.ImportResult) {
toast(when (result) {
IcsImporter.ImportResult.IMPORT_OK -> R.string.holidays_imported_successfully
IcsImporter.ImportResult.IMPORT_PARTIAL -> R.string.importing_some_holidays_failed
else -> R.string.importing_holidays_failed
}, Toast.LENGTH_LONG)
}
private fun updateView(view: Int) {
calendar_fab.beGoneIf(view == YEARLY_VIEW)
mIsMonthSelected = view == MONTHLY_VIEW

View File

@ -54,6 +54,8 @@ object Formatter {
return "$month $day $year"
}
fun getTodayCode() = Formatter.getDayCodeFromTS((System.currentTimeMillis() / 1000).toInt())
fun getHours(context: Context, dateTime: DateTime) = dateTime.toString(getHourPattern(context))
fun getTime(context: Context, dateTime: DateTime) = dateTime.toString(getTimePattern(context))