| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.util.Log; |
| | | import android.widget.Toast; |
| | | |
| | | import com.yeshi.makemoney.video.app.utils.Constant; |
| | |
| | | import com.demo.lib.common.util.device.DeviceInfoUtil; |
| | | import com.demo.lib.common.util.device.MobileUtil; |
| | | import com.demo.lib.common.util.security.MD5Utils; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | private static final String TAG = "HttpApiUtil"; |
| | | |
| | | public static String BASE_URL = Constant.HOST + "/fanli/api/v1/"; |
| | | public static String BASE_URL = Constant.HOST + "/api/v1/"; |
| | | |
| | | public static OkHttpClient mOkHttpClient;//okHttpClient 实例 |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 请求demo |
| | | * |
| | | * @param context |
| | | * @param handler |
| | | */ |
| | | public static void xxx(Context context, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | commonPostWithFailture(context, BASE_URL + "xxx/xxx", params, handler); |
| | | } |
| | | |
| | | |
| | | public static void getConfig(Context context, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | commonPostWithFailture(context, BASE_URL + "xxx/xxx", params, handler); |
| | | } |
| | | |
| | | |
| | | public static void uploadPushRegId(Context context, String regId, BasicTextHttpResponseHandler handler) { |
| | | Log.i(TAG,"uploadPushRegId:"+regId); |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | String uid = UserUtil.getUid(context); |
| | | if (!StringUtils.isEmpty(uid)) |
| | | params.put("uid", uid); |
| | | params.put("regId", regId); |
| | | commonPostWithFailture(context, BASE_URL + "user/uploadPushRegId", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 获取任务信息 |
| | | * |
| | | * @param context |
| | | * @param type |
| | | * @param handler |
| | | */ |
| | | public static void getTaskInfo(Context context, String type, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | String uid = UserUtil.getUid(context); |
| | | if (!StringUtils.isEmpty(uid)) |
| | | params.put("uid", uid); |
| | | params.put("type", type); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/getTaskInfo", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 观看短视频 |
| | | * |
| | | * @param context |
| | | * @param second |
| | | * @param handler |
| | | */ |
| | | public static void watchDrawVideo(Context context, int second, boolean isDouble, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("timeSeconds", second + ""); |
| | | String uid = UserUtil.getUid(context); |
| | | params.put("uid", uid); |
| | | params.put("type", "watchVideo"); |
| | | params.put("doubles", isDouble + ""); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/doTask", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 读小说 |
| | | * |
| | | * @param context |
| | | * @param second |
| | | * @param handler |
| | | */ |
| | | public static void readNovel(Context context, int second, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("timeSeconds", second + ""); |
| | | String uid = UserUtil.getUid(context); |
| | | params.put("uid", uid); |
| | | params.put("type", "readNovel"); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/doTask", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 浏览资讯 |
| | | * |
| | | * @param context |
| | | * @param num |
| | | * @param handler |
| | | */ |
| | | public static void scanNews(Context context, int num, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("num", num + ""); |
| | | String uid = UserUtil.getUid(context); |
| | | params.put("uid", uid); |
| | | params.put("type", "scanNews"); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/doTask", params, handler); |
| | | } |
| | | |
| | | |
| | | private static void commonPost(Context context, String url, |
| | |
| | | for (String str : list) { |
| | | sign += str + "&"; |
| | | } |
| | | return MD5Utils.getMD532(sign + "buXiNjie2017!"); |
| | | return MD5Utils.getMD532(sign + "BuWan*@_%MakeMoney!!"); |
| | | } |
| | | |
| | | |
| | |
| | | long time = System.currentTimeMillis(); |
| | | String deviceType = DeviceInfoUtil.getSystemModel(context); |
| | | params.put("packages", context.getPackageName()); |
| | | params.put("Version", version + ""); |
| | | params.put("version", version + ""); |
| | | params.put("platform", "android"); |
| | | params.put("channel", ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL")); |
| | | params.put("osVersion", MobileUtil.getSystemVersion()); |
| | | params.put("deviceType", StringUtils.isEmpty(deviceType) ? "" : deviceType); |
| | | params.put("time", time + ""); |
| | | params.put("timestamp", time + ""); |
| | | params.put("device", DeviceInfoUtil.getDeviceId(context)); |
| | | params.put("utdid", DeviceInfoUtil.getUtdid(context)); |
| | | params.put("utdId", DeviceInfoUtil.getUtdid(context)); |
| | | return params; |
| | | } |
| | | } |