package com.ss.android.ugc.aweme.tools.music.avoidonresult;

import X.FX4;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import kotlin.h.b.n;

public final class AvoidOnResultFragment extends Fragment {
    public final HashMap<Integer, List<FX4>> LIZ = new HashMap<>();
    public HashMap LIZIZ;

    static {
        Covode.recordClassIndex(119953);
    }

    public final /* synthetic */ void onDestroyView() {
        AvoidOnResultFragment.super.onDestroyView();
        HashMap hashMap = this.LIZIZ;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final void onDestroy() {
        AvoidOnResultFragment.super.onDestroy();
        Set<Integer> keySet = this.LIZ.keySet();
        n.LIZIZ(keySet, "");
        Iterator<T> it = keySet.iterator();
        while (it.hasNext()) {
            this.LIZ.remove(it.next());
        }
    }

    public final void onCreate(Bundle bundle) {
        AvoidOnResultFragment.super.onCreate(bundle);
        setRetainInstance(true);
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        AvoidOnResultFragment.super.onActivityResult(i, i2, intent);
        List list = this.LIZ.get(Integer.valueOf(i));
        if (list == null || list.isEmpty()) {
            this.LIZ.remove(Integer.valueOf(i));
            return;
        }
        FX4 fx4 = (FX4) list.remove(list.size() - 1);
        if (list.isEmpty()) {
            this.LIZ.remove(Integer.valueOf(i));
        }
        if (fx4 != null) {
            fx4.LIZ(i2, intent);
        }
    }
}
