本文整理汇总了Java中android.app.LoaderManager.destroyLoader方法的典型用法代码示例。如果您正苦于以下问题:Java LoaderManager.destroyLoader方法的具体用法?Java LoaderManager.destroyLoader怎么用?Java LoaderManager.destroyLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.LoaderManager
的用法示例。
在下文中一共展示了LoaderManager.destroyLoader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStartLoaderThatIsAlreadyInitialized
import android.app.LoaderManager; //导入方法依赖的package包/类
@Test
public void testStartLoaderThatIsAlreadyInitialized() {
final Activity activity = Robolectric.buildActivity(TestActivity.class).create().start().resume().get();
final FragmentManager fragmentManager = activity.getFragmentManager();
final BaseFragment fragment = new TestFragment();
fragmentManager.beginTransaction().add(fragment, null).commit();
fragmentManager.executePendingTransactions();
final LoaderManager loaderManager = fragment.getLoaderManager();
final LoaderManager.LoaderCallbacks mockLoaderCallbacks = mock(LoaderManager.LoaderCallbacks.class);
final Loader firstLoader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null);
final Loader secondLoader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null);
when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(firstLoader);
loaderManager.initLoader(1, null, mockLoaderCallbacks);
when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(secondLoader);
assertThat(fragment.startLoader(1, null, mockLoaderCallbacks), is(secondLoader));
assertThat(loaderManager.getLoader(1), is(secondLoader));
loaderManager.destroyLoader(1);
}
示例2: onPostExecute
import android.app.LoaderManager; //导入方法依赖的package包/类
/**
* Updates the View after the deletion.
* That is, re-enables the menu item that triggered this task, shows a {@link Toast} and refreshes the
* action bar as well as the list itself.
*/
@Override
protected void onPostExecute(Void unused) {
super.onPostExecute(unused);
String toastText = entriesToDelete + " "
+ getResources().getQuantityString(R.plurals.entry, entriesToDelete) + " "
+ getResources().getString(R.string.toast_delete_success);
Toast toast = Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_SHORT);
//Check achievements for relocked achievements after deletion
AchievementSet.getInstance(getApplicationContext()).checkAchievements();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
/*
* For some reason, at older Android versions, ListView#getCheckedItemCount()
* sums up previous selections even if those
* have already been deleted - even though calling listView.clearChoices() after deleting.
*
* The only way to clear all selections seems to restart the activity...
*/
startActivity(getIntent());
toast.show();
} else {
isEntryChecked = false;
LoaderManager loaderManager = getLoaderManager();
loaderManager.destroyLoader(HISTORY_LOADER);
loaderManager.initLoader(HISTORY_LOADER, null, loaderCallbacks); // Reloads the list.
toast.show();
toDisable.setEnabled(true);
invalidateOptionsMenu();
adapter.notifyDataSetChanged();
}
}
示例3: testStartLoader
import android.app.LoaderManager; //导入方法依赖的package包/类
@Test
public void testStartLoader() {
final Activity activity = Robolectric.buildActivity(TestActivity.class).create().start().resume().get();
final FragmentManager fragmentManager = activity.getFragmentManager();
final BaseFragment fragment = new TestFragment();
fragmentManager.beginTransaction().add(fragment, null).commit();
fragmentManager.executePendingTransactions();
final LoaderManager loaderManager = fragment.getLoaderManager();
final LoaderManager.LoaderCallbacks mockLoaderCallbacks = mock(LoaderManager.LoaderCallbacks.class);
final Loader<Cursor> loader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null);
when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(loader);
assertThat(fragment.startLoader(1, null, mockLoaderCallbacks), Is.<Loader>is(loader));
assertThat(loaderManager.getLoader(1), is(not(nullValue())));
loaderManager.destroyLoader(1);
}
示例4: testInitLoader
import android.app.LoaderManager; //导入方法依赖的package包/类
@Test
public void testInitLoader() {
final Activity activity = Robolectric.buildActivity(TestActivity.class).create().start().resume().get();
final FragmentManager fragmentManager = activity.getFragmentManager();
final BaseFragment fragment = new TestFragment();
fragmentManager.beginTransaction().add(fragment, null).commit();
fragmentManager.executePendingTransactions();
final LoaderManager loaderManager = fragment.getLoaderManager();
final LoaderManager.LoaderCallbacks mockLoaderCallbacks = mock(LoaderManager.LoaderCallbacks.class);
final Loader loader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null);
when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(loader);
assertThat(fragment.initLoader(1, null, mockLoaderCallbacks), is(loader));
assertThat(loaderManager.getLoader(1), is(loader));
loaderManager.destroyLoader(1);
}
示例5: testRestartLoader
import android.app.LoaderManager; //导入方法依赖的package包/类
@Test
public void testRestartLoader() {
final Activity activity = Robolectric.buildActivity(TestActivity.class).create().start().resume().get();
final FragmentManager fragmentManager = activity.getFragmentManager();
final BaseFragment fragment = new TestFragment();
fragmentManager.beginTransaction().add(fragment, null).commit();
fragmentManager.executePendingTransactions();
final LoaderManager loaderManager = fragment.getLoaderManager();
final LoaderManager.LoaderCallbacks mockLoaderCallbacks = mock(LoaderManager.LoaderCallbacks.class);
final Loader loader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null);
when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(loader);
assertThat(fragment.restartLoader(1, null, mockLoaderCallbacks), is(loader));
assertThat(loaderManager.getLoader(1), is(loader));
loaderManager.destroyLoader(1);
}
示例6: changeClick
import android.app.LoaderManager; //导入方法依赖的package包/类
private void changeClick() {
mChangeAdapter.swapCursor(null);
LoaderManager manager = getLoaderManager();
manager.destroyLoader(ID_DELETE_LOADER);
manager.restartLoader(ID_CHANGE_LOADER, null, this);
}
示例7: deleteClick
import android.app.LoaderManager; //导入方法依赖的package包/类
private void deleteClick() {
mChangeAdapter.swapCursor(null);
LoaderManager manager = getLoaderManager();
manager.destroyLoader(ID_CHANGE_LOADER);
manager.restartLoader(ID_DELETE_LOADER, null, this);
}