create a weekly pager adapter
This commit is contained in:
parent
55afe6b544
commit
8598cb5e17
|
@ -11,6 +11,7 @@ import android.view.View
|
|||
import com.simplemobiletools.calendar.BuildConfig
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.adapters.MyMonthPagerAdapter
|
||||
import com.simplemobiletools.calendar.adapters.MyWeekPagerAdapter
|
||||
import com.simplemobiletools.calendar.adapters.MyYearPagerAdapter
|
||||
import com.simplemobiletools.calendar.dialogs.ChangeViewDialog
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
|
@ -109,7 +110,7 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
} else if (config.storedView == EVENTS_LIST_VIEW) {
|
||||
fillEventsList()
|
||||
} else if (config.storedView == WEEKLY_VIEW) {
|
||||
|
||||
fillWeeklyViewPager()
|
||||
} else {
|
||||
val targetDay = DateTime().toString(Formatter.DAYCODE_PATTERN)
|
||||
fillMonthlyViewPager(targetDay)
|
||||
|
@ -157,6 +158,13 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
return months
|
||||
}
|
||||
|
||||
private fun fillWeeklyViewPager() {
|
||||
val weeklyAdapter = MyWeekPagerAdapter(supportFragmentManager)
|
||||
main_view_pager.apply {
|
||||
adapter = weeklyAdapter
|
||||
}
|
||||
}
|
||||
|
||||
private fun fillYearlyViewPager() {
|
||||
calendar_fab.visibility = View.GONE
|
||||
val targetYear = DateTime().toString(Formatter.YEAR_PATTERN).toInt()
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.simplemobiletools.calendar.adapters
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.app.FragmentStatePagerAdapter
|
||||
import com.simplemobiletools.calendar.fragments.WeekFragment
|
||||
|
||||
class MyWeekPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
|
||||
|
||||
override fun getCount() = 1
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
val bundle = Bundle()
|
||||
val fragment = WeekFragment()
|
||||
fragment.arguments = bundle
|
||||
return fragment
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.simplemobiletools.calendar.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import java.util.*
|
||||
import kotlin.comparisons.compareBy
|
||||
|
||||
class WeekFragment : Fragment(), DBHelper.GetEventsListener {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val view = inflater.inflate(R.layout.fragment_week, container, false)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
override fun gotEvents(events: MutableList<Event>) {
|
||||
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description })))
|
||||
activity?.runOnUiThread {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/week_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue