127 lines
4.2 KiB
Java
127 lines
4.2 KiB
Java
package androidx.fragment.app;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentSender;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.core.app.ActivityCompat;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.core.util.Preconditions;
|
|
import java.io.FileDescriptor;
|
|
import java.io.PrintWriter;
|
|
public abstract class FragmentHostCallback<E> extends FragmentContainer {
|
|
@Nullable
|
|
private final Activity mActivity;
|
|
@NonNull
|
|
private final Context mContext;
|
|
public final FragmentManager mFragmentManager;
|
|
@NonNull
|
|
private final Handler mHandler;
|
|
private final int mWindowAnimations;
|
|
|
|
public FragmentHostCallback(@Nullable Activity activity, @NonNull Context context, @NonNull Handler handler, int i) {
|
|
this.mFragmentManager = new FragmentManagerImpl();
|
|
this.mActivity = activity;
|
|
this.mContext = (Context) Preconditions.checkNotNull(context, "context == null");
|
|
this.mHandler = (Handler) Preconditions.checkNotNull(handler, "handler == null");
|
|
this.mWindowAnimations = i;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public FragmentHostCallback(@NonNull Context context, @NonNull Handler handler, int i) {
|
|
this(context instanceof Activity ? (Activity) context : null, context, handler, i);
|
|
}
|
|
|
|
public FragmentHostCallback(@NonNull FragmentActivity fragmentActivity) {
|
|
this(fragmentActivity, fragmentActivity, new Handler(), 0);
|
|
}
|
|
|
|
@Nullable
|
|
public Activity getActivity() {
|
|
return this.mActivity;
|
|
}
|
|
|
|
@NonNull
|
|
public Context getContext() {
|
|
return this.mContext;
|
|
}
|
|
|
|
@NonNull
|
|
public Handler getHandler() {
|
|
return this.mHandler;
|
|
}
|
|
|
|
public void onDump(@NonNull String str, @Nullable FileDescriptor fileDescriptor, @NonNull PrintWriter printWriter, @Nullable String[] strArr) {
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentContainer
|
|
@Nullable
|
|
public View onFindViewById(int i) {
|
|
return null;
|
|
}
|
|
|
|
@Nullable
|
|
public abstract E onGetHost();
|
|
|
|
@NonNull
|
|
public LayoutInflater onGetLayoutInflater() {
|
|
return LayoutInflater.from(this.mContext);
|
|
}
|
|
|
|
public int onGetWindowAnimations() {
|
|
return this.mWindowAnimations;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentContainer
|
|
public boolean onHasView() {
|
|
return true;
|
|
}
|
|
|
|
public boolean onHasWindowAnimations() {
|
|
return true;
|
|
}
|
|
|
|
@Deprecated
|
|
public void onRequestPermissionsFromFragment(@NonNull Fragment fragment, @NonNull String[] strArr, int i) {
|
|
}
|
|
|
|
public boolean onShouldSaveFragmentState(@NonNull Fragment fragment) {
|
|
return true;
|
|
}
|
|
|
|
public boolean onShouldShowRequestPermissionRationale(@NonNull String str) {
|
|
return false;
|
|
}
|
|
|
|
public void onStartActivityFromFragment(@NonNull Fragment fragment, @SuppressLint({"UnknownNullness"}) Intent intent, int i) {
|
|
onStartActivityFromFragment(fragment, intent, i, null);
|
|
}
|
|
|
|
public void onStartActivityFromFragment(@NonNull Fragment fragment, @SuppressLint({"UnknownNullness"}) Intent intent, int i, @Nullable Bundle bundle) {
|
|
if (i == -1) {
|
|
ContextCompat.startActivity(this.mContext, intent, bundle);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Starting activity with a requestCode requires a FragmentActivity host");
|
|
}
|
|
|
|
@Deprecated
|
|
public void onStartIntentSenderFromFragment(@NonNull Fragment fragment, @SuppressLint({"UnknownNullness"}) IntentSender intentSender, int i, @Nullable Intent intent, int i2, int i3, int i4, @Nullable Bundle bundle) throws IntentSender.SendIntentException {
|
|
if (i == -1) {
|
|
ActivityCompat.startIntentSenderForResult(this.mActivity, intentSender, i, intent, i2, i3, i4, bundle);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Starting intent sender with a requestCode requires a FragmentActivity host");
|
|
}
|
|
|
|
public void onSupportInvalidateOptionsMenu() {
|
|
}
|
|
}
|