Kufar v3.2.0版本的 MD5 值为:6a4d203db1c561c7e3bcd50d23fed59f

以下内容为反编译后的 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.gms.measurement.api.AppMeasurementSdk;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.my.tracker.MyTracker;
import com.my.tracker.obfuscated.d;
import com.my.tracker.obfuscated.t;
import com.my.tracker.obfuscated.v0;
import com.my.tracker.recsys.OfferRequest;
import com.vungle.warren.persistence.IdColumns;
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 f52305a;

    final Handler f52306b;
    public final String data;
    public final List<String> placementIds;
    public final Boolean reset;
    public final String userId;

    private final AtomicBoolean f52308d = new AtomicBoolean(false);

    final String f52307c = "https://recsys.tracker.my.com/api/public/v3/rec/item";

    public interface OnCompleteListener {
        void onComplete(OfferRequest offerRequest, List<Offer> list, String str);
    }

    public class a implements t.a {
        public 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));
        }
    }

    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.f52305a = onCompleteListener;
        this.f52306b = handler;
    }

    public 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 i11 = 0; i11 < size; i11++) {
                buildUpon.appendQueryParameter("placement_id", this.placementIds.get(i11));
            }
        }
        return buildUpon.toString();
    }

    public void send() {
        if (this.f52305a == null) {
            v0.a("OfferRequest: listener is null, offers from response can not be returned");
        } else if (!this.f52308d.compareAndSet(false, true)) {
            v0.a("OfferRequest: send has already been called");
        } else {
            d.b(new Runnable() {
                @Override
                public final void run() {
                    OfferRequest.this.a();
                }
            });
        }
    }

    public static List<Offer> a(String str) {
        try {
            JSONArray jSONArray = new JSONObject(str).getJSONArray("data");
            ArrayList arrayList = new ArrayList();
            int length = jSONArray.length();
            for (int i11 = 0; i11 < length; i11++) {
                try {
                    JSONObject jSONObject = jSONArray.getJSONObject(i11);
                    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(IdColumns.COLUMN_IDENTIFIER), jSONObject2.optDouble("price"), jSONObject2.optDouble("discount_price"), jSONObject2.optInt(AppMeasurementSdk.ConditionalUserProperty.VALUE), jSONObject2.optInt("discount_value"), optInt, optInt2));
                } catch (Throwable unused) {
                    v0.a("OfferRequest: json response has invalid item");
                }
            }
            return arrayList;
        } catch (Throwable unused2) {
            v0.a("OfferRequest: error occurred while parsing values from json response");
            return null;
        }
    }

    public void a() {
        String id2 = MyTracker.getTrackerConfig().getId();
        if (TextUtils.isEmpty(id2)) {
            v0.b("OfferRequest: MyTracker hasn't been initialized yet, MyTracker.initTracker() should be called first");
            a(this, this.f52306b, this.f52305a, (t.b<String>) null);
        } else {
            a(this, this.f52306b, this.f52305a, t.a(new a(), null, false).a(a(this.f52307c, id2)));
        }
    }

    public static void a(final OfferRequest offerRequest, Handler handler, final OnCompleteListener onCompleteListener, t.b<String> bVar) {
        final String str;
        final List<Offer> list = null;
        if (bVar == null) {
            str = "MyTracker hasn't been initialized yet";
        } else if (bVar.b()) {
            String a11 = bVar.a();
            if (TextUtils.isEmpty(a11)) {
                v0.a("OfferRequest: http response is empty ");
                str = "Empty response";
            } else {
                List<Offer> a12 = a(a11);
                if (a12 == null) {
                    v0.a("OfferRequest: error while parsing offers from response");
                    str = "Offers parsing error";
                } else {
                    list = a12;
                    str = null;
                }
            }
        } else {
            v0.a("OfferRequest: http response is unsuccessful");
            str = "Unsuccessful response";
        }
        handler.post(new Runnable() {
            @Override
            public final void run() {
                OfferRequest.OnCompleteListener.this.onComplete(offerRequest, list, str);
            }
        });
    }
}