當前位置: 首頁>>代碼示例>>Java>>正文


Java LoaderManager.destroyLoader方法代碼示例

本文整理匯總了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);
}
 
開發者ID:universum-studios,項目名稱:android_fragments,代碼行數:19,代碼來源:BaseFragmentTest.java

示例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();
    }
}
 
開發者ID:mr-kojo,項目名稱:Veggietizer,代碼行數:39,代碼來源:HistoryActivity.java

示例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);
}
 
開發者ID:universum-studios,項目名稱:android_fragments,代碼行數:16,代碼來源:BaseFragmentTest.java

示例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);
}
 
開發者ID:universum-studios,項目名稱:android_fragments,代碼行數:16,代碼來源:BaseFragmentTest.java

示例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);
}
 
開發者ID:universum-studios,項目名稱:android_fragments,代碼行數:16,代碼來源:BaseFragmentTest.java

示例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);
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:7,代碼來源:ChangedContacts.java

示例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);
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:7,代碼來源:ChangedContacts.java


注:本文中的android.app.LoaderManager.destroyLoader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。