From 2c5b6e472c368e80d85b8ea2b461c9ea62981d9b Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期日, 08 十月 2023 11:28:56 +0800
Subject: [PATCH] 广告升级/bug修复

---
 BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java |  322 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 298 insertions(+), 24 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java b/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java
index 3f084a5..fbe9cdd 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java
@@ -3,8 +3,12 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -19,7 +23,6 @@
 import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 import com.lcjian.library.DeviceUuidFactory;
-import com.lcjian.library.okhttp.OkHttpUtils;
 import com.lcjian.library.util.ManifestDataUtil;
 import com.lcjian.library.util.SystemCommon;
 import com.lcjian.library.util.common.PackageUtils2;
@@ -31,10 +34,13 @@
 import com.loopj.android.http.ResponseHandlerInterface;
 import com.loopj.android.http.SyncHttpClient;
 import com.ut.device.UTDevice;
+import com.video.youth.util.YouthUtil;
 import com.weikou.beibeivideo.util.BeibeiConstant;
 import com.weikou.beibeivideo.util.UserUtil;
 
+import org.apache.http.Header;
 import org.json.JSONArray;
+import org.json.JSONObject;
 
 import okhttp3.Call;
 import okhttp3.Callback;
@@ -62,7 +68,6 @@
     private static AsyncHttpClient sortTimeAsyncHttpClient = new AsyncHttpClient();
 
     static {
-
         mOkHttpClient = new OkHttpClient().newBuilder()
                 .connectTimeout(10 * 1000, TimeUnit.SECONDS)//璁剧疆瓒呮椂鏃堕棿
                 .readTimeout(10 * 1000, TimeUnit.SECONDS)//璁剧疆璇诲彇瓒呮椂鏃堕棿
@@ -79,13 +84,12 @@
     }
 
     public static void getUid(Context context, String channel, String device,
-                              String imei, String mac, String lat, String lng,
+                              String imei, String lat, String lng,
                               ResponseHandlerInterface handler) {
         LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
         params.put("Method", "getUid");
         params.put("Device", device);
         params.put("Imei", imei);
-        params.put("Mac", mac);
         params.put("Lat", lat);
         params.put("Lng", lng);
         params.put("Channel", channel);
@@ -372,6 +376,15 @@
         commonPost(context, BASE_URL + "user", params, handler);
     }
 
+
+    public static void phoneLogin(Context context, String phone, String code, ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        params.put("Method", "phoneLogin");
+        params.put("phone", phone);
+        params.put("code", code);
+        commonPost(context, BASE_URL + "user", params, handler);
+    }
+
     /**
      * 鐢佃瘽鍙风爜缁戝畾
      *
@@ -483,6 +496,15 @@
         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);
+    }
+
+
+    public static void sendLoginVerifyCode(Context context, String phone,
+                                          ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        params.put("Method", "sendSMSCode");
         params.put("phone", phone);
         commonPost(context, BASE_URL + "user", params, handler);
     }
@@ -618,8 +640,14 @@
     public static void getHotSearch(Context context, String uid,
                                     ResponseHandlerInterface handler) {
         LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
-        params.put("Method", "getHotSearch");
+        params.put("Method", "getHotSearchNew");
         params.put("Uid", uid);
+        commonPost(context, BASE_URL + "user", params, handler);
+    }
+
+    public static void getSearchRank(Context context, ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        params.put("Method", "getSearchRank");
         commonPost(context, BASE_URL + "user", params, handler);
     }
 
@@ -753,12 +781,15 @@
     }
 
 
-    public static void getHomeAd(Context context, String uid, String vtid,
+    public static void getHomeAd(Context context, String uid, String vtid, String dataKey,
                                  ResponseHandlerInterface handler) {
         LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
         params.put("Method", "getHomeAd");
         params.put("Uid", uid);
         params.put("Vtid", vtid);
+        if (dataKey != null) {
+            params.put("DataKey", dataKey);
+        }
         commonPost(context, BASE_URL + "recommend", params, handler);
     }
 
@@ -827,12 +858,27 @@
     }
 
 
-    public static void getHomeType(Context context, String uid, String vtid,
+    public static void getHomeType(Context context, String uid, String vtid, String dataKey, int page, int pageSize,
                                    ResponseHandlerInterface handler) {
         LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
-        params.put("Method", "getHomeType");
+        params.put("Method", "getHomeTypeNew");
         params.put("Uid", uid);
         params.put("Vtid", vtid);
+        params.put("Page", page + "");
+        params.put("PageSize", pageSize + "");
+        if (dataKey != null) {
+            params.put("DataKey", dataKey);
+        }
+        commonPost(context, BASE_URL + "recommend", params, handler);
+    }
+
+
+    public static void getHomeVideoList(Context context, String id, int page,
+                                        ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        params.put("Method", "getHomeVideoList");
+        params.put("Id", id);
+        params.put("Page", page + "");
         commonPost(context, BASE_URL + "recommend", params, handler);
     }
 
@@ -1105,7 +1151,7 @@
     }
 
     public static void getVideoDetail(Context context, String uid,
-                                      String ResourceId, String videoId, Integer position, String loginid, String type,
+                                      String ResourceId, String videoId, Integer position, String loginid, String type, String from,
                                       ResponseHandlerInterface handler) {
         LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
         params.put("Method", "getVideoDetail");
@@ -1115,10 +1161,26 @@
         if (position != null) {
             params.put("Position", position + "");
         }
+
+        if (from != null) {
+            params.put("From", from + "");
+        }
         params.put("ResourceId", ResourceId);
         params.put("Type", type);
         commonPost(context, BASE_URL + "recommend", params, handler);
 
+    }
+
+
+    public static void uploadSession(Context context, String sessionId,
+                                     String type,
+                                     ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        if (sessionId != null)
+            params.put("sessionId", sessionId);
+        if (type != null)
+            params.put("type", type);
+        commonPost(context, BASE_URL + "session/uploadSession", params, handler);
     }
 
 
@@ -1133,12 +1195,13 @@
      * @param handler
      */
     public static void getVideoEpisodeList(Context context, String uid,
-                                           String ResourceId, String videoId, int page,
+                                           String ResourceId, String videoId, int page, int pageSize,
                                            ResponseHandlerInterface handler) {
         LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
         params.put("Method", "getVideoEpisodeList");
         params.put("Uid", uid);
         params.put("Page", page + "");
+        params.put("PageSize", pageSize + "");
         params.put("VideoId", videoId);
         params.put("ResourceId", ResourceId);
         commonPost(context, BASE_URL + "recommend", params, handler);
@@ -1266,8 +1329,8 @@
         LinkedHashMap<String, String> params = new LinkedHashMap<>();
         if (loginUid != null)
 
-        if (type != null)
-            params.put("type", type);
+            if (type != null)
+                params.put("type", type);
 
         if (token != null)
             params.put("regId", token);
@@ -1308,23 +1371,223 @@
         commonPost(context, BASE_URL + "video/play/pptvPlay", params, handler);
     }
 
+    public static void pptvFinishPlay(Context context, String cid, String vid, Integer currentTime,
+                                      ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        String uid = UserUtil.getUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+        if (uid != null)
+            params.put("Uid", uid);
+        params.put("cid", cid);
+        params.put("vid", vid);
+        if (currentTime != null) {
+            params.put("currentTime", currentTime + "");
+        }
+
+        commonPost(context, BASE_URL + "video/play/pptvFinishPlay", params, handler);
+    }
+
+
+    /**
+     * 鑾峰彇PPTV鐨勬挱鏀剧姸鎬�
+     *
+     * @param context
+     * @param cid
+     * @param vid
+     * @param handler
+     */
+
+    public static void getPPTVVideoPlayState(Context context, String cid, String vid,
+                                             ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        String uid = UserUtil.getUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+        if (uid != null)
+            params.put("Uid", uid);
+        params.put("cid", cid);
+        params.put("vid", vid);
+        commonPost(context, BASE_URL + "video/play/getPPTVVideoPlayState", params, handler);
+    }
+
+
+    /**
+     * 浠樿垂瑙嗛鐨勮喘涔版椿鍔�
+     *
+     * @param context
+     * @param cid
+     * @param vid
+     * @param handler
+     */
+    public static void getPPTVVIPVideoActivity(Context context, String url, String cid, String vid,
+                                               ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+        if (url != null) {
+            params.put("url", url);
+        }
+        params.put("cid", cid);
+        params.put("vid", vid);
+        commonPost(context, BASE_URL + "video/play/getPPTVVIPVideoActivity", params, handler);
+    }
+
+    /**
+     * --------------褰辫璞�--------------
+     */
+
+
+    /**
+     * 鎸e奖瑙嗚眴
+     *
+     * @param context
+     * @param code
+     * @param param1
+     * @param param2
+     * @param handler
+     */
+    public static void makeGoldCorn(Context context, String code, String param1, String param2,
+                                    ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        if (loginUid == null || StringUtils.isEmpty(loginUid)) {
+            return;
+        }
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        params.put("loginUid", loginUid);
+        if (code != null) {
+            params.put("code", code);
+        }
+        if (code != null) {
+            params.put("param1", param1);
+        }
+        if (code != null) {
+            params.put("param2", param2);
+        }
+        commonPost(context, BASE_URL + "goldcorn/makeGoldCorn", params, handler);
+    }
+
+
+    //鑾峰彇绛惧埌淇℃伅
+    public static void getSignInInfo(Context context,
+                                     ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+
+        commonPost(context, BASE_URL + "goldcorn/getSignInData", params, handler);
+    }
+
+    //绛惧埌
+    public static void signIn(Context context,
+                              ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+
+        commonPost(context, BASE_URL + "goldcorn/signIn", params, handler);
+    }
+
+    //鏄惁鍙互鍋氶噾甯佷换鍔�
+    public static void canDoGoldCornTask(Context context, String code,
+                                         ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+
+        params.put("code", code);
+
+        commonPost(context, BASE_URL + "goldcorn/canDoTask", params, handler);
+    }
+
+
+    //鑾峰彇鍙互鍏戞崲鍒哥殑瑙嗛
+    public static void getGoldCornCouponVideoList(Context context,
+                                                  ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+
+        commonPost(context, BASE_URL + "goldcorn/getCouponVideoList", params, handler);
+    }
+
+    //鑾峰彇浠诲姟鍒楄〃
+    public static void getGoldCornTaskList(Context context,
+                                           ResponseHandlerInterface handler) {
+        String loginUid = UserUtil.getLoginUid(context);
+        LinkedHashMap<String, String> params = new LinkedHashMap<>();
+        if (loginUid != null)
+            params.put("loginUid", loginUid);
+
+        commonPost(context, BASE_URL + "goldcorn/getTaskList", params, handler);
+    }
+
+
+    /*************浜嬩欢涓婃姤**************/
+
+    public static void readNews(Context context, ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        if (UserUtil.getUid(context) != null)
+            params.put("Uid", UserUtil.getUid(context));
+        String loginUid = UserUtil.getLoginUid(context);
+        if (loginUid != null) {
+            params.put("LoginUid", loginUid);
+        }
+        commonPost(context, BASE_URL + "event/readNews", params, handler);
+    }
+
+
+    public static void playDrawVideo(Context context,String source, String from, boolean finish, ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        if (UserUtil.getUid(context) != null)
+            params.put("Uid", UserUtil.getUid(context));
+        String loginUid = UserUtil.getLoginUid(context);
+        if (loginUid != null) {
+            params.put("LoginUid", loginUid);
+        }
+        params.put("From", from);
+        params.put("Source", source);
+        params.put("Finish", finish + "");
+        commonPost(context, BASE_URL+ "event/playDrawVideo", params, handler);
+    }
+
+    public static void readNovel(Context context, long duration,ResponseHandlerInterface handler) {
+        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
+        if (UserUtil.getUid(context) != null)
+            params.put("Uid", UserUtil.getUid(context));
+        String loginUid = UserUtil.getLoginUid(context);
+        if (loginUid != null) {
+            params.put("LoginUid", loginUid);
+        }
+        params.put("Duration", duration + "");
+        commonPost(context, BASE_URL + "event/readNovel", params, handler);
+    }
+
 
     public static LinkedHashMap<String, String> validateParams(
             LinkedHashMap<String, String> params, Context context) {
         params.put("System", "1");
-        StringBuilder sign = new StringBuilder();
-        // for (Entry<String, String> entry : params.entrySet()) {
-        // sign.append(entry.getValue());
-        // }
-        sign.append(params.get("Method"))
-                .append(StringUtils.isEmpty(params.get("Uid")) ? params.get("Device")
-                        : params.get("Uid")).append(params.get("System"));
-        if (BuildConfig.DEBUG) {
-            Log.i(TAG, "sign: " + sign);
-        }
-        params.put("Sign", MD5Utils.getMD532(sign.toString()));
         params.put("Platform", "Android");
+        params.put("YouthMode", YouthUtil.isOpenYouthMode(context) + "");
         params.put("Channel", ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL"));
+
+        //绛惧悕
+        List<String> list = new ArrayList<>();
+        for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) {
+            String key = its.next();
+            list.add(key + "=" + params.get(key));
+        }
+        Collections.sort(list);
+        String str = StringUtils.toString(list, "&");
+        String sign = MD5Utils.getMD532(str + "8888B&*@-uWan88/',@@^");
+        params.put("Sign", sign);
         return params;
     }
 
@@ -1355,8 +1618,19 @@
     private static void commonPost(Context context, String url,
                                    LinkedHashMap<String, String> params,
                                    ResponseHandlerInterface handler) {
+
+        LinkedHashMap<String, String> newParams = new LinkedHashMap<String, String>();
+        //绉婚櫎涓簄ull鐨勫��
+        for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) {
+            String key = its.next();
+            if (params.get(key) != null) {
+                newParams.put(key, params.get(key));
+            }
+        }
+
+
         if (BeibeiConstant.isDisableProxy()) {
-            commonPost(context, url, params, null, handler);
+            commonPost(context, url, newParams, null, handler);
         } else {
             Toast.makeText(context, "鏈嶅姟鍣ㄦ嫆缁濊闂紝璇锋煡鐪嬫槸鍚︾鐢ㄤ簡浠g悊鏈嶅姟鍣紒",
                     Toast.LENGTH_SHORT).show();

--
Gitblit v1.8.0