Search in sources :

Example 1 with SearchWorkerFragment

use of com.amaze.filemanager.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)
        return;
    final MainFragment ma = (MainFragment) tabFragment.getCurrentTabFragment();
    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;
    mainActivity.mainFragment = (MainFragment) mainActivity.getTabFragment().getCurrentTabFragment();
    FragmentManager fm = mainActivity.getSupportFragmentManager();
    SearchWorkerFragment fragment = (SearchWorkerFragment) fm.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);
    if (fragment != null) {
        if (fragment.mSearchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
            fragment.mSearchAsyncTask.cancel(true);
        }
        fm.beginTransaction().remove(fragment).commit();
    }
    addSearchFragment(fm, new SearchWorkerFragment(), fpath, query, ma.openMode, mainActivity.isRootExplorer(), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX, false), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX_MATCHES, false));
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MainFragment(com.amaze.filemanager.fragments.MainFragment) TabFragment(com.amaze.filemanager.fragments.TabFragment) SearchWorkerFragment(com.amaze.filemanager.fragments.SearchWorkerFragment)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)1 MainFragment (com.amaze.filemanager.fragments.MainFragment)1 SearchWorkerFragment (com.amaze.filemanager.fragments.SearchWorkerFragment)1 TabFragment (com.amaze.filemanager.fragments.TabFragment)1