Search in sources :

Example 21 with LoaderManager

use of android.app.LoaderManager in project platform_packages_apps_Settings by BlissRoms.

the class SearchFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    long startTime = System.currentTimeMillis();
    setHasOptionsMenu(true);
    final LoaderManager loaderManager = getLoaderManager();
    mSearchAdapter = new SearchResultsAdapter(this, mSearchFeatureProvider);
    mSavedQueryController = new SavedQueryController(getContext(), loaderManager, mSearchAdapter);
    mSearchFeatureProvider.initFeedbackButton();
    if (savedInstanceState != null) {
        mQuery = savedInstanceState.getString(STATE_QUERY);
        mNeverEnteredQuery = savedInstanceState.getBoolean(STATE_NEVER_ENTERED_QUERY);
        mResultClickCount = savedInstanceState.getInt(STATE_RESULT_CLICK_COUNT);
        mShowingSavedQuery = savedInstanceState.getBoolean(STATE_SHOWING_SAVED_QUERY);
    } else {
        mShowingSavedQuery = true;
    }
    final Activity activity = getActivity();
    // Run the Index update only if we have some space
    if (!Utils.isLowStorage(activity)) {
        mSearchFeatureProvider.updateIndexAsync(activity, this);
    } else {
        Log.w(TAG, "Cannot update the Indexer as we are running low on storage space!");
    }
    if (SettingsSearchIndexablesProvider.DEBUG) {
        Log.d(TAG, "onCreate spent " + (System.currentTimeMillis() - startTime) + " ms");
    }
}
Also used : LoaderManager(android.app.LoaderManager) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity)

Example 22 with LoaderManager

use of android.app.LoaderManager in project platform_packages_apps_Settings by BlissRoms.

the class SearchFragment method onQueryTextChange.

@Override
public boolean onQueryTextChange(String query) {
    if (TextUtils.equals(query, mQuery)) {
        return true;
    }
    final boolean isEmptyQuery = TextUtils.isEmpty(query);
    // Hide no-results-view when the new query is not a super-string of the previous
    if (mQuery != null && mNoResultsView.getVisibility() == View.VISIBLE && query.length() < mQuery.length()) {
        mNoResultsView.setVisibility(View.GONE);
    }
    mResultClickCount = 0;
    mNeverEnteredQuery = false;
    mQuery = query;
    // If indexing is not finished, register the query text, but don't search.
    if (!mSearchFeatureProvider.isIndexingComplete(getActivity())) {
        return true;
    }
    if (isEmptyQuery) {
        final LoaderManager loaderManager = getLoaderManager();
        loaderManager.destroyLoader(SearchLoaderId.DATABASE);
        loaderManager.destroyLoader(SearchLoaderId.INSTALLED_APPS);
        loaderManager.destroyLoader(SearchLoaderId.ACCESSIBILITY_SERVICES);
        loaderManager.destroyLoader(SearchLoaderId.INPUT_DEVICES);
        mShowingSavedQuery = true;
        mSavedQueryController.loadSavedQueries();
        mSearchFeatureProvider.hideFeedbackButton();
    } else {
        mSearchAdapter.initializeSearch(mQuery);
        restartLoaders();
    }
    return true;
}
Also used : LoaderManager(android.app.LoaderManager)

Example 23 with LoaderManager

use of android.app.LoaderManager in project k-9 by k9mail.

the class MessageListFragment method restartLoader.

private void restartLoader() {
    if (cursorValid == null) {
        return;
    }
    // Refresh the message list
    LoaderManager loaderManager = getLoaderManager();
    for (int i = 0; i < accountUuids.length; i++) {
        loaderManager.restartLoader(i, null, this);
        cursorValid[i] = false;
    }
}
Also used : LoaderManager(android.app.LoaderManager)

Example 24 with LoaderManager

use of android.app.LoaderManager in project k-9 by k9mail.

the class MessageListFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    messageHelper = MessageHelper.getInstance(getActivity());
    initializeMessageList();
    // This needs to be done before initializing the cursor loader below
    initializeSortSettings();
    loaderJustInitialized = true;
    LoaderManager loaderManager = getLoaderManager();
    int len = accountUuids.length;
    cursors = new Cursor[len];
    cursorValid = new boolean[len];
    for (int i = 0; i < len; i++) {
        loaderManager.initLoader(i, null, this);
        cursorValid[i] = false;
    }
}
Also used : LoaderManager(android.app.LoaderManager)

Example 25 with LoaderManager

use of android.app.LoaderManager in project k-9 by k9mail.

the class MessageListFragment method reSort.

private void reSort() {
    int toastString = sortType.getToast(sortAscending);
    Toast toast = Toast.makeText(getActivity(), toastString, Toast.LENGTH_SHORT);
    toast.show();
    LoaderManager loaderManager = getLoaderManager();
    for (int i = 0, len = accountUuids.length; i < len; i++) {
        loaderManager.restartLoader(i, null, this);
    }
}
Also used : LoaderManager(android.app.LoaderManager) Toast(android.widget.Toast)

Aggregations

LoaderManager (android.app.LoaderManager)42 Activity (android.app.Activity)6 SettingsActivity (com.android.settings.SettingsActivity)6 AppItem (com.android.settingslib.AppItem)6 Test (org.junit.Test)6 Bundle (android.os.Bundle)2 Context (android.content.Context)1 CursorLoader (android.content.CursorLoader)1 Loader (android.content.Loader)1 Cursor (android.database.Cursor)1 Toast (android.widget.Toast)1 AlbumFolder (com.codez.collar.bean.AlbumFolder)1 Account (com.fsck.k9.Account)1 ReplyToParser (com.fsck.k9.helper.ReplyToParser)1 ComposePgpInlineDecider (com.fsck.k9.message.ComposePgpInlineDecider)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1