翰林优商.apk(点击下载) / TbSaasManager.java


package com.tb.mob;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.bytedance.sdk.openadsdk.api.plugin.PluginConstants;
import com.tb.mob.TbManager;
import com.tb.mob.bean.TbTag;
import com.tb.mob.config.TbSaasConfig;
import com.tb.mob.saas.SaasH5Activity;
import com.tb.mob.utils.ValueUtils;
import com.tb.tb_lib.b;
import com.tb.tb_lib.b.a;
import com.tb.tb_lib.b.c;
import com.tb.tb_lib.l.h;
import com.tb.tb_lib.l.i;
import com.tb.tb_lib.l.k;
import java.util.Map;

public class TbSaasManager {
    private static boolean a = false;
    private static boolean b = false;
    public static final long loadingTime = 3000;

    public static void goSaas(Activity activity, TbSaasConfig tbSaasConfig) {
        Intent intent = new Intent(activity, SaasH5Activity.class);
        intent.putExtra("moduleGroupId", tbSaasConfig.getModuleGroupId());
        intent.putExtra("userId", tbSaasConfig.getUserId());
        activity.startActivity(intent);
    }

    public static void loadAd(final String str, final String str2, final Activity activity, final TbManager.InteractionLoadListener interactionLoadListener, final TbManager.RewardVideoLoadListener rewardVideoLoadListener) {
        final String a2 = i.a(activity, str);
        final String d = k.d(activity.getApplicationContext(), str);
        if (!TextUtils.isEmpty(d)) {
            if (interactionLoadListener != null) {
                b.a(d, a2, "", 450, activity, interactionLoadListener);
            }
            if (rewardVideoLoadListener != null) {
                b.a(d, a2, true, "", str2, "", TbManager.Orientation.VIDEO_VERTICAL, activity, rewardVideoLoadListener);
            }
        }
        AnonymousClass3 r8 = new a() {
            /* class com.tb.mob.TbSaasManager.AnonymousClass3 */

            @Override // com.tb.tb_lib.b.a
            public void onFailure(int i, String str) {
                if (TextUtils.isEmpty(d)) {
                    TbManager.InteractionLoadListener interactionLoadListener = interactionLoadListener;
                    if (interactionLoadListener != null) {
                        interactionLoadListener.onFail("网络错误_" + str);
                    }
                    TbManager.RewardVideoLoadListener rewardVideoLoadListener = rewardVideoLoadListener;
                    if (rewardVideoLoadListener != null) {
                        rewardVideoLoadListener.onFail("网络错误_" + str);
                    }
                }
                if (i != -1) {
                    k.c(activity.getApplicationContext(), "", str);
                }
            }

            @Override // com.tb.tb_lib.b.a
            public void onResponse(Map<String, Object> map) {
                if (1 == ValueUtils.getInt(map.get(PluginConstants.KEY_ERROR_CODE)).intValue()) {
                    String a2 = com.tb.tb_lib.l.a.a(ValueUtils.getString(map.get("data")));
                    if (TextUtils.isEmpty(d)) {
                        TbManager.InteractionLoadListener interactionLoadListener = interactionLoadListener;
                        if (interactionLoadListener != null) {
                            b.a(a2, a2, "", 450, activity, interactionLoadListener);
                        }
                        TbManager.RewardVideoLoadListener rewardVideoLoadListener = rewardVideoLoadListener;
                        if (rewardVideoLoadListener != null) {
                            b.a(a2, a2, true, "", str2, "", TbManager.Orientation.VIDEO_VERTICAL, activity, rewardVideoLoadListener);
                        }
                    }
                    k.c(activity.getApplicationContext(), a2, str);
                } else if (TextUtils.isEmpty(d)) {
                    String string = ValueUtils.getString(map.get("msg"));
                    TbManager.InteractionLoadListener interactionLoadListener2 = interactionLoadListener;
                    if (interactionLoadListener2 != null) {
                        interactionLoadListener2.onFail(string);
                    }
                    TbManager.RewardVideoLoadListener rewardVideoLoadListener2 = rewardVideoLoadListener;
                    if (rewardVideoLoadListener2 != null) {
                        rewardVideoLoadListener2.onFail(string);
                    }
                }
            }
        };
        c.a(activity, r8, "/sets/v9/position?positionId=" + str + "&os=" + 1 + "&channelNum=&channelVersion=&imei=" + h.a(activity));
    }

    public static void loadInteraction(String str, Activity activity, TbManager.InteractionLoadListener interactionLoadListener) {
        String str2 = TbTag.QbManager;
        Log.d(str2, "___" + Process.myPid() + "___loadInteraction");
        if (a) {
            interactionLoadListener.onFail("请求频率过快");
            return;
        }
        if (TbManager.handlerMain == null) {
            TbManager.handlerMain = new Handler(Looper.getMainLooper());
        }
        TbManager.handlerMain.postDelayed(new Runnable() {
            /* class com.tb.mob.TbSaasManager.AnonymousClass1 */

            public void run() {
                boolean unused = TbSaasManager.a = false;
            }
        }, 3000);
        a = true;
        loadAd(str, "", activity, interactionLoadListener, null);
    }

    public static void loadRewardVideo(String str, String str2, Activity activity, TbManager.RewardVideoLoadListener rewardVideoLoadListener) {
        String str3 = TbTag.QbManager;
        Log.d(str3, "___" + Process.myPid() + "___loadRewardVideo");
        if (b) {
            rewardVideoLoadListener.onFail("请求频率过快");
            return;
        }
        if (TbManager.handlerMain == null) {
            TbManager.handlerMain = new Handler(Looper.getMainLooper());
        }
        TbManager.handlerMain.postDelayed(new Runnable() {
            /* class com.tb.mob.TbSaasManager.AnonymousClass2 */

            public void run() {
                boolean unused = TbSaasManager.b = false;
            }
        }, 3000);
        b = true;
        if (TextUtils.isEmpty(str2)) {
            rewardVideoLoadListener.onFail("userID不能为空");
            Toast.makeText(activity, "userID不能为空", 0).show();
        } else if (str2.length() > 32) {
            rewardVideoLoadListener.onFail("userID长度不能大于32位");
            Toast.makeText(activity, "userID长度不能大于32位", 0).show();
        } else {
            loadAd(str, str2, activity, null, rewardVideoLoadListener);
        }
    }
}