content: package io.agora.baselibrary.base;
  
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.fragment.app.DialogFragment;
  import androidx.lifecycle.Lifecycle;
  
  import com.trello.lifecycle2.android.lifecycle.AndroidLifecycle;
  import com.trello.rxlifecycle3.LifecycleProvider;
  
  import pub.devrel.easypermissions.EasyPermissions;
  import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks;
  
  /**
   * 基础
   *
   * @author chenhengfei@agora.io
   */
  public abstract class BaseDialogFragment extends DialogFragment {
  
      protected final LifecycleProvider<Lifecycle.Event> mLifecycleProvider = AndroidLifecycle.createLifecycleProvider(this);
  
      @Override
      public void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Bundle bundle = getArguments();
          if (bundle != null) {
              iniBundle(bundle);
          }
      }
  
      @Nullable
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          return inflater.inflate(getLayoutId(), container);
      }
  
      @Override
      public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
          iniView();
      }
  
      @Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          iniListener();
          iniData();
      }
  
      public abstract void iniBundle(@NonNull Bundle bundle);
  
      public abstract int getLayoutId();
  
      public abstract void iniView();
  
      public abstract void iniListener();
  
      public abstract void iniData();
  
      @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                             @NonNull int[] grantResults) {
          super.onRequestPermissionsResult(requestCode, permissions, grantResults);
          if (this instanceof PermissionCallbacks) {
              EasyPermissions
                      .onRequestPermissionsResult(requestCode, permissions, grantResults, this);
          }
      }
  
      public boolean isShowing() {
          return getDialog() != null && getDialog().isShowing();
      }
  }