do notremoving some unnecessary calls at changing visible weekly days count

This commit is contained in:
tibbi 2021-09-26 16:19:14 +02:00
parent 3572deadd6
commit 03bbf71652
3 changed files with 3 additions and 31 deletions

View file

@ -8,9 +8,9 @@ import androidx.fragment.app.FragmentStatePagerAdapter
import com.simplemobiletools.calendar.pro.fragments.WeekFragment
import com.simplemobiletools.calendar.pro.helpers.WEEK_START_TIMESTAMP
import com.simplemobiletools.calendar.pro.interfaces.WeekFragmentListener
import com.simplemobiletools.commons.helpers.DAY_SECONDS
class MyWeekPagerAdapter(fm: FragmentManager, private val mWeekTimestamps: List<Long>, private val mListener: WeekFragmentListener) : FragmentStatePagerAdapter(fm) {
class MyWeekPagerAdapter(fm: FragmentManager, private val mWeekTimestamps: List<Long>, private val mListener: WeekFragmentListener) :
FragmentStatePagerAdapter(fm) {
private val mFragments = SparseArray<WeekFragment>()
override fun getCount() = mWeekTimestamps.size
@ -44,15 +44,6 @@ class MyWeekPagerAdapter(fm: FragmentManager, private val mWeekTimestamps: List<
mFragments[pos + 1]?.updateNotVisibleViewScaleLevel()
}
fun updateVisibleDaysCount(pos: Int, count: Int, currentWeekTimestamp: Long) {
mFragments[pos - 1]?.updateWeekStartTimestamp(currentWeekTimestamp - count * DAY_SECONDS)
mFragments[pos + 1]?.updateWeekStartTimestamp(currentWeekTimestamp + count * DAY_SECONDS)
for (i in -1..1) {
mFragments[pos + i]?.updateVisibleDaysCount(count)
}
}
fun togglePrintMode(pos: Int) {
mFragments[pos].togglePrintMode()
}

View file

@ -28,11 +28,11 @@ import com.simplemobiletools.calendar.pro.views.MyScrollView
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.views.MyTextView
import java.util.*
import kotlinx.android.synthetic.main.fragment_week.*
import kotlinx.android.synthetic.main.fragment_week.view.*
import org.joda.time.DateTime
import org.joda.time.Days
import java.util.*
class WeekFragment : Fragment(), WeeklyCalendar {
private val WEEKLY_EVENT_ID_LABEL = "event_id_label"
@ -184,24 +184,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
}
fun updateVisibleDaysCount(count: Int) {
dayColumns.clear()
addDayColumns()
mView.week_horizontal_grid_holder.apply {
daysCount = count
invalidate()
}
addEvents(currEvents)
setupDayLabels()
}
fun updateWeekStartTimestamp(newTimestamp: Long) {
weekTimestamp = newTimestamp
updateCalendar()
}
private fun addDayColumns() {
mView.week_events_columns_holder.removeAllViews()
(0 until config.weeklyViewDays).forEach {

View file

@ -234,7 +234,6 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun updateDaysCount(cnt: Int) {
weekHolder!!.week_view_days_count.text = context!!.resources.getQuantityString(R.plurals.days, cnt, cnt)
(viewPager?.adapter as? MyWeekPagerAdapter)?.updateVisibleDaysCount(viewPager!!.currentItem, cnt, currentWeekTS)
}
override fun refreshEvents() {