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 androidx.coordinatorlayout.widget.CoordinatorLayout | ||||
| import com.simplemobiletools.applauncher.BuildConfig | ||||
| import com.simplemobiletools.applauncher.LauncherAdapterUpdateListener | ||||
| import com.simplemobiletools.applauncher.R | ||||
| import com.simplemobiletools.applauncher.adapters.LaunchersAdapter | ||||
| 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.extensions.* | ||||
| import com.simplemobiletools.commons.helpers.ensureBackgroundThread | ||||
| import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener | ||||
| import com.simplemobiletools.commons.models.FAQItem | ||||
| import com.simplemobiletools.commons.models.RadioItem | ||||
| import com.simplemobiletools.commons.models.Release | ||||
| @@ -24,7 +24,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager | ||||
| import com.simplemobiletools.commons.views.MyRecyclerView | ||||
| import kotlinx.android.synthetic.main.activity_main.* | ||||
|  | ||||
| class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | ||||
| class MainActivity : SimpleActivity(), LauncherAdapterUpdateListener { | ||||
|     private val MAX_COLUMN_COUNT = 15 | ||||
|  | ||||
|     private var launchersIgnoringSearch = ArrayList<AppLauncher>() | ||||
| @@ -275,9 +275,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { | ||||
|     } | ||||
|  | ||||
|     override fun refreshItems() { | ||||
|         main_menu.closeSearch() | ||||
|         setupLaunchers() | ||||
|     } | ||||
|  | ||||
|     override fun refetchItems() { | ||||
|         launchersIgnoringSearch = dbHelper.getLaunchers() | ||||
|     } | ||||
|  | ||||
|     private fun checkWhatsNewDialog() { | ||||
|         arrayListOf<Release>().apply { | ||||
|             add(Release(7, R.string.release_7)) | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import android.view.ViewGroup | ||||
| import androidx.recyclerview.widget.ItemTouchHelper | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller | ||||
| import com.simplemobiletools.applauncher.LauncherAdapterUpdateListener | ||||
| import com.simplemobiletools.applauncher.R | ||||
| import com.simplemobiletools.applauncher.activities.SimpleActivity | ||||
| 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.interfaces.ItemMoveCallback | ||||
| import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract | ||||
| import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener | ||||
| import com.simplemobiletools.commons.interfaces.StartReorderDragListener | ||||
| import com.simplemobiletools.commons.views.MyRecyclerView | ||||
| import kotlinx.android.synthetic.main.item_launcher_label.view.* | ||||
| @@ -29,7 +29,7 @@ import java.util.* | ||||
| class LaunchersAdapter( | ||||
|     activity: SimpleActivity, | ||||
|     val launchers: ArrayList<AppLauncher>, | ||||
|     val listener: RefreshRecyclerViewListener, | ||||
|     val listener: LauncherAdapterUpdateListener, | ||||
|     recyclerView: MyRecyclerView, | ||||
|     itemClick: (Any) -> Unit | ||||
| ) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate { | ||||
| @@ -180,6 +180,8 @@ class LaunchersAdapter( | ||||
|         removeSelectedItems(positions) | ||||
|         if (launchers.isEmpty()) { | ||||
|             listener.refreshItems() | ||||
|         } else { | ||||
|             listener.refetchItems() | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user