- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
91 lines
4.4 KiB
Java
91 lines
4.4 KiB
Java
package com.facebook.gamingservices;
|
|
|
|
import android.os.Bundle;
|
|
import com.facebook.AccessToken;
|
|
import com.facebook.FacebookException;
|
|
import com.facebook.FacebookRequestError;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.GraphRequest;
|
|
import com.facebook.GraphResponse;
|
|
import com.facebook.HttpMethod;
|
|
import com.facebook.bolts.TaskCompletionSource;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.GsonBuilder;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import kotlin.collections.ArraysKt___ArraysKt;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.StringCompanionObject;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class TournamentFetcher {
|
|
public final TaskCompletionSource<List<Tournament>> fetchTournaments() {
|
|
final TaskCompletionSource<List<Tournament>> taskCompletionSource = new TaskCompletionSource<>();
|
|
Bundle bundle = new Bundle();
|
|
AccessToken.Companion companion = AccessToken.Companion;
|
|
AccessToken currentAccessToken = companion.getCurrentAccessToken();
|
|
if (currentAccessToken == null || currentAccessToken.isExpired()) {
|
|
throw new FacebookException("Attempted to fetch tournament with an invalid access token");
|
|
}
|
|
if (currentAccessToken.getGraphDomain() == null || !Intrinsics.areEqual(FacebookSdk.GAMING, currentAccessToken.getGraphDomain())) {
|
|
throw new FacebookException("User is not using gaming login");
|
|
}
|
|
GraphRequest graphRequest = new GraphRequest(companion.getCurrentAccessToken(), "me/tournaments", bundle, HttpMethod.GET, new GraphRequest.Callback() { // from class: com.facebook.gamingservices.TournamentFetcher$$ExternalSyntheticLambda0
|
|
@Override // com.facebook.GraphRequest.Callback
|
|
public final void onCompleted(GraphResponse graphResponse) {
|
|
TournamentFetcher.m550fetchTournaments$lambda1(TaskCompletionSource.this, graphResponse);
|
|
}
|
|
}, null, 32, null);
|
|
graphRequest.setParameters(bundle);
|
|
graphRequest.executeAsync();
|
|
return taskCompletionSource;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: fetchTournaments$lambda-1, reason: not valid java name */
|
|
public static final void m550fetchTournaments$lambda1(TaskCompletionSource task, GraphResponse response) {
|
|
List list;
|
|
Intrinsics.checkNotNullParameter(task, "$task");
|
|
Intrinsics.checkNotNullParameter(response, "response");
|
|
if (response.getError() != null) {
|
|
FacebookRequestError error = response.getError();
|
|
if ((error == null ? null : error.getException()) != null) {
|
|
FacebookRequestError error2 = response.getError();
|
|
task.setError(error2 != null ? error2.getException() : null);
|
|
return;
|
|
} else {
|
|
task.setError(new GraphAPIException("Graph API Error"));
|
|
return;
|
|
}
|
|
}
|
|
try {
|
|
JSONObject jSONObject = response.getJSONObject();
|
|
if (jSONObject == null) {
|
|
task.setError(new GraphAPIException("Failed to get response"));
|
|
return;
|
|
}
|
|
JSONArray jSONArray = jSONObject.getJSONArray("data");
|
|
if (jSONArray != null && jSONArray.length() >= 1) {
|
|
Gson create = new GsonBuilder().create();
|
|
String jSONArray2 = jSONArray.toString();
|
|
Intrinsics.checkNotNullExpressionValue(jSONArray2, "data.toString()");
|
|
Object fromJson = create.fromJson(jSONArray2, (Class<Object>) Tournament[].class);
|
|
Intrinsics.checkNotNullExpressionValue(fromJson, "gson.fromJson(dataString, Array<Tournament>::class.java)");
|
|
list = ArraysKt___ArraysKt.toList((Object[]) fromJson);
|
|
task.setResult(list);
|
|
return;
|
|
}
|
|
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
|
|
String format = String.format(Locale.ROOT, "No tournament found", Arrays.copyOf(new Object[]{Integer.valueOf(jSONArray.length()), 1}, 2));
|
|
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(locale, format, *args)");
|
|
task.setError(new GraphAPIException(format));
|
|
} catch (JSONException e) {
|
|
task.setError(e);
|
|
}
|
|
}
|
|
}
|