Loader.java 5.78 KB
package android.support.v4.content;

import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
import android.support.v4.util.DebugUtils;
import java.io.FileDescriptor;
import java.io.PrintWriter;

public class Loader<D>
{
  int n;
  OnLoadCompleteListener<D> o;
  OnLoadCanceledListener<D> p;
  Context q;
  boolean r = false;
  boolean s = false;
  boolean t = true;
  boolean u = false;
  boolean v = false;
  
  public Loader(Context paramContext)
  {
    this.q = paramContext.getApplicationContext();
  }
  
  public void abandon()
  {
    this.s = true;
    onAbandon();
  }
  
  public boolean cancelLoad()
  {
    return onCancelLoad();
  }
  
  public void commitContentChanged()
  {
    this.v = false;
  }
  
  public String dataToString(D paramD)
  {
    StringBuilder localStringBuilder = new StringBuilder(64);
    DebugUtils.buildShortClassTag(paramD, localStringBuilder);
    localStringBuilder.append("}");
    return localStringBuilder.toString();
  }
  
  public void deliverCancellation()
  {
    if (this.p != null) {
      this.p.onLoadCanceled(this);
    }
  }
  
  public void deliverResult(D paramD)
  {
    if (this.o != null) {
      this.o.onLoadComplete(this, paramD);
    }
  }
  
  public void dump(String paramString, FileDescriptor paramFileDescriptor, PrintWriter paramPrintWriter, String[] paramArrayOfString)
  {
    paramPrintWriter.print(paramString);
    paramPrintWriter.print("mId=");
    paramPrintWriter.print(this.n);
    paramPrintWriter.print(" mListener=");
    paramPrintWriter.println(this.o);
    if ((this.r) || (this.u) || (this.v))
    {
      paramPrintWriter.print(paramString);
      paramPrintWriter.print("mStarted=");
      paramPrintWriter.print(this.r);
      paramPrintWriter.print(" mContentChanged=");
      paramPrintWriter.print(this.u);
      paramPrintWriter.print(" mProcessingChange=");
      paramPrintWriter.println(this.v);
    }
    if ((this.s) || (this.t))
    {
      paramPrintWriter.print(paramString);
      paramPrintWriter.print("mAbandoned=");
      paramPrintWriter.print(this.s);
      paramPrintWriter.print(" mReset=");
      paramPrintWriter.println(this.t);
    }
  }
  
  public void forceLoad()
  {
    onForceLoad();
  }
  
  public Context getContext()
  {
    return this.q;
  }
  
  public int getId()
  {
    return this.n;
  }
  
  public boolean isAbandoned()
  {
    return this.s;
  }
  
  public boolean isReset()
  {
    return this.t;
  }
  
  public boolean isStarted()
  {
    return this.r;
  }
  
  protected void onAbandon() {}
  
  protected boolean onCancelLoad()
  {
    return false;
  }
  
  public void onContentChanged()
  {
    if (this.r)
    {
      forceLoad();
      return;
    }
    this.u = true;
  }
  
  protected void onForceLoad() {}
  
  protected void onReset() {}
  
  protected void onStartLoading() {}
  
  protected void onStopLoading() {}
  
  public void registerListener(int paramInt, OnLoadCompleteListener<D> paramOnLoadCompleteListener)
  {
    if (this.o != null) {
      throw new IllegalStateException("There is already a listener registered");
    }
    this.o = paramOnLoadCompleteListener;
    this.n = paramInt;
  }
  
  public void registerOnLoadCanceledListener(OnLoadCanceledListener<D> paramOnLoadCanceledListener)
  {
    if (this.p != null) {
      throw new IllegalStateException("There is already a listener registered");
    }
    this.p = paramOnLoadCanceledListener;
  }
  
  public void reset()
  {
    onReset();
    this.t = true;
    this.r = false;
    this.s = false;
    this.u = false;
    this.v = false;
  }
  
  public void rollbackContentChanged()
  {
    if (this.v) {
      onContentChanged();
    }
  }
  
  public final void startLoading()
  {
    this.r = true;
    this.t = false;
    this.s = false;
    onStartLoading();
  }
  
  public void stopLoading()
  {
    this.r = false;
    onStopLoading();
  }
  
  public boolean takeContentChanged()
  {
    boolean bool = this.u;
    this.u = false;
    this.v |= bool;
    return bool;
  }
  
  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder(64);
    DebugUtils.buildShortClassTag(this, localStringBuilder);
    localStringBuilder.append(" id=");
    localStringBuilder.append(this.n);
    localStringBuilder.append("}");
    return localStringBuilder.toString();
  }
  
  public void unregisterListener(OnLoadCompleteListener<D> paramOnLoadCompleteListener)
  {
    if (this.o == null) {
      throw new IllegalStateException("No listener register");
    }
    if (this.o != paramOnLoadCompleteListener) {
      throw new IllegalArgumentException("Attempting to unregister the wrong listener");
    }
    this.o = null;
  }
  
  public void unregisterOnLoadCanceledListener(OnLoadCanceledListener<D> paramOnLoadCanceledListener)
  {
    if (this.p == null) {
      throw new IllegalStateException("No listener register");
    }
    if (this.p != paramOnLoadCanceledListener) {
      throw new IllegalArgumentException("Attempting to unregister the wrong listener");
    }
    this.p = null;
  }
  
  public final class ForceLoadContentObserver
    extends ContentObserver
  {
    public ForceLoadContentObserver()
    {
      super();
    }
    
    public final boolean deliverSelfNotifications()
    {
      return true;
    }
    
    public final void onChange(boolean paramBoolean)
    {
      Loader.this.onContentChanged();
    }
  }
  
  public static abstract interface OnLoadCanceledListener<D>
  {
    public abstract void onLoadCanceled(Loader<D> paramLoader);
  }
  
  public static abstract interface OnLoadCompleteListener<D>
  {
    public abstract void onLoadComplete(Loader<D> paramLoader, D paramD);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/content/Loader.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */