From 5f336629b21293daafef8b4c75bba9bbea31a0d9 Mon Sep 17 00:00:00 2001 From: queuejw Date: Sun, 1 Sep 2024 14:33:18 +0400 Subject: [PATCH] Minor improvements --- .../main/java/ru/dimon6018/metrolauncher/content/NewStart.kt | 4 ++-- .../ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt index f2c2d1c..8df554e 100644 --- a/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt +++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt @@ -189,7 +189,7 @@ class NewStart: Fragment(), OnStartDragListener { super.onViewCreated(view, savedInstanceState) if(context != null) { viewLifecycleOwner.lifecycleScope.launch(defaultDispatcher) { - lastItemPos = mainViewModel.getTileDao().getUserTiles().size + 6 + lastItemPos = mainViewModel.getTileDao().getTileLastPosition().appPos!! + 6 tiles = mainViewModel.getTileDao().getTilesList() setupRecyclerViewLayoutManager(requireContext()) setupAdapter() @@ -831,7 +831,7 @@ class NewStart: Fragment(), OnStartDragListener { mainViewModel.getTileDao().updateTile(item) } val updatedList = mainViewModel.getTileDao().getTilesList() - lastItemPos = mainViewModel.getTileDao().getUserTiles().last().appPos!! + 6 + lastItemPos = mainViewModel.getTileDao().getTileLastPosition().appPos!! + 6 withContext(mainDispatcher) { if (isEditMode) { refreshData(updatedList) diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt index 95d9af4..4b86a2e 100644 --- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt +++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt @@ -30,4 +30,6 @@ interface TileDao { fun getTileByID(id: Int): Tile @Query("DELETE FROM tiles") fun deleteAllTiles() + @Query("SELECT * FROM tiles WHERE tileType != -1 ORDER BY appPos DESC LIMIT 1") + fun getTileLastPosition(): Tile } \ No newline at end of file