Пример #1
0
  private void run() {
    System.out.println(new A().i);

    // Now run the class from the -ex file.

    FancyLoader loader = new FancyLoader(getClass().getClassLoader());

    try {
      Class testEx = loader.loadClass("TestEx");
      Method test = testEx.getDeclaredMethod("test");
      test.invoke(null);
    } catch (Exception exc) {
      exc.printStackTrace();
    }
  }
  @Override
  public void onCanceled(int[] statistics) {
    if (DEBUG) Log.i(TAG, "+++ onCanceled() called! +++");
    // Attempt to cancel the current asynchronous load.
    super.onCanceled(statistics);

    // The load has been canceled, so we should release the resources
    // associated with 'data'.
    onReleaseResources(statistics);
  }
  @Override
  public void deliverResult(int[] statistics) {
    mIsLoading = false;
    if (isReset()) {
      if (DEBUG) Log.w(TAG, "+++ Loader delivered result while loader was reseting. +++");
      // The Loader has been reset; ignore the result and invalidate the
      // data.
      onReleaseResources(mStatistics);
      return;
    }

    int[] oldStatistics = null;

    oldStatistics = mStatistics;
    mStatistics = statistics;

    if (isStarted()) {
      if (DEBUG)
        Log.i(
            TAG,
            "+++ Delivering results to the LoaderManager[mHasMoreResult: "
                + mHasMoreResult
                + ", mHasError: "
                + mHasError
                + ", mOnline: "
                + mOnline
                + "] +++");
      // If the Loader is in a started state, deliver the results to the
      // client. The superclass method does this for us.
      super.deliverResult(mStatistics == null ? null : mStatistics);
    }

    // Invalidate the old data as we don't need it any more.
    if (oldStatistics != null && oldStatistics != statistics) {
      onReleaseResources(oldStatistics);
    }
  }
 @Override
 public void forceLoad() {
   if (DEBUG) Log.i(TAG, "+++ forceLoad() called! +++");
   super.forceLoad();
 }