313 lines
13 KiB
Java
313 lines
13 KiB
Java
package o;
|
|
|
|
import android.app.Activity;
|
|
import android.app.Application;
|
|
import android.app.FragmentManager;
|
|
import android.app.FragmentTransaction;
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.os.Message;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.manager.RequestManagerFragment;
|
|
import com.bumptech.glide.manager.SupportRequestManagerFragment;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import o.oEA;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class tXR implements Handler.Callback {
|
|
private static final LWm h = new LWm() { // from class: o.tXR.3
|
|
@Override // o.tXR.LWm
|
|
public final YSJ a(Glide glide, zZV zzv, InterfaceC17301vdx interfaceC17301vdx, Context context) {
|
|
return new YSJ(glide, zzv, interfaceC17301vdx, context);
|
|
}
|
|
};
|
|
public final raU a;
|
|
public final C16601pdN b;
|
|
public final SQq e;
|
|
private volatile YSJ f;
|
|
private final Handler i;
|
|
private final LWm j;
|
|
private Map<FragmentManager, RequestManagerFragment> g = new HashMap();
|
|
private Map<yRS, SupportRequestManagerFragment> l = new HashMap();
|
|
public final nyh<View, Fragment> d = new nyh<>();
|
|
public final nyh<View, android.app.Fragment> c = new nyh<>();
|
|
private final Bundle n = new Bundle();
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface LWm {
|
|
YSJ a(Glide glide, zZV zzv, InterfaceC17301vdx interfaceC17301vdx, Context context);
|
|
}
|
|
|
|
public tXR(LWm lWm, C16601pdN c16601pdN) {
|
|
raU tnb;
|
|
lWm = lWm == null ? h : lWm;
|
|
this.j = lWm;
|
|
this.b = c16601pdN;
|
|
this.i = new Handler(Looper.getMainLooper(), this);
|
|
this.e = new SQq(lWm);
|
|
if (!sTL.d || !sTL.a) {
|
|
tnb = new Tnb();
|
|
} else if (c16601pdN.a.containsKey(oEA.IeS.class)) {
|
|
tnb = new SKD();
|
|
} else {
|
|
tnb = new XTO();
|
|
}
|
|
this.a = tnb;
|
|
}
|
|
|
|
private YSJ e(Context context) {
|
|
if (this.f == null) {
|
|
synchronized (this) {
|
|
if (this.f == null) {
|
|
this.f = this.j.a(Glide.a(context.getApplicationContext()), new LRK(), new C0701Moq(), context.getApplicationContext());
|
|
}
|
|
}
|
|
}
|
|
return this.f;
|
|
}
|
|
|
|
public final YSJ c(Context context) {
|
|
while (context != null) {
|
|
if (FKd.e() && !(context instanceof Application)) {
|
|
if (context instanceof FragmentActivity) {
|
|
return a((FragmentActivity) context);
|
|
}
|
|
if (context instanceof Activity) {
|
|
return Fz_((Activity) context);
|
|
}
|
|
if (context instanceof ContextWrapper) {
|
|
ContextWrapper contextWrapper = (ContextWrapper) context;
|
|
if (contextWrapper.getBaseContext().getApplicationContext() != null) {
|
|
context = contextWrapper.getBaseContext();
|
|
}
|
|
}
|
|
}
|
|
return e(context);
|
|
}
|
|
throw new IllegalArgumentException("You cannot start a load on a null Context");
|
|
}
|
|
|
|
public final YSJ a(FragmentActivity fragmentActivity) {
|
|
if (FKd.a()) {
|
|
return c(fragmentActivity.getApplicationContext());
|
|
}
|
|
if (!fragmentActivity.isDestroyed()) {
|
|
yRS supportFragmentManager = fragmentActivity.getSupportFragmentManager();
|
|
boolean a = a((Context) fragmentActivity);
|
|
if (this.b.a.containsKey(oEA.RVV.class)) {
|
|
Context applicationContext = fragmentActivity.getApplicationContext();
|
|
return this.e.d(applicationContext, Glide.a(applicationContext), fragmentActivity.getLifecycle(), fragmentActivity.getSupportFragmentManager(), a);
|
|
}
|
|
return c(fragmentActivity, supportFragmentManager, null, a);
|
|
}
|
|
throw new IllegalArgumentException("You cannot start a load for a destroyed activity");
|
|
}
|
|
|
|
@Deprecated
|
|
public final YSJ Fz_(Activity activity) {
|
|
if (FKd.a()) {
|
|
return c(activity.getApplicationContext());
|
|
}
|
|
if (activity instanceof FragmentActivity) {
|
|
return a((FragmentActivity) activity);
|
|
}
|
|
if (!activity.isDestroyed()) {
|
|
return Fx_(activity, activity.getFragmentManager(), null, a(activity));
|
|
}
|
|
throw new IllegalArgumentException("You cannot start a load for a destroyed activity");
|
|
}
|
|
|
|
public static void a(Collection<Fragment> collection, Map<View, Fragment> map) {
|
|
if (collection == null) {
|
|
return;
|
|
}
|
|
for (Fragment fragment : collection) {
|
|
if (fragment != null && fragment.getView() != null) {
|
|
map.put(fragment.getView(), fragment);
|
|
a(fragment.getChildFragmentManager().r(), map);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Deprecated
|
|
public final void Fw_(FragmentManager fragmentManager, nyh<View, android.app.Fragment> nyhVar) {
|
|
for (android.app.Fragment fragment : fragmentManager.getFragments()) {
|
|
if (fragment.getView() != null) {
|
|
nyhVar.put(fragment.getView(), fragment);
|
|
Fw_(fragment.getChildFragmentManager(), nyhVar);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static Activity Fv_(Context context) {
|
|
while (!(context instanceof Activity)) {
|
|
if (!(context instanceof ContextWrapper)) {
|
|
return null;
|
|
}
|
|
context = ((ContextWrapper) context).getBaseContext();
|
|
}
|
|
return (Activity) context;
|
|
}
|
|
|
|
public final RequestManagerFragment Fy_(FragmentManager fragmentManager, android.app.Fragment fragment) {
|
|
RequestManagerFragment requestManagerFragment = this.g.get(fragmentManager);
|
|
if (requestManagerFragment != null) {
|
|
return requestManagerFragment;
|
|
}
|
|
RequestManagerFragment requestManagerFragment2 = (RequestManagerFragment) fragmentManager.findFragmentByTag("com.bumptech.glide.manager");
|
|
if (requestManagerFragment2 == null) {
|
|
requestManagerFragment2 = new RequestManagerFragment();
|
|
requestManagerFragment2.a = fragment;
|
|
if (fragment != null && fragment.getActivity() != null) {
|
|
requestManagerFragment2.Fu_(fragment.getActivity());
|
|
}
|
|
this.g.put(fragmentManager, requestManagerFragment2);
|
|
fragmentManager.beginTransaction().add(requestManagerFragment2, "com.bumptech.glide.manager").commitAllowingStateLoss();
|
|
this.i.obtainMessage(1, fragmentManager).sendToTarget();
|
|
}
|
|
return requestManagerFragment2;
|
|
}
|
|
|
|
@Deprecated
|
|
public final YSJ Fx_(Context context, FragmentManager fragmentManager, android.app.Fragment fragment, boolean z) {
|
|
RequestManagerFragment Fy_ = Fy_(fragmentManager, fragment);
|
|
YSJ ysj = Fy_.e;
|
|
if (ysj == null) {
|
|
ysj = this.j.a(Glide.a(context), Fy_.d, Fy_.c, context);
|
|
if (z) {
|
|
ysj.a();
|
|
}
|
|
Fy_.e = ysj;
|
|
}
|
|
return ysj;
|
|
}
|
|
|
|
public final SupportRequestManagerFragment c(yRS yrs, Fragment fragment) {
|
|
yRS b;
|
|
SupportRequestManagerFragment supportRequestManagerFragment = this.l.get(yrs);
|
|
if (supportRequestManagerFragment != null) {
|
|
return supportRequestManagerFragment;
|
|
}
|
|
SupportRequestManagerFragment supportRequestManagerFragment2 = (SupportRequestManagerFragment) yrs.findFragmentByTag("com.bumptech.glide.manager");
|
|
if (supportRequestManagerFragment2 == null) {
|
|
supportRequestManagerFragment2 = new SupportRequestManagerFragment();
|
|
supportRequestManagerFragment2.d = fragment;
|
|
if (fragment != null && fragment.getContext() != null && (b = SupportRequestManagerFragment.b(fragment)) != null) {
|
|
supportRequestManagerFragment2.d(fragment.getContext(), b);
|
|
}
|
|
this.l.put(yrs, supportRequestManagerFragment2);
|
|
AbstractC13482fbE a = yrs.a();
|
|
a.b(0, supportRequestManagerFragment2, "com.bumptech.glide.manager", 1);
|
|
a.a();
|
|
this.i.obtainMessage(2, yrs).sendToTarget();
|
|
}
|
|
return supportRequestManagerFragment2;
|
|
}
|
|
|
|
public final YSJ c(Context context, yRS yrs, Fragment fragment, boolean z) {
|
|
SupportRequestManagerFragment c = c(yrs, fragment);
|
|
YSJ ysj = c.c;
|
|
if (ysj == null) {
|
|
ysj = this.j.a(Glide.a(context), c.b, c.a, context);
|
|
if (z) {
|
|
ysj.a();
|
|
}
|
|
c.c = ysj;
|
|
}
|
|
return ysj;
|
|
}
|
|
|
|
@Override // android.os.Handler.Callback
|
|
public final boolean handleMessage(Message message) {
|
|
boolean z = message.arg1 == 1;
|
|
int i = message.what;
|
|
if (i == 1) {
|
|
FragmentManager fragmentManager = (FragmentManager) message.obj;
|
|
RequestManagerFragment requestManagerFragment = this.g.get(fragmentManager);
|
|
RequestManagerFragment requestManagerFragment2 = (RequestManagerFragment) fragmentManager.findFragmentByTag("com.bumptech.glide.manager");
|
|
if (requestManagerFragment2 != requestManagerFragment) {
|
|
if (requestManagerFragment2 != null && requestManagerFragment2.e != null) {
|
|
StringBuilder sb = new StringBuilder("We've added two fragments with requests! Old: ");
|
|
sb.append(requestManagerFragment2);
|
|
sb.append(" New: ");
|
|
sb.append(requestManagerFragment);
|
|
throw new IllegalStateException(sb.toString());
|
|
}
|
|
if (z || fragmentManager.isDestroyed()) {
|
|
if (Log.isLoggable("RMRetriever", 5)) {
|
|
fragmentManager.isDestroyed();
|
|
}
|
|
requestManagerFragment.d.d();
|
|
} else {
|
|
FragmentTransaction add = fragmentManager.beginTransaction().add(requestManagerFragment, "com.bumptech.glide.manager");
|
|
if (requestManagerFragment2 != null) {
|
|
add.remove(requestManagerFragment2);
|
|
}
|
|
add.commitAllowingStateLoss();
|
|
this.i.obtainMessage(1, 1, 0, fragmentManager).sendToTarget();
|
|
}
|
|
}
|
|
this.g.remove(fragmentManager);
|
|
} else {
|
|
if (i != 2) {
|
|
return false;
|
|
}
|
|
yRS yrs = (yRS) message.obj;
|
|
SupportRequestManagerFragment supportRequestManagerFragment = this.l.get(yrs);
|
|
SupportRequestManagerFragment supportRequestManagerFragment2 = (SupportRequestManagerFragment) yrs.findFragmentByTag("com.bumptech.glide.manager");
|
|
if (supportRequestManagerFragment2 != supportRequestManagerFragment) {
|
|
if (supportRequestManagerFragment2 != null && supportRequestManagerFragment2.c != null) {
|
|
StringBuilder sb2 = new StringBuilder("We've added two fragments with requests! Old: ");
|
|
sb2.append(supportRequestManagerFragment2);
|
|
sb2.append(" New: ");
|
|
sb2.append(supportRequestManagerFragment);
|
|
throw new IllegalStateException(sb2.toString());
|
|
}
|
|
if (z || yrs.B()) {
|
|
yrs.B();
|
|
supportRequestManagerFragment.b.d();
|
|
} else {
|
|
AbstractC13482fbE a = yrs.a();
|
|
a.b(0, supportRequestManagerFragment, "com.bumptech.glide.manager", 1);
|
|
if (supportRequestManagerFragment2 != null) {
|
|
a.e(supportRequestManagerFragment2);
|
|
}
|
|
a.e();
|
|
this.i.obtainMessage(2, 1, 0, yrs).sendToTarget();
|
|
}
|
|
}
|
|
this.l.remove(yrs);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private static boolean a(Context context) {
|
|
Activity activity;
|
|
if (context instanceof Activity) {
|
|
activity = (Activity) context;
|
|
} else {
|
|
if (context instanceof ContextWrapper) {
|
|
Context baseContext = ((ContextWrapper) context).getBaseContext();
|
|
while (!(baseContext instanceof Activity)) {
|
|
if (baseContext instanceof ContextWrapper) {
|
|
baseContext = ((ContextWrapper) baseContext).getBaseContext();
|
|
}
|
|
}
|
|
activity = (Activity) baseContext;
|
|
}
|
|
activity = null;
|
|
break;
|
|
}
|
|
return activity == null || !activity.isFinishing();
|
|
}
|
|
}
|