a.smali

.class public final Llife/knowledge4/videotrimmer/utils/a;
.super Ljava/lang/Object;
.source "SourceFile"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Llife/knowledge4/videotrimmer/utils/a$a;
    }
.end annotation


# static fields
.field public static final a:Ljava/util/concurrent/ScheduledExecutorService;

.field public static b:Ljava/util/concurrent/ScheduledExecutorService;

.field public static final c:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Llife/knowledge4/videotrimmer/utils/a$a;",
            ">;"
        }
    .end annotation
.end field

.field public static final d:Ljava/lang/ThreadLocal;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public static constructor <clinit>()V
    .registers 3

    .line 1
    invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/Runtime;->availableProcessors()I

    move-result v0

    mul-int/lit8 v0, v0, 0x2

    .line 2
    sget-object v1, Lcom/shopee/app/asm/fix/threadpool/config/a;->a:Lcom/shopee/app/asm/fix/threadpool/config/a;

    invoke-virtual {v1}, Lcom/shopee/app/asm/fix/threadpool/config/a;->f()Z

    move-result v1

    if-eqz v1, :cond_19

    .line 3
    sget-object v1, Lcom/shopee/app/asm/fix/threadpool/pool/d;->a:Lcom/shopee/app/asm/fix/threadpool/pool/d;

    invoke-virtual {v1, v0}, Lcom/shopee/app/asm/fix/threadpool/pool/d;->e(I)Ljava/util/concurrent/ScheduledExecutorService;

    move-result-object v0

    goto :goto_2f

    .line 4
    :cond_19
    invoke-static {}, Lcom/garena/android/appkit/logging/a;->C()Z

    move-result v1

    if-eqz v1, :cond_2b

    const/4 v1, 0x0

    const-string v2, "life/knowledge4/videotrimmer/utils/BackgroundExecutor"

    .line 5
    invoke-static {v1, v2}, Lcom/garena/android/appkit/logging/a;->t0(Ljava/util/concurrent/ThreadFactory;Ljava/lang/String;)Ljava/util/concurrent/ThreadFactory;

    move-result-object v1

    invoke-static {v0, v1}, Ljava/util/concurrent/Executors;->newScheduledThreadPool(ILjava/util/concurrent/ThreadFactory;)Ljava/util/concurrent/ScheduledExecutorService;

    move-result-object v0

    goto :goto_2f

    .line 6
    :cond_2b
    invoke-static {v0}, Ljava/util/concurrent/Executors;->newScheduledThreadPool(I)Ljava/util/concurrent/ScheduledExecutorService;

    move-result-object v0

    .line 7
    :goto_2f
    sput-object v0, Llife/knowledge4/videotrimmer/utils/a;->a:Ljava/util/concurrent/ScheduledExecutorService;

    .line 8
    sput-object v0, Llife/knowledge4/videotrimmer/utils/a;->b:Ljava/util/concurrent/ScheduledExecutorService;

    .line 9
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    sput-object v0, Llife/knowledge4/videotrimmer/utils/a;->c:Ljava/util/ArrayList;

    .line 10
    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Llife/knowledge4/videotrimmer/utils/a;->d:Ljava/lang/ThreadLocal;

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static a(Ljava/lang/Runnable;J)Ljava/util/concurrent/Future;
    .registers 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/Runnable;",
            "J)",
            "Ljava/util/concurrent/Future<",
            "*>;"
        }
    .end annotation

    const-wide/16 v0, 0x0

    cmp-long v2, p1, v0

    if-lez v2, :cond_1b

    .line 1
    sget-object v0, Llife/knowledge4/videotrimmer/utils/a;->b:Ljava/util/concurrent/ScheduledExecutorService;

    instance-of v1, v0, Ljava/util/concurrent/ScheduledExecutorService;

    if-eqz v1, :cond_13

    .line 2
    sget-object v1, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;

    invoke-interface {v0, p0, p1, p2, v1}, Ljava/util/concurrent/ScheduledExecutorService;->schedule(Ljava/lang/Runnable;JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;

    move-result-object p0

    goto :goto_7b

    .line 3
    :cond_13
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string p1, "The executor set does not support scheduling"

    invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0

    .line 4
    :cond_1b
    sget-object p1, Llife/knowledge4/videotrimmer/utils/a;->b:Ljava/util/concurrent/ScheduledExecutorService;

    instance-of p2, p1, Ljava/util/concurrent/ExecutorService;

    if-eqz p2, :cond_26

    .line 5
    invoke-interface {p1, p0}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;

    move-result-object p0

    goto :goto_7b

    .line 6
    :cond_26
    invoke-static {}, Lcom/shopee/app/asm/anr/threadpool/c;->b()Z

    move-result p2

    if-eqz p2, :cond_60

    invoke-static {}, Lcom/shopee/app/asm/anr/threadpool/c;->a()Z

    move-result p2

    if-eqz p2, :cond_60

    .line 7
    :try_start_32
    sget-object p2, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;

    .line 8
    sget-object p2, Lcom/shopee/app/asm/anr/threadpool/c;->b:Landroid/os/Handler;

    new-instance v0, Lcom/shopee/app/asm/anr/threadpool/a$b;

    invoke-direct {v0, p1, p0}, Lcom/shopee/app/asm/anr/threadpool/a$b;-><init>(Ljava/util/concurrent/Executor;Ljava/lang/Runnable;)V

    invoke-virtual {p2, v0}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
    :try_end_3e
    .catchall {:try_start_32 .. :try_end_3e} :catchall_3f

    goto :goto_7a

    :catchall_3f
    move-exception p2

    .line 9
    invoke-virtual {p2}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    sget-object p2, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;

    .line 10
    :try_start_45
    invoke-static {p0, p1}, Lcom/shopee/app/asm/anr/threadpool/a;->a(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result p2

    if-eqz p2, :cond_51

    .line 11
    sget-object p1, Lcom/shopee/app/asm/fix/threadpool/global/i;->e:Lcom/shopee/app/asm/fix/threadpool/global/j;

    .line 12
    invoke-virtual {p1, p0}, Lcom/shopee/app/asm/anr/threadpool/b;->execute(Ljava/lang/Runnable;)V

    goto :goto_7a

    .line 13
    :cond_51
    invoke-interface {p1, p0}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
    :try_end_54
    .catchall {:try_start_45 .. :try_end_54} :catchall_55

    goto :goto_7a

    :catchall_55
    move-exception p0

    .line 14
    sget-object p1, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;

    .line 15
    invoke-static {}, Lcom/shopee/app/apm/c;->d()Lcom/shopee/app/apm/nonfatal/a;

    move-result-object p1

    invoke-virtual {p1, p0}, Lcom/shopee/app/apm/nonfatal/a;->c(Ljava/lang/Throwable;)V

    goto :goto_7a

    .line 16
    :cond_60
    :try_start_60
    invoke-static {p0, p1}, Lcom/shopee/app/asm/anr/threadpool/a;->a(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result p2

    if-eqz p2, :cond_6c

    .line 17
    sget-object p1, Lcom/shopee/app/asm/fix/threadpool/global/i;->e:Lcom/shopee/app/asm/fix/threadpool/global/j;

    .line 18
    invoke-virtual {p1, p0}, Lcom/shopee/app/asm/anr/threadpool/b;->execute(Ljava/lang/Runnable;)V

    goto :goto_7a

    .line 19
    :cond_6c
    invoke-interface {p1, p0}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
    :try_end_6f
    .catchall {:try_start_60 .. :try_end_6f} :catchall_70

    goto :goto_7a

    :catchall_70
    move-exception p0

    .line 20
    sget-object p1, Lcom/shopee/app/asm/anr/threadpool/c;->a:Landroid/os/HandlerThread;

    .line 21
    invoke-static {}, Lcom/shopee/app/apm/c;->d()Lcom/shopee/app/apm/nonfatal/a;

    move-result-object p1

    invoke-virtual {p1, p0}, Lcom/shopee/app/apm/nonfatal/a;->c(Ljava/lang/Throwable;)V

    :goto_7a
    const/4 p0, 0x0

    :goto_7b
    return-object p0
.end method

.method public static declared-synchronized b(Llife/knowledge4/videotrimmer/utils/a$a;)V
    .registers 7

    const-class v0, Llife/knowledge4/videotrimmer/utils/a;

    monitor-enter v0

    .line 1
    :try_start_3
    iget-object v1, p0, Llife/knowledge4/videotrimmer/utils/a$a;->d:Ljava/lang/String;

    const/4 v2, 0x1

    if-eqz v1, :cond_2e

    .line 2
    sget-object v3, Llife/knowledge4/videotrimmer/utils/a;->c:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v3

    :cond_e
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_28

    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Llife/knowledge4/videotrimmer/utils/a$a;

    .line 3
    iget-boolean v5, v4, Llife/knowledge4/videotrimmer/utils/a$a;->e:Z

    if-eqz v5, :cond_e

    .line 4
    iget-object v4, v4, Llife/knowledge4/videotrimmer/utils/a$a;->d:Ljava/lang/String;

    .line 5
    invoke-virtual {v1, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v4

    if-eqz v4, :cond_e

    const/4 v1, 0x1

    goto :goto_29

    :cond_28
    const/4 v1, 0x0

    :goto_29
    if-nez v1, :cond_2c

    goto :goto_2e

    :cond_2c
    const/4 v1, 0x0

    goto :goto_36

    .line 6
    :cond_2e
    :goto_2e
    iput-boolean v2, p0, Llife/knowledge4/videotrimmer/utils/a$a;->e:Z

    .line 7
    iget-wide v1, p0, Llife/knowledge4/videotrimmer/utils/a$a;->b:J

    .line 8
    invoke-static {p0, v1, v2}, Llife/knowledge4/videotrimmer/utils/a;->a(Ljava/lang/Runnable;J)Ljava/util/concurrent/Future;

    move-result-object v1

    .line 9
    :goto_36
    iget-object v2, p0, Llife/knowledge4/videotrimmer/utils/a$a;->a:Ljava/lang/String;

    if-nez v2, :cond_3e

    .line 10
    iget-object v2, p0, Llife/knowledge4/videotrimmer/utils/a$a;->d:Ljava/lang/String;

    if-eqz v2, :cond_4d

    .line 11
    :cond_3e
    iget-object v2, p0, Llife/knowledge4/videotrimmer/utils/a$a;->g:Ljava/util/concurrent/atomic/AtomicBoolean;

    .line 12
    invoke-virtual {v2}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v2

    if-nez v2, :cond_4d

    .line 13
    iput-object v1, p0, Llife/knowledge4/videotrimmer/utils/a$a;->f:Ljava/util/concurrent/Future;

    .line 14
    sget-object v1, Llife/knowledge4/videotrimmer/utils/a;->c:Ljava/util/ArrayList;

    invoke-virtual {v1, p0}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_4d
    .catchall {:try_start_3 .. :try_end_4d} :catchall_4f

    .line 15
    :cond_4d
    monitor-exit v0

    return-void

    :catchall_4f
    move-exception p0

    monitor-exit v0

    throw p0
.end method