mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-16 19:07:32 +02:00
show an Edit button if there is only 1 item selected
This commit is contained in:
parent
7e6edc20e6
commit
884e22d67e
@ -28,6 +28,9 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
val deleteMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
|
||||
when (item?.itemId) {
|
||||
R.id.cab_edit -> {
|
||||
|
||||
}
|
||||
R.id.cab_delete -> {
|
||||
val positions = multiSelector.selectedPositions
|
||||
val deleteIds = ArrayList<String>(positions.size)
|
||||
@ -51,6 +54,12 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
act.menuInflater.inflate(R.menu.cab, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu?): Boolean {
|
||||
val menuItem = menu?.findItem(R.id.cab_edit)
|
||||
menuItem?.isVisible = multiSelector.selectedPositions.size == 1
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
@ -112,6 +121,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
} else {
|
||||
actMode?.title = selectedCnt.toString()
|
||||
}
|
||||
actMode?.invalidate()
|
||||
} else {
|
||||
itemClick(appLauncher)
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/cab_edit"
|
||||
android:icon="@mipmap/edit"
|
||||
android:title="@string/edit"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/cab_delete"
|
||||
android:icon="@mipmap/delete"
|
||||
|
@ -1,6 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">Simple App Launcher</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="edit">Edit</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">About</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user