Ejemplo n.º 1
0
  /**
   * Call to initialize a particular ID with a Loader. If this ID already has a Loader associated
   * with it, it is left unchanged and any previous callbacks replaced with the newly provided ones.
   * If there is not currently a Loader for the ID, a new one is created and started.
   *
   * <p>This function should generally be used when a component is initializing, to ensure that a
   * Loader it relies on is created. This allows it to re-use an existing Loader's data if there
   * already is one, so that for example when an {@link Activity} is re-created after a
   * configuration change it does not need to re-create its loaders.
   *
   * <p>Note that in the case where an existing Loader is re-used, the <var>args</var> given here
   * <em>will be ignored</em> because you will continue using the previous Loader.
   *
   * @param id A unique (to this LoaderManager instance) identifier under which to manage the new
   *     Loader.
   * @param args Optional arguments that will be propagated to {@link
   *     LoaderCallbacks#onCreateLoader(int, Bundle) LoaderCallbacks.onCreateLoader()}.
   * @param callback Interface implementing management of this Loader. Required. Its
   *     onCreateLoader() method will be called while inside of the function to instantiate the
   *     Loader object.
   */
  @SuppressWarnings("unchecked")
  public <D> Loader<D> initLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback) {
    if (mCreatingLoader) {
      throw new IllegalStateException("Called while creating a loader");
    }

    LoaderInfo info = mLoaders.get(id);

    if (DEBUG) Log.v(TAG, "initLoader in " + this + ": args=" + args);

    if (info == null) {
      // Loader doesn't already exist; create.
      info = createAndInstallLoader(id, args, (LoaderManager.LoaderCallbacks<Object>) callback);
      if (DEBUG) Log.v(TAG, "  Created new loader " + info);
    } else {
      if (DEBUG) Log.v(TAG, "  Re-using existing loader " + info);
      info.mCallbacks = (LoaderManager.LoaderCallbacks<Object>) callback;
    }

    if (info.mHaveData && mStarted) {
      // If the loader has already generated its data, report it now.
      info.callOnLoadFinished(info.mLoader, info.mData);
    }

    return (Loader<D>) info.mLoader;
  }
 public <D> Loader<D> initLoader(
     int paramInt, Bundle paramBundle, LoaderManager.LoaderCallbacks<D> paramLoaderCallbacks) {
   if (this.mCreatingLoader) {
     throw new IllegalStateException("Called while creating a loader");
   }
   LoaderInfo localLoaderInfo = (LoaderInfo) this.mLoaders.get(paramInt);
   if (DEBUG) {
     Log.v("LoaderManager", "initLoader in " + this + ": args=" + paramBundle);
   }
   if (localLoaderInfo == null) {
     paramLoaderCallbacks = createAndInstallLoader(paramInt, paramBundle, paramLoaderCallbacks);
     paramBundle = paramLoaderCallbacks;
     if (DEBUG) {
       Log.v("LoaderManager", "  Created new loader " + paramLoaderCallbacks);
     }
   }
   for (paramBundle = paramLoaderCallbacks; ; paramBundle = localLoaderInfo) {
     if ((paramBundle.mHaveData) && (this.mStarted)) {
       paramBundle.callOnLoadFinished(paramBundle.mLoader, paramBundle.mData);
     }
     return paramBundle.mLoader;
     if (DEBUG) {
       Log.v("LoaderManager", "  Re-using existing loader " + localLoaderInfo);
     }
     localLoaderInfo.mCallbacks = paramLoaderCallbacks;
   }
 }
