use of com.amaze.filemanager.ui.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method onPrepareOptionsMenu.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem s = menu.findItem(R.id.view);
MenuItem search = menu.findItem(R.id.search);
Fragment fragment = getFragmentAtFrame();
if (fragment instanceof TabFragment) {
appbar.setTitle(R.string.appbar_name);
if (getBoolean(PREFERENCE_VIEW)) {
s.setTitle(getResources().getString(R.string.gridview));
} else {
s.setTitle(getResources().getString(R.string.listview));
}
try {
executeWithMainFragment(mainFragment -> {
if (mainFragment.getMainFragmentViewModel().isList()) {
s.setTitle(R.string.gridview);
} else {
s.setTitle(R.string.listview);
}
appbar.getBottomBar().updatePath(mainFragment.getCurrentPath(), mainFragment.getMainFragmentViewModel().getResults(), MainActivityHelper.SEARCH_TEXT, mainFragment.getMainFragmentViewModel().getOpenMode(), mainFragment.getMainFragmentViewModel().getFolderCount(), mainFragment.getMainFragmentViewModel().getFileCount(), mainFragment);
return null;
});
} catch (Exception e) {
e.printStackTrace();
}
appbar.getBottomBar().setClickListener();
search.setVisible(true);
if (indicator_layout != null)
indicator_layout.setVisibility(View.VISIBLE);
menu.findItem(R.id.search).setVisible(true);
menu.findItem(R.id.home).setVisible(true);
menu.findItem(R.id.history).setVisible(true);
menu.findItem(R.id.sethome).setVisible(true);
menu.findItem(R.id.sort).setVisible(true);
menu.findItem(R.id.hiddenitems).setVisible(true);
menu.findItem(R.id.view).setVisible(true);
menu.findItem(R.id.extract).setVisible(false);
invalidatePasteSnackbar(true);
findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE);
} else if (fragment instanceof AppsListFragment || fragment instanceof ProcessViewerFragment || fragment instanceof FtpServerFragment) {
appBarLayout.setExpanded(true);
menu.findItem(R.id.sethome).setVisible(false);
if (indicator_layout != null)
indicator_layout.setVisibility(View.GONE);
findViewById(R.id.buttonbarframe).setVisibility(View.GONE);
menu.findItem(R.id.search).setVisible(false);
menu.findItem(R.id.home).setVisible(false);
menu.findItem(R.id.history).setVisible(false);
menu.findItem(R.id.extract).setVisible(false);
if (fragment instanceof ProcessViewerFragment) {
menu.findItem(R.id.sort).setVisible(false);
} else if (fragment instanceof FtpServerFragment) {
menu.findItem(R.id.sort).setVisible(false);
} else {
menu.findItem(R.id.dsort).setVisible(false);
menu.findItem(R.id.sortby).setVisible(false);
}
menu.findItem(R.id.hiddenitems).setVisible(false);
menu.findItem(R.id.view).setVisible(false);
invalidatePasteSnackbar(false);
} else if (fragment instanceof CompressedExplorerFragment) {
appbar.setTitle(R.string.appbar_name);
menu.findItem(R.id.sethome).setVisible(false);
if (indicator_layout != null)
indicator_layout.setVisibility(View.GONE);
getAppbar().getBottomBar().resetClickListener();
menu.findItem(R.id.search).setVisible(false);
menu.findItem(R.id.home).setVisible(false);
menu.findItem(R.id.history).setVisible(false);
menu.findItem(R.id.sort).setVisible(false);
menu.findItem(R.id.hiddenitems).setVisible(false);
menu.findItem(R.id.view).setVisible(false);
menu.findItem(R.id.extract).setVisible(true);
invalidatePasteSnackbar(false);
}
return super.onPrepareOptionsMenu(menu);
}
use of com.amaze.filemanager.ui.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method goToMain.
public void goToMain(String path) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// title.setText(R.string.app_name);
TabFragment tabFragment = new TabFragment();
if (intent != null && intent.getAction() != null) {
if (INTENT_ACTION_OPEN_QUICK_ACCESS.equals(intent.getAction())) {
path = "5";
} else if (INTENT_ACTION_OPEN_RECENT.equals(intent.getAction())) {
path = "6";
}
}
if (path != null && path.length() > 0) {
Bundle b = new Bundle();
b.putString("path", path);
tabFragment.setArguments(b);
}
transaction.replace(R.id.content_frame, tabFragment);
// Commit the transaction
transaction.addToBackStack("tabt" + 1);
transaction.commitAllowingStateLoss();
appbar.setTitle(null);
floatingActionButton.show();
if (openzip && zippath != null) {
openCompressed(zippath);
zippath = null;
}
}
use of com.amaze.filemanager.ui.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method onPermissionGranted.
@Override
public void onPermissionGranted() {
drawer.refreshDrawer();
TabFragment tabFragment = getTabFragment();
boolean b = getBoolean(PREFERENCE_NEED_TO_SET_HOME);
// reset home and current paths according to new storages
if (b) {
TabHandler tabHandler = TabHandler.getInstance();
tabHandler.clear().subscribe(() -> {
if (tabFragment != null) {
tabFragment.refactorDrawerStorages(false);
Fragment main = tabFragment.getFragmentAtIndex(0);
if (main != null)
((MainFragment) main).updateTabWithDb(tabHandler.findTab(1));
Fragment main1 = tabFragment.getFragmentAtIndex(1);
if (main1 != null)
((MainFragment) main1).updateTabWithDb(tabHandler.findTab(2));
}
getPrefs().edit().putBoolean(PREFERENCE_NEED_TO_SET_HOME, false).commit();
});
} else {
// just refresh list
if (tabFragment != null) {
Fragment main = tabFragment.getFragmentAtIndex(0);
if (main != null)
((MainFragment) main).updateList();
Fragment main1 = tabFragment.getFragmentAtIndex(1);
if (main1 != null)
((MainFragment) main1).updateList();
}
}
}
use of com.amaze.filemanager.ui.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method initLeftRightAndTopDragListeners.
private void initLeftRightAndTopDragListeners(boolean destroy, boolean shouldInvokeLeftAndRight) {
TabFragment tabFragment = getTabFragment();
tabFragment.initLeftRightAndTopDragListeners(destroy, shouldInvokeLeftAndRight);
}
use of com.amaze.filemanager.ui.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method search.
/**
* Creates a fragment which will handle the search AsyncTask {@link SearchWorkerFragment}
*
* @param query the text query entered the by user
*/
public void search(SharedPreferences sharedPrefs, String query) {
TabFragment tabFragment = mainActivity.getTabFragment();
if (tabFragment == null) {
Log.w(getClass().getSimpleName(), "Failed to search: tab fragment not available");
return;
}
final MainFragment ma = (MainFragment) tabFragment.getCurrentTabFragment();
if (ma == null || ma.getMainFragmentViewModel() == null) {
Log.w(getClass().getSimpleName(), "Failed to search: main fragment not available");
return;
}
final String fpath = ma.getCurrentPath();
/*SearchTask task = new SearchTask(ma.searchHelper, ma, query);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fpath);*/
// ma.searchTask = task;
SEARCH_TEXT = query;
FragmentManager fm = mainActivity.getSupportFragmentManager();
SearchWorkerFragment fragment = (SearchWorkerFragment) fm.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);
if (fragment != null) {
if (fragment.searchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
fragment.searchAsyncTask.cancel(true);
}
fm.beginTransaction().remove(fragment).commit();
}
addSearchFragment(fm, new SearchWorkerFragment(), fpath, query, ma.getMainFragmentViewModel().getOpenMode(), mainActivity.isRootExplorer(), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX, false), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX_MATCHES, false));
}
Aggregations