package com.google.android.gms.dynamic; import android.R; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.dynamic.LifecycleDelegate; import java.util.LinkedList; /* loaded from: classes2.dex */ public abstract class DeferredLifecycleHelper { private T zaa; private Bundle zab; private LinkedList zac; private final OnDelegateCreatedListener zad = new zaa(this); public static void showGooglePlayUnavailableMessage(FrameLayout frameLayout) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); Context context = frameLayout.getContext(); int isGooglePlayServicesAvailable = googleApiAvailability.isGooglePlayServicesAvailable(context); String zad = com.google.android.gms.common.internal.zac.zad(context, isGooglePlayServicesAvailable); String zac = com.google.android.gms.common.internal.zac.zac(context, isGooglePlayServicesAvailable); LinearLayout linearLayout = new LinearLayout(frameLayout.getContext()); linearLayout.setOrientation(1); linearLayout.setLayoutParams(new FrameLayout.LayoutParams(-2, -2)); frameLayout.addView(linearLayout); TextView textView = new TextView(frameLayout.getContext()); textView.setLayoutParams(new FrameLayout.LayoutParams(-2, -2)); textView.setText(zad); linearLayout.addView(textView); Intent errorResolutionIntent = googleApiAvailability.getErrorResolutionIntent(context, isGooglePlayServicesAvailable, null); if (errorResolutionIntent != null) { Button button = new Button(context); button.setId(R.id.button1); button.setLayoutParams(new FrameLayout.LayoutParams(-2, -2)); button.setText(zac); linearLayout.addView(button); button.setOnClickListener(new zae(context, errorResolutionIntent)); } } private final void zae(int i) { while (!this.zac.isEmpty() && this.zac.getLast().zaa() >= i) { this.zac.removeLast(); } } private final void zaf(Bundle bundle, zah zahVar) { T t = this.zaa; if (t != null) { zahVar.zab(t); return; } if (this.zac == null) { this.zac = new LinkedList<>(); } this.zac.add(zahVar); if (bundle != null) { Bundle bundle2 = this.zab; if (bundle2 == null) { this.zab = (Bundle) bundle.clone(); } else { bundle2.putAll(bundle); } } createDelegate(this.zad); } protected abstract void createDelegate(OnDelegateCreatedListener onDelegateCreatedListener); protected void handleGooglePlayUnavailable(FrameLayout frameLayout) { showGooglePlayUnavailableMessage(frameLayout); } public void onCreate(Bundle bundle) { zaf(bundle, new zac(this, bundle)); } public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { FrameLayout frameLayout = new FrameLayout(layoutInflater.getContext()); zaf(bundle, new zad(this, frameLayout, layoutInflater, viewGroup, bundle)); if (this.zaa == null) { handleGooglePlayUnavailable(frameLayout); } return frameLayout; } public void onDestroy() { T t = this.zaa; if (t != null) { t.onDestroy(); } else { zae(1); } } public void onDestroyView() { T t = this.zaa; if (t != null) { t.onDestroyView(); } else { zae(2); } } public void onInflate(Activity activity, Bundle bundle, Bundle bundle2) { zaf(bundle2, new zab(this, activity, bundle, bundle2)); } public void onLowMemory() { T t = this.zaa; if (t != null) { t.onLowMemory(); } } public void onPause() { T t = this.zaa; if (t != null) { t.onPause(); } else { zae(5); } } public void onResume() { zaf(null, new zag(this)); } public void onSaveInstanceState(Bundle bundle) { T t = this.zaa; if (t != null) { t.onSaveInstanceState(bundle); return; } Bundle bundle2 = this.zab; if (bundle2 != null) { bundle.putAll(bundle2); } } public void onStart() { zaf(null, new zaf(this)); } public void onStop() { T t = this.zaa; if (t != null) { t.onStop(); } else { zae(4); } } public T getDelegate() { return this.zaa; } }