Ejemplo n.º 3
0
 public void destroyLoader(int paramInt)
 {
   if (this.mCreatingLoader)
     throw new IllegalStateException("Called while creating a loader");
   if (DEBUG)
   {
     String str = "destroyLoader in " + this + " of " + paramInt;
     int i = Log.v("LoaderManager", str);
   }
   int j = this.mLoaders.indexOfKey(paramInt);
   if (j >= 0)
   {
     LoaderInfo localLoaderInfo1 = (LoaderInfo)this.mLoaders.valueAt(j);
     this.mLoaders.removeAt(j);
     localLoaderInfo1.destroy();
   }
   int k = this.mInactiveLoaders.indexOfKey(paramInt);
   if (k >= 0)
   {
     LoaderInfo localLoaderInfo2 = (LoaderInfo)this.mInactiveLoaders.valueAt(k);
     this.mInactiveLoaders.removeAt(k);
     localLoaderInfo2.destroy();
   }
   if (this.mActivity == null)
     return;
   if (hasRunningLoaders())
     return;
   this.mActivity.mFragments.startPendingDeferredFragments();
 }
Ejemplo n.º 4
0
 private LoaderInfo createLoader(int paramInt, Bundle paramBundle, LoaderManager.LoaderCallbacks<Object> paramLoaderCallbacks)
 {
   LoaderInfo localLoaderInfo = new LoaderInfo(paramInt, paramBundle, paramLoaderCallbacks);
   Loader localLoader = paramLoaderCallbacks.onCreateLoader(paramInt, paramBundle);
   localLoaderInfo.mLoader = localLoader;
   return localLoaderInfo;
 }
Ejemplo n.º 5
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.º 6
0
    @Override
    public void onLoadComplete(Loader<Object> loader, Object data) {
      if (DEBUG) Log.v(TAG, "onLoadComplete: " + this);

      if (mDestroyed) {
        if (DEBUG) Log.v(TAG, "  Ignoring load complete -- destroyed");
        return;
      }

      if (mLoaders.get(mId) != this) {
        // This data is not coming from the current active loader.
        // We don't care about it.
        if (DEBUG) Log.v(TAG, "  Ignoring load complete -- not active");
        return;
      }

      LoaderInfo pending = mPendingLoader;
      if (pending != null) {
        // There is a new request pending and we were just
        // waiting for the old one to complete before starting
        // it.  So now it is time, switch over to the new loader.
        if (DEBUG) Log.v(TAG, "  Switching to pending loader: " + pending);
        mPendingLoader = null;
        mLoaders.put(mId, null);
        destroy();
        installLoader(pending);
        return;
      }

      // Notify of the new data so the app can switch out the old data before
      // we try to destroy it.
      if (mData != data || !mHaveData) {
        mData = data;
        mHaveData = true;
        if (mStarted) {
          callOnLoadFinished(loader, data);
        }
      }

      // if (DEBUG) Log.v(TAG, "  onLoadFinished returned: " + this);

      // We have now given the application the new loader with its
      // loaded data, so it should have stopped using the previous
      // loader.  If there is a previous loader on the inactive list,
      // clean it up.
      LoaderInfo info = mInactiveLoaders.get(mId);
      if (info != null && info != this) {
        info.mDeliveredData = false;
        info.destroy();
        mInactiveLoaders.remove(mId);
      }
    }
 public <D> Loader<D> restartLoader(
     int paramInt, Bundle paramBundle, LoaderManager.LoaderCallbacks<D> paramLoaderCallbacks) {
   if (this.mCreatingLoader) {
     throw new IllegalStateException("Called while creating a loader");
   }
   LoaderInfo localLoaderInfo1 = (LoaderInfo) this.mLoaders.get(paramInt);
   if (DEBUG) {
     Log.v("LoaderManager", "restartLoader in " + this + ": args=" + paramBundle);
   }
   if (localLoaderInfo1 != null) {
     LoaderInfo localLoaderInfo2 = (LoaderInfo) this.mInactiveLoaders.get(paramInt);
     if (localLoaderInfo2 == null) {
       break label329;
     }
     if (!localLoaderInfo1.mHaveData) {
       break label175;
     }
     if (DEBUG) {
       Log.v("LoaderManager", "  Removing last inactive loader: " + localLoaderInfo1);
     }
     localLoaderInfo2.mDeliveredData = false;
     localLoaderInfo2.destroy();
     localLoaderInfo1.mLoader.abandon();
     this.mInactiveLoaders.put(paramInt, localLoaderInfo1);
   }
   for (; ; ) {
     return createAndInstallLoader(paramInt, paramBundle, paramLoaderCallbacks).mLoader;
     label175:
     if (!localLoaderInfo1.mStarted) {
       if (DEBUG) {
         Log.v("LoaderManager", "  Current loader is stopped; replacing");
       }
       this.mLoaders.put(paramInt, null);
       localLoaderInfo1.destroy();
     } else {
       if (DEBUG) {
         Log.v("LoaderManager", "  Current loader is running; attempting to cancel");
       }
       localLoaderInfo1.cancel();
       if (localLoaderInfo1.mPendingLoader != null) {
         if (DEBUG) {
           Log.v("LoaderManager", "  Removing pending loader: " + localLoaderInfo1.mPendingLoader);
         }
         localLoaderInfo1.mPendingLoader.destroy();
         localLoaderInfo1.mPendingLoader = null;
       }
       if (DEBUG) {
         Log.v("LoaderManager", "  Enqueuing as new pending loader");
       }
       localLoaderInfo1.mPendingLoader = createLoader(paramInt, paramBundle, paramLoaderCallbacks);
       return localLoaderInfo1.mPendingLoader.mLoader;
       label329:
       if (DEBUG) {
         Log.v("LoaderManager", "  Making last loader inactive: " + localLoaderInfo1);
       }
       localLoaderInfo1.mLoader.abandon();
       this.mInactiveLoaders.put(paramInt, localLoaderInfo1);
     }
   }
 }
