admin
2021-02-03 1981dee5aec45793d3c4ebdbc4e637528c71b3c5
BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java
@@ -28,7 +28,6 @@
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.ResponseHandlerInterface;
import com.loopj.android.http.SyncHttpClient;
import com.yeshi.buwanshequ.BuildConfig;
import com.weikou.beibeivideo.util.BeibeiConstant;
import okhttp3.Call;
@@ -54,6 +53,8 @@
    private static SyncHttpClient syncHttpClient = new SyncHttpClient();
    private static AsyncHttpClient sortTimeAsyncHttpClient = new AsyncHttpClient();
    static {
        mOkHttpClient = new OkHttpClient().newBuilder()
@@ -63,8 +64,12 @@
                .build();
        asyncHttpClient.setTimeout(60 * 1000);
        syncHttpClient.setTimeout(60 * 1000);
        //5s
        sortTimeAsyncHttpClient.setTimeout(5 * 1000);
        asyncHttpClient.setURLEncodingEnabled(false);
        syncHttpClient.setURLEncodingEnabled(false);
        sortTimeAsyncHttpClient.setURLEncodingEnabled(false);
    }
    public static void getUid(Context context, String channel, String device,
@@ -83,6 +88,32 @@
            params.put("DeviceNumber", BeibeiVideoApplication.deviceNumber);
        }
        commonPost(context, BASE_URL + "user", params, handler);
    }
    /**
     * 获取配置信息
     *
     * @param context
     * @param handler
     */
    public static void getConfig(Context context,
                                 ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<>();
        params.put("Method", "getConfig");
        if (!StringUtils.isBlank(BeibeiVideoApplication.deviceNumber)) {
            params.put("DeviceName", BeibeiVideoApplication.deviceName);
            params.put("DeviceNumber", BeibeiVideoApplication.deviceNumber);
        }
        commonPost(context, BASE_URL + "config", params, null, handler, true, true);
    }
    public static void getHomeConfig(Context context,
                                     ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<>();
        params.put("Method", "getHomeConfig");
        commonPost(context, BASE_URL + "config", params, null, handler, true, true);
    }
    /**
@@ -135,6 +166,24 @@
        commonPost(context, BASE_URL + "comment", params, handler);
    }
    /**
     * 微信登录
     *
     * @param context
     * @param uid
     * @param code
     * @param handler
     */
    public static void wxLogin(Context context, String uid, String code,
                               ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "wxLogin");
        params.put("Uid", uid);
        params.put("Code", code);
        commonPost(context, BASE_URL + "comment", params, handler);
    }
    /**
     * 获取专题列表
     *
@@ -155,11 +204,10 @@
    public static void search(Context context, String uid, String key,
                              String contentType, String page, ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "search");
        params.put("Method", "searchNew");
        params.put("Uid", uid);
        params.put("Key", key);
        params.put("Type", "1");
        params.put("ContentType", contentType);
        params.put("Type", contentType);
        params.put("Page", page);
        commonPost(context, BASE_URL + "user", params, handler);
    }
@@ -278,6 +326,88 @@
    }
    /**
     * 电话号码绑定
     *
     * @param context
     * @param loginUid
     * @param phone
     * @param code
     * @param accessToken
     * @param handler
     */
    public static void bindPhone(Context context, String loginUid, String phone, String code, String accessToken, ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "bindPhone");
        params.put("loginUid", loginUid);
        if (phone != null)
            params.put("phone", phone);
        if (code != null)
            params.put("code", code);
        if (accessToken != null)
            params.put("accessToken", accessToken);
        commonPost(context, BASE_URL + "user", params, handler);
    }
    /**
     * 绑定QQ
     *
     * @param context
     * @param loginUid
     * @param name
     * @param portrait
     * @param openId
     * @param handler
     */
    public static void bindQQ(Context context, String loginUid, String name, String portrait, String openId, ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "bindQQ");
        params.put("loginUid", loginUid);
        if (name != null)
            params.put("Name", name);
        if (portrait != null)
            params.put("Portrait", portrait);
        if (openId != null)
            params.put("OpenId", openId);
        commonPost(context, BASE_URL + "user", params, handler);
    }
    /**
     * 是否允许一键登录
     *
     * @param context
     * @param loginUid
     * @param handler
     */
    public static void allowOneKeyLogin(Context context, String loginUid, ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "allowOneKeyLogin");
        params.put("loginUid", loginUid);
        commonPost(context, BASE_URL + "user", params, handler);
    }
    /**
     * 绑定微信
     *
     * @param context
     * @param loginUid
     * @param code
     * @param handler
     */
    public static void bindWX(Context context, String loginUid, String code, ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "bindWX");
        params.put("loginUid", loginUid);
        if (code != null)
            params.put("code", code);
        commonPost(context, BASE_URL + "user", params, handler);
    }
    /**
     * 获取验证码
     *
     * @param context
@@ -290,6 +420,23 @@
        params.put("Method", "sendVerifyCode");
        params.put("Uid", uid);
        params.put("Email", name);
        commonPost(context, BASE_URL + "user", params, handler);
    }
    /**
     * 发送绑定验证码
     *
     * @param context
     * @param loginUid
     * @param phone
     * @param handler
     */
    public static void sendBindVerifyCode(Context context, String loginUid, String phone,
                                          ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "sendBindVerifyCode");
        params.put("loginUid", loginUid);
        params.put("phone", phone);
        commonPost(context, BASE_URL + "user", params, handler);
    }
