package bf;

import ie.e0;
import java.util.ArrayList;
import java.util.List;
import t4.f;
import xyz.stream.download.DownloadFile;
import xyz.stream.download.DownloadManager;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class b implements Runnable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f4852a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ d f4853b;

    public /* synthetic */ b(d dVar, int i10) {
        this.f4852a = i10;
        this.f4853b = dVar;
    }

    @Override // java.lang.Runnable
    public final void run() {
        int i10 = this.f4852a;
        d dVar = this.f4853b;
        switch (i10) {
            case 0:
                int i11 = d.I0;
                dVar.getClass();
                List<DownloadFile> listQueryDownloadTask = DownloadManager.getInstance().queryDownloadTask(false);
                ArrayList arrayList = dVar.F0;
                arrayList.clear();
                ArrayList<DownloadFile> arrayList2 = dVar.E0;
                arrayList2.clear();
                if (listQueryDownloadTask != null && !listQueryDownloadTask.isEmpty()) {
                    arrayList2.addAll(listQueryDownloadTask);
                    for (DownloadFile downloadFile : arrayList2) {
                        if (downloadFile.getSourceType().intValue() == 2) {
                            ArrayList arrayList3 = new ArrayList();
                            arrayList3.add(downloadFile);
                            arrayList.add(arrayList3);
                        } else if (downloadFile.getSourceType().intValue() == 3) {
                            Object obj = f.x(arrayList).e(new com.google.gson.internal.a(downloadFile, 21)).g().f32947a;
                            if (obj == null) {
                                obj = null;
                            }
                            List list = (List) obj;
                            if (list == null || arrayList.indexOf(list) == -1) {
                                ArrayList arrayList4 = new ArrayList();
                                arrayList4.add(downloadFile);
                                arrayList.add(arrayList4);
                            } else {
                                list.add(downloadFile);
                            }
                        }
                    }
                }
                dVar.requireActivity().runOnUiThread(new b(dVar, 1));
                break;
            default:
                int i12 = d.I0;
                dVar.getClass();
                UiUtils.dismissProgressDialog();
                if (dVar.F0.isEmpty()) {
                    ((e0) dVar.binding).f26796c.setVisibility(0);
                } else {
                    ((e0) dVar.binding).f26796c.setVisibility(8);
                    dVar.H0.notifyDataSetChanged();
                }
                break;
        }
    }
}
