mirror of
https://github.com/TeamAmaze/AmazeFileManager.git
synced 2026-10-17 05:08:00 +08:00
2010: Replace clear db calls with update on load list; remove one redundant call
This commit is contained in:
@@ -54,6 +54,10 @@ public class TabHandler {
|
||||
database.tabDao().insertTab(tab).subscribeOn(Schedulers.io()).subscribe();
|
||||
}
|
||||
|
||||
public void update(Tab tab) {
|
||||
database.tabDao().update(tab);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
database.tabDao().clear().subscribeOn(Schedulers.io()).subscribe();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
import androidx.room.Update;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Single;
|
||||
@@ -56,6 +57,9 @@ public interface TabDao {
|
||||
@Query("SELECT * FROM " + TABLE_TAB + " WHERE " + COLUMN_TAB_NO + " = :tabNo")
|
||||
Single<Tab> find(int tabNo);
|
||||
|
||||
@Update(onConflict = OnConflictStrategy.REPLACE)
|
||||
void update(Tab tab);
|
||||
|
||||
@Query("SELECT * FROM " + TABLE_TAB)
|
||||
Single<List<Tab>> list();
|
||||
}
|
||||
|
||||
@@ -189,7 +189,6 @@ public class TabFragment extends Fragment implements ViewPager.OnPageChangeListe
|
||||
|
||||
// Getting old path from database before clearing
|
||||
TabHandler tabHandler = TabHandler.getInstance();
|
||||
tabHandler.clear();
|
||||
|
||||
int i = 1;
|
||||
for (Fragment fragment : fragments) {
|
||||
@@ -198,13 +197,12 @@ public class TabFragment extends Fragment implements ViewPager.OnPageChangeListe
|
||||
if (i - 1 == MainActivity.currentTab && i == pos) {
|
||||
updateBottomBar(m);
|
||||
mainActivity.getDrawer().selectCorrectDrawerItemForPath(m.getCurrentPath());
|
||||
if (m.openMode == OpenMode.FILE) {
|
||||
tabHandler.update(new Tab(i, m.getCurrentPath(), m.home));
|
||||
} else {
|
||||
tabHandler.update(new Tab(i, m.home, m.home));
|
||||
}
|
||||
}
|
||||
if (m.openMode == OpenMode.FILE) {
|
||||
tabHandler.addTab(new Tab(i, m.getCurrentPath(), m.home));
|
||||
} else {
|
||||
tabHandler.addTab(new Tab(i, m.home, m.home));
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user