use of com.amaze.filemanager.database.models.explorer.Tab in project AmazeFileManager by TeamAmaze.
the class TabFragment method updatepaths.
public void updatepaths(int pos) {
// Getting old path from database before clearing
TabHandler tabHandler = TabHandler.getInstance();
int i = 1;
for (Fragment fragment : fragments) {
if (fragment instanceof MainFragment) {
MainFragment mainFragment = (MainFragment) fragment;
if (mainFragment.getMainFragmentViewModel() != null && i - 1 == MainActivity.currentTab && i == pos) {
updateBottomBar(mainFragment);
mainActivity.getDrawer().selectCorrectDrawerItemForPath(mainFragment.getCurrentPath());
if (mainFragment.getMainFragmentViewModel().getOpenMode() == OpenMode.FILE) {
tabHandler.update(new Tab(i, mainFragment.getCurrentPath(), mainFragment.getMainFragmentViewModel().getHome()));
} else {
tabHandler.update(new Tab(i, mainFragment.getMainFragmentViewModel().getHome(), mainFragment.getMainFragmentViewModel().getHome()));
}
}
i++;
}
}
}
use of com.amaze.filemanager.database.models.explorer.Tab in project AmazeFileManager by TeamAmaze.
the class TabFragment method refactorDrawerStorages.
/**
* Fetches new storage paths from drawer and apply to tabs This method will just create tabs in UI
* change paths in database. Calls should implement updating each tab's list for new paths.
*
* @param addTab whether new tabs should be added to ui or just change values in database
*/
public void refactorDrawerStorages(boolean addTab) {
TabHandler tabHandler = TabHandler.getInstance();
Tab tab1 = tabHandler.findTab(1);
Tab tab2 = tabHandler.findTab(2);
Tab[] tabs = tabHandler.getAllTabs();
String firstTabPath = mainActivity.getDrawer().getFirstPath();
String secondTabPath = mainActivity.getDrawer().getSecondPath();
if (tabs == null || tabs.length < 1 || tab1 == null || tab2 == null) {
// creating tabs in db for the first time, probably the first launch of
// app, or something got corrupted
String currentFirstTab = Utils.isNullOrEmpty(firstTabPath) ? "/" : firstTabPath;
String currentSecondTab = Utils.isNullOrEmpty(secondTabPath) ? firstTabPath : secondTabPath;
if (addTab) {
addNewTab(1, currentSecondTab, true);
addNewTab(2, currentFirstTab, false);
}
tabHandler.addTab(new Tab(1, currentSecondTab, currentSecondTab)).blockingAwait();
tabHandler.addTab(new Tab(2, currentFirstTab, currentFirstTab)).blockingAwait();
if (currentFirstTab.equalsIgnoreCase("/")) {
sharedPrefs.edit().putBoolean(PreferencesConstants.PREFERENCE_ROOTMODE, true).apply();
}
} else {
if (path != null && path.length() != 0) {
if (MainActivity.currentTab == 0) {
addTab(tab1, path, true);
addTab(tab2, "", false);
}
if (MainActivity.currentTab == 1) {
addTab(tab1, "", false);
addTab(tab2, path, true);
}
} else {
addTab(tab1, "", true);
addTab(tab2, "", false);
}
}
}
Aggregations