use of com.amaze.filemanager.ui.fragments.SearchWorkerFragment 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