package com.mugua.mgvideo;
|
|
import java.io.File;
|
import java.io.FileNotFoundException;
|
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
import java.util.Map.Entry;
|
|
import android.content.Context;
|
import android.content.SharedPreferences;
|
import android.util.Log;
|
import android.widget.Toast;
|
|
import com.lcjian.library.DeviceUuidFactory;
|
import com.lcjian.library.util.ManifestDataUtil;
|
import com.lcjian.library.util.common.PackageUtils2;
|
import com.lcjian.library.util.common.StringUtils;
|
import com.lcjian.library.util.security.MD5Utils;
|
import com.loopj.android.http.AsyncHttpClient;
|
import com.loopj.android.http.RequestParams;
|
import com.loopj.android.http.ResponseHandlerInterface;
|
import com.loopj.android.http.SyncHttpClient;
|
import com.yeshi.base.utils.BeibeiConstant;
|
import com.yeshi.base.utils.YouthUtil;
|
import com.yeshi.base.utils.http.API;
|
|
public class MGVideoAPI {
|
|
public static final boolean isDebug = false;
|
|
private static final String TAG = "BeibeiVideoAPI";
|
|
public static String ERROR_NOTICE = "";
|
|
public static String BASE_URL = API.HOST + "/BuWan/api/v2/";
|
|
private static AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
|
|
private static SyncHttpClient syncHttpClient = new SyncHttpClient();
|
|
static {
|
asyncHttpClient.setTimeout(60 * 1000);
|
syncHttpClient.setTimeout(60 * 1000);
|
asyncHttpClient.setURLEncodingEnabled(false);
|
syncHttpClient.setURLEncodingEnabled(false);
|
}
|
|
public static String getDeviceId(Context context) {
|
SharedPreferences deviceInfo = context.getSharedPreferences("deviceInfo", Context.MODE_PRIVATE);
|
String deviceId = deviceInfo.getString("device", "");
|
if (StringUtils.isEmpty(deviceId)) {
|
deviceId = new DeviceUuidFactory(context).getDeviceUuid() + "";
|
if (!StringUtils.isEmpty(deviceId)) {
|
SharedPreferences.Editor editor = deviceInfo.edit();
|
editor.putString("device", deviceId);
|
editor.commit();
|
}
|
}
|
return deviceId;
|
}
|
|
public static void getUid(Context context, String channel, String device,
|
String imei, String mac, String lat, String lng,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<>();
|
params.put("Method", "getUid");
|
params.put("Device", device);
|
if (imei != null)
|
params.put("Imei", imei);
|
if (mac != null)
|
params.put("Mac", mac);
|
if (lat != null)
|
params.put("Lat", lat);
|
if (lng != null)
|
params.put("Lng", lng);
|
params.put("Channel", channel);
|
if (!StringUtils.isBlank(MGVideoApplication.deviceNumber)) {
|
params.put("DeviceName", MGVideoApplication.deviceName);
|
params.put("DeviceNumber", MGVideoApplication.deviceNumber);
|
}
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getAdState1(Context context, String channel,
|
String device, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getAdState1");
|
params.put("Device", device);
|
params.put("Channel", channel);
|
if (!StringUtils.isBlank(MGVideoApplication.deviceNumber)) {
|
params.put("DeviceName", MGVideoApplication.deviceName);
|
params.put("DeviceNumber", MGVideoApplication.deviceNumber);
|
}
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void suggestSearch(Context context, String uid, String key,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "suggestSearch");
|
params.put("Uid", uid);
|
params.put("Key", key);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 用户登录
|
*
|
* @param context
|
* @param uid 用户uid
|
* @param name 用户名称
|
* @param openId 用户第三方登录唯一识别码
|
* @param portrait 头像
|
* @param sex 性别
|
* @param loginType 登录类型:1 QQ
|
* @param handler
|
*/
|
public static void userLogin(Context context, String uid, String name,
|
String openId, String portrait, String sex, String loginType,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "userLogin");
|
params.put("Uid", uid);
|
params.put("Name", name);
|
params.put("OpenId", openId);
|
params.put("Portrait", portrait);
|
params.put("Sex", sex);
|
params.put("LoginType", loginType);
|
commonPost(context, BASE_URL + "comment", 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);
|
}
|
|
|
/**
|
* 获取专题列表
|
*
|
* @param context
|
* @param uid
|
* @param page 分页数
|
* @param handler
|
*/
|
public static void getSpecialList(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getSpecialList");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
public static void search(Context context, String uid, String key,
|
String videoType, String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "searchNew");
|
params.put("Uid", uid);
|
params.put("Key", key);
|
params.put("Type", "1");
|
params.put("VideoType", videoType);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 百战网资讯分类
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void newsCategory(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getNewsType");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "news", params, handler);
|
}
|
|
/**
|
* 百战网资讯列表
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getNewsList(Context context, String uid, String type,
|
int page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getNewsTypeContent");
|
params.put("Uid", uid);
|
params.put("Type", type);
|
params.put("Page", page + "");
|
commonPost(context, BASE_URL + "news", params, handler);
|
}
|
|
/**
|
* 上传通讯录
|
*
|
* @param context
|
* @param uid
|
* @param contact
|
* @param handler
|
*/
|
public static void updateContact(Context context, String uid,
|
String contact, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "addContact");
|
params.put("Uid", uid);
|
params.put("Contact", contact);
|
commonPost(context, BASE_URL + "other", 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("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 获取我的评论列表
|
*/
|
public static void getMyCommentList(Context context, String uid,
|
String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getMyCommentReply");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
/**
|
* 获取我是否拥有新消息
|
*/
|
public static void getReadState(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getReadState");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
public static void getAdList(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getAdList");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
}
|
|
/**
|
* 相关视频
|
*
|
* @param context
|
* @param uid
|
* @param videoId
|
* @param handler
|
*/
|
public static void getRelativeVideos(Context context, String uid,
|
String videoId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getRelativeVideos");
|
params.put("VideoId", videoId);
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 猜你喜欢
|
*
|
* @param context
|
* @param uid
|
* @param videoId
|
* @param handler
|
*/
|
public static void guessLike(Context context, String uid, String videoId,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "guessLike");
|
params.put("VideoId", videoId);
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 大家都在看
|
*
|
* @param context
|
* @param uid
|
* @param videoId
|
* @param handler
|
*/
|
public static void getPeopleSeeVideos(Context context, String uid,
|
String videoId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getPeopleSeeVideos");
|
params.put("VideoId", videoId);
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getUserInfo(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getUserInfo");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 获取广告为ID
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getConfig(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<>();
|
params.put("Method", "getConfig");
|
commonPost(context, BASE_URL + "config", params, handler);
|
}
|
|
public static void getCollectedVideo(Context context, String uid,
|
String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getCollectedVideo");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getWatchHistory(Context context, String uid,
|
String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getWatchHistory");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreHistory(Context context, String uid,
|
String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreHistory");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreRule(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreRule");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void costScore(Context context, String uid, String ruleId,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "costScore");
|
params.put("Uid", uid);
|
params.put("Id", ruleId);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreOpen(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreOpen");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreWatch(Context context, String uid,
|
String videoDetailId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreWatch");
|
params.put("Uid", uid);
|
params.put("VideoDetailId", videoDetailId);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreSave(Context context, String uid,
|
String videoDetailId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreSave");
|
params.put("Uid", uid);
|
params.put("VideoDetailId", videoDetailId);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreCollect(Context context, String uid,
|
String videoId, String thirdType, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreCollect");
|
params.put("Uid", uid);
|
params.put("VideoId", videoId);
|
params.put("ThirdType", thirdType);
|
params.put("Type", type);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getScoreShare(Context context, String uid,
|
String platform, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getScoreShare");
|
params.put("Uid", uid);
|
params.put("SharePlatform", platform);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 用户登录
|
*
|
* @param context
|
* @param uid 用户uid
|
* @param name 用户名称
|
* @param openId 用户第三方登录唯一识别码
|
* @param portrait 头像
|
* @param sex 性别
|
* @param loginType 登录类型:1 QQ
|
* @param handler
|
*/
|
public static void userLogin(Context context, String uid, String name,
|
String openId, String portrait, String sex, String province,
|
String city, String loginType, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "userLogin");
|
params.put("Uid", uid);
|
params.put("Name", name);
|
params.put("OpenId", openId);
|
params.put("Portrait", portrait);
|
params.put("Province", province);
|
params.put("City", city);
|
params.put("Sex", sex);
|
params.put("LoginType", loginType);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
/**
|
* Email登陆
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void emailLogin(Context context, String uid, String name,
|
String pwd, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "login");
|
params.put("Uid", uid);
|
params.put("Email", name);
|
params.put("Pwd", pwd);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
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);
|
if (vtid != null) {
|
params.put("Vtid", vtid);
|
}
|
if (dataKey != null) {
|
params.put("DataKey", dataKey);
|
}
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
}
|
|
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", "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);
|
}
|
|
/**
|
* 修改密码
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void revisePwd(Context context, String uid, String email,
|
String verfycode, String pwd, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "setPwd");
|
params.put("Uid", uid);
|
params.put("Email", email);
|
params.put("Pwd", pwd);
|
params.put("VerifyCode", verfycode);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 获取验证码
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getVerficationCode(Context context, String uid,
|
String name, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "sendVerifyCode");
|
params.put("Uid", uid);
|
params.put("Email", name);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getMoreVideo(Context context, String uid, String type,
|
String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getMoreVideo");
|
params.put("Uid", uid);
|
params.put("Type", type);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
}
|
|
public static void getClass(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getNewClass");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
public static void getHotStars(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getHotStars");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
/**
|
* 获取个人信息
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
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);
|
}
|
|
/**
|
* 上传个人信息
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void upLoadPersonInfo(Context context, String uid,
|
String loginUid, String sex, String birthday, 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);
|
}
|
|
/**
|
* Email注册
|
*
|
* @param context
|
* @param uid
|
* @param name
|
* @param handler
|
*/
|
public static void emailRegister(Context context, String uid, String email,
|
String pwd, String verficationCode, String name,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "register");
|
params.put("Uid", uid);
|
params.put("Email", email);
|
params.put("Pwd", pwd);
|
params.put("VerifyCode", verficationCode);
|
params.put("NickName", name);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getHotStarsVideo(Context context, String uid,
|
String starId, String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getHotStarsVideo");
|
params.put("Uid", uid);
|
params.put("StarId", starId);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
public static void getVideoList(Context context, String uid, String starId,
|
String homeType, String videoType, String page,
|
String category_two, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getVideoList");
|
params.put("Uid", uid);
|
params.put("StarId", starId);
|
params.put("HomeType", homeType);
|
params.put("VideoType", videoType);
|
params.put("Page", page);
|
params.put("Order", category_two);
|
commonPost(context, BASE_URL + "class", params, handler);
|
|
}
|
|
public static void getMVideoList(Context context, String uid, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getIntersection");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "other", params, handler);
|
}
|
|
/**
|
* 专题详情
|
*
|
* @param context
|
* @param uid
|
* @param id
|
* @param handler
|
*/
|
public static void getSpecialDetail(Context context, String uid, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getSpecialDetail");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
/**
|
* 明星详情
|
*
|
* @param context
|
* @param id
|
* @param handler
|
*/
|
public static void getHotStarDetail(Context context, String uid, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getHotStarDetail");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
/**
|
* 添加收藏
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void addGoodsFavourite(Context context, String uid,
|
String id, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "addCollect");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
/**
|
* 取消收藏
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void cancelGoodsFavourite(Context context, String uid,
|
String id, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "cancelCollect");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
|
/**
|
* 视频评论列表
|
*
|
* @param context
|
* @param uid
|
* @param videoId
|
* @param thirdType
|
* @param Page
|
* @param handler
|
*/
|
public static void getVideoCommentList(Context context, String uid,
|
String videoId, String thirdType, String Page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getVideoCommentList");
|
params.put("Uid", uid);
|
params.put("VideoId", videoId);
|
params.put("ThirdType", thirdType);
|
params.put("Page", Page);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
/**
|
* 添加评论
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void Comment(Context context, String loginUid,
|
String videoId, String thirdTyoe, String Content,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "comment");
|
params.put("Uid", loginUid);
|
params.put("VideoId", videoId);
|
params.put("ThirdType", thirdTyoe);
|
params.put("Content", Content);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
/**
|
* 淘宝客收藏列表
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getCollectList(Context context, String uid, String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getCollectList");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
/**
|
* 广告点击上报
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void reportCommonAd(Context context, String uid, String pId,
|
String adId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "reportCommonAd");
|
params.put("Uid", uid);
|
params.put("Pid", pId);
|
params.put("AdId", adId);
|
params.put("Type", "3");
|
commonPost(context, BASE_URL + "ad", params, handler);
|
}
|
|
public static void getDiscpverAd(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getSpecialMainList");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "found", params, handler);
|
}
|
|
/**
|
* 获取商品列表
|
*
|
* @param context
|
* @param uid
|
* @param page
|
* @param handler
|
*/
|
public static void getWareList(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getGoodsItemList");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
/**
|
* 获取商品评论列表
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getWareCommentList(Context context, String uid,
|
String id, String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getCommentList");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
/**
|
* 添加关注
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void addAttention(Context context, String uid,
|
String loginId, String videoId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "addAttention");
|
params.put("Uid", uid);
|
params.put("LoginUid", loginId);
|
params.put("VideoId", videoId);
|
commonPost(context, BASE_URL + "attention", params, handler);
|
}
|
|
/**
|
* 取消关注
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void cancelAttention(Context context, String uid,
|
String loginId, String videoId, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "cancelAttention");
|
params.put("Uid", uid);
|
params.put("LoginUid", loginId);
|
params.put("VideoId", videoId);
|
commonPost(context, BASE_URL + "attention", params, handler);
|
}
|
|
/**
|
* 回复评论
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void replayComment(Context context, String loginUid,
|
String commentReplyId, String commentId, String Content,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "replayComment");
|
params.put("Uid", loginUid);
|
params.put("CommentReplyId", commentReplyId);
|
params.put("CommentId", commentId);
|
params.put("Content", Content);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
/**
|
* 有道广告展示统计
|
*
|
* @param context
|
* @param uid
|
* @param key 有道key
|
* @param handler
|
*/
|
public static void setYdAdNum(Context context, String uid, String key,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "ydAd");
|
params.put("Uid", uid);
|
params.put("Key", key);
|
commonPost(context, BASE_URL + "other", params, handler);
|
}
|
|
/**
|
* 发现页明星合辑
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getRecommendStars(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getHotStarMainList");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "found", params, handler);
|
}
|
|
/**
|
* 获取美女直播信息
|
*
|
* @param context
|
* @param uid
|
* @param type
|
* @param handler
|
*/
|
public static void getLiveList(Context context, String uid, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getMeiNvZhiBo");
|
params.put("Uid", uid);
|
params.put("Type", type);
|
commonPost(context, BASE_URL + "other", params, handler);
|
}
|
|
/**
|
* 发表评论
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void addComment(Context context, String uid, String id,
|
String loginID, String content, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "addComment");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
params.put("LoginUid", loginID);
|
params.put("Content", content);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
/**
|
* 获取商品详情
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getWareDetail(Context context, String uid, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getGoodsItemDetail");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "shop", params, handler);
|
}
|
|
public static void getFirstChildType(Context context, String ParentId,
|
String uid, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getFirstChildType");
|
params.put("ParentId", ParentId);
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
public static void getHotStars(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getHotType");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "class", params, handler);
|
}
|
|
public static void getVideoLiveList(Context context, String start,
|
ResponseHandlerInterface handler) {
|
RequestParams params = new RequestParams();
|
|
asyncHttpClient.post(context,
|
"http://www.kktv1.com/CDN/output/M/3/I/10002002/P/start-"
|
+ start + "_offset-20_platform-2/json.js", params,
|
handler);
|
}
|
|
/**
|
* 么么直播数据请求
|
*
|
* @param context
|
* @param page
|
* @param handler
|
*/
|
public static void getMeMeVideoLiveList(Context context, String page,
|
ResponseHandlerInterface handler) {
|
RequestParams params = new RequestParams();
|
asyncHttpClient.post(context,
|
"http://api.memeyule.com/union/star_json?from=mugua_2&page="
|
+ page + "&size=20&sort=1", params, handler);
|
}
|
|
public static void getVideoDetail(Context context, String uid,
|
String videoId, String type, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getVideoDetail");
|
params.put("Uid", uid);
|
params.put("Id", videoId);
|
params.put("Type", type);
|
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);
|
}
|
|
// 统计KK的安装次数
|
public static void kkInstall(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "kkinstall");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "other", params, handler);
|
}
|
|
public static void isCollect(Context context, String uid, String videoId,
|
String thirdType, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "isCollect");
|
params.put("Uid", uid);
|
params.put("Id", videoId);
|
params.put("ThirdType", thirdType);
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
}
|
|
public static void getAdState(Context context, String uid, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getAdState");
|
params.put("Uid", uid);
|
params.put("Type", type);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
/**
|
* 获取真实播放路劲
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void getPlayUrl(Context context, String uid, String type,
|
String videoId, String vid, String resourceId, String eId,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getPlayUrl");
|
params.put("Uid", uid);
|
params.put("Type", type);
|
params.put("VideoId", videoId);
|
params.put("Id", vid);
|
params.put("EId", eId);
|
params.put("ResourceId", resourceId);
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
}
|
|
public static void getVideoDetail(Context context, String uid,
|
String ResourceId, String videoId, String loginid, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getVideoDetail");
|
params.put("Uid", uid);
|
params.put("LoginUid", loginid);
|
params.put("VideoId", videoId);
|
params.put("ResourceId", ResourceId);
|
params.put("Type", type);
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
|
}
|
|
public static void getHomeMoreVideo(Context context, String uid,
|
String page, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getHomeMoreVideo");
|
params.put("Uid", uid);
|
params.put("Page", page);
|
commonPost(context, BASE_URL + "recommend", params, handler);
|
}
|
|
public static void getUserBanner(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getUserBanner");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "user", params, handler);
|
}
|
|
public static void getThirdVideo(Context context, String uid, String url,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getThirdVideo");
|
params.put("Uid", uid);
|
params.put("Url", url);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
public static void getThirdVideoRequest(Context context, String uid,
|
String videoDetailId, String url, String step, String data,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getThirdVideoRequest");
|
params.put("Uid", uid);
|
params.put("Id", videoDetailId);
|
params.put("Url", url);
|
params.put("Step", step);
|
params.put("Data", data);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
public static void parseVideoUrl(Context context, String uid,
|
String baseurl, String videoDetailId, String data,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "parseVideoUrl");
|
params.put("Uid", uid);
|
params.put("Id", videoDetailId);
|
params.put("Data", data);
|
params.put("Url", baseurl);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
public static void setVideoError(Context context, String uid, String data,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "setVideoError");
|
params.put("Uid", uid);
|
params.put("Data", data);
|
commonPost(context, BASE_URL + "other", params, null, handler);
|
}
|
|
public static void setVideoErrorSy(Context context, String uid,
|
String data, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "setVideoError");
|
params.put("Uid", uid);
|
params.put("Data", data);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
public static void getWxAd(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getWxAd");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "other", params, null, handler);
|
}
|
|
public static void wxClickAction(Context context, String uid, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "wxClickAction");
|
params.put("Uid", uid);
|
params.put("Id", id);
|
commonPost(context, BASE_URL + "other", params, null, handler);
|
}
|
|
public static void getNotice(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getNotice");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "other", params, handler);
|
}
|
|
// 获取真实连接
|
public static void getRealUrl(Context context, String uid, String urlId,
|
String url, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getRealUrl");
|
params.put("Uid", uid);
|
params.put("Url", url);
|
params.put("Id", urlId);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
// 获取注册链接
|
public static void getLSRegisterUrlRequest(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getLSRegisterUrl");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
// 获取激活链接
|
public static void getLSActiveUrlRequest(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getLSActiveUrl");
|
params.put("Uid", uid);
|
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
// 获取登录链接
|
public static void getLSLoginUrlRequest(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "getLSLoginUrl");
|
params.put("Uid", uid);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
public static void reportRequestResult(Context context, String uid,
|
String type, String header, String data,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "reportRequestResult");
|
params.put("Uid", uid);
|
params.put("Type", type);
|
params.put("Data", data);
|
params.put("Header", header);
|
commonPost(context, BASE_URL + "other", params, null, handler, false);
|
}
|
|
|
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"));
|
return params;
|
}
|
|
@SuppressWarnings("unused")
|
private static void commonGet(Context context, String url,
|
LinkedHashMap<String, String> params,
|
ResponseHandlerInterface handler) {
|
commonGet(context, url, params, handler, true);
|
}
|
|
public static void commonGet(Context context, String url,
|
LinkedHashMap<String, String> params,
|
ResponseHandlerInterface handler, boolean asyn) {
|
params.put("Package", PackageUtils2.getPackageName(context));
|
LinkedHashMap<String, String> map = validateParams(params, context);
|
|
RequestParams requestParams = new RequestParams(map);
|
if (BuildConfig.DEBUG) {
|
Log.i(TAG, "get url: " + url + "?" + requestParams.toString());
|
}
|
if (asyn) {
|
(asyncHttpClient).get(context, url, requestParams, handler);
|
} else {
|
(syncHttpClient).get(context, url, requestParams, handler);
|
}
|
}
|
|
private static void commonPost(Context context, String url,
|
LinkedHashMap<String, String> params,
|
ResponseHandlerInterface handler) {
|
if (BeibeiConstant.isDisableProxy()) {
|
commonPost(context, url, params, null, handler);
|
} else {
|
Toast.makeText(context, "服务器拒绝访问,请查看是否禁用了代理服务器!",
|
Toast.LENGTH_SHORT).show();
|
return;
|
}
|
}
|
|
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);
|
}
|
|
private static void commonPost(Context context, String url,
|
LinkedHashMap<String, String> params, HashMap<String, File> files,
|
ResponseHandlerInterface handler, boolean asyn) {
|
params.put("Package", PackageUtils2.getPackageName(context));//context.getPackageName()
|
int version = PackageUtils2.getVersionCode(context);
|
params.put("Version", version + "");
|
|
LinkedHashMap<String, String> map = validateParams(params, context);
|
RequestParams requestParams = new RequestParams(map);
|
if (BuildConfig.DEBUG) {
|
Log.i(TAG, "post url: " + url + "?" + requestParams.toString());
|
}
|
if (files != null) {
|
for (Entry<String, File> entry : files.entrySet()) {
|
try {
|
requestParams.put(entry.getKey(), entry.getValue());
|
} catch (FileNotFoundException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
if (asyn) {
|
// asyncHttpClient.setProxy("192.168.1.122", 8888);
|
asyncHttpClient.post(context, url, requestParams, handler);
|
} else {
|
// asyncHttpClient.setProxy("192.168.1.122", 8888);
|
syncHttpClient.post(context, url, requestParams, handler);
|
}
|
}
|
|
public static void commonGet(Context context, String url,
|
RequestParams params, ResponseHandlerInterface handler, boolean asyn) {
|
if (asyn) {
|
asyncHttpClient.get(context, url, params, handler);
|
} else {
|
syncHttpClient.get(context, url, params, handler);
|
}
|
}
|
|
public static void commonGet(Context context, String url,
|
ResponseHandlerInterface handler, boolean asyn) {
|
if (asyn) {
|
asyncHttpClient.get(context, url, handler);
|
} else {
|
syncHttpClient.get(context, url, handler);
|
}
|
|
}
|
}
|