Ejemplo n.º 1
0
 private LoaderInfo createLoader(
     int id, Bundle args, LoaderManager.LoaderCallbacks<Object> callback) {
   LoaderInfo info = new LoaderInfo(id, args, (LoaderManager.LoaderCallbacks<Object>) callback);
   Loader<Object> loader = callback.onCreateLoader(id, args);
   info.mLoader = (Loader<Object>) loader;
   return info;
 }
Ejemplo n.º 2
0
 void destroy() {
   if (DEBUG) Log.v(TAG, "  Destroying: " + this);
   mDestroyed = true;
   boolean needReset = mDeliveredData;
   mDeliveredData = false;
   if (mCallbacks != null && mLoader != null && mHaveData && needReset) {
     if (DEBUG) Log.v(TAG, "  Reseting: " + this);
     String lastBecause = null;
     if (mActivity != null) {
       lastBecause = mActivity.mFragments.mNoTransactionsBecause;
       mActivity.mFragments.mNoTransactionsBecause = "onLoaderReset";
     }
     try {
       mCallbacks.onLoaderReset(mLoader);
     } finally {
       if (mActivity != null) {
         mActivity.mFragments.mNoTransactionsBecause = lastBecause;
       }
     }
   }
   mCallbacks = null;
   mData = null;
   mHaveData = false;
   if (mLoader != null) {
     if (mListenerRegistered) {
       mListenerRegistered = false;
       mLoader.unregisterListener(this);
     }
     mLoader.reset();
   }
   if (mPendingLoader != null) {
     mPendingLoader.destroy();
   }
 }
Ejemplo n.º 3
0
    void start() {
      if (mRetaining && mRetainingStarted) {
        // Our owner is started, but we were being retained from a
        // previous instance in the started state...  so there is really
        // nothing to do here, since the loaders are still started.
        mStarted = true;
        return;
      }

      if (mStarted) {
        // If loader already started, don't restart.
        return;
      }

      mStarted = true;

      if (DEBUG) Log.v(TAG, "  Starting: " + this);
      if (mLoader == null && mCallbacks != null) {
        mLoader = mCallbacks.onCreateLoader(mId, mArgs);
      }
      if (mLoader != null) {
        if (mLoader.getClass().isMemberClass()
            && !Modifier.isStatic(mLoader.getClass().getModifiers())) {
          throw new IllegalArgumentException(
              "Object returned from onCreateLoader must not be a non-static inner member class: "
                  + mLoader);
        }
        if (!mListenerRegistered) {
          mLoader.registerListener(mId, this);
          mListenerRegistered = true;
        }
        mLoader.startLoading();
      }
    }
Ejemplo n.º 4
0
 void callOnLoadFinished(Loader<Object> loader, Object data) {
   if (mCallbacks != null) {
     String lastBecause = null;
     if (mActivity != null) {
       lastBecause = mActivity.mFragments.mNoTransactionsBecause;
       mActivity.mFragments.mNoTransactionsBecause = "onLoadFinished";
     }
     try {
       if (DEBUG) Log.v(TAG, "  onLoadFinished in " + loader + ": " + loader.dataToString(data));
       mCallbacks.onLoadFinished(loader, data);
     } finally {
       if (mActivity != null) {
         mActivity.mFragments.mNoTransactionsBecause = lastBecause;
       }
     }
     mDeliveredData = true;
   }
 }