use of android.app.LoaderManager in project android_packages_apps_Settings by LineageOS.
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;
}
use of android.app.LoaderManager in project android_packages_apps_Settings by LineageOS.
the class SearchFragment method restartLoaders.
private void restartLoaders() {
mShowingSavedQuery = false;
final LoaderManager loaderManager = getLoaderManager();
mUnfinishedLoadersCount.set(NUM_QUERY_LOADERS);
loaderManager.restartLoader(SearchLoaderId.DATABASE, null, /* args */
this);
loaderManager.restartLoader(SearchLoaderId.INSTALLED_APPS, null, /* args */
this);
loaderManager.restartLoader(SearchLoaderId.ACCESSIBILITY_SERVICES, null, /* args */
this);
loaderManager.restartLoader(SearchLoaderId.INPUT_DEVICES, null, /* args */
this);
}
use of android.app.LoaderManager in project frostwire by frostwire.
the class MyFilesFragment method reloadFiles.
private void reloadFiles(byte fileType) {
try {
if (isAdded()) {
LoaderManager loaderManager = getLoaderManager();
loaderManager.destroyLoader(LOADER_FILES_ID);
Bundle bundle = new Bundle();
bundle.putByte("fileType", fileType);
loaderManager.restartLoader(LOADER_FILES_ID, bundle, this);
}
} catch (Throwable t) {
LOG.error(t.getMessage(), t);
}
}
use of android.app.LoaderManager in project android_packages_apps_Settings by omnirom.
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;
}
use of android.app.LoaderManager in project android_packages_apps_Settings by omnirom.
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");
}
}
Aggregations