add multichoice model touch to events
This commit is contained in:
parent
4388e23ff1
commit
5b15389f4e
|
@ -189,13 +189,13 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.delete -> {
|
R.id.delete -> {
|
||||||
prepareDeleteEvents()
|
prepareDeleteEvents()
|
||||||
mode.finish()
|
mode.finish()
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
else -> return false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@ package com.simplemobiletools.calendar.fragments
|
||||||
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
|
||||||
import android.view.LayoutInflater
|
import android.view.*
|
||||||
import android.view.View
|
import android.widget.AbsListView
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import com.simplemobiletools.calendar.Constants
|
import com.simplemobiletools.calendar.Constants
|
||||||
import com.simplemobiletools.calendar.DBHelper
|
import com.simplemobiletools.calendar.DBHelper
|
||||||
|
@ -22,11 +21,12 @@ import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.comparisons.compareBy
|
import kotlin.comparisons.compareBy
|
||||||
|
|
||||||
class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.OnItemClickListener {
|
class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener {
|
||||||
private val EDIT_EVENT = 1
|
private val EDIT_EVENT = 1
|
||||||
|
|
||||||
lateinit var mView: View
|
var mSelectedItemsCnt = 0
|
||||||
var mListItems: ArrayList<ListItem> = ArrayList()
|
var mListItems: ArrayList<ListItem> = ArrayList()
|
||||||
|
lateinit var mView: View
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
mView = inflater!!.inflate(R.layout.fragment_event_list, container, false)
|
mView = inflater!!.inflate(R.layout.fragment_event_list, container, false)
|
||||||
|
@ -59,6 +59,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On
|
||||||
mView.calendar_events_list.apply {
|
mView.calendar_events_list.apply {
|
||||||
adapter = eventsAdapter
|
adapter = eventsAdapter
|
||||||
onItemClickListener = this@EventListFragment
|
onItemClickListener = this@EventListFragment
|
||||||
|
setMultiChoiceModeListener(this@EventListFragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,4 +73,39 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On
|
||||||
intent.putExtra(Constants.EVENT_ID, eventId)
|
intent.putExtra(Constants.EVENT_ID, eventId)
|
||||||
startActivityForResult(intent, EDIT_EVENT)
|
startActivityForResult(intent, EDIT_EVENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return when (item.itemId) {
|
||||||
|
R.id.delete -> {
|
||||||
|
mode.finish()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu?): Boolean {
|
||||||
|
val inflater = mode.menuInflater
|
||||||
|
inflater.inflate(R.menu.menu_day_cab, menu)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyActionMode(mode: ActionMode?) {
|
||||||
|
mSelectedItemsCnt = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemCheckedStateChanged(mode: ActionMode, position: Int, id: Long, checked: Boolean) {
|
||||||
|
if (checked) {
|
||||||
|
mSelectedItemsCnt++
|
||||||
|
} else {
|
||||||
|
mSelectedItemsCnt--
|
||||||
|
}
|
||||||
|
|
||||||
|
mode.title = mSelectedItemsCnt.toString()
|
||||||
|
mode.invalidate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue