package xyz.stream.api.database;

import a4.s;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import vf.t;
import xyz.stream.api.database.entity.MyListEntity;
import xyz.stream.utils.f0;

/* JADX INFO: loaded from: classes3.dex */
public abstract class n {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final ExecutorService f35835a = Executors.newSingleThreadExecutor();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static volatile t f35836b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static volatile boolean f35837c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static volatile boolean f35838d;

    public static t a() {
        if (f35836b != null) {
            return f35836b;
        }
        synchronized (n.class) {
            try {
                if (f35836b != null) {
                    return f35836b;
                }
                if (xyz.stream.utils.e.d().f36112a == null) {
                    return null;
                }
                if (q.a().f35845c != null) {
                    f35836b = q.a().f35845c;
                } else {
                    f35836b = q.a().e(xyz.stream.utils.e.d().f36112a).myListDao();
                }
                return f35836b;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public static boolean b(int i10) {
        t tVarA = a();
        if (tVarA == null) {
            return false;
        }
        c(tVarA);
        try {
            return ((Integer) f35835a.submit(new b(i10, 1, tVarA)).get()).intValue() > 0;
        } catch (Exception e10) {
            xyz.stream.utils.h.c(e10.getMessage());
            return false;
        }
    }

    public static void c(t tVar) {
        if (f35837c) {
            return;
        }
        synchronized (n.class) {
            if (f35837c) {
                return;
            }
            try {
                ExecutorService executorService = f35835a;
                if (((Integer) executorService.submit(new s(tVar, 4)).get()).intValue() == 0) {
                    ArrayList arrayListM = f0.o().m(MyListEntity.class, "sp_my_list");
                    if (!arrayListM.isEmpty()) {
                        executorService.execute(new ve.b(arrayListM, tVar, 21));
                    }
                }
            } catch (InterruptedException | ExecutionException e10) {
                xyz.stream.utils.h.c(e10.getMessage());
            }
            f35837c = true;
        }
    }

    public static MyListEntity d(MyListEntity myListEntity) {
        MyListEntity myListEntity2 = new MyListEntity();
        myListEntity2.videoId = myListEntity.getVideoId();
        myListEntity2.videoPic = myListEntity.getVideoPic();
        myListEntity2.backdropPath = myListEntity.getBackdropPath();
        myListEntity2.wideBackdropPath = myListEntity.getWideBackdropPath();
        myListEntity2.voteAverage = myListEntity.getVoteAverage();
        myListEntity2.sourceType = myListEntity.getSourceType();
        myListEntity2.title = myListEntity.getTitle();
        myListEntity2.updateTime = myListEntity.getUpdateTime();
        myListEntity2.roleId = myListEntity.getRoleId();
        return myListEntity2;
    }
}
