| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private static AsyncHttpClient sortTimeAsyncHttpClient = new AsyncHttpClient(); |
| | | |
| | | static { |
| | | |
| | | mOkHttpClient = new OkHttpClient().newBuilder() |
| | | .connectTimeout(10 * 1000, TimeUnit.SECONDS)//设置超时时间 |
| | | .readTimeout(10 * 1000, TimeUnit.SECONDS)//设置读取超时时间 |
| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 电话号码绑定 |
| | | * |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public static void getHomeType(Context context, String uid, String vtid, String dataKey, |
| | | 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); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取剧集列表 |
| | | * |
| | |
| | | * @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); |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 付费视频的购买活动 |
| | |
| | | commonPost(context, BASE_URL + "video/play/getPPTVVIPVideoActivity", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * --------------影视豆-------------- |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * 挣影视豆 |
| | | * |
| | | * @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"); |
| | | params.put("Platform", "Android"); |
| | | params.put("YouthMode", YouthUtil.isOpenYouthMode(context) + ""); |
| | | params.put("Channel", ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL")); |
| | | |
| | | //签名 |