updating some code style for better readability

This commit is contained in:
tibbi 2020-03-20 17:53:57 +01:00
parent 7a36e6be6a
commit 6bbb509d0f
2 changed files with 19 additions and 9 deletions

View File

@ -105,7 +105,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
context!!.eventsHelper.getEventTypes(activity!!, false) { context!!.eventsHelper.getEventTypes(activity!!, false) {
it.map { eventTypeColors.put(it.id!!, it.color) } it.map {
eventTypeColors.put(it.id!!, it.color)
}
} }
setupDayLabels() setupDayLabels()
@ -122,8 +124,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val bounds = Rect() val bounds = Rect()
week_events_holder.getGlobalVisibleRect(bounds) week_events_holder.getGlobalVisibleRect(bounds)
maxScrollY -= bounds.bottom - bounds.top maxScrollY -= bounds.bottom - bounds.top
if (minScrollY > maxScrollY) if (minScrollY > maxScrollY) {
maxScrollY = -1 maxScrollY = -1
}
checkScrollLimits(scrollView.scrollY) checkScrollLimits(scrollView.scrollY)
} }
@ -261,7 +264,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var hadAllDayEvent = false var hadAllDayEvent = false
val replaceDescription = config.replaceDescription val replaceDescription = config.replaceDescription
val sorted = events.sortedWith(compareBy<Event> { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description }) val sorted = events.sortedWith(
compareBy<Event> { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description }
)
for (event in sorted) { for (event in sorted) {
val startDateTime = Formatter.getDateTimeFromTS(event.startTS) val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
val endDateTime = Formatter.getDateTimeFromTS(event.endTS) val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
@ -344,7 +350,11 @@ class WeekFragment : Fragment(), WeeklyCalendar {
} }
} }
minHeight = if (event.startTS == event.endTS) minimalHeight else (duration * minuteHeight).toInt() - 1 minHeight = if (event.startTS == event.endTS) {
minimalHeight
} else {
(duration * minuteHeight).toInt() - 1
}
} }
setOnClickListener { setOnClickListener {
Intent(context, EventActivity::class.java).apply { Intent(context, EventActivity::class.java).apply {
@ -378,8 +388,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
mView.week_events_holder.removeView(currentTimeView) mView.week_events_holder.removeView(currentTimeView)
} }
currentTimeView = (inflater.inflate(R.layout.week_now_marker, null, false) as ImageView) currentTimeView = (inflater.inflate(R.layout.week_now_marker, null, false) as ImageView).apply {
currentTimeView!!.apply {
applyColorFilter(primaryColor) applyColorFilter(primaryColor)
mView.week_events_holder.addView(this, 0) mView.week_events_holder.addView(this, 0)
val extraWidth = (todayColumn.width * 0.3).toInt() val extraWidth = (todayColumn.width * 0.3).toInt()

View File

@ -8,6 +8,7 @@ import android.view.ViewGroup
import android.widget.DatePicker import android.widget.DatePicker
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity import com.simplemobiletools.calendar.pro.activities.MainActivity
@ -122,12 +123,12 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
if (startDateTime.year != DateTime().year) { if (startDateTime.year != DateTime().year) {
newTitle += " - ${startDateTime.year}" newTitle += " - ${startDateTime.year}"
} }
(activity as MainActivity).updateActionBarTitle(newTitle) (activity as AppCompatActivity).updateActionBarTitle(newTitle)
} else { } else {
val endMonthName = Formatter.getMonthName(context!!, endDateTime.monthOfYear) val endMonthName = Formatter.getMonthName(context!!, endDateTime.monthOfYear)
(activity as MainActivity).updateActionBarTitle("$startMonthName - $endMonthName") (activity as AppCompatActivity).updateActionBarTitle("$startMonthName - $endMonthName")
} }
(activity as MainActivity).updateActionBarSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}") (activity as AppCompatActivity).updateActionBarSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}")
} }
override fun goToToday() { override fun goToToday() {