本文整理汇总了Java中android.app.LoaderManager.getLoader方法的典型用法代码示例。如果您正苦于以下问题:Java LoaderManager.getLoader方法的具体用法?Java LoaderManager.getLoader怎么用?Java LoaderManager.getLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.LoaderManager
的用法示例。
在下文中一共展示了LoaderManager.getLoader方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChange
import android.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onChange(boolean selfChange) {
if (!isAdded()) {
return;
}
//clear map reload all data
clearMap();
setupMap(false);
// reload data from loaders
LoaderManager lm = getActivity().getLoaderManager();
Loader<Cursor> loader =
lm.getLoader(TOKEN_LOADER_MARKERS);
if (loader != null) {
loader.forceLoad();
}
loader = lm.getLoader(TOKEN_LOADER_TILES);
if (loader != null) {
loader.forceLoad();
}
}
示例2: onChange
import android.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onChange(boolean selfChange) {
if (!isAdded()) {
return;
}
//clear map reload all data
clearMap();
setupMap(false);
// reload data from loaders
LoaderManager lm = getActivity().getLoaderManager();
mMarkersLoaded = false;
mOverlaysLoaded = false;
Loader<Cursor> loader =
lm.getLoader(MarkerQuery._TOKEN);
if (loader != null) {
loader.forceLoad();
}
loader = lm.getLoader(OverlayQuery._TOKEN);
if (loader != null) {
loader.forceLoad();
}
}
示例3: onChange
import android.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onChange(boolean selfChange) {
if (!isAdded()) {
return;
}
//Reload data
LoaderManager lm = getLoaderManager();
Loader<Cursor> loader = lm.getLoader(0);
if (loader != null) {
loader.forceLoad();
}
}
示例4: onStart
import android.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
db = StaticDataStore.getInstance(getActivity());
Logging.Log(LOG_TAG,"Setting prefs.");
numResultsPref = Integer.valueOf(db.getPref("numResults"));
sortPref = db.getPref("sortOrder");
if(this.getArguments().containsKey("Artist")){
String artist = this.getArguments().getString("Artist");
if(artist!=null){
this.browseArtist(artist);
this.getArguments().remove("Artist");
}
}
// Must call in order to get callback to onOptionsItemSelected()
setHasOptionsMenu(true);
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
getActivity().getActionBar().setTitle("Search");
LoaderManager lm = this.getLoaderManager();
if(lm.getLoader(0)!=null){
// The second argument is the query for a new loader, but here we are trying to
// reconnect to an already existing loader, and "If a loader already exists
// (a new one does not need to be created), this parameter will be ignored and
// the last arguments continue to be used.If a loader already exists (a new one
// does not need to be created), this parameter will be ignored and the last arguments
// continue to be used.
// http://developer.android.com/reference/android/app/LoaderManager.html
lm.initLoader(0, null, this);
}
}
示例5: executeSearch
import android.app.LoaderManager; //导入方法依赖的package包/类
private void executeSearch(String query) {
dateChanged = false;
Bundle b = new Bundle();
b.putString("query", query);
LoaderManager lm = this.getLoaderManager();
if(lm.getLoader(0)!=null){
// We already have a loader.
Logging.Log(LOG_TAG, "RESTART.");
lm.restartLoader(0, b, this);
} else{
// We need a new loader.
lm.initLoader(0, b, this);
}
}
示例6: initOrRestartLoader
import android.app.LoaderManager; //导入方法依赖的package包/类
public static void initOrRestartLoader(LoaderManager loaderManager, int id, Bundle bundle, LoaderManager.LoaderCallbacks callbacks) {
Loader loader = loaderManager.getLoader(id);
if (loader == null) {
loaderManager.initLoader(id, bundle, callbacks);
} else {
loaderManager.restartLoader(id, bundle, callbacks);
}
}
示例7: onItemSelected
import android.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mBox = (Integer) parent.getItemAtPosition(position);
// init or restart async word loader
LoaderManager loaderManager = getLoaderManager();
if (loaderManager.getLoader( LOADER_ID) == null) {
loaderManager.initLoader( LOADER_ID, null, this);
} else {
loaderManager.restartLoader(LOADER_ID, null, this);
}
}
示例8: refreshData
import android.app.LoaderManager; //导入方法依赖的package包/类
private void refreshData() {
displaySpinningWheelWhileLoading();
dbAdapter.notifyDataSetChanged();
getListView().invalidateViews();
LoaderManager lm = getLoaderManager();
if (lm.getLoader(LOADER_ID) != null) {
lm.restartLoader(LOADER_ID, null, this);
} else {
lm.initLoader(LOADER_ID, null, this);
}
}
示例9: startLoader
import android.app.LoaderManager; //导入方法依赖的package包/类
/**
* Starts a loader with the specified <var>id</var>. If there was already started loader with the
* same id before, such a loader will be <b>re-started</b>, otherwise new loader will be <b>initialized</b>.
*
* @param id Id of the desired loader to start.
* @param params Params for loader.
* @param callbacks Callbacks for loader.
* @return Initialized or re-started loader instance or {@code null} if the specified <var>callbacks</var>
* do not create loader for the specified <var>id</var>.
* @see #initLoader(int, Bundle, LoaderManager.LoaderCallbacks)
* @see #restartLoader(int, Bundle, LoaderManager.LoaderCallbacks)
* @see #destroyLoader(int)
*/
@Nullable
public <D> Loader<D> startLoader(@IntRange(from = 0) final int id, @Nullable final Bundle params, @NonNull final LoaderManager.LoaderCallbacks<D> callbacks) {
final LoaderManager manager = getLoaderManager();
return manager.getLoader(id) == null ?
initLoader(id, params, callbacks) :
restartLoader(id, params, callbacks);
}