some style cleanup here and there
This commit is contained in:
parent
11d2215e37
commit
206dfe0271
|
@ -101,9 +101,8 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
|||
days.filter { eventCodes.contains(it.code) }.forEach { it.hasEvent = true }
|
||||
}
|
||||
|
||||
private fun isToday(targetDate: DateTime, curDayInMonth: Int): Boolean {
|
||||
return targetDate.withDayOfMonth(curDayInMonth).toString(Formatter.DAYCODE_PATTERN) == mToday
|
||||
}
|
||||
private fun isToday(targetDate: DateTime, curDayInMonth: Int) =
|
||||
targetDate.withDayOfMonth(curDayInMonth).toString(Formatter.DAYCODE_PATTERN) == mToday
|
||||
|
||||
private val monthName: String
|
||||
get() {
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.simplemobiletools.calendar.adapters.MyYearPagerAdapter
|
|||
import com.simplemobiletools.calendar.extensions.updateWidget
|
||||
import com.simplemobiletools.calendar.fragments.EventListFragment
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.views.dialogs.ChangeViewDialog
|
||||
import com.simplemobiletools.calendar.dialogs.ChangeViewDialog
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.simplemobiletools.calendar.views.dialogs
|
||||
package com.simplemobiletools.calendar.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.widget.RadioGroup
|
||||
import com.simplemobiletools.calendar.helpers.Config
|
||||
import com.simplemobiletools.calendar.Constants
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.Config
|
||||
import kotlinx.android.synthetic.main.dialog_change_views.view.*
|
||||
|
||||
class ChangeViewDialog(val activity: Activity) : AlertDialog.Builder(activity), RadioGroup.OnCheckedChangeListener {
|
||||
|
@ -29,20 +29,16 @@ class ChangeViewDialog(val activity: Activity) : AlertDialog.Builder(activity),
|
|||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
fun getNewView(id: Int): Int {
|
||||
return when (id) {
|
||||
R.id.dialog_radio_yearly -> Constants.YEARLY_VIEW
|
||||
R.id.dialog_radio_events_list -> Constants.EVENTS_LIST_VIEW
|
||||
else -> Constants.MONTHLY_VIEW
|
||||
}
|
||||
fun getNewView(id: Int) = when (id) {
|
||||
R.id.dialog_radio_yearly -> Constants.YEARLY_VIEW
|
||||
R.id.dialog_radio_events_list -> Constants.EVENTS_LIST_VIEW
|
||||
else -> Constants.MONTHLY_VIEW
|
||||
}
|
||||
|
||||
fun getSavedItem(): Int {
|
||||
return when (Config.newInstance(activity).storedView) {
|
||||
Constants.YEARLY_VIEW -> R.id.dialog_radio_yearly
|
||||
Constants.EVENTS_LIST_VIEW -> R.id.dialog_radio_events_list
|
||||
else -> R.id.dialog_radio_monthly
|
||||
}
|
||||
fun getSavedItem() = when (Config.newInstance(activity).storedView) {
|
||||
Constants.YEARLY_VIEW -> R.id.dialog_radio_yearly
|
||||
Constants.EVENTS_LIST_VIEW -> R.id.dialog_radio_events_list
|
||||
else -> R.id.dialog_radio_monthly
|
||||
}
|
||||
|
||||
interface ChangeViewListener {
|
|
@ -13,13 +13,14 @@ import android.widget.AbsListView
|
|||
import android.widget.AdapterView
|
||||
import android.widget.DatePicker
|
||||
import android.widget.RelativeLayout
|
||||
import com.simplemobiletools.calendar.*
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.Constants
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.adapters.EventsAdapter
|
||||
import com.simplemobiletools.calendar.extensions.updateWidget
|
||||
import com.simplemobiletools.calendar.helpers.Config
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.helpers.Utils
|
||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
@ -153,18 +154,14 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
|
|||
}
|
||||
}
|
||||
|
||||
private fun getEventsToShow(events: MutableList<Event>): List<Event> {
|
||||
return events.filter { !mToBeDeleted.contains(it.id) }
|
||||
}
|
||||
private fun getEventsToShow(events: MutableList<Event>) = events.filter { !mToBeDeleted.contains(it.id) }
|
||||
|
||||
private fun prepareDeleteEvents() {
|
||||
val checked = mHolder.day_events.checkedItemPositions
|
||||
for (i in mEvents!!.indices) {
|
||||
if (checked.get(i)) {
|
||||
val event = mEvents!![i]
|
||||
mToBeDeleted.add(event.id)
|
||||
}
|
||||
}
|
||||
mEvents!!.indices
|
||||
.filter { checked.get(it) }
|
||||
.map { mEvents!![it] }
|
||||
.forEach { mToBeDeleted.add(it.id) }
|
||||
|
||||
notifyDeletion()
|
||||
}
|
||||
|
@ -184,9 +181,7 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
|
|||
updateEvents(mEvents!!)
|
||||
}
|
||||
|
||||
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||
return true
|
||||
}
|
||||
override fun onPrepareActionMode(mode: ActionMode, menu: Menu) = true
|
||||
|
||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
|
|
|
@ -8,8 +8,8 @@ import android.support.v4.app.Fragment
|
|||
import android.view.*
|
||||
import android.widget.AbsListView
|
||||
import android.widget.AdapterView
|
||||
import com.simplemobiletools.calendar.*
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.Constants
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.activities.MainActivity
|
||||
import com.simplemobiletools.calendar.adapters.EventsListAdapter
|
||||
|
@ -17,6 +17,7 @@ import com.simplemobiletools.calendar.extensions.beGoneIf
|
|||
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
||||
import com.simplemobiletools.calendar.extensions.updateWidget
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import com.simplemobiletools.calendar.models.ListEvent
|
||||
|
@ -95,21 +96,13 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On
|
|||
mView.calendar_events_list.beGoneIf(events.isEmpty())
|
||||
}
|
||||
|
||||
private fun getEventsToShow(events: MutableList<Event>?): List<Event> {
|
||||
if (events == null)
|
||||
return ArrayList()
|
||||
|
||||
return events.filter { !mToBeDeleted.contains(it.id) }
|
||||
}
|
||||
private fun getEventsToShow(events: MutableList<Event>?) = events?.filter { !mToBeDeleted.contains(it.id) } ?: ArrayList()
|
||||
|
||||
private fun prepareDeleteEvents() {
|
||||
val checked = mView.calendar_events_list.checkedItemPositions
|
||||
for (i in mListItems.indices) {
|
||||
if (checked.get(i)) {
|
||||
val event = mListItems[i]
|
||||
mToBeDeleted.add((event as ListEvent).id)
|
||||
}
|
||||
}
|
||||
mListItems.indices.filter { checked.get(it) }
|
||||
.map { mListItems[it] }
|
||||
.forEach { mToBeDeleted.add((it as ListEvent).id) }
|
||||
|
||||
notifyDeletion()
|
||||
}
|
||||
|
@ -155,9 +148,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On
|
|||
checkEvents()
|
||||
}
|
||||
|
||||
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
|
||||
return true
|
||||
}
|
||||
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?) = true
|
||||
|
||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.simplemobiletools.calendar.models
|
||||
|
||||
class Day(val value: Int, val isThisMonth: Boolean, val isToday: Boolean, val code: String, var hasEvent: Boolean, val weekOfYear: Int) {
|
||||
override fun toString(): String {
|
||||
return "Day {value=$value, isThisMonth=$isThisMonth, itToday=$isToday, code=$code, hasEvent=$hasEvent, weekOfYear=$weekOfYear}"
|
||||
}
|
||||
override fun toString() = "Day {value=$value, isThisMonth=$isThisMonth, itToday=$isToday, code=$code, hasEvent=$hasEvent, weekOfYear=$weekOfYear}"
|
||||
}
|
||||
|
|
|
@ -7,10 +7,8 @@ import java.io.Serializable
|
|||
|
||||
class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "",
|
||||
var reminderMinutes: Int = 0, var repeatInterval: Int = 0) : Serializable {
|
||||
override fun toString(): String {
|
||||
return "Event {id=$id, startTS=$startTS, endTS=$endTS, title=$title, description=$description, " +
|
||||
"reminderMinutes=$reminderMinutes, repeatInterval=$repeatInterval}"
|
||||
}
|
||||
override fun toString() = "Event {id=$id, startTS=$startTS, endTS=$endTS, title=$title, description=$description, " +
|
||||
"reminderMinutes=$reminderMinutes, repeatInterval=$repeatInterval}"
|
||||
|
||||
companion object {
|
||||
private val serialVersionUID = -32456795132344616L
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.simplemobiletools.calendar.models
|
||||
|
||||
class ListSection(val title: String, val isToday: Boolean) : ListItem() {
|
||||
override fun toString(): String {
|
||||
return "ListSection {title=$title, isToday=$isToday}"
|
||||
}
|
||||
override fun toString() = "ListSection {title=$title, isToday=$isToday}"
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import android.graphics.Color
|
|||
import android.graphics.Paint
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import com.simplemobiletools.calendar.helpers.Config
|
||||
import com.simplemobiletools.calendar.Constants
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.Config
|
||||
import com.simplemobiletools.calendar.helpers.Utils
|
||||
import java.util.*
|
||||
|
||||
|
@ -92,7 +92,5 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
}
|
||||
}
|
||||
|
||||
private fun getPaint(curId: Int): Paint {
|
||||
return if (mEvents?.contains(curId) == true) mColoredPaint else mPaint
|
||||
}
|
||||
private fun getPaint(curId: Int) = if (mEvents?.contains(curId) == true) mColoredPaint else mPaint
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue