recheck daily events more frequently, at every resume

This commit is contained in:
tibbi 2016-09-18 20:52:38 +02:00
parent 7fb26ea71c
commit 8c4b4a6c6d
2 changed files with 10 additions and 11 deletions

View File

@ -381,7 +381,6 @@ public class EventActivity extends SimpleActivity implements DBHelper.DBOperatio
public void eventUpdated(Event event) {
Utils.scheduleNotification(getApplicationContext(), event);
Utils.showToast(getApplicationContext(), R.string.event_updated);
setResult(RESULT_OK);
finish();
}

View File

@ -59,6 +59,10 @@ class DayFragment : Fragment(), DBHelper.DBOperationsListener, AdapterView.OnIte
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mToBeDeleted = ArrayList<Int>()
}
override fun onResume() {
super.onResume()
checkEvents()
}
@ -134,10 +138,7 @@ class DayFragment : Fragment(), DBHelper.DBOperationsListener, AdapterView.OnIte
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == EDIT_EVENT && resultCode == Activity.RESULT_OK) {
if (data == null) {
checkEvents()
} else {
if (requestCode == EDIT_EVENT && resultCode == Activity.RESULT_OK && data != null) {
val deletedId = data.getIntExtra(DELETED_ID, -1)
if (deletedId != -1) {
mToBeDeleted.clear()
@ -146,7 +147,6 @@ class DayFragment : Fragment(), DBHelper.DBOperationsListener, AdapterView.OnIte
}
}
}
}
private fun getEventsToShow(events: MutableList<Event>): List<Event> {
return events.filter { !mToBeDeleted.contains(it.id) }