本文整理汇总了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());
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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());
}
示例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;
}
}
示例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);
}
示例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");
}
}
}
}
示例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
);
}
示例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);
}
}
示例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;
}
示例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();
}
示例14: getLoaderCallbacks
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
protected LoaderManager.LoaderCallbacks<List<Song>> getLoaderCallbacks() {
return mLoaderCallbacks;
}
示例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);
}