mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-22 22:07:26 +02:00
small refactoring
This commit is contained in:
parent
1944c0bd3a
commit
bad094482a
@ -64,24 +64,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
|||||||
with(launcher) {
|
with(launcher) {
|
||||||
itemView.launcher_label.text = launcher.name
|
itemView.launcher_label.text = launcher.name
|
||||||
itemView.setOnClickListener {
|
itemView.setOnClickListener {
|
||||||
if (multiSelector.isSelectable) {
|
viewClicked(multiSelector, launcher)
|
||||||
val isSelected = multiSelector.selectedPositions.contains(viewHolder.layoutPosition)
|
|
||||||
multiSelector.setSelected(viewHolder, !isSelected)
|
|
||||||
if (isSelected) {
|
|
||||||
itemView.launcher_check.hide()
|
|
||||||
} else {
|
|
||||||
itemView.launcher_check.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
val selectedCnt = multiSelector.selectedPositions.size
|
|
||||||
if (selectedCnt == 0) {
|
|
||||||
actMode?.finish()
|
|
||||||
} else {
|
|
||||||
actMode?.title = selectedCnt.toString()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
itemClick(this)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnLongClickListener {
|
itemView.setOnLongClickListener {
|
||||||
@ -103,5 +86,26 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun viewClicked(multiSelector: MultiSelector, appLauncher: AppLauncher) {
|
||||||
|
if (multiSelector.isSelectable) {
|
||||||
|
val isSelected = multiSelector.selectedPositions.contains(viewHolder.layoutPosition)
|
||||||
|
multiSelector.setSelected(viewHolder, !isSelected)
|
||||||
|
if (isSelected) {
|
||||||
|
itemView.launcher_check.hide()
|
||||||
|
} else {
|
||||||
|
itemView.launcher_check.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
val selectedCnt = multiSelector.selectedPositions.size
|
||||||
|
if (selectedCnt == 0) {
|
||||||
|
actMode?.finish()
|
||||||
|
} else {
|
||||||
|
actMode?.title = selectedCnt.toString()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemClick(appLauncher)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user