diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 79bb88227..af8a3b72e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -1,9 +1,7 @@ package com.simplemobiletools.calendar.activities -import android.app.Activity import android.app.DatePickerDialog import android.app.TimePickerDialog -import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -12,9 +10,9 @@ import android.view.WindowManager import android.widget.AdapterView import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.* -import com.simplemobiletools.calendar.fragments.DayFragment import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.models.Event +import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog import com.simplemobiletools.filepicker.extensions.toast import kotlinx.android.synthetic.main.activity_event.* import org.joda.time.DateTime @@ -221,11 +219,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } private fun deleteEvent() { - Intent().apply { - putExtra(DayFragment.DELETED_ID, mEvent.id) - setResult(Activity.RESULT_OK, this) + ConfirmationDialog(this) { + DBHelper(applicationContext, this).deleteEvents(arrayOf(mEvent.id.toString())) + finish() } - finish() } private fun saveEvent() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt index f7896a783..b48234f07 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.calendar.fragments -import android.app.Activity import android.content.Intent import android.content.res.Resources import android.graphics.Color @@ -29,8 +28,6 @@ import java.util.* import kotlin.comparisons.compareBy class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEventsListener, EventsAdapter.ItemOperationsListener { - private val EDIT_EVENT = 1 - private var mTextColor = 0 private var mDayCode = "" private var mEvents: MutableList? = null @@ -41,10 +38,6 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents lateinit var mConfig: Config lateinit var mToBeDeleted: MutableList - companion object { - val DELETED_ID = "deleted_id" - } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_day, container, false) mRes = resources @@ -139,18 +132,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents private fun editEvent(eventId: Int) { Intent(activity.applicationContext, EventActivity::class.java).apply { putExtra(EVENT_ID, eventId) - startActivityForResult(this, EDIT_EVENT) - } - } - - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - if (requestCode == EDIT_EVENT && resultCode == Activity.RESULT_OK && data != null) { - val deletedId = data.getIntExtra(DELETED_ID, -1) - if (deletedId != -1) { - mToBeDeleted.clear() - mToBeDeleted.add(deletedId) - notifyDeletion() - } + startActivity(this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt index 10561257a..302860e2b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.calendar.fragments -import android.app.Activity import android.content.Intent import android.os.Bundle import android.support.v4.app.Fragment @@ -28,8 +27,6 @@ import java.util.* import kotlin.comparisons.compareBy class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.EventUpdateListener, EventListAdapter.ItemOperationsListener { - private val EDIT_EVENT = 1 - var mAllEvents: MutableList? = null lateinit var mToBeDeleted: MutableList lateinit var mView: View @@ -100,18 +97,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event private fun editEvent(eventId: Int) { Intent(activity.applicationContext, EventActivity::class.java).apply { putExtra(EVENT_ID, eventId) - startActivityForResult(this, EDIT_EVENT) - } - } - - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - if (requestCode == EDIT_EVENT && resultCode == Activity.RESULT_OK && data != null) { - val deletedId = data.getIntExtra(DayFragment.DELETED_ID, -1) - if (deletedId != -1) { - mToBeDeleted.clear() - mToBeDeleted.add(deletedId) - notifyDeletion() - } + startActivity(this) } }