Ejemplo n.º 8
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.º 9
0
 void installLoader(LoaderInfo info) {
   mLoaders.put(info.mId, info);
   if (mStarted) {
     // The activity will start all existing loaders in it's onStart(),
     // so only start them here if we're past that point of the activitiy's
     // life cycle
     info.start();
   }
 }
Ejemplo n.º 10
0
 void installLoader(LoaderInfo paramLoaderInfo)
 {
   SparseArrayCompat localSparseArrayCompat = this.mLoaders;
   int i = paramLoaderInfo.mId;
   localSparseArrayCompat.put(i, paramLoaderInfo);
   if (!this.mStarted)
     return;
   paramLoaderInfo.start();
 }
Ejemplo n.º 11
0
  /**
   * Call to re-create the Loader associated with a particular ID. If there is currently a Loader
   * associated with this ID, it will be canceled/stopped/destroyed as appropriate. A new Loader
   * with the given arguments will be created and its data delivered to you once available.
   *
   * <p>This function does some throttling of Loaders. If too many Loaders have been created for the
   * given ID but not yet generated their data, new calls to this function will create and return a
   * new Loader but not actually start it until some previous loaders have completed.
   *
   * <p>After calling this function, any previous Loaders associated with this ID will be considered
   * invalid, and you will receive no further data updates from them.
   *
   * @param id A unique (to this LoaderManager instance) identifier under which to manage the new
   *     Loader.
   * @param args Optional arguments that will be propagated to {@link
   *     LoaderCallbacks#onCreateLoader(int, Bundle) LoaderCallbacks.onCreateLoader()}.
   * @param callback Interface implementing management of this Loader. Required. Its
   *     onCreateLoader() method will be called while inside of the function to instantiate the
   *     Loader object.
   */
  @SuppressWarnings("unchecked")
  public <D> Loader<D> restartLoader(
      int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback) {
    if (mCreatingLoader) {
      throw new IllegalStateException("Called while creating a loader");
    }

    LoaderInfo info = mLoaders.get(id);
    if (DEBUG) Log.v(TAG, "restartLoader in " + this + ": args=" + args);
    if (info != null) {
      LoaderInfo inactive = mInactiveLoaders.get(id);
      if (inactive != null) {
        if (info.mHaveData) {
          // This loader now has data...  we are probably being
          // called from within onLoadComplete, where we haven't
          // yet destroyed the last inactive loader.  So just do
          // that now.
          if (DEBUG) Log.v(TAG, "  Removing last inactive loader: " + info);
          inactive.mDeliveredData = false;
          inactive.destroy();
          info.mLoader.abandon();
          mInactiveLoaders.put(id, info);
        } else {
          // We already have an inactive loader for this ID that we are
          // waiting for!  What to do, what to do...
          if (!info.mStarted) {
            // The current Loader has not been started...  we thus
            // have no reason to keep it around, so bam, slam,
            // thank-you-ma'am.
            if (DEBUG) Log.v(TAG, "  Current loader is stopped; replacing");
            mLoaders.put(id, null);
            info.destroy();
          } else {
            // Now we have three active loaders... we'll queue
            // up this request to be processed once one of the other loaders
            // finishes.
            if (info.mPendingLoader != null) {
              if (DEBUG) Log.v(TAG, "  Removing pending loader: " + info.mPendingLoader);
              info.mPendingLoader.destroy();
              info.mPendingLoader = null;
            }
            if (DEBUG) Log.v(TAG, "  Enqueuing as new pending loader");
            info.mPendingLoader =
                createLoader(id, args, (LoaderManager.LoaderCallbacks<Object>) callback);
            return (Loader<D>) info.mPendingLoader.mLoader;
          }
        }
      } else {
        // Keep track of the previous instance of this loader so we can destroy
        // it when the new one completes.
        if (DEBUG) Log.v(TAG, "  Making last loader inactive: " + info);
        info.mLoader.abandon();
        mInactiveLoaders.put(id, info);
      }
    }

    info = createAndInstallLoader(id, args, (LoaderManager.LoaderCallbacks<Object>) callback);
    return (Loader<D>) info.mLoader;
  }
