mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-06-05 21:49:21 +02:00
allow changing the column count with gestures too
This commit is contained in:
@ -20,6 +20,7 @@ import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
|||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -28,6 +29,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
|
|
||||||
private var displayedLaunchers = ArrayList<AppLauncher>()
|
private var displayedLaunchers = ArrayList<AppLauncher>()
|
||||||
private var notDisplayedLaunchers: ArrayList<AppLauncher>? = null
|
private var notDisplayedLaunchers: ArrayList<AppLauncher>? = null
|
||||||
|
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
||||||
|
|
||||||
private var mStoredPrimaryColor = 0
|
private var mStoredPrimaryColor = 0
|
||||||
private var mStoredTextColor = 0
|
private var mStoredTextColor = 0
|
||||||
|
|
||||||
@ -111,7 +114,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
private fun setupLaunchers() {
|
private fun setupLaunchers() {
|
||||||
displayedLaunchers = dbHelper.getLaunchers()
|
displayedLaunchers = dbHelper.getLaunchers()
|
||||||
checkInvalidApps()
|
checkInvalidApps()
|
||||||
val adapter = LaunchersAdapter(this, displayedLaunchers, this, launchers_grid, launchers_fastscroller) {
|
initZoomListener()
|
||||||
|
|
||||||
|
LaunchersAdapter(this, displayedLaunchers, this, launchers_grid, launchers_fastscroller) {
|
||||||
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
|
val launchIntent = packageManager.getLaunchIntentForPackage((it as AppLauncher).packageName)
|
||||||
if (launchIntent != null) {
|
if (launchIntent != null) {
|
||||||
try {
|
try {
|
||||||
@ -129,8 +134,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
launchViewIntent("https://play.google.com/store/apps/details?id=${it.packageName}")
|
launchViewIntent("https://play.google.com/store/apps/details?id=${it.packageName}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.apply {
|
||||||
|
setupZoomListener(zoomListener)
|
||||||
|
launchers_grid.adapter = this
|
||||||
}
|
}
|
||||||
launchers_grid.adapter = adapter
|
|
||||||
|
|
||||||
launchers_fastscroller.setViews(launchers_grid) {
|
launchers_fastscroller.setViews(launchers_grid) {
|
||||||
launchers_fastscroller.updateBubbleText(displayedLaunchers.getOrNull(it)?.getBubbleText() ?: "")
|
launchers_fastscroller.updateBubbleText(displayedLaunchers.getOrNull(it)?.getBubbleText() ?: "")
|
||||||
@ -172,6 +179,25 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
layoutManager.spanCount = config.columnCnt
|
layoutManager.spanCount = config.columnCnt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initZoomListener() {
|
||||||
|
val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager
|
||||||
|
zoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
|
override fun zoomIn() {
|
||||||
|
if (layoutManager.spanCount > 1) {
|
||||||
|
reduceColumnCount()
|
||||||
|
getGridAdapter()?.finishActMode()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun zoomOut() {
|
||||||
|
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
|
||||||
|
increaseColumnCount()
|
||||||
|
getGridAdapter()?.finishActMode()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkInvalidApps() {
|
private fun checkInvalidApps() {
|
||||||
val invalidIds = ArrayList<String>()
|
val invalidIds = ArrayList<String>()
|
||||||
for ((id, name, packageName) in displayedLaunchers) {
|
for ((id, name, packageName) in displayedLaunchers) {
|
||||||
|
Reference in New Issue
Block a user