package ඓ.㸾.K;

import android.app.Activity;
import android.app.FragmentManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.fragment.app.FragmentActivity;
import java.util.HashMap;
import java.util.Map;
import ῲ.Ԕ.K.AbstractC1531;

/* renamed from: ඓ.㸾.K.ؿ  reason: contains not printable characters */
/* compiled from: RequestManagerRetriever */
public class C1367 implements Handler.Callback {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Map<FragmentManager, FragmentC1382> f5223 = new HashMap();

    /* renamed from: ῲ  reason: contains not printable characters */
    public Handler f5224 = new Handler(Looper.getMainLooper(), this);

    /* renamed from: K  reason: contains not printable characters */
    public String f5225 = C1387.class.getName();

    /* renamed from: 㸾  reason: contains not printable characters */
    public final Map<AbstractC1531, C1383> f5226 = new HashMap();

    /* renamed from: ඓ.㸾.K.ؿ$ῲ  reason: contains not printable characters */
    /* compiled from: RequestManagerRetriever */
    public static class C1368 {

        /* renamed from: K  reason: contains not printable characters */
        public static final C1367 f5227 = new C1367(null);
    }

    public /* synthetic */ C1367(C1369 k) {
    }

    /* renamed from: K  reason: contains not printable characters */
    public static C1367 m3559() {
        return C1368.f5227;
    }

    public boolean handleMessage(Message message) {
        int i = message.what;
        if (i == 1) {
            this.f5223.remove((FragmentManager) message.obj);
            return true;
        } else if (i != 2) {
            return false;
        } else {
            this.f5226.remove((AbstractC1531) message.obj);
            return true;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1387 m3560(Activity activity) {
        if (activity != null) {
            String str = this.f5225 + System.identityHashCode(activity);
            if (activity instanceof FragmentActivity) {
                AbstractC1531 supportFragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
                C1383 r2 = (C1383) supportFragmentManager.m3914(str);
                if (r2 == null && (r2 = this.f5226.get(supportFragmentManager)) == null) {
                    r2 = new C1383();
                    this.f5226.put(supportFragmentManager, r2);
                    supportFragmentManager.m3915().m4100(r2, str).m4091();
                    this.f5224.obtainMessage(2, supportFragmentManager).sendToTarget();
                }
                return r2.m3574(activity);
            }
            FragmentManager fragmentManager = activity.getFragmentManager();
            FragmentC1382 r22 = (FragmentC1382) fragmentManager.findFragmentByTag(str);
            if (r22 == null && (r22 = this.f5223.get(fragmentManager)) == null) {
                r22 = new FragmentC1382();
                this.f5223.put(fragmentManager, r22);
                fragmentManager.beginTransaction().add(r22, str).commitAllowingStateLoss();
                this.f5224.obtainMessage(1, fragmentManager).sendToTarget();
            }
            if (r22.f5288 == null) {
                r22.f5288 = new RunnableC1384(activity);
            }
            return r22.f5288.m3578();
        }
        throw new NullPointerException("activity is null");
    }
}
