what-the-bank/sources/com/huawei/hms/support/api/ErrorResultImpl.java

110 lines
3.8 KiB
Java

package com.huawei.hms.support.api;
import android.os.Handler;
import android.os.Looper;
import com.huawei.hms.support.api.client.PendingResult;
import com.huawei.hms.support.api.client.Result;
import com.huawei.hms.support.api.client.ResultCallback;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.gentyref.GenericTypeReflector;
import com.huawei.hms.support.log.HMSLog;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.concurrent.TimeUnit;
/* loaded from: classes2.dex */
public abstract class ErrorResultImpl<R extends Result> extends PendingResult<R> {
private R a = null;
private int b;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class a implements Runnable {
final ResultCallback a;
final ErrorResultImpl b;
final ErrorResultImpl c;
a(ErrorResultImpl errorResultImpl, ResultCallback resultCallback, ErrorResultImpl errorResultImpl2) {
this.c = errorResultImpl;
this.a = resultCallback;
this.b = errorResultImpl2;
}
@Override // java.lang.Runnable
public void run() {
ResultCallback resultCallback = this.a;
ErrorResultImpl errorResultImpl = this.c;
resultCallback.onResult(errorResultImpl.a(errorResultImpl.b, this.b));
}
}
public ErrorResultImpl(int i) {
this.b = i;
}
@Override // com.huawei.hms.support.api.client.PendingResult
public final R await() {
return await(0L, null);
}
@Override // com.huawei.hms.support.api.client.PendingResult
@Deprecated
public void cancel() {
}
@Override // com.huawei.hms.support.api.client.PendingResult
@Deprecated
public boolean isCanceled() {
return false;
}
protected void postRunnable(Looper looper, ResultCallback<R> resultCallback, ErrorResultImpl errorResultImpl) {
if (looper == null) {
looper = Looper.myLooper();
}
new Handler(looper).post(new a(this, resultCallback, errorResultImpl));
}
@Override // com.huawei.hms.support.api.client.PendingResult
public final void setResultCallback(ResultCallback<R> resultCallback) {
setResultCallback(Looper.getMainLooper(), resultCallback);
}
@Override // com.huawei.hms.support.api.client.PendingResult
public R await(long j, TimeUnit timeUnit) {
if (Looper.myLooper() != Looper.getMainLooper()) {
return a(this.b, this);
}
throw new IllegalStateException("await must not be called on the UI thread");
}
/* JADX INFO: Access modifiers changed from: private */
public R a(int i, ErrorResultImpl errorResultImpl) {
Type genericSuperclass = errorResultImpl.getClass().getGenericSuperclass();
if (genericSuperclass == null) {
return null;
}
try {
R r = (R) GenericTypeReflector.getType(((ParameterizedType) genericSuperclass).getActualTypeArguments()[0]).newInstance();
this.a = r;
r.setStatus(new Status(i));
} catch (IllegalAccessException unused) {
HMSLog.e("ErrorResultImpl", "IllegalAccessException");
} catch (InstantiationException unused2) {
HMSLog.e("ErrorResultImpl", "InstantiationException");
}
return this.a;
}
@Override // com.huawei.hms.support.api.client.PendingResult
@Deprecated
public void setResultCallback(ResultCallback<R> resultCallback, long j, TimeUnit timeUnit) {
setResultCallback(resultCallback);
}
@Override // com.huawei.hms.support.api.client.PendingResult
public final void setResultCallback(Looper looper, ResultCallback<R> resultCallback) {
postRunnable(looper, resultCallback, this);
}
}