android.support.v4.content.Loader.forceLoad()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中android.support.v4.content.Loader.forceLoad()方法的一些代码示例,展示了Loader.forceLoad()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.forceLoad()方法的具体详情如下:
包路径:android.support.v4.content.Loader
类名称:Loader
方法名:forceLoad

Loader.forceLoad介绍

[英]Force an asynchronous load. Unlike #startLoading() this will ignore a previously loaded data set and load a new one. This simply calls through to the implementation's #onForceLoad(). You generally should only call this when the loader is started -- that is, #isStarted() returns true.

Must be called from the process's main thread.
[中]强制异步加载。与#startLoading()不同,这将忽略以前加载的数据集并加载新的数据集。这只是调用实现的#onForceLoad()。通常只应在加载程序启动时调用此函数,即#isStarted()返回true。
必须从进程的主线程调用。

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
 public void shouldCallOnForceLoad() {
  loader.forceLoad();
  assertThat(onForceLoadCalled).isTrue();
 }
}

代码示例来源:origin: stackoverflow.com

public class MyFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate():" + mContent);
    Loader loader = getLoaderManager().initLoader(0, null, this);
    loader.forceLoad();
  }   

  @Override
  public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    Log.d(TAG, "onCreateLoader()")  ;
    return new FooLoader(getActivity());
  }

  @Override
  public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    Log.d(TAG, "onLoadFinished");            
  }

  @Override
  public void onLoaderReset(Loader<Cursor> cursorLoader) {   
  }
}

代码示例来源:origin: com.google.android/support-v4

/**
 * Called when {@link ForceLoadContentObserver} detects a change.  The
 * default implementation checks to see if the loader is currently started;
 * if so, it simply calls {@link #forceLoad()}; otherwise, it sets a flag
 * so that {@link #takeContentChanged()} returns true.
 *
 * <p>Must be called from the process's main thread.
 */
public void onContentChanged() {
  if (mStarted) {
    forceLoad();
  } else {
    // This loader has been stopped, so we don't want to load
    // new data right now...  but keep track of it changing to
    // refresh later if we start again.
    mContentChanged = true;
  }
}

代码示例来源:origin: kingargyle/adt-leanback-support

/**
 * Called when {@link ForceLoadContentObserver} detects a change.  The
 * default implementation checks to see if the loader is currently started;
 * if so, it simply calls {@link #forceLoad()}; otherwise, it sets a flag
 * so that {@link #takeContentChanged()} returns true.
 *
 * <p>Must be called from the process's main thread.
 */
public void onContentChanged() {
  if (mStarted) {
    forceLoad();
  } else {
    // This loader has been stopped, so we don't want to load
    // new data right now...  but keep track of it changing to
    // refresh later if we start again.
    mContentChanged = true;
  }
}

代码示例来源:origin: M66B/XPrivacyLua

private void loadData() {
  Log.i(TAG, "Starting data loader");
  LoaderManager manager = getActivity().getSupportLoaderManager();
  manager.restartLoader(ActivityMain.LOADER_DATA, new Bundle(), dataLoaderCallbacks).forceLoad();
}

代码示例来源:origin: be.e_contract.jwatchdog/jwatchdog-android

@Override
protected void onNewIntent(Intent intent) {
  super.onNewIntent(intent);
  Log.d(Constants.TAG, "onNewIntent");
  startAlarm(intent);
  FragmentManager fragmentManager = getSupportFragmentManager();
  Fragment fragment = fragmentManager
      .findFragmentById(R.id.notificationListFragment);
  LoaderManager loaderManager = fragment.getLoaderManager();
  loaderManager.getLoader(0).forceLoad();
}

代码示例来源:origin: n76/wifi_backend

@TextChange(R.id.search_term)
protected void searchTermChanged() {
  Loader loader = getSupportLoaderManager().getLoader(LOADER_ID);
  if (loader != null) {
    updateLoaderSelection((CursorLoader) loader);
    loader.forceLoad();
  }
}

相关文章