fill the simple list with future and present events

This commit is contained in:
tibbi 2016-10-23 00:02:27 +02:00
parent 8b85ed656c
commit f5e0bf81d7
2 changed files with 18 additions and 3 deletions

View File

@ -151,6 +151,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DBHelper.DB_NAME, n
Thread({
val events = ArrayList<Event>()
events.addAll(getEventsFor(fromTS, toTS))
val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL"
val selectionArgs = arrayOf(toTS.toString(), fromTS.toString())
val cursor = getEventsCursor(selection, selectionArgs)

View File

@ -7,16 +7,30 @@ import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.calendar.DBHelper
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.adapters.EventsAdapter
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 {
lateinit var mView: View
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater!!.inflate(R.layout.fragment_event_list, container, false)
return view
mView = inflater!!.inflate(R.layout.fragment_event_list, container, false)
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>) {
val eventsAdapter = EventsAdapter(context, events)
activity?.runOnUiThread {
mView.calendar_events_list.adapter = eventsAdapter
}
}
}