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


Java LoaderManager.initLoader方法代碼示例

本文整理匯總了Java中android.app.LoaderManager.initLoader方法的典型用法代碼示例。如果您正苦於以下問題:Java LoaderManager.initLoader方法的具體用法?Java LoaderManager.initLoader怎麽用?Java LoaderManager.initLoader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.LoaderManager的用法示例。


在下文中一共展示了LoaderManager.initLoader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    String themes = sharedPrefs.getString(
            getString(R.string.settings_themes_key),
            getString(R.string.settings_themes_default));
    switch (themes) {
        case "dark":
            setTheme(R.style.AppTheme);
            break;
        case "light":
            setTheme(R.style.AppTheme_Light);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    LoaderManager loaderManager = getLoaderManager();
    loaderManager.initLoader(0, null, this);
    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

}
 
開發者ID:rahul051296,項目名稱:quake-alert-android-app,代碼行數:22,代碼來源:MapsActivity.java

示例2: onActivityCreated

import android.app.LoaderManager; //導入方法依賴的package包/類
@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;
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:22,代碼來源:MessageListFragment.java

示例3: onActivityCreated

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mLoaderIdlingResource =
            new LoaderIdlingResource(getClass().getName() + "/" + getId(), getLoaderManager());

    // Load data queries if any.
    if (mInitialQueriesToLoad != null && mInitialQueriesToLoad.length > 0) {
        LoaderManager manager = getLoaderManager();
        for (int i = 0; i < mInitialQueriesToLoad.length; i++) {
            manager.initLoader(mInitialQueriesToLoad[i].getId(), null, this);
        }
    } else {
        // No data query to load, update the view.
        mUpdatableView.displayData(mModel, null);
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:19,代碼來源:PresenterFragmentImpl.java

示例4: 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

示例5: onActivityCreated

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mMessageHelper = MessageHelper.getInstance(getActivity());

    initializeMessageList();

    // This needs to be done before initializing the cursor loader below
    initializeSortSettings();

    mLoaderJustInitialized = true;
    LoaderManager loaderManager = getLoaderManager();
    int len = mAccountUuids.length;
    mCursors = new Cursor[len];
    mCursorValid = new boolean[len];
    for (int i = 0; i < len; i++) {
        loaderManager.initLoader(i, null, this);
        mCursorValid[i] = false;
    }
}
 
開發者ID:scoute-dich,項目名稱:K9-MailClient,代碼行數:22,代碼來源:MessageListFragment.java

示例6: onCreate

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mAdapter = new SimpleCursorAdapter(getActivity(),
            R.layout.structureslist_item, null,
            new String[]{StructuresValues.Structures.NAME, StructuresValues.Structures.AWAY},
            new int[]{R.id.structure_name, R.id.structure_away}, 0);

    setListAdapter(mAdapter);

    LoaderManager.LoaderCallbacks<Cursor> mCallbacks = this;

    LoaderManager lm = getLoaderManager();
    lm.initLoader(LOADER_ID, null, mCallbacks);
}
 
開發者ID:rmceoin,項目名稱:cominghome,代碼行數:17,代碼來源:StructuresListFragment.java

示例7: onCreate

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mAdapter = new SimpleCursorAdapter(getActivity(),
            R.layout.historylist_item, null,
            new String[]{HistoryValues.History.ENTRY, HistoryValues.History.CREATED_DATE_STR},
            new int[]{R.id.history_entry, R.id.history_date}, 0);

    setListAdapter(mAdapter);

    LoaderManager.LoaderCallbacks<Cursor> mCallbacks = this;

    LoaderManager lm = getLoaderManager();
    lm.initLoader(LOADER_ID, null, mCallbacks);
}
 
開發者ID:rmceoin,項目名稱:cominghome,代碼行數:17,代碼來源:HistoryListFragment.java

示例8: onCreate

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mAdapter = new SimpleCursorAdapter(getActivity(),
                                       android.R.layout.simple_list_item_1,
                                       null,
                                       new String[] { Direction.FIELD_TITLE },
                                       new int[] { android.R.id.text1 },
                                       0);
    setListAdapter(mAdapter);

    Bundle bundle = getArguments();
    LoaderManager loaderManager = getLoaderManager();
    if (bundle != null && loaderManager != null) {
        mRouteTag = bundle.getString(SelectRouteFragment.ROUTE_TAG);
        loaderManager.initLoader(0, null, this);
    }
}
 
開發者ID:elliottsj,項目名稱:ftw-android,代碼行數:20,代碼來源:AddStopActivity.java

示例9: onCreate

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_earthquake);
    init();

    //TODO: verify if there's internet connection

        if(thereIsInternet()){
            progressBar.setVisibility(View.VISIBLE);
        }
        else if(!(thereIsInternet())){
            progressBar.setVisibility(View.GONE);
            noInternetConection.setText("There is no internet connection");
        }
    // Find a reference to the {@link ListView} in the layout
    LoaderManager loaderManager = getLoaderManager();
    loaderManager.initLoader(EARTHQUAKE_LOADER, null, this);

    //TODO: set up the correct url
    earthquakeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Earthquake earthquake = earthquakeAdapterm.getItem(i);
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(earthquake.getUrl()));
            startActivity(intent);
        }
    });
}
 
開發者ID:Legendarywicho,項目名稱:Earthquake-App,代碼行數:31,代碼來源:EarthquakeActivity.java

示例10: 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

示例11: start

import android.app.LoaderManager; //導入方法依賴的package包/類
/**
 *	Start the asynchronous request
 *	Result will be received through the given listener
 */
@Override
public void start(LoaderManager loaderManager, Listener listener) {
	if(DBG) Log.d(TAG, "start");
	super.start(loaderManager, listener);

	loaderManager.initLoader( getLoaderManagerId(), null, this);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:12,代碼來源:SingleCursorCoverProvider.java

示例12: init

import android.app.LoaderManager; //導入方法依賴的package包/類
public void init(@NonNull Observer<T> observer) {
    final LoaderManager lm = mLmRef.get();
    if (lm != null) {
        synchronized (LoaderManager.class) {
            lm.initLoader(mLoaderId, Bundle.EMPTY, new RxLcImpl<>(mContext, mObservable, observer));
        }
    }
}
 
開發者ID:ArturVasilov,項目名稱:AndroidArchitecture,代碼行數:9,代碼來源:RxLoader.java

示例13: onCreate

import android.app.LoaderManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String[] from = {CustomQuoteContract.Quotes.TEXT, CustomQuoteContract.Quotes.SOURCE};
    int[] to = {R.id.listitem_custom_quote_text, R.id.listitem_custom_quote_source};
    mAdapter = new SimpleCursorAdapter(this, R.layout.listitem_custom_quote, null, from, to, 0);
    setListAdapter(mAdapter);

    LoaderManager loaderManager = getLoaderManager();
    loaderManager.initLoader(0, null, this);

    ListView listView = getListView();
    registerForContextMenu(listView);
}
 
開發者ID:apsun,項目名稱:QuoteLock,代碼行數:16,代碼來源:CustomQuoteConfigActivity.java

示例14: updateEarthquakeData

import android.app.LoaderManager; //導入方法依賴的package包/類
private void updateEarthquakeData() {
    ConnectivityManager manager =
            (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);

    if (QueryUtils.getParamMap() == null) {
        displayError(getString(R.string.error_no_params));
    } else if (url == null) {
        displayError(getString(R.string.error_bad_url));
    } else if (!manager.getActiveNetworkInfo().isConnected()) {
        displayError(getString(R.string.error_no_connection));
    } else {
        LoaderManager loaderManager = getLoaderManager();
        loaderManager.initLoader(NEWS_LOADER_ID, null, this);
    }
}
 
開發者ID:JeremySilverTongue,項目名稱:UdacityAndroidBasicsNanodegree,代碼行數:16,代碼來源:NewsActivity.java

示例15: testDestroyLoader

import android.app.LoaderManager; //導入方法依賴的package包/類
@Test
public void testDestroyLoader() {
	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);
	when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null));
	loaderManager.initLoader(1, null, mockLoaderCallbacks);
	fragment.destroyLoader(1);
	assertThat(loaderManager.getLoader(1), is(nullValue()));
}
 
開發者ID:universum-studios,項目名稱:android_fragments,代碼行數:15,代碼來源:BaseFragmentTest.java


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