Ejemplo n.º 12
0
  /**
   * Rip down, tear apart, shred to pieces a current Loader ID. After returning from this function,
   * any Loader objects associated with this ID are destroyed. Any data associated with them is
   * destroyed. You better not be using it when you do this.
   *
   * @param id Identifier of the Loader to be destroyed.
   */
  public void destroyLoader(int id) {
    if (mCreatingLoader) {
      throw new IllegalStateException("Called while creating a loader");
    }

    if (DEBUG) Log.v(TAG, "destroyLoader in " + this + " of " + id);
    int idx = mLoaders.indexOfKey(id);
    if (idx >= 0) {
      LoaderInfo info = mLoaders.valueAt(idx);
      mLoaders.removeAt(idx);
      info.destroy();
    }
    idx = mInactiveLoaders.indexOfKey(id);
    if (idx >= 0) {
      LoaderInfo info = mInactiveLoaders.valueAt(idx);
      mInactiveLoaders.removeAt(idx);
      info.destroy();
    }
  }
 public void dump(
     String paramString,
     FileDescriptor paramFileDescriptor,
     PrintWriter paramPrintWriter,
     String[] paramArrayOfString) {
   String str;
   int i;
   LoaderInfo localLoaderInfo;
   if (this.mLoaders.size() > 0) {
     paramPrintWriter.print(paramString);
     paramPrintWriter.println("Active Loaders:");
     str = paramString + "    ";
     i = 0;
     while (i < this.mLoaders.size()) {
       localLoaderInfo = (LoaderInfo) this.mLoaders.valueAt(i);
       paramPrintWriter.print(paramString);
       paramPrintWriter.print("  #");
       paramPrintWriter.print(this.mLoaders.keyAt(i));
       paramPrintWriter.print(": ");
       paramPrintWriter.println(localLoaderInfo.toString());
       localLoaderInfo.dump(str, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
       i += 1;
     }
   }
   if (this.mInactiveLoaders.size() > 0) {
     paramPrintWriter.print(paramString);
     paramPrintWriter.println("Inactive Loaders:");
     str = paramString + "    ";
     i = 0;
     while (i < this.mInactiveLoaders.size()) {
       localLoaderInfo = (LoaderInfo) this.mInactiveLoaders.valueAt(i);
       paramPrintWriter.print(paramString);
       paramPrintWriter.print("  #");
       paramPrintWriter.print(this.mInactiveLoaders.keyAt(i));
       paramPrintWriter.print(": ");
       paramPrintWriter.println(localLoaderInfo.toString());
       localLoaderInfo.dump(str, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
       i += 1;
     }
   }
 }
Ejemplo n.º 14
0
 @Override
 public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
   if (mLoaders.size() > 0) {
     writer.print(prefix);
     writer.println("Active Loaders:");
     String innerPrefix = prefix + "    ";
     for (int i = 0; i < mLoaders.size(); i++) {
       LoaderInfo li = mLoaders.valueAt(i);
       writer.print(prefix);
       writer.print("  #");
       writer.print(mLoaders.keyAt(i));
       writer.print(": ");
       writer.println(li.toString());
       li.dump(innerPrefix, fd, writer, args);
     }
   }
   if (mInactiveLoaders.size() > 0) {
     writer.print(prefix);
     writer.println("Inactive Loaders:");
     String innerPrefix = prefix + "    ";
     for (int i = 0; i < mInactiveLoaders.size(); i++) {
       LoaderInfo li = mInactiveLoaders.valueAt(i);
       writer.print(prefix);
       writer.print("  #");
       writer.print(mInactiveLoaders.keyAt(i));
       writer.print(": ");
       writer.println(li.toString());
       li.dump(innerPrefix, fd, writer, args);
     }
   }
 }
Ejemplo n.º 15
0
 public <D> Loader<D> initLoader(int paramInt, Bundle paramBundle, LoaderManager.LoaderCallbacks<D> paramLoaderCallbacks)
 {
   if (this.mCreatingLoader)
     throw new IllegalStateException("Called while creating a loader");
   LoaderInfo localLoaderInfo = (LoaderInfo)this.mLoaders.get(paramInt);
   if (DEBUG)
   {
     String str1 = "initLoader in " + this + ": args=" + paramBundle;
     int i = Log.v("LoaderManager", str1);
   }
   if (localLoaderInfo == null)
   {
     localLoaderInfo = createAndInstallLoader(paramInt, paramBundle, paramLoaderCallbacks);
     if (DEBUG)
     {
       String str2 = "  Created new loader " + localLoaderInfo;
       int j = Log.v("LoaderManager", str2);
     }
   }
   while (true)
   {
     if ((localLoaderInfo.mHaveData) && (this.mStarted))
     {
       Loader localLoader = localLoaderInfo.mLoader;
       Object localObject = localLoaderInfo.mData;
       localLoaderInfo.callOnLoadFinished(localLoader, localObject);
     }
     return localLoaderInfo.mLoader;
     if (DEBUG)
     {
       String str3 = "  Re-using existing loader " + localLoaderInfo;
       int k = Log.v("LoaderManager", str3);
     }
     localLoaderInfo.mCallbacks = paramLoaderCallbacks;
   }
 }
 public void destroyLoader(int paramInt) {
   if (this.mCreatingLoader) {
     throw new IllegalStateException("Called while creating a loader");
   }
   if (DEBUG) {
     Log.v("LoaderManager", "destroyLoader in " + this + " of " + paramInt);
   }
   int i = this.mLoaders.indexOfKey(paramInt);
   LoaderInfo localLoaderInfo;
   if (i >= 0) {
     localLoaderInfo = (LoaderInfo) this.mLoaders.valueAt(i);
     this.mLoaders.removeAt(i);
     localLoaderInfo.destroy();
   }
   paramInt = this.mInactiveLoaders.indexOfKey(paramInt);
   if (paramInt >= 0) {
     localLoaderInfo = (LoaderInfo) this.mInactiveLoaders.valueAt(paramInt);
     this.mInactiveLoaders.removeAt(paramInt);
     localLoaderInfo.destroy();
   }
   if ((this.mHost != null) && (!hasRunningLoaders())) {
     this.mHost.mFragmentManager.startPendingDeferredFragments();
   }
 }
Ejemplo n.º 17
0
 public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
   writer.print(prefix);
   writer.print("mId=");
   writer.print(mId);
   writer.print(" mArgs=");
   writer.println(mArgs);
   writer.print(prefix);
   writer.print("mCallbacks=");
   writer.println(mCallbacks);
   writer.print(prefix);
   writer.print("mLoader=");
   writer.println(mLoader);
   if (mLoader != null) {
     mLoader.dump(prefix + "  ", fd, writer, args);
   }
   if (mHaveData || mDeliveredData) {
     writer.print(prefix);
     writer.print("mHaveData=");
     writer.print(mHaveData);
     writer.print("  mDeliveredData=");
     writer.println(mDeliveredData);
     writer.print(prefix);
     writer.print("mData=");
     writer.println(mData);
   }
   writer.print(prefix);
   writer.print("mStarted=");
   writer.print(mStarted);
   writer.print(" mRetaining=");
   writer.print(mRetaining);
   writer.print(" mDestroyed=");
   writer.println(mDestroyed);
   writer.print(prefix);
   writer.print("mListenerRegistered=");
   writer.println(mListenerRegistered);
   if (mPendingLoader != null) {
     writer.print(prefix);
     writer.println("Pending Loader ");
     writer.print(mPendingLoader);
     writer.println(":");
     mPendingLoader.dump(prefix + "  ", fd, writer, args);
   }
 }
Ejemplo n.º 18
0
 public void dump(String paramString, FileDescriptor paramFileDescriptor, PrintWriter paramPrintWriter, String[] paramArrayOfString)
 {
   if (this.mLoaders.size() > 0)
   {
     paramPrintWriter.print(paramString);
     paramPrintWriter.println("Active Loaders:");
     str1 = paramString + "    ";
     i = 0;
     while (true)
     {
       int j = this.mLoaders.size();
       if (i >= j)
         break;
       LoaderInfo localLoaderInfo1 = (LoaderInfo)this.mLoaders.valueAt(i);
       paramPrintWriter.print(paramString);
       paramPrintWriter.print("  #");
       int k = this.mLoaders.keyAt(i);
       paramPrintWriter.print(k);
       paramPrintWriter.print(": ");
       String str2 = localLoaderInfo1.toString();
       paramPrintWriter.println(str2);
       localLoaderInfo1.dump(str1, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
       i += 1;
     }
   }
   if (this.mInactiveLoaders.size() <= 0)
     return;
   paramPrintWriter.print(paramString);
   paramPrintWriter.println("Inactive Loaders:");
   String str1 = paramString + "    ";
   int i = 0;
   while (true)
   {
     int m = this.mInactiveLoaders.size();
     if (i >= m)
       return;
     LoaderInfo localLoaderInfo2 = (LoaderInfo)this.mInactiveLoaders.valueAt(i);
     paramPrintWriter.print(paramString);
     paramPrintWriter.print("  #");
     int n = this.mInactiveLoaders.keyAt(i);
     paramPrintWriter.print(n);
     paramPrintWriter.print(": ");
     String str3 = localLoaderInfo2.toString();
     paramPrintWriter.println(str3);
     localLoaderInfo2.dump(str1, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
     i += 1;
   }
 }
Ejemplo n.º 19
0
 public <D> Loader<D> restartLoader(int paramInt, Bundle paramBundle, LoaderManager.LoaderCallbacks<D> paramLoaderCallbacks)
 {
   if (this.mCreatingLoader)
     throw new IllegalStateException("Called while creating a loader");
   LoaderInfo localLoaderInfo1 = (LoaderInfo)this.mLoaders.get(paramInt);
   if (DEBUG)
   {
     String str1 = "restartLoader in " + this + ": args=" + paramBundle;
     int i = Log.v("LoaderManager", str1);
   }
   if (localLoaderInfo1 != null)
   {
     LoaderInfo localLoaderInfo2 = (LoaderInfo)this.mInactiveLoaders.get(paramInt);
     if (localLoaderInfo2 == null)
       break label346;
     if (!localLoaderInfo1.mHaveData)
       break label189;
     if (DEBUG)
     {
       String str2 = "  Removing last inactive loader: " + localLoaderInfo1;
       int j = Log.v("LoaderManager", str2);
     }
     localLoaderInfo2.mDeliveredData = false;
     localLoaderInfo2.destroy();
     localLoaderInfo1.mLoader.abandon();
     this.mInactiveLoaders.put(paramInt, localLoaderInfo1);
   }
   while (true)
   {
     for (Loader localLoader = createAndInstallLoader(paramInt, paramBundle, paramLoaderCallbacks).mLoader; ; localLoader = localLoaderInfo1.mPendingLoader.mLoader)
     {
       return localLoader;
       label189: if (!localLoaderInfo1.mStarted)
       {
         if (DEBUG)
           int k = Log.v("LoaderManager", "  Current loader is stopped; replacing");
         this.mLoaders.put(paramInt, null);
         localLoaderInfo1.destroy();
         break;
       }
       if (localLoaderInfo1.mPendingLoader != null)
       {
         if (DEBUG)
         {
           StringBuilder localStringBuilder = new StringBuilder().append("  Removing pending loader: ");
           LoaderInfo localLoaderInfo3 = localLoaderInfo1.mPendingLoader;
           String str3 = localLoaderInfo3;
           int m = Log.v("LoaderManager", str3);
         }
         localLoaderInfo1.mPendingLoader.destroy();
         localLoaderInfo1.mPendingLoader = null;
       }
       if (DEBUG)
         int n = Log.v("LoaderManager", "  Enqueuing as new pending loader");
       LoaderInfo localLoaderInfo4 = createLoader(paramInt, paramBundle, paramLoaderCallbacks);
       localLoaderInfo1.mPendingLoader = localLoaderInfo4;
     }
     label346: if (DEBUG)
     {
       String str4 = "  Making last loader inactive: " + localLoaderInfo1;
       int i1 = Log.v("LoaderManager", str4);
     }
     localLoaderInfo1.mLoader.abandon();
     this.mInactiveLoaders.put(paramInt, localLoaderInfo1);
   }
 }
 void installLoader(LoaderInfo paramLoaderInfo) {
   this.mLoaders.put(paramLoaderInfo.mId, paramLoaderInfo);
   if (this.mStarted) {
     paramLoaderInfo.start();
   }
 }
Ejemplo n.º 21
0
 public void dump(String paramString, FileDescriptor paramFileDescriptor, PrintWriter paramPrintWriter, String[] paramArrayOfString)
 {
   paramPrintWriter.print(paramString);
   paramPrintWriter.print("mId=");
   int i = this.mId;
   paramPrintWriter.print(i);
   paramPrintWriter.print(" mArgs=");
   Bundle localBundle = this.mArgs;
   paramPrintWriter.println(localBundle);
   paramPrintWriter.print(paramString);
   paramPrintWriter.print("mCallbacks=");
   LoaderManager.LoaderCallbacks localLoaderCallbacks = this.mCallbacks;
   paramPrintWriter.println(localLoaderCallbacks);
   paramPrintWriter.print(paramString);
   paramPrintWriter.print("mLoader=");
   Loader localLoader1 = this.mLoader;
   paramPrintWriter.println(localLoader1);
   if (this.mLoader != null)
   {
     Loader localLoader2 = this.mLoader;
     String str1 = paramString + "  ";
     localLoader2.dump(str1, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
   }
   if ((this.mHaveData) || (this.mDeliveredData))
   {
     paramPrintWriter.print(paramString);
     paramPrintWriter.print("mHaveData=");
     boolean bool1 = this.mHaveData;
     paramPrintWriter.print(bool1);
     paramPrintWriter.print("  mDeliveredData=");
     boolean bool2 = this.mDeliveredData;
     paramPrintWriter.println(bool2);
     paramPrintWriter.print(paramString);
     paramPrintWriter.print("mData=");
     Object localObject = this.mData;
     paramPrintWriter.println(localObject);
   }
   paramPrintWriter.print(paramString);
   paramPrintWriter.print("mStarted=");
   boolean bool3 = this.mStarted;
   paramPrintWriter.print(bool3);
   paramPrintWriter.print(" mReportNextStart=");
   boolean bool4 = this.mReportNextStart;
   paramPrintWriter.print(bool4);
   paramPrintWriter.print(" mDestroyed=");
   boolean bool5 = this.mDestroyed;
   paramPrintWriter.println(bool5);
   paramPrintWriter.print(paramString);
   paramPrintWriter.print("mRetaining=");
   boolean bool6 = this.mRetaining;
   paramPrintWriter.print(bool6);
   paramPrintWriter.print(" mRetainingStarted=");
   boolean bool7 = this.mRetainingStarted;
   paramPrintWriter.print(bool7);
   paramPrintWriter.print(" mListenerRegistered=");
   boolean bool8 = this.mListenerRegistered;
   paramPrintWriter.println(bool8);
   if (this.mPendingLoader == null)
     return;
   paramPrintWriter.print(paramString);
   paramPrintWriter.println("Pending Loader ");
   LoaderInfo localLoaderInfo1 = this.mPendingLoader;
   paramPrintWriter.print(localLoaderInfo1);
   paramPrintWriter.println(":");
   LoaderInfo localLoaderInfo2 = this.mPendingLoader;
   String str2 = paramString + "  ";
   localLoaderInfo2.dump(str2, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
 }
Ejemplo n.º 22
0
 public void onLoadComplete(Loader<Object> paramLoader, Object paramObject)
 {
   if (LoaderManagerImpl.DEBUG)
   {
     String str1 = "onLoadComplete: " + this;
     int i = Log.v("LoaderManager", str1);
   }
   if (this.mDestroyed)
   {
     if (!LoaderManagerImpl.DEBUG)
       return;
     int j = Log.v("LoaderManager", "  Ignoring load complete -- destroyed");
     return;
   }
   SparseArrayCompat localSparseArrayCompat1 = LoaderManagerImpl.this.mLoaders;
   int k = this.mId;
   if (localSparseArrayCompat1.get(k) != this)
   {
     if (!LoaderManagerImpl.DEBUG)
       return;
     int m = Log.v("LoaderManager", "  Ignoring load complete -- not active");
     return;
   }
   LoaderInfo localLoaderInfo1 = this.mPendingLoader;
   if (localLoaderInfo1 != null)
   {
     if (LoaderManagerImpl.DEBUG)
     {
       String str2 = "  Switching to pending loader: " + localLoaderInfo1;
       int n = Log.v("LoaderManager", str2);
     }
     this.mPendingLoader = null;
     SparseArrayCompat localSparseArrayCompat2 = LoaderManagerImpl.this.mLoaders;
     int i1 = this.mId;
     localSparseArrayCompat2.put(i1, null);
     destroy();
     LoaderManagerImpl.this.installLoader(localLoaderInfo1);
     return;
   }
   if ((this.mData != paramObject) || (!this.mHaveData))
   {
     this.mData = paramObject;
     this.mHaveData = true;
     if (this.mStarted)
       callOnLoadFinished(paramLoader, paramObject);
   }
   SparseArrayCompat localSparseArrayCompat3 = LoaderManagerImpl.this.mInactiveLoaders;
   int i2 = this.mId;
   LoaderInfo localLoaderInfo2 = (LoaderInfo)localSparseArrayCompat3.get(i2);
   if ((localLoaderInfo2 != null) && (localLoaderInfo2 != this))
   {
     localLoaderInfo2.mDeliveredData = false;
     localLoaderInfo2.destroy();
     SparseArrayCompat localSparseArrayCompat4 = LoaderManagerImpl.this.mInactiveLoaders;
     int i3 = this.mId;
     localSparseArrayCompat4.remove(i3);
   }
   if (LoaderManagerImpl.this.mActivity == null)
     return;
   if (LoaderManagerImpl.this.hasRunningLoaders())
     return;
   LoaderManagerImpl.this.mActivity.mFragments.startPendingDeferredFragments();
 }