content: package androidx.loader.content;
  
  import android.content.Context;
  import android.database.ContentObserver;
  import android.os.Handler;
  import androidx.core.util.DebugUtils;
  import java.io.FileDescriptor;
  import java.io.PrintWriter;
  
  public class Loader<D> {
      boolean mAbandoned = false;
      boolean mContentChanged = false;
      Context mContext;
      int mId;
      OnLoadCompleteListener<D> mListener;
      OnLoadCanceledListener<D> mOnLoadCanceledListener;
      boolean mProcessingChange = false;
      boolean mReset = true;
      boolean mStarted = false;
  
      public final class ForceLoadContentObserver extends ContentObserver {
          public ForceLoadContentObserver() {
              super(new Handler());
          }
  
          public boolean deliverSelfNotifications() {
              return true;
          }
  
          public void onChange(boolean selfChange) {
              Loader.this.onContentChanged();
          }
      }
  
      public interface OnLoadCanceledListener<D> {
          void onLoadCanceled(Loader<D> loader);
      }
  
      public interface OnLoadCompleteListener<D> {
          void onLoadComplete(Loader<D> loader, D d);
      }
  
      public Loader(Context context) {
          this.mContext = context.getApplicationContext();
      }
  
      public void abandon() {
          this.mAbandoned = true;
          onAbandon();
      }
  
      public boolean cancelLoad() {
          return onCancelLoad();
      }
  
      public void commitContentChanged() {
          this.mProcessingChange = false;
      }
  
      public String dataToString(D d) {
          StringBuilder sb = new StringBuilder(64);
          DebugUtils.buildShortClassTag(d, sb);
          sb.append("}");
          return sb.toString();
      }
  
      public void deliverCancellation() {
          OnLoadCanceledListener<D> onLoadCanceledListener = this.mOnLoadCanceledListener;
          if (onLoadCanceledListener != null) {
              onLoadCanceledListener.onLoadCanceled(this);
          }
      }
  
      public void deliverResult(D d) {
          OnLoadCompleteListener<D> onLoadCompleteListener = this.mListener;
          if (onLoadCompleteListener != null) {
              onLoadCompleteListener.onLoadComplete(this, d);
          }
      }
  
      @Deprecated
      public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
          writer.print(prefix);
          writer.print("mId=");
          writer.print(this.mId);
          writer.print(" mListener=");
          writer.println(this.mListener);
          if (this.mStarted || this.mContentChanged || this.mProcessingChange) {
              writer.print(prefix);
              writer.print("mStarted=");
              writer.print(this.mStarted);
              writer.print(" mContentChanged=");
              writer.print(this.mContentChanged);
              writer.print(" mProcessingChange=");
              writer.println(this.mProcessingChange);
          }
          if (this.mAbandoned || this.mReset) {
              writer.print(prefix);
              writer.print("mAbandoned=");
              writer.print(this.mAbandoned);
              writer.print(" mReset=");
              writer.println(this.mReset);
          }
      }
  
      public void forceLoad() {
          onForceLoad();
      }
  
      public Context getContext() {
          return this.mContext;
      }
  
      public int getId() {
          return this.mId;
      }
  
      public boolean isAbandoned() {
          return this.mAbandoned;
      }
  
      public boolean isReset() {
          return this.mReset;
      }
  
      public boolean isStarted() {
          return this.mStarted;
      }
  
      /* access modifiers changed from: protected */
      public void onAbandon() {
      }
  
      /* access modifiers changed from: protected */
      public boolean onCancelLoad() {
          return false;
      }
  
      public void onContentChanged() {
          if (this.mStarted) {
              forceLoad();
          } else {
              this.mContentChanged = true;
          }
      }
  
      /* access modifiers changed from: protected */
      public void onForceLoad() {
      }
  
      /* access modifiers changed from: protected */
      public void onReset() {
      }
  
      /* access modifiers changed from: protected */
      public void onStartLoading() {
      }
  
      /* access modifiers changed from: protected */
      public void onStopLoading() {
      }
  
      public void registerListener(int id, OnLoadCompleteListener<D> onLoadCompleteListener) {
          if (this.mListener == null) {
              this.mListener = onLoadCompleteListener;
              this.mId = id;
              return;
          }
          throw new IllegalStateException("There is already a listener registered");
      }
  
      public void registerOnLoadCanceledListener(OnLoadCanceledListener<D> onLoadCanceledListener) {
          if (this.mOnLoadCanceledListener == null) {
              this.mOnLoadCanceledListener = onLoadCanceledListener;
              return;
          }
          throw new IllegalStateException("There is already a listener registered");
      }
  
      public void reset() {
          onReset();
          this.mReset = true;
          this.mStarted = false;
          this.mAbandoned = false;
          this.mContentChanged = false;
          this.mProcessingChange = false;
      }
  
      public void rollbackContentChanged() {
          if (this.mProcessingChange) {
              onContentChanged();
          }
      }
  
      public final void startLoading() {
          this.mStarted = true;
          this.mReset = false;
          this.mAbandoned = false;
          onStartLoading();
      }
  
      public void stopLoading() {
          this.mStarted = false;
          onStopLoading();
      }
  
      public boolean takeContentChanged() {
          boolean z = this.mContentChanged;
          this.mContentChanged = false;
          this.mProcessingChange |= z;
          return z;
      }
  
      public String toString() {
          StringBuilder sb = new StringBuilder(64);
          DebugUtils.buildShortClassTag(this, sb);
          sb.append(" id=");
          sb.append(this.mId);
          sb.append("}");
          return sb.toString();
      }
  
      public void unregisterListener(OnLoadCompleteListener<D> onLoadCompleteListener) {
          OnLoadCompleteListener<D> onLoadCompleteListener2 = this.mListener;
          if (onLoadCompleteListener2 == null) {
              throw new IllegalStateException("No listener register");
          } else if (onLoadCompleteListener2 == onLoadCompleteListener) {
              this.mListener = null;
          } else {
              throw new IllegalArgumentException("Attempting to unregister the wrong listener");
          }
      }
  
      public void unregisterOnLoadCanceledListener(OnLoadCanceledListener<D> onLoadCanceledListener) {
          OnLoadCanceledListener<D> onLoadCanceledListener2 = this.mOnLoadCanceledListener;
          if (onLoadCanceledListener2 == null) {
              throw new IllegalStateException("No listener register");
          } else if (onLoadCanceledListener2 == onLoadCanceledListener) {
              this.mOnLoadCanceledListener = null;
          } else {
              throw new IllegalArgumentException("Attempting to unregister the wrong listener");
          }
      }
  }
  