GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5
以下内容为反编译后的 OfferRequest.java 源代码,内容仅作参考
package com.my.tracker.recsys;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
import com.applovin.sdk.AppLovinWebViewActivity;
import com.google.android.exoplayer2.C;
import com.my.tracker.MyTracker;
import com.my.tracker.MyTrackerConfig;
import com.my.tracker.obfuscated.e;
import com.my.tracker.obfuscated.g;
import com.my.tracker.obfuscated.u;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONArray;
import org.json.JSONObject;
public final class OfferRequest {
final OnCompleteListener f3240a;
final Handler b;
public final String data;
public final List<String> placementIds;
public final Boolean reset;
public final String userId;
private final AtomicBoolean d = new AtomicBoolean(false);
final String c = "https://recsys.tracker.my.com/api/public/v3/rec/item";
public interface OnCompleteListener {
void onComplete(OfferRequest offerRequest, List<Offer> list, String str);
}
public static class a implements Runnable {
final OnCompleteListener f3241a;
final OfferRequest b;
final List c;
final String d;
a(OnCompleteListener onCompleteListener, OfferRequest offerRequest, List list, String str) {
this.f3241a = onCompleteListener;
this.b = offerRequest;
this.c = list;
this.d = str;
}
@Override
public void run() {
this.f3241a.onComplete(this.b, this.c, this.d);
}
}
class b implements Runnable {
class a implements u.a {
a() {
}
@Override
public String a() {
return "application/json";
}
@Override
public void a(OutputStream outputStream) {
if (TextUtils.isEmpty(OfferRequest.this.data)) {
return;
}
outputStream.write(OfferRequest.this.data.getBytes(C.UTF8_NAME));
}
}
b() {
}
@Override
public void run() {
String id = MyTracker.getTrackerConfig().getId();
if (TextUtils.isEmpty(id)) {
e.b("OfferRequest: MyTracker hasn't been initialized yet, MyTracker.initTracker() should be called first");
OfferRequest offerRequest = OfferRequest.this;
OfferRequest.a(offerRequest, offerRequest.b, offerRequest.f3240a, null);
} else {
u<String> a2 = u.a(new a(), (MyTrackerConfig.OkHttpClientProvider) null);
OfferRequest offerRequest2 = OfferRequest.this;
u.b<String> a3 = a2.a(offerRequest2.a(offerRequest2.c, id), false);
OfferRequest offerRequest3 = OfferRequest.this;
OfferRequest.a(offerRequest3, offerRequest3.b, offerRequest3.f3240a, a3);
}
}
}
public OfferRequest(String str, List<String> list, String str2, Boolean bool, OnCompleteListener onCompleteListener, Handler handler) {
this.userId = str;
this.placementIds = list;
this.data = str2;
this.reset = bool;
this.f3240a = onCompleteListener;
this.b = handler;
}
static List<Offer> a(String str) {
try {
JSONArray jSONArray = new JSONObject(str).getJSONArray("data");
ArrayList arrayList = new ArrayList();
int length = jSONArray.length();
for (int i = 0; i < length; i++) {
try {
JSONObject jSONObject = jSONArray.getJSONObject(i);
String optString = jSONObject.optString("placement_id");
int optInt = jSONObject.optInt("test_id");
int optInt2 = jSONObject.optInt("split_id");
JSONObject jSONObject2 = jSONObject.getJSONObject("offer");
arrayList.add(new Offer(optString, jSONObject2.optString("item_id"), jSONObject2.optDouble("price"), jSONObject2.optDouble("discount_price"), jSONObject2.optInt("value"), jSONObject2.optInt("discount_value"), optInt, optInt2));
} catch (Throwable unused) {
e.a("OfferRequest: json response has invalid item");
}
}
return arrayList;
} catch (Throwable unused2) {
e.a("OfferRequest: error occurred while parsing values from json response");
return null;
}
}
static void a(OfferRequest offerRequest, Handler handler, OnCompleteListener onCompleteListener, u.b<String> bVar) {
String str;
List<Offer> list = null;
if (bVar == null) {
str = "MyTracker hasn't been initialized yet";
} else if (bVar.b()) {
String a2 = bVar.a();
if (TextUtils.isEmpty(a2)) {
e.a("OfferRequest: http response is empty ");
str = "Empty response";
} else {
List<Offer> a3 = a(a2);
if (a3 == null) {
e.a("OfferRequest: error while parsing offers from response");
str = "Offers parsing error";
} else {
list = a3;
str = null;
}
}
} else {
e.a("OfferRequest: http response is unsuccessful");
str = "Unsuccessful response";
}
handler.post(new a(onCompleteListener, offerRequest, list, str));
}
String a(String str, String str2) {
Uri.Builder buildUpon = Uri.parse(str).buildUpon();
buildUpon.appendQueryParameter("custom_user_id", this.userId);
buildUpon.appendQueryParameter(AppLovinWebViewActivity.INTENT_EXTRA_KEY_SDK_KEY, str2);
Boolean bool = this.reset;
if (bool != null) {
buildUpon.appendQueryParameter("reset", String.valueOf(bool));
}
if (!this.placementIds.isEmpty()) {
int size = this.placementIds.size();
for (int i = 0; i < size; i++) {
buildUpon.appendQueryParameter("placement_id", this.placementIds.get(i));
}
}
return buildUpon.toString();
}
public void send() {
if (this.f3240a == null) {
e.a("OfferRequest: listener is null, offers from response can not be returned");
} else if (this.d.compareAndSet(false, true)) {
g.b(new b());
} else {
e.a("OfferRequest: send has been already called");
}
}
}