content: package androidx.fragment.app;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.view.View;
  import androidx.fragment.app.FragmentManager;
  import java.util.Iterator;
  import java.util.concurrent.CopyOnWriteArrayList;
  
  class FragmentLifecycleCallbacksDispatcher {
      private final FragmentManager mFragmentManager;
      private final CopyOnWriteArrayList<FragmentLifecycleCallbacksHolder> mLifecycleCallbacks = new CopyOnWriteArrayList<>();
  
      private static final class FragmentLifecycleCallbacksHolder {
          final FragmentManager.FragmentLifecycleCallbacks mCallback;
          final boolean mRecursive;
  
          FragmentLifecycleCallbacksHolder(FragmentManager.FragmentLifecycleCallbacks callback, boolean recursive) {
              this.mCallback = callback;
              this.mRecursive = recursive;
          }
      }
  
      FragmentLifecycleCallbacksDispatcher(FragmentManager fragmentManager) {
          this.mFragmentManager = fragmentManager;
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentActivityCreated(Fragment f, Bundle savedInstanceState, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentActivityCreated(f, savedInstanceState, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentActivityCreated(this.mFragmentManager, f, savedInstanceState);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentAttached(Fragment f, boolean onlyRecursive) {
          Context context = this.mFragmentManager.getHost().getContext();
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentAttached(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentAttached(this.mFragmentManager, f, context);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentCreated(Fragment f, Bundle savedInstanceState, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentCreated(f, savedInstanceState, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentCreated(this.mFragmentManager, f, savedInstanceState);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentDestroyed(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentDestroyed(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentDestroyed(this.mFragmentManager, f);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentDetached(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentDetached(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentDetached(this.mFragmentManager, f);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentPaused(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentPaused(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentPaused(this.mFragmentManager, f);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentPreAttached(Fragment f, boolean onlyRecursive) {
          Context context = this.mFragmentManager.getHost().getContext();
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentPreAttached(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentPreAttached(this.mFragmentManager, f, context);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentPreCreated(Fragment f, Bundle savedInstanceState, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentPreCreated(f, savedInstanceState, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentPreCreated(this.mFragmentManager, f, savedInstanceState);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentResumed(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentResumed(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentResumed(this.mFragmentManager, f);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentSaveInstanceState(Fragment f, Bundle outState, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentSaveInstanceState(f, outState, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentSaveInstanceState(this.mFragmentManager, f, outState);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentStarted(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentStarted(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentStarted(this.mFragmentManager, f);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentStopped(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentStopped(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentStopped(this.mFragmentManager, f);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentViewCreated(Fragment f, View v, Bundle savedInstanceState, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentViewCreated(f, v, savedInstanceState, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentViewCreated(this.mFragmentManager, f, v, savedInstanceState);
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public void dispatchOnFragmentViewDestroyed(Fragment f, boolean onlyRecursive) {
          Fragment parent = this.mFragmentManager.getParent();
          if (parent != null) {
              parent.getParentFragmentManager().getLifecycleCallbacksDispatcher().dispatchOnFragmentViewDestroyed(f, true);
          }
          Iterator<FragmentLifecycleCallbacksHolder> it = this.mLifecycleCallbacks.iterator();
          while (it.hasNext()) {
              FragmentLifecycleCallbacksHolder next = it.next();
              if (!onlyRecursive || next.mRecursive) {
                  next.mCallback.onFragmentViewDestroyed(this.mFragmentManager, f);
              }
          }
      }
  
      public void registerFragmentLifecycleCallbacks(FragmentManager.FragmentLifecycleCallbacks cb, boolean recursive) {
          this.mLifecycleCallbacks.add(new FragmentLifecycleCallbacksHolder(cb, recursive));
      }
  
      public void unregisterFragmentLifecycleCallbacks(FragmentManager.FragmentLifecycleCallbacks cb) {
          synchronized (this.mLifecycleCallbacks) {
              int i = 0;
              int size = this.mLifecycleCallbacks.size();
              while (true) {
                  if (i >= size) {
                      break;
                  } else if (this.mLifecycleCallbacks.get(i).mCallback == cb) {
                      this.mLifecycleCallbacks.remove(i);
                      break;
                  } else {
                      i++;
                  }
              }
          }
      }
  }
  