mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 04:10:45 +01:00
make sure the default date doesn't change when adding a new event before midnight
This commit is contained in:
parent
d08c210eba
commit
72a2b574fd
@ -21,9 +21,8 @@ import kotlinx.android.synthetic.main.event_item_day_view.view.*
|
||||
class DayEventsAdapter(activity: SimpleActivity, val events: List<Event>, val listener: DeleteEventsListener?, recyclerView: MyRecyclerView,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
||||
private val config = activity.config
|
||||
private var allDayString = resources.getString(R.string.all_day)
|
||||
private var replaceDescriptionWithLocation = config.replaceDescription
|
||||
private var replaceDescriptionWithLocation = activity.config.replaceDescription
|
||||
|
||||
init {
|
||||
selectableItemCount = events.count()
|
||||
|
@ -24,13 +24,12 @@ import java.util.*
|
||||
class EventListAdapter(activity: SimpleActivity, val listItems: List<ListItem>, val allowLongClick: Boolean, val listener: DeleteEventsListener?,
|
||||
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
||||
private val config = activity.config
|
||||
private val ITEM_EVENT = 0
|
||||
private val ITEM_HEADER = 1
|
||||
|
||||
private val topDivider = resources.getDrawable(R.drawable.divider_width)
|
||||
private val allDayString = resources.getString(R.string.all_day)
|
||||
private val replaceDescriptionWithLocation = config.replaceDescription
|
||||
private val replaceDescriptionWithLocation = activity.config.replaceDescription
|
||||
private val redTextColor = resources.getColor(R.color.red_text)
|
||||
private val now = (System.currentTimeMillis() / 1000).toInt()
|
||||
private val todayDate = Formatter.getDayTitle(activity, Formatter.getDayCodeFromTS(now))
|
||||
|
@ -21,8 +21,6 @@ import java.util.*
|
||||
class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: List<EventType>, val listener: DeleteEventTypesListener?, recyclerView: MyRecyclerView,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
||||
private val config = activity.config
|
||||
|
||||
init {
|
||||
selectableItemCount = eventTypes.size
|
||||
}
|
||||
@ -58,7 +56,7 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: List<Eve
|
||||
private fun setupView(view: View, eventType: EventType) {
|
||||
view.apply {
|
||||
event_type_title.text = eventType.getDisplayTitle()
|
||||
event_type_color.setBackgroundWithStroke(eventType.color, config.backgroundColor)
|
||||
event_type_color.setBackgroundWithStroke(eventType.color, activity.config.backgroundColor)
|
||||
event_type_title.setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,9 @@ fun Context.launchNewEventIntent() {
|
||||
fun Context.getNewEventTimestampFromCode(dayCode: String): Int {
|
||||
val currHour = DateTime(System.currentTimeMillis(), DateTimeZone.getDefault()).hourOfDay
|
||||
val dateTime = Formatter.getLocalDateTimeFromCode(dayCode).withHourOfDay(currHour)
|
||||
return dateTime.plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).seconds()
|
||||
val newDateTime = dateTime.plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0)
|
||||
// make sure the date doesn't change
|
||||
return newDateTime.withDate(dateTime.year, dateTime.monthOfYear, dateTime.dayOfMonth).seconds()
|
||||
}
|
||||
|
||||
fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date())
|
||||
|
Loading…
x
Reference in New Issue
Block a user