use of android.app.LoaderManager in project android_packages_apps_Settings by crdroidandroid.
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 crdroidandroid.
the class InstalledAppDetails method onResume.
@Override
public void onResume() {
super.onResume();
if (mFinishing) {
return;
}
AppItem app = new AppItem(mAppEntry.info.uid);
app.addUid(mAppEntry.info.uid);
if (mStatsSession != null) {
LoaderManager loaderManager = getLoaderManager();
loaderManager.restartLoader(LOADER_CHART_DATA, ChartDataLoader.buildArgs(getTemplate(getContext()), app), mDataCallbacks);
loaderManager.restartLoader(LOADER_STORAGE, Bundle.EMPTY, this);
}
restartBatteryStatsLoader();
if (mDevelopmentSettingsEnabler.getLastEnabledState()) {
new MemoryUpdater().execute();
}
updateDynamicPrefs();
}
use of android.app.LoaderManager in project android_packages_apps_Settings by SudaMod.
the class SearchFragmentTest method onIndexingFinished_notShowingSavedQuery_initLoaders.
@Test
public void onIndexingFinished_notShowingSavedQuery_initLoaders() {
ActivityController<SearchActivity> activityController = Robolectric.buildActivity(SearchActivity.class);
activityController.setup();
SearchFragment fragment = (SearchFragment) spy(activityController.get().getFragmentManager().findFragmentById(R.id.main_content));
final LoaderManager loaderManager = mock(LoaderManager.class);
when(fragment.getLoaderManager()).thenReturn(loaderManager);
fragment.mShowingSavedQuery = false;
fragment.mQuery = null;
fragment.onIndexingFinished();
verify(loaderManager).initLoader(eq(SearchFragment.SearchLoaderId.DATABASE), eq(null), any(LoaderManager.LoaderCallbacks.class));
verify(loaderManager).initLoader(eq(SearchFragment.SearchLoaderId.INSTALLED_APPS), eq(null), any(LoaderManager.LoaderCallbacks.class));
}
use of android.app.LoaderManager in project android_packages_apps_Settings by SudaMod.
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 android_packages_apps_Settings by SudaMod.
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;
}
Aggregations