@@ -323,10 +470,9 @@
    public static void getPersonInfo(Context context, String uid, String loginUid,
                                     ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "getLoginUserInfo");
        params.put("Uid", uid);
        params.put("LoginUid", loginUid);
        commonPost(context, BASE_URL + "user", params, handler);
        params.put("loginUid", loginUid);
        commonPost(context, BASE_URL + "user/getUserInfo", params, handler);
    }
    /**
@@ -340,15 +486,19 @@
                                        String personSign, String portrait, String nickName,
                                        ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "updateLoginUserInfo");
        params.put("Uid", uid);
        params.put("LoginUid", loginUid);
        params.put("Sex", sex);
        params.put("BirthDay", birthday);
        params.put("PersonalSign", personSign);
        params.put("Portrait", portrait);
        params.put("NickName", nickName);
        commonPost(context, BASE_URL + "user", params, handler);
        params.put("loginUid", loginUid);
        if (sex != null)
            params.put("sex", sex);
        if (birthday != null)
            params.put("birthday", birthday);
        if (personSign != null)
            params.put("personSign", personSign);
        if (portrait != null)
            params.put("portrait", portrait);
        if (nickName != null)
            params.put("nickName", nickName);
        commonPost(context, BASE_URL + "user/updateUserInfo", params, handler);
    }
    /**
@@ -388,7 +538,6 @@
    }
    public static void sendLiveClick(Context context, String uid, String type, String roomid,
                                     ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
@@ -398,7 +547,6 @@
        params.put("RoomId", roomid);
        commonPost(context, BASE_URL + "zhibo", params, handler);
    }
    /**
@@ -448,7 +596,7 @@
     * @param handler
     */
    public static void getGuessLike(Context context, String page,
                                 ResponseHandlerInterface handler) {
                                    ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "guessLike");
        params.put("Page", page);
@@ -676,7 +824,7 @@
    public static void getChoiceClass(Context context, String uid,
                                      ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "getVideoClass");
        params.put("Method", "getHomeClass");
        params.put("Uid", uid);
        commonPost(context, BASE_URL + "class", params, handler);
    }
@@ -923,12 +1071,47 @@
    }
    /**
     * 获取剧集列表
     *
     * @param context
     * @param uid
     * @param ResourceId
     * @param videoId
     * @param page
     * @param handler
     */
    public static void getVideoEpisodeList(Context context, String uid,
                                           String ResourceId, String videoId, int page,
                                           ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "getVideoEpisodeList");
        params.put("Uid", uid);
        params.put("Page", page + "");
        params.put("VideoId", videoId);
        params.put("ResourceId", ResourceId);
        commonPost(context, BASE_URL + "recommend", params, handler);
    }
    public static void advice(Context context, String uid, String content,
                              ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "advice");
        params.put("Uid", uid);
        params.put("Content", content);
        commonPost(context, BASE_URL + "other", params, handler);
    }
    //播放统计
    public static void playStatistic(Context context, String videoId, String resourceId,
                                     ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "playStatistic");
        params.put("VideoId", videoId);
        params.put("ResourceId", resourceId);
        commonPost(context, BASE_URL + "other", params, handler);
    }
@@ -953,7 +1136,7 @@
        params.put("Url", url);
        params.put("Step", step);
        params.put("Data", data);
        commonPost(context, BASE_URL + "other", params, null, handler, false);
        commonPost(context, BASE_URL + "other", params, null, handler, false, false);
    }
    public static void parseVideoUrl(Context context, String uid,
@@ -965,7 +1148,7 @@
        params.put("Id", videoDetailId);
        params.put("Data", data);
        params.put("Url", baseurl);
        commonPost(context, BASE_URL + "other", params, null, handler, false);
        commonPost(context, BASE_URL + "other", params, null, handler, false, false);
    }
    public static void setVideoError(Context context, String uid, String data,
@@ -983,7 +1166,7 @@
        params.put("Method", "setVideoError");
        params.put("Uid", uid);
        params.put("Data", data);
        commonPost(context, BASE_URL + "other", params, null, handler, false);
        commonPost(context, BASE_URL + "other", params, null, handler, false, false);
    }
@@ -993,6 +1176,29 @@
        params.put("Method", "getNotice");
        params.put("Uid", uid);
        commonPost(context, BASE_URL + "other", params, handler);
    }
    public static void getFuntvAuthCode(Context context,
                                        ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "getFuntvAuthCode");
        commonPost(context, BASE_URL + "other", params, handler);
    }
    public static void getBaiDuNewsTypeList(Context context,
                                            ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<>();
        params.put("Method", "getNewsTypeList");
        commonPost(context, BASE_URL + "baidu", params, handler);
    }
    public static void getBaiDuVideoTypeList(Context context,
                                             ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<>();
        params.put("Method", "getVideoTypeList");
        commonPost(context, BASE_URL + "baidu", params, handler);
    }
@@ -1066,13 +1272,13 @@
    private static void commonPost(Context context, String url,
                                   LinkedHashMap<String, String> params, HashMap<String, File> files,
                                   ResponseHandlerInterface handler) {
        commonPost(context, url, params, files, handler, true);
        commonPost(context, url, params, files, handler, true, false);
    }
    private static void commonPost1(Context context, String url,
                                    LinkedHashMap<String, String> params, HashMap<String, File> files,
                                    ResponseHandlerInterface handler) {
        commonPost(context, url, params, files, handler, false);
        commonPost(context, url, params, files, handler, false, false);
    }
    /**
@@ -1169,7 +1375,7 @@
    }
    public static String getDeviceId(Context context) {
        SharedPreferences deviceInfo = context.getSharedPreferences("deviceInfo",Context.MODE_PRIVATE);
        SharedPreferences deviceInfo = context.getSharedPreferences("deviceInfo", Context.MODE_PRIVATE);
        String deviceId = deviceInfo.getString("device", "");
        if (StringUtils.isEmpty(deviceId)) {
            deviceId = new DeviceUuidFactory(context).getDeviceUuid() + "";
@@ -1184,9 +1390,8 @@
    private static void commonPost(Context context, String url,
                                   LinkedHashMap<String, String> params, HashMap<String, File> files,
                                   ResponseHandlerInterface handler, boolean asyn) {
                                   ResponseHandlerInterface handler, boolean asyn, boolean shortTime) {
        params.put("Package", context.getPackageName());
        // params.put("Package", "com.beibei.beibeivideo");
        int version = PackageUtils2.getVersionCode(context);
        params.put("Version", version + "");
        params.put("Device", getDeviceId(context));
@@ -1206,7 +1411,11 @@
        }
        if (asyn) {
            // asyncHttpClient.setProxy("192.168.1.122", 8888);
            asyncHttpClient.post(context, url, requestParams, handler);
            if (!shortTime)
                asyncHttpClient.post(context, url, requestParams, handler);
            else {
                sortTimeAsyncHttpClient.post(context, url, requestParams, handler);
            }
        } else {
            // syncHttpClient.post(context, url, requestParams, handler);