当前位置: 首页>>代码示例>>Java>>正文


Java LoaderManager.LoaderCallbacks方法代码示例

本文整理汇总了Java中android.support.v4.app.LoaderManager.LoaderCallbacks方法的典型用法代码示例。如果您正苦于以下问题:Java LoaderManager.LoaderCallbacks方法的具体用法?Java LoaderManager.LoaderCallbacks怎么用?Java LoaderManager.LoaderCallbacks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.LoaderManager的用法示例。


在下文中一共展示了LoaderManager.LoaderCallbacks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test09TestLoadResetCallback

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Test
@UiThreadTest
public void test09TestLoadResetCallback() throws Exception {

    CursorLoader loader = BasicCRUDLoader.newInstance(context, mockLoaderManager)
            .forUri(testUri)
            .callback(mockBasicCRUDLoaderCallback)
            .loaderId(LOADER_ID)
            .initLoader();

    // Ensure the callback has not yet been called
    assertFalse(mockBasicCRUDLoaderCallback.isCalled());

    @SuppressWarnings("unchecked")
    LoaderManager.LoaderCallbacks<Cursor> callbacks = (LoaderManager.LoaderCallbacks<Cursor>) mockLoaderManager.getLoaderCallbacks();
    assertNotNull(callbacks);

    // Simulate a loader reset. The loader id should be set and cursor is null
    callbacks.onLoaderReset(loader);

    assertTrue(mockBasicCRUDLoaderCallback.isCalled());
    assertEquals(LOADER_ID, mockBasicCRUDLoaderCallback.getLoaderId());
    assertNull(mockBasicCRUDLoaderCallback.getCursor());
}
 
开发者ID:joerogers,项目名称:CrudContent,代码行数:25,代码来源:BasicCRUDLoaderTest.java

示例2: onClick

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
	switch (v.getId()) {
	case R.id.buttonAuth:
		mTwitter = new TwitterFactory().getInstance();
		mTwitter.setOAuthConsumer(getString(R.string.twitter_consumer_key),
				getString(R.string.twitter_consumer_key_secret));
		mTwitter.setOAuthAccessToken(null);
		LoaderManager.LoaderCallbacks<RequestToken> requestTokenCallbacks = new TwitterOAuthRequestTokenCallbacks(
				this, mTwitter);
		getSupportLoaderManager()
				.initLoader(0, null, requestTokenCallbacks);
		break;
	case R.id.buttonSendPin:
		EditText editTextPin = (EditText) findViewById(R.id.editTextPin);
		if (editTextPin.getText().length() > 0 && mTwitter != null) {
			LoaderManager.LoaderCallbacks<AccessToken> accessTokenCallbacks = new TwitterOAuthAccessTokenCallbacks(
					this, mTwitter, editTextPin.getText().toString());
			getSupportLoaderManager().initLoader(1, null,
					accessTokenCallbacks);
		}
		break;
	default:
		break;
	}
}
 
开发者ID:rsato,项目名称:android-sample-twitter4j-auth,代码行数:27,代码来源:MainActivity.java

示例3: onCreate

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_asset_class_list);

    mAdapter = new AssetClassListAdapter(null);
    initRecyclerView(mAdapter);

    LoaderManager.LoaderCallbacks<Cursor> loaderCallbacks = initLoaderCallbacks();

    // get target asset class id, to exclude from the offered list
    Bundle loaderArgs = null;
    Intent intent = getIntent();
    if (intent != null) {
        loaderArgs = new Bundle();
        int assetClassId = intent.getIntExtra(EXTRA_ASSET_CLASS_ID, Constants.NOT_SET);
        loaderArgs.putInt(EXTRA_ASSET_CLASS_ID, assetClassId);
    }
    // start loader
    Loader loader = getSupportLoaderManager().initLoader(LOADER_ASSET_CLASSES, loaderArgs, loaderCallbacks);
}
 
开发者ID:moneymanagerex,项目名称:android-money-manager-ex,代码行数:22,代码来源:AssetClassListActivity.java

示例4: onOptionsItemSelected

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.delete) {
        final AlertDialog dialog = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.dialog_delete_title)
                .setMessage(R.string.dialog_delete_msg)
                .setPositiveButton(R.string.dialog_yes, null)
                .setNegativeButton(R.string.dialog_no, null)
                .create();
        dialog.show();

        final LoaderManager.LoaderCallbacks loaderCallbacks = this;

        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                Uri uri = MotorContract.Waypoints.buildWaypointUri();
                getActivity().getContentResolver().delete(uri, null, null);
                getActivity().sendBroadcast(new Intent(CollectionWidgetProvider.ACTION_UPDATE));
                directionCollectionAdapter.swapCursor(null);
            }
        });
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:opticod,项目名称:Moto-Navigator,代码行数:30,代码来源:DriveCollectionFragment.java

