delete the event from eventActivity, do not allow Undo
This commit is contained in:
parent
a0e2c53318
commit
34a88c544c
|
@ -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,12 +219,11 @@ 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()
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveEvent() {
|
||||
val newTitle = event_title.value
|
||||
|
|
|
@ -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<Event>? = null
|
||||
|
@ -41,10 +38,6 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
|||
lateinit var mConfig: Config
|
||||
lateinit var mToBeDeleted: MutableList<Int>
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Event>? = null
|
||||
lateinit var mToBeDeleted: MutableList<Int>
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue