fill the simple list with future and present events
This commit is contained in:
parent
8b85ed656c
commit
f5e0bf81d7
|
@ -151,6 +151,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DBHelper.DB_NAME, n
|
||||||
Thread({
|
Thread({
|
||||||
val events = ArrayList<Event>()
|
val events = ArrayList<Event>()
|
||||||
events.addAll(getEventsFor(fromTS, toTS))
|
events.addAll(getEventsFor(fromTS, toTS))
|
||||||
|
|
||||||
val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL"
|
val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL"
|
||||||
val selectionArgs = arrayOf(toTS.toString(), fromTS.toString())
|
val selectionArgs = arrayOf(toTS.toString(), fromTS.toString())
|
||||||
val cursor = getEventsCursor(selection, selectionArgs)
|
val cursor = getEventsCursor(selection, selectionArgs)
|
||||||
|
|
|
@ -7,16 +7,30 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.calendar.DBHelper
|
import com.simplemobiletools.calendar.DBHelper
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
|
import com.simplemobiletools.calendar.adapters.EventsAdapter
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
|
import kotlinx.android.synthetic.main.fragment_event_list.view.*
|
||||||
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
class EventListFragment : Fragment(), DBHelper.GetEventsListener {
|
class EventListFragment : Fragment(), DBHelper.GetEventsListener {
|
||||||
|
lateinit var mView: View
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val view = inflater!!.inflate(R.layout.fragment_event_list, container, false)
|
mView = inflater!!.inflate(R.layout.fragment_event_list, container, false)
|
||||||
return view
|
return mView
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
val fromTS = (DateTime().millis / 1000).toInt()
|
||||||
|
val toTS = (DateTime().plusYears(1).millis / 1000).toInt()
|
||||||
|
DBHelper(context).getEvents(fromTS, toTS, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun gotEvents(events: MutableList<Event>) {
|
override fun gotEvents(events: MutableList<Event>) {
|
||||||
|
val eventsAdapter = EventsAdapter(context, events)
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
mView.calendar_events_list.adapter = eventsAdapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue