当前位置: 首页>>代码示例>>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;未经允许,请勿转载。