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
|
package com.simplemobiletools.calendar.activities
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.DatePickerDialog
|
import android.app.DatePickerDialog
|
||||||
import android.app.TimePickerDialog
|
import android.app.TimePickerDialog
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
@ -12,9 +10,9 @@ import android.view.WindowManager
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.extensions.*
|
import com.simplemobiletools.calendar.extensions.*
|
||||||
import com.simplemobiletools.calendar.fragments.DayFragment
|
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
|
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.filepicker.extensions.toast
|
import com.simplemobiletools.filepicker.extensions.toast
|
||||||
import kotlinx.android.synthetic.main.activity_event.*
|
import kotlinx.android.synthetic.main.activity_event.*
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
@ -221,11 +219,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteEvent() {
|
private fun deleteEvent() {
|
||||||
Intent().apply {
|
ConfirmationDialog(this) {
|
||||||
putExtra(DayFragment.DELETED_ID, mEvent.id)
|
DBHelper(applicationContext, this).deleteEvents(arrayOf(mEvent.id.toString()))
|
||||||
setResult(Activity.RESULT_OK, this)
|
finish()
|
||||||
}
|
}
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveEvent() {
|
private fun saveEvent() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.simplemobiletools.calendar.fragments
|
package com.simplemobiletools.calendar.fragments
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
@ -29,8 +28,6 @@ import java.util.*
|
||||||
import kotlin.comparisons.compareBy
|
import kotlin.comparisons.compareBy
|
||||||
|
|
||||||
class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEventsListener, EventsAdapter.ItemOperationsListener {
|
class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEventsListener, EventsAdapter.ItemOperationsListener {
|
||||||
private val EDIT_EVENT = 1
|
|
||||||
|
|
||||||
private var mTextColor = 0
|
private var mTextColor = 0
|
||||||
private var mDayCode = ""
|
private var mDayCode = ""
|
||||||
private var mEvents: MutableList<Event>? = null
|
private var mEvents: MutableList<Event>? = null
|
||||||
|
@ -41,10 +38,6 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
||||||
lateinit var mConfig: Config
|
lateinit var mConfig: Config
|
||||||
lateinit var mToBeDeleted: MutableList<Int>
|
lateinit var mToBeDeleted: MutableList<Int>
|
||||||
|
|
||||||
companion object {
|
|
||||||
val DELETED_ID = "deleted_id"
|
|
||||||
}
|
|
||||||
|
|
||||||
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_day, container, false)
|
val view = inflater.inflate(R.layout.fragment_day, container, false)
|
||||||
mRes = resources
|
mRes = resources
|
||||||
|
@ -139,18 +132,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
||||||
private fun editEvent(eventId: Int) {
|
private fun editEvent(eventId: Int) {
|
||||||
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||||
putExtra(EVENT_ID, eventId)
|
putExtra(EVENT_ID, eventId)
|
||||||
startActivityForResult(this, EDIT_EVENT)
|
startActivity(this)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.simplemobiletools.calendar.fragments
|
package com.simplemobiletools.calendar.fragments
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
|
@ -28,8 +27,6 @@ import java.util.*
|
||||||
import kotlin.comparisons.compareBy
|
import kotlin.comparisons.compareBy
|
||||||
|
|
||||||
class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.EventUpdateListener, EventListAdapter.ItemOperationsListener {
|
class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.EventUpdateListener, EventListAdapter.ItemOperationsListener {
|
||||||
private val EDIT_EVENT = 1
|
|
||||||
|
|
||||||
var mAllEvents: MutableList<Event>? = null
|
var mAllEvents: MutableList<Event>? = null
|
||||||
lateinit var mToBeDeleted: MutableList<Int>
|
lateinit var mToBeDeleted: MutableList<Int>
|
||||||
lateinit var mView: View
|
lateinit var mView: View
|
||||||
|
@ -100,18 +97,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event
|
||||||
private fun editEvent(eventId: Int) {
|
private fun editEvent(eventId: Int) {
|
||||||
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||||
putExtra(EVENT_ID, eventId)
|
putExtra(EVENT_ID, eventId)
|
||||||
startActivityForResult(this, EDIT_EVENT)
|
startActivity(this)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue