mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-06-05 21:49:21 +02:00
properly refetch all launchers after deleting one
This commit is contained in:
@ -0,0 +1,7 @@
|
|||||||
|
package com.simplemobiletools.applauncher
|
||||||
|
|
||||||
|
interface LauncherAdapterUpdateListener {
|
||||||
|
fun refreshItems()
|
||||||
|
|
||||||
|
fun refetchItems()
|
||||||
|
}
|
@ -4,6 +4,7 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import com.simplemobiletools.applauncher.BuildConfig
|
import com.simplemobiletools.applauncher.BuildConfig
|
||||||
|
import com.simplemobiletools.applauncher.LauncherAdapterUpdateListener
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.adapters.LaunchersAdapter
|
import com.simplemobiletools.applauncher.adapters.LaunchersAdapter
|
||||||
import com.simplemobiletools.applauncher.dialogs.AddLaunchersDialog
|
import com.simplemobiletools.applauncher.dialogs.AddLaunchersDialog
|
||||||
@ -16,7 +17,6 @@ import com.simplemobiletools.applauncher.models.AppLauncher
|
|||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
@ -24,7 +24,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
|||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class MainActivity : SimpleActivity(), LauncherAdapterUpdateListener {
|
||||||
private val MAX_COLUMN_COUNT = 15
|
private val MAX_COLUMN_COUNT = 15
|
||||||
|
|
||||||
private var launchersIgnoringSearch = ArrayList<AppLauncher>()
|
private var launchersIgnoringSearch = ArrayList<AppLauncher>()
|
||||||
@ -275,9 +275,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshItems() {
|
override fun refreshItems() {
|
||||||
|
main_menu.closeSearch()
|
||||||
setupLaunchers()
|
setupLaunchers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun refetchItems() {
|
||||||
|
launchersIgnoringSearch = dbHelper.getLaunchers()
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkWhatsNewDialog() {
|
private fun checkWhatsNewDialog() {
|
||||||
arrayListOf<Release>().apply {
|
arrayListOf<Release>().apply {
|
||||||
add(Release(7, R.string.release_7))
|
add(Release(7, R.string.release_7))
|
||||||
|
@ -7,6 +7,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
|
import com.simplemobiletools.applauncher.LauncherAdapterUpdateListener
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.activities.SimpleActivity
|
import com.simplemobiletools.applauncher.activities.SimpleActivity
|
||||||
import com.simplemobiletools.applauncher.dialogs.EditDialog
|
import com.simplemobiletools.applauncher.dialogs.EditDialog
|
||||||
@ -20,7 +21,6 @@ import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
|
|||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
|
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
|
||||||
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
|
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
|
||||||
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
||||||
@ -29,7 +29,7 @@ import java.util.*
|
|||||||
class LaunchersAdapter(
|
class LaunchersAdapter(
|
||||||
activity: SimpleActivity,
|
activity: SimpleActivity,
|
||||||
val launchers: ArrayList<AppLauncher>,
|
val launchers: ArrayList<AppLauncher>,
|
||||||
val listener: RefreshRecyclerViewListener,
|
val listener: LauncherAdapterUpdateListener,
|
||||||
recyclerView: MyRecyclerView,
|
recyclerView: MyRecyclerView,
|
||||||
itemClick: (Any) -> Unit
|
itemClick: (Any) -> Unit
|
||||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
|
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||||
@ -180,6 +180,8 @@ class LaunchersAdapter(
|
|||||||
removeSelectedItems(positions)
|
removeSelectedItems(positions)
|
||||||
if (launchers.isEmpty()) {
|
if (launchers.isEmpty()) {
|
||||||
listener.refreshItems()
|
listener.refreshItems()
|
||||||
|
} else {
|
||||||
|
listener.refetchItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user