示例5: loadWeather

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void loadWeather(boolean restart) {
    mWeatherLayout.setVisibility(View.INVISIBLE);
    mErrorLayout.setVisibility(View.GONE);
    mLoadingView.showLoadingIndicator();
    LoaderManager.LoaderCallbacks<City> callbacks = new WeatherCallbacks();
    if (restart) {
        getSupportLoaderManager().restartLoader(R.id.weather_loader_id, Bundle.EMPTY, callbacks);
    } else {
        getSupportLoaderManager().initLoader(R.id.weather_loader_id, Bundle.EMPTY, callbacks);
    }
}
 
开发者ID:ArturVasilov,项目名称:AndroidSchool,代码行数:12,代码来源:WeatherActivity.java

示例6: test08TestLoadFinishedCallback

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Test
@UiThreadTest
public void test08TestLoadFinishedCallback() throws Exception {

    CursorLoader loader = BasicCRUDLoader.newInstance(context, mockLoaderManager)
            .forUri(testUri)
            .callback(mockBasicCRUDLoaderCallback)
            .loaderId(LOADER_ID)
            .initLoader();

    // Ensure the callback has not yet been called
    assertFalse(mockBasicCRUDLoaderCallback.isCalled());

    @SuppressWarnings("unchecked")
    LoaderManager.LoaderCallbacks<Cursor> callbacks = (LoaderManager.LoaderCallbacks<Cursor>) mockLoaderManager.getLoaderCallbacks();
    assertNotNull(callbacks);

    MatrixCursor cursor = new MatrixCursor(new String[]{"Column1"});

    // Simulate a loader call. Loader id should be set and the cursor should be the same
    // cursor that was just built.
    callbacks.onLoadFinished(loader, cursor);

    assertTrue(mockBasicCRUDLoaderCallback.isCalled());
    assertEquals(LOADER_ID, mockBasicCRUDLoaderCallback.getLoaderId());
    assertEquals(cursor, mockBasicCRUDLoaderCallback.getCursor());
}
 
开发者ID:joerogers,项目名称:CrudContent,代码行数:28,代码来源:BasicCRUDLoaderTest.java

示例7: onClick

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
	switch (v.getId()) {
	case R.id.buttonAuth:
		mTwitter = new TwitterFactory().getInstance();
		mTwitter.setOAuthConsumer(getString(R.string.twitter_consumer_key),
				getString(R.string.twitter_consumer_key_secret));
		mTwitter.setOAuthAccessToken(null);
		LoaderManager.LoaderCallbacks<RequestToken> requestTokenCallbacks = new TwitterOAuthRequestTokenCallbacks(
				this, mTwitter);
		getSupportLoaderManager()
				.initLoader(0, null, requestTokenCallbacks);
		break;

	case R.id.buttonSendPin:
		EditText editTextPin = (EditText) findViewById(R.id.editTextPin);
		if (editTextPin.getText().length() > 0 && mTwitter != null) {
			LoaderManager.LoaderCallbacks<AccessToken> accessTokenCallbacks = new TwitterOAuthAccessTokenCallbacks(
					this, mTwitter, editTextPin.getText().toString());
			getSupportLoaderManager().initLoader(1, null,
					accessTokenCallbacks);
		}
		break;

	case R.id.buttonTimeLine:
		Intent intent=new Intent();
        intent.setClassName(this,"twitter.sample.cliant.TweetTimeline");
        startActivity(intent);
        break;

	default:
		break;
	}
}
 
开发者ID:engawa,项目名称:android-twittersample,代码行数:35,代码来源:MainActivity.java

示例8: onLoaderReset

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onLoaderReset(Loader<Cursor> loader) {
    LoaderManager.LoaderCallbacks<Cursor> parent = getSearchResultFragmentLoaderCallbacks();
    if (parent != null) parent.onLoaderReset(loader);

    //((CursorAdapter) getListAdapter()).swapCursor(null);
    ((CursorAdapter) getListAdapter()).changeCursor(null);
}
 
开发者ID:moneymanagerex,项目名称:android-money-manager-ex,代码行数:9,代码来源:AllDataListFragment.java

示例9: onLoadFinished

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        LoaderManager.LoaderCallbacks<Cursor> parent = getSearchResultFragmentLoaderCallbacks();
        if (parent != null) parent.onLoadFinished(loader, data);

        switch (loader.getId()) {
            case ID_LOADER_ALL_DATA_DETAIL:
                // Transactions list loaded.
                AllDataAdapter adapter = (AllDataAdapter) getListAdapter();
//                adapter.swapCursor(data);
                adapter.changeCursor(data);
                if (isResumed()) {
                    setListShown(true);
                    if (data != null && data.getCount() <= 0 && getFloatingActionButton() != null)
                        getFloatingActionButton().show(true);
                } else {
                    setListShownNoAnimation(true);
                }

                // reset the transaction groups (account name collection)
                adapter.resetAccountHeaderIndexes();

                // Show totals
                if (this.mShowFooter) {
                    try {
                        this.updateFooter(data);
                    } catch (Exception e) {
                        Timber.e(e, "displaying footer");
                    }
                }
        }
    }
 
开发者ID:moneymanagerex,项目名称:android-money-manager-ex,代码行数:33,代码来源:AllDataListFragment.java

示例10: LoaderManagerCreator

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
/**
 * Init Loader Manager for fragment
 * @param fragment fragment
 * @param callbacks callbacks
 * @param args arguments for loader construction
 * @param <T>
 */
public <T> LoaderManagerCreator(Fragment fragment, LoaderManager.LoaderCallbacks<T> callbacks, Bundle args) {
    this(
            fragment.getActivity().getApplicationContext(),
            fragment.getLoaderManager(),
            (int) HashUtil.longHash(((Object) fragment).getClass(), fragment.getArguments(), callbacks),
            callbacks,
            args
    );
}
 
开发者ID:blandware,项目名称:android-atleap,代码行数:17,代码来源:LoaderManagerCreator.java

示例11: restartLoader

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public static void restartLoader(Fragment fragment, int loaderId, Bundle args, LoaderManager.LoaderCallbacks<?> loaderCallbacks) {
	try {
		if (fragment == null) {
			return;
		}
		if (fragment.getActivity() == null) {
			return;
		}
		restartLoader(fragment.getLoaderManager(), loaderId, args, loaderCallbacks);
	} catch (Exception e) {
		MTLog.w(TAG, e, "Error while restarting loader ID '%s' for '%s'", loaderId, loaderCallbacks);
	}
}
 
开发者ID:mtransitapps,项目名称:mtransit-for-android,代码行数:14,代码来源:LoaderUtils.java

示例12: restartLoader

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
/** Restarts the FetchJsonTaskLoader if the URL being fetched has changed. */
private static <T> FetchJsonTaskLoader<T> restartLoader(LoaderManager loaderMgr, int id,
        FetchJsonTaskLoader<T> loader, LoaderManager.LoaderCallbacks<T> callbacks, String url) {
    FetchJsonTaskLoader<T> result = loader;
    Bundle bundle = new Bundle();
    bundle.putString("url", url);

    if (!TextUtils.equals(url, loader.getUrl())) {
        result = (FetchJsonTaskLoader<T>) loaderMgr.restartLoader(id, bundle, callbacks);
    }

    return result;
}
 
开发者ID:vicfryzel,项目名称:gplus-photohunt-client-android,代码行数:14,代码来源:ThemeViewActivity.java

示例13: TodayTasksCursorAdapter

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public TodayTasksCursorAdapter(Context context, LoaderManager.LoaderCallbacks mLoaderCallbacks) {
    this.mLoaderCallbacks = mLoaderCallbacks;
    this.mContext = context;
    mDataSetObserver = new NotifyingDataSetObserver();
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:6,代码来源:TodayTasksCursorAdapter.java

示例14: getLoaderCallbacks

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
protected LoaderManager.LoaderCallbacks<List<Song>> getLoaderCallbacks() {
    return mLoaderCallbacks;
}
 
开发者ID:andryr,项目名称:Harmony-Music-Player,代码行数:5,代码来源:GenreFragment.java

示例15: init

import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public static void init(@NonNull LoaderManager supportLoaderManager, @NonNull LoaderManager.LoaderCallbacks<List<Post>> callback) {
    supportLoaderManager.initLoader(POST_LOADER_ID, null, callback);
}
 
开发者ID:droidpl,项目名称:offline-architecture,代码行数:4,代码来源:PostLoader.java


注:本文中的android.support.v4.app.LoaderManager.LoaderCallbacks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。