mf.java 8.36 KB
import android.app.Activity;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.gms.common.internal.zzac;
import com.google.android.gms.internal.zzabe;
import com.google.android.gms.internal.zzabf;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.RuntimeExecutionException;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskExecutors;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executor;

public final class mf<TResult>
  extends Task<TResult>
{
  private final Object a = new Object();
  private final me<TResult> b = new me();
  private boolean c;
  private TResult d;
  private Exception e;
  
  private void a()
  {
    zzac.zza(this.c, "Task is not yet complete");
  }
  
  private void b()
  {
    if (!this.c) {}
    for (boolean bool = true;; bool = false)
    {
      zzac.zza(bool, "Task is already complete");
      return;
    }
  }
  
  private void c()
  {
    synchronized (this.a)
    {
      if (!this.c) {
        return;
      }
      this.b.a(this);
      return;
    }
  }
  
  public final void a(@NonNull Exception paramException)
  {
    zzac.zzb(paramException, "Exception must not be null");
    synchronized (this.a)
    {
      b();
      this.c = true;
      this.e = paramException;
      this.b.a(this);
      return;
    }
  }
  
  public final void a(TResult paramTResult)
  {
    synchronized (this.a)
    {
      b();
      this.c = true;
      this.d = paramTResult;
      this.b.a(this);
      return;
    }
  }
  
  @NonNull
  public final Task<TResult> addOnCompleteListener(@NonNull Activity paramActivity, @NonNull OnCompleteListener<TResult> paramOnCompleteListener)
  {
    paramOnCompleteListener = new ma(TaskExecutors.MAIN_THREAD, paramOnCompleteListener);
    this.b.a(paramOnCompleteListener);
    mf.a.a(paramActivity).a(paramOnCompleteListener);
    c();
    return this;
  }
  
  @NonNull
  public final Task<TResult> addOnCompleteListener(@NonNull OnCompleteListener<TResult> paramOnCompleteListener)
  {
    return addOnCompleteListener(TaskExecutors.MAIN_THREAD, paramOnCompleteListener);
  }
  
  @NonNull
  public final Task<TResult> addOnCompleteListener(@NonNull Executor paramExecutor, @NonNull OnCompleteListener<TResult> paramOnCompleteListener)
  {
    this.b.a(new ma(paramExecutor, paramOnCompleteListener));
    c();
    return this;
  }
  
  @NonNull
  public final Task<TResult> addOnFailureListener(@NonNull Activity paramActivity, @NonNull OnFailureListener paramOnFailureListener)
  {
    paramOnFailureListener = new mb(TaskExecutors.MAIN_THREAD, paramOnFailureListener);
    this.b.a(paramOnFailureListener);
    mf.a.a(paramActivity).a(paramOnFailureListener);
    c();
    return this;
  }
  
  @NonNull
  public final Task<TResult> addOnFailureListener(@NonNull OnFailureListener paramOnFailureListener)
  {
    return addOnFailureListener(TaskExecutors.MAIN_THREAD, paramOnFailureListener);
  }
  
  @NonNull
  public final Task<TResult> addOnFailureListener(@NonNull Executor paramExecutor, @NonNull OnFailureListener paramOnFailureListener)
  {
    this.b.a(new mb(paramExecutor, paramOnFailureListener));
    c();
    return this;
  }
  
  @NonNull
  public final Task<TResult> addOnSuccessListener(@NonNull Activity paramActivity, @NonNull OnSuccessListener<? super TResult> paramOnSuccessListener)
  {
    paramOnSuccessListener = new mc(TaskExecutors.MAIN_THREAD, paramOnSuccessListener);
    this.b.a(paramOnSuccessListener);
    mf.a.a(paramActivity).a(paramOnSuccessListener);
    c();
    return this;
  }
  
  @NonNull
  public final Task<TResult> addOnSuccessListener(@NonNull OnSuccessListener<? super TResult> paramOnSuccessListener)
  {
    return addOnSuccessListener(TaskExecutors.MAIN_THREAD, paramOnSuccessListener);
  }
  
  @NonNull
  public final Task<TResult> addOnSuccessListener(@NonNull Executor paramExecutor, @NonNull OnSuccessListener<? super TResult> paramOnSuccessListener)
  {
    this.b.a(new mc(paramExecutor, paramOnSuccessListener));
    c();
    return this;
  }
  
  public final boolean b(@NonNull Exception paramException)
  {
    zzac.zzb(paramException, "Exception must not be null");
    synchronized (this.a)
    {
      if (this.c) {
        return false;
      }
      this.c = true;
      this.e = paramException;
      this.b.a(this);
      return true;
    }
  }
  
  public final boolean b(TResult paramTResult)
  {
    synchronized (this.a)
    {
      if (this.c) {
        return false;
      }
      this.c = true;
      this.d = paramTResult;
      this.b.a(this);
      return true;
    }
  }
  
  @NonNull
  public final <TContinuationResult> Task<TContinuationResult> continueWith(@NonNull Continuation<TResult, TContinuationResult> paramContinuation)
  {
    return continueWith(TaskExecutors.MAIN_THREAD, paramContinuation);
  }
  
  @NonNull
  public final <TContinuationResult> Task<TContinuationResult> continueWith(@NonNull Executor paramExecutor, @NonNull Continuation<TResult, TContinuationResult> paramContinuation)
  {
    mf localmf = new mf();
    this.b.a(new ly(paramExecutor, paramContinuation, localmf));
    c();
    return localmf;
  }
  
  @NonNull
  public final <TContinuationResult> Task<TContinuationResult> continueWithTask(@NonNull Continuation<TResult, Task<TContinuationResult>> paramContinuation)
  {
    return continueWithTask(TaskExecutors.MAIN_THREAD, paramContinuation);
  }
  
  @NonNull
  public final <TContinuationResult> Task<TContinuationResult> continueWithTask(@NonNull Executor paramExecutor, @NonNull Continuation<TResult, Task<TContinuationResult>> paramContinuation)
  {
    mf localmf = new mf();
    this.b.a(new lz(paramExecutor, paramContinuation, localmf));
    c();
    return localmf;
  }
  
  @Nullable
  public final Exception getException()
  {
    synchronized (this.a)
    {
      Exception localException = this.e;
      return localException;
    }
  }
  
  public final TResult getResult()
  {
    synchronized (this.a)
    {
      a();
      if (this.e != null) {
        throw new RuntimeExecutionException(this.e);
      }
    }
    Object localObject3 = this.d;
    return (TResult)localObject3;
  }
  
  public final <X extends Throwable> TResult getResult(@NonNull Class<X> paramClass)
    throws Throwable
  {
    synchronized (this.a)
    {
      a();
      if (paramClass.isInstance(this.e)) {
        throw ((Throwable)paramClass.cast(this.e));
      }
    }
    if (this.e != null) {
      throw new RuntimeExecutionException(this.e);
    }
    paramClass = this.d;
    return paramClass;
  }
  
  public final boolean isComplete()
  {
    synchronized (this.a)
    {
      boolean bool = this.c;
      return bool;
    }
  }
  
  public final boolean isSuccessful()
  {
    for (;;)
    {
      synchronized (this.a)
      {
        if ((this.c) && (this.e == null))
        {
          bool = true;
          return bool;
        }
      }
      boolean bool = false;
    }
  }
  
  static class a
    extends zzabe
  {
    private final List<WeakReference<md<?>>> a = new ArrayList();
    
    private a(zzabf paramzzabf)
    {
      super();
      this.zzaCR.zza("TaskOnStopCallback", this);
    }
    
    public static a a(Activity paramActivity)
    {
      zzabf localzzabf = zzs(paramActivity);
      a locala = (a)localzzabf.zza("TaskOnStopCallback", a.class);
      paramActivity = locala;
      if (locala == null) {
        paramActivity = new a(localzzabf);
      }
      return paramActivity;
    }
    
    public final <T> void a(md<T> parammd)
    {
      synchronized (this.a)
      {
        this.a.add(new WeakReference(parammd));
        return;
      }
    }
    
    @MainThread
    public void onStop()
    {
      synchronized (this.a)
      {
        Iterator localIterator = this.a.iterator();
        while (localIterator.hasNext())
        {
          md localmd = (md)((WeakReference)localIterator.next()).get();
          if (localmd != null) {
            localmd.a();
          }
        }
      }
      this.a.clear();
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/mf.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */