整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3

以下内容为反编译后的 TestBaseFragment.java 源代码,内容仅作参考


package com.kc.openset.ks.base;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.bytedance.sdk.openadsdk.api.plugin.PluginConstants;
import com.kc.openset.b;
import com.kc.openset.ks.Callback;
import com.kc.openset.listener.OSETLoadVideoListener;
import com.kc.openset.listener.OSETRequestCallback;
import com.kc.openset.util.m;
import com.kc.openset.util.q;
import com.kc.openset.util.r;
import com.kwad.sdk.api.KsContentPage;
import java.io.IOException;
import java.util.HashMap;
import okhttp3.Call;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public abstract class TestBaseFragment extends Fragment {
    protected static final String KEY_POS_ID = "KEY_POS_ID";
    private static final String TAG = "KSVC";
    protected OSETLoadVideoListener loadVideoListener;
    protected KsContentPage.VideoListener mFragmentListener;
    protected String mPosId;

    class a implements OSETRequestCallback {
        final Callback a;

        a(Callback callback) {
            this.a = callback;
        }

        @Override
        public void onFailure(Call call, IOException iOException) {
            m.g(TestBaseFragment.TAG, "排序获取视频内容: " + TestBaseFragment.this.videoType() + " -> onFailure 网络错误:" + iOException.getMessage());
            OSETLoadVideoListener oSETLoadVideoListener = TestBaseFragment.this.loadVideoListener;
            if (oSETLoadVideoListener != null) {
                oSETLoadVideoListener.loadFailure(70001, "请求失败:" + iOException.getMessage());
            }
        }

        @Override
        public void onResponse(String str) {
            JSONArray optJSONArray;
            try {
                m.f(TestBaseFragment.TAG, "排序获取视频内容:" + TestBaseFragment.this.videoType() + " -> onResponse: " + str);
                JSONObject jSONObject = new JSONObject(str);
                int optInt = jSONObject.optInt(PluginConstants.KEY_ERROR_CODE);
                String optString = jSONObject.optString("message");
                if (optInt != 1 || (optJSONArray = jSONObject.optJSONArray("data")) == null || optJSONArray.length() == 0) {
                    TestBaseFragment.this.onError(optInt, optString);
                    return;
                }
                for (int i = 0; i < optJSONArray.length(); i++) {
                    JSONObject optJSONObject = optJSONArray.optJSONObject(i);
                    String optString2 = optJSONObject.optString("advertisingAgency");
                    String optString3 = optJSONObject.optString("key");
                    if ("kuaishou".equals(optString2) && !TextUtils.isEmpty(optString3) && r.e) {
                        this.a.onResponse(optString3);
                        TestBaseFragment testBaseFragment = TestBaseFragment.this;
                        OSETLoadVideoListener oSETLoadVideoListener = testBaseFragment.loadVideoListener;
                        if (oSETLoadVideoListener != null) {
                            oSETLoadVideoListener.loadSuccess(testBaseFragment.videoType());
                            return;
                        }
                        return;
                    }
                }
                TestBaseFragment.this.onError(70002, "未能匹配到合适的入口组件");
            } catch (JSONException e) {
                e.printStackTrace();
                TestBaseFragment testBaseFragment2 = TestBaseFragment.this;
                testBaseFragment2.onError(71000, "解析失败: " + e.getMessage());
            }
        }
    }

    public void onError(int i, String str) {
        if (this.loadVideoListener != null) {
            FragmentActivity activity = getActivity();
            if (activity == null || ((Build.VERSION.SDK_INT >= 17 && activity.isDestroyed()) || activity.isFinishing())) {
                m.g(TAG, "排序获取视频内容: " + videoType() + " -> onError: S70070 activity已经被关闭");
                this.loadVideoListener.loadFailure(70070, "activity已经被关闭");
                return;
            }
            m.g(TAG, "排序获取视频内容: " + videoType() + " -> onError: " + i + " " + str);
            this.loadVideoListener.loadFailure(i, str);
        }
    }

    public Activity getMActivity() {
        return super.getActivity();
    }

    public void httpPosId(Callback<String> callback) {
        HashMap hashMap = new HashMap();
        hashMap.put("adSpotId", this.mPosId);
        hashMap.put("deviceId", q.c(getContext()));
        b.a(getContext(), "http://track.shenshiads.com/track/content/ks/open", hashMap);
        HashMap hashMap2 = new HashMap();
        hashMap2.put("appKey", com.kc.openset.a.w);
        hashMap2.put("advertId", this.mPosId);
        m.f(TAG, "调用视频内容模块:" + videoType() + ", mPosId=" + this.mPosId);
        b.a(getContext(), hashMap2, new a(callback));
    }

    public boolean onBackPressed() {
        return false;
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            this.mPosId = arguments.getString(KEY_POS_ID);
        }
    }

    public TestBaseFragment setFragmentVideoListener(KsContentPage.VideoListener videoListener) {
        this.mFragmentListener = videoListener;
        return this;
    }

    public TestBaseFragment setOSETLoadVideoListener(OSETLoadVideoListener oSETLoadVideoListener) {
        this.loadVideoListener = oSETLoadVideoListener;
        return this;
    }

    public abstract int videoType();
}