|
|
@@ -239,7 +239,6 @@ public class CommonUtil {
|
|
|
*/
|
|
|
public DownLoadInfo addNewDownloadTask(String gameName, String downloadUrl, String packageName,
|
|
|
int versionCode, String iconUrl, String size, Integer gameId, int whereFrom) {
|
|
|
-
|
|
|
DownLoadInfo task = new DownLoadInfo();
|
|
|
task.setMIconUrl(iconUrl);
|
|
|
task.setMGameName(gameName);
|
|
|
@@ -249,7 +248,7 @@ public class CommonUtil {
|
|
|
task.setMTotalSize(Double.valueOf(size));
|
|
|
task.setMGameID(gameId);
|
|
|
task.setWhereFrom(whereFrom);
|
|
|
- task.setMApkPath(DIR + File.separator + packageName + ClassFileHelper.FILE_SUFFIX);
|
|
|
+ task.setMApkPath(DIR + File.separator + packageName + downloadUrl.hashCode() + ClassFileHelper.FILE_SUFFIX);
|
|
|
return task;
|
|
|
}
|
|
|
|
|
|
@@ -502,7 +501,7 @@ public class CommonUtil {
|
|
|
break;
|
|
|
default:
|
|
|
String url = entity.getUrl();
|
|
|
- if(TextUtils.isEmpty(url))
|
|
|
+ if (TextUtils.isEmpty(url))
|
|
|
G.showToast(R.string.coming_soon);
|
|
|
else//有链接直接跳转内部h5
|
|
|
Jump2View.getInstance().goWeb(context, entity.getUrl(), entity.getTitle());
|
|
|
@@ -597,7 +596,7 @@ public class CommonUtil {
|
|
|
* 更新用户信息
|
|
|
*/
|
|
|
public void getUserInfo(Context context) {
|
|
|
- SheepApp.getInstance()
|
|
|
+ SheepApp.getInstance()
|
|
|
.getNetComponent()
|
|
|
.getApiService()
|
|
|
.getInfo()
|
|
|
@@ -850,11 +849,11 @@ public class CommonUtil {
|
|
|
|
|
|
public void shareBySysSend(Activity activity) {
|
|
|
PackageInfo packageInfo = ApkUtils.getPackageInfo(SheepApp.getInstance().getPackageName());
|
|
|
- if(packageInfo != null && packageInfo.applicationInfo != null && !TextUtils.isEmpty(packageInfo.applicationInfo.sourceDir)){
|
|
|
+ if (packageInfo != null && packageInfo.applicationInfo != null && !TextUtils.isEmpty(packageInfo.applicationInfo.sourceDir)) {
|
|
|
String dir = DIR;
|
|
|
//File dir = SheepApp.getInstance().getDir("apk", Context.MODE_PRIVATE);
|
|
|
File file = new File(dir, String.format(Locale.CHINA, "sheep_release_v%s_%d-%s.apk", packageInfo.versionName, packageInfo.versionCode, DataUtil.getInstance().getInvitationCode()));
|
|
|
- if(!file.exists()){
|
|
|
+ if (!file.exists()) {
|
|
|
try {
|
|
|
FileUtil.copyFile(new File(packageInfo.applicationInfo.sourceDir), file);
|
|
|
ZipChannelUtil.writeQUA(file, DataUtil.getInstance().getInvitationCode());
|
|
|
@@ -862,7 +861,7 @@ public class CommonUtil {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- if(file.exists())
|
|
|
+ if (file.exists())
|
|
|
shareFile(activity, file);
|
|
|
else
|
|
|
G.showToast("暂不支持,或未打开权限");
|
|
|
@@ -903,6 +902,7 @@ public class CommonUtil {
|
|
|
}
|
|
|
return mime;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 分享
|
|
|
*
|
|
|
@@ -916,6 +916,7 @@ public class CommonUtil {
|
|
|
|
|
|
/**
|
|
|
* 把homeList列表分开,例如:超维对决显示的图片是充满的,并且在绵羊头条下面
|
|
|
+ *
|
|
|
* @param allList
|
|
|
* @param homeList
|
|
|
* @param fullHomeList
|
|
|
@@ -925,19 +926,20 @@ public class CommonUtil {
|
|
|
@Override
|
|
|
public Boolean call(HomeListEntity item) {
|
|
|
boolean result = "1024".equals(item.getDesc()) || "17".equals(item.getJump());//描述为1024或者jump为17的跳转超维对决
|
|
|
- if(result){
|
|
|
+ if (result) {
|
|
|
fullHomeList.add(item);
|
|
|
}
|
|
|
return !result;
|
|
|
}
|
|
|
}));
|
|
|
}
|
|
|
+
|
|
|
//尝试直接分享小绵羊
|
|
|
public void tryShowShareDialog(final Activity activity) {
|
|
|
- callActionWithFriendCountAndAward(new Action1<FriendAndAwardEntity>() {
|
|
|
+ callActionWithFriendCountAndAward(new Action1<FriendAndAwardEntity>() {
|
|
|
@Override
|
|
|
public void call(FriendAndAwardEntity result) {
|
|
|
- if(result != null) {
|
|
|
+ if (result != null) {
|
|
|
tryShowShareDialog(activity, result.getShare_desc());
|
|
|
} else {
|
|
|
G.showToast("分享功能调试中");
|
|
|
@@ -945,12 +947,13 @@ public class CommonUtil {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
//显示分享对话框
|
|
|
public void tryShowShareDialog(final Activity activity, final String description) {
|
|
|
CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
@Override
|
|
|
public void call(UserEntity userEntity) {
|
|
|
- if(userEntity == null) {
|
|
|
+ if (userEntity == null) {
|
|
|
G.showToast("分享功能调试中");
|
|
|
return;
|
|
|
}
|
|
|
@@ -1089,7 +1092,7 @@ public class CommonUtil {
|
|
|
.showProgress(context);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("status", status);
|
|
|
- SheepApp.getInstance()
|
|
|
+ SheepApp.getInstance()
|
|
|
.getNetComponent()
|
|
|
.getApiService()
|
|
|
.gameTaskPayOrGiveUp(id, jsonObject)
|
|
|
@@ -1156,7 +1159,7 @@ public class CommonUtil {
|
|
|
* 获取代理是否显示
|
|
|
*/
|
|
|
public void getAgencyState(final Context context, final Action1<BaseMessage> action1) {
|
|
|
- SheepApp.getInstance()
|
|
|
+ SheepApp.getInstance()
|
|
|
.getNetComponent()
|
|
|
.getApiService()
|
|
|
.agentRegion()
|
|
|
@@ -1237,12 +1240,13 @@ public class CommonUtil {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
public void callActionWithUserInfo(final Action1<UserEntity> action1) {
|
|
|
UserEntity userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
- if(userEntity == null) {
|
|
|
+ if (userEntity == null) {
|
|
|
updateUserInfo(action1);
|
|
|
} else {
|
|
|
- if(action1 != null){
|
|
|
+ if (action1 != null) {
|
|
|
action1.call(userEntity);
|
|
|
}
|
|
|
}
|
|
|
@@ -1285,14 +1289,14 @@ public class CommonUtil {
|
|
|
action1.call(1);
|
|
|
}
|
|
|
}));
|
|
|
- } else if(baseMessage.getCode() == 0){
|
|
|
+ } else if (baseMessage.getCode() == 0) {
|
|
|
try {
|
|
|
if (action1 != null)
|
|
|
- action1.call(TextUtils.isEmpty(baseMessage.getData()+"")?0:Integer.valueOf(baseMessage.getData()+""));
|
|
|
+ action1.call(TextUtils.isEmpty(baseMessage.getData() + "") ? 0 : Integer.valueOf(baseMessage.getData() + ""));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
G.showToast(baseMessage.getMsg());
|
|
|
}
|
|
|
}
|
|
|
@@ -1303,6 +1307,7 @@ public class CommonUtil {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
public void acceptedTask(final Context context, final GameEntity gameEntity, final Action1<Integer> action1) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("device_id", DeviceUtil.getDeviceId(context));
|
|
|
@@ -1316,7 +1321,7 @@ public class CommonUtil {
|
|
|
try {
|
|
|
String acceptId = baseMessage.getData(String.class);
|
|
|
try {
|
|
|
- if(!TextUtils.isEmpty(acceptId))
|
|
|
+ if (!TextUtils.isEmpty(acceptId))
|
|
|
gameEntity.setAccepted_task_id(Integer.valueOf(acceptId));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -1333,19 +1338,21 @@ public class CommonUtil {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
//对---游戏任务中的领取奖励
|
|
|
public void receiveAward(final Context context, final GameEntity gameEntity, final Action1<Integer> action1) {
|
|
|
RECEIVE_AWARD_GAME_TASK.onEvent();
|
|
|
- if(gameEntity.getAccepted_task_id() < 1){
|
|
|
- acceptedTask(context,gameEntity,action1);
|
|
|
- }else {
|
|
|
+ if (gameEntity.getAccepted_task_id() < 1) {
|
|
|
+ acceptedTask(context, gameEntity, action1);
|
|
|
+ } else {
|
|
|
receiveAwards(context, gameEntity, action1);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//领取奖励
|
|
|
- public void receiveAwards(final Context context, final GameEntity gameEntity, final Action1<Integer> action1){
|
|
|
+ public void receiveAwards(final Context context, final GameEntity gameEntity, final Action1<Integer> action1) {
|
|
|
SheepApp.getInstance()
|
|
|
.getNetComponent()
|
|
|
.getApiService()
|
|
|
@@ -1778,7 +1785,7 @@ public class CommonUtil {
|
|
|
|
|
|
//设置无数据显示
|
|
|
public void updateEmptyView(View empty_view, boolean showEmpty, boolean isNetImg) {
|
|
|
- if(empty_view == null){
|
|
|
+ if (empty_view == null) {
|
|
|
return;
|
|
|
}
|
|
|
if (showEmpty) {
|
|
|
@@ -1843,7 +1850,7 @@ public class CommonUtil {
|
|
|
jsonObject.put("id", ((XiaomiGameEntity) items).getId());
|
|
|
} else if (items instanceof FindApp) {
|
|
|
jsonObject.put("id", ((FindApp) items).getId());
|
|
|
- } else if(items instanceof PlayGameEntity){
|
|
|
+ } else if (items instanceof PlayGameEntity) {
|
|
|
jsonObject.put("id", ((PlayGameEntity) items).getId());
|
|
|
}
|
|
|
|
|
|
@@ -2218,11 +2225,12 @@ public class CommonUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *tag 标签绘制
|
|
|
- R.drawable.shape_blue_stroke_rectangle_no_lb
|
|
|
- @param i -1:不限制 否者限制tag 个数
|
|
|
+ * tag 标签绘制
|
|
|
+ * R.drawable.shape_blue_stroke_rectangle_no_lb
|
|
|
+ *
|
|
|
+ * @param i -1:不限制 否者限制tag 个数
|
|
|
*/
|
|
|
- public void paintLineaLayout(Context activity, GameEntity gameEntity, LinearLayout ll_game_tag, int i, int color, int drawable){
|
|
|
+ public void paintLineaLayout(Context activity, GameEntity gameEntity, LinearLayout ll_game_tag, int i, int color, int drawable) {
|
|
|
String game_tag = gameEntity.getApp().getGame_tag();
|
|
|
if (!TextUtils.isEmpty(game_tag)) {
|
|
|
ll_game_tag.removeAllViews();
|
|
|
@@ -2249,31 +2257,32 @@ public class CommonUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 玩转游戏 按钮设置
|
|
|
* type 1
|
|
|
* 0,--------1,已接受任务 2,正在进行中,3完成任务,4放弃任务,5任务失败,6审核失败,7提交审核,8任务已下线,9至少完成了一个任务了
|
|
|
*/
|
|
|
- public void palyGameDetailBtnValue(final Context context, final GameEntity gameEntity, final TextView detail_task_tv_center, final int type){
|
|
|
+ public void palyGameDetailBtnValue(final Context context, final GameEntity gameEntity, final TextView detail_task_tv_center, final int type) {
|
|
|
final TaskReleaseEty releaseEty = gameEntity.getRelease_task();
|
|
|
- final TaskEty taskEty = releaseEty != null?releaseEty.getTask():null;
|
|
|
- if(releaseEty != null && taskEty != null) {//游戏任务
|
|
|
+ final TaskEty taskEty = releaseEty != null ? releaseEty.getTask() : null;
|
|
|
+ if (releaseEty != null && taskEty != null) {//游戏任务
|
|
|
|
|
|
if (taskEty.isGameReservationCantDownload()) {//预约
|
|
|
- if(gameEntity.getStatus() == 1 || gameEntity.getStatus() == 2 || gameEntity.getStatus() == 3){
|
|
|
+ if (gameEntity.getStatus() == 1 || gameEntity.getStatus() == 2 || gameEntity.getStatus() == 3) {
|
|
|
detail_task_tv_center.setText("已经预约");
|
|
|
detail_task_tv_center.setEnabled(false);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
detail_task_tv_center.setText("预约下载");
|
|
|
detail_task_tv_center.setEnabled(true);
|
|
|
- if(type == 0){
|
|
|
+ if (type == 0) {
|
|
|
detail_task_tv_center.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
CommonUtil.getInstance().reservationGameTask(context, releaseEty, new Action1<Integer>() {
|
|
|
@Override
|
|
|
public void call(Integer integer) {
|
|
|
- if(integer > 0){
|
|
|
+ if (integer > 0) {
|
|
|
gameEntity.setAccepted_task_id(integer);
|
|
|
detail_task_tv_center.setText("已预约");
|
|
|
detail_task_tv_center.setEnabled(false);
|
|
|
@@ -2290,7 +2299,7 @@ public class CommonUtil {
|
|
|
} else {
|
|
|
releaseEty.getDownloadHelper().updateDownloadTaskView((Activity) context, taskEty, detail_task_tv_center, null, type);
|
|
|
}
|
|
|
- }else if (gameEntity.getApp().isCanDonload()) {//可下载
|
|
|
+ } else if (gameEntity.getApp().isCanDonload()) {//可下载
|
|
|
gameEntity.getApp().getFindAppHelper().updateDownloadTaskView((Activity) context, gameEntity.getApp(), detail_task_tv_center, type);
|
|
|
detail_task_tv_center.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + gameEntity.getApp().getDownload_link());
|
|
|
} else {//预约下载
|
|
|
@@ -2301,6 +2310,7 @@ public class CommonUtil {
|
|
|
|
|
|
/**
|
|
|
* 领取礼包
|
|
|
+ *
|
|
|
* @param item
|
|
|
*/
|
|
|
public void receiveGiftById(final Context context, final GiftBagApp item, final Action1<Integer> action1, final String packageName) {
|
|
|
@@ -2312,7 +2322,7 @@ public class CommonUtil {
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
String code = baseMessage.getData(String.class);
|
|
|
item.setCode(code);
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(TO_REFRESH);
|
|
|
ViewUtil.showGetWelfareDialog((Activity) context, item, packageName);
|
|
|
}
|
|
|
@@ -2327,25 +2337,26 @@ public class CommonUtil {
|
|
|
/**
|
|
|
* 判断是否 安装应用
|
|
|
*/
|
|
|
- public boolean isInstallApp(String packageName, String name){
|
|
|
+ public boolean isInstallApp(String packageName, String name) {
|
|
|
boolean isInstalled = PackageUtil.isAppInstalled(SheepApp.getInstance(), packageName);
|
|
|
- if(!isInstalled){
|
|
|
- G.showToast("还未安装"+name);
|
|
|
+ if (!isInstalled) {
|
|
|
+ G.showToast("还未安装" + name);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 抢任务
|
|
|
*/
|
|
|
- public void robTask(final Action1<RobTask> action1){
|
|
|
+ public void robTask(final Action1<RobTask> action1) {
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().getNewTask(SpUtils.getOrder("order"))
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
- if(action1 != null){
|
|
|
+ if (action1 != null) {
|
|
|
mRobTask = baseMessage.getData(RobTask.class);
|
|
|
action1.call(mRobTask);
|
|
|
}
|
|
|
@@ -2353,7 +2364,7 @@ public class CommonUtil {
|
|
|
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
- if(action1 != null){
|
|
|
+ if (action1 != null) {
|
|
|
action1.call(null);
|
|
|
}
|
|
|
}
|
|
|
@@ -2362,24 +2373,24 @@ public class CommonUtil {
|
|
|
|
|
|
public void callActionWithFriendCountAndAward(final Action1<FriendAndAwardEntity> action1) {
|
|
|
FriendAndAwardEntity friendAndAwardEntity = DataUtil.getInstance().getCacheResult(ApiKey.friend_count_and_award, FriendAndAwardEntity.class);
|
|
|
- if(friendAndAwardEntity == null)
|
|
|
+ if (friendAndAwardEntity == null)
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().FriendCountAndAward()
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(baseMessage.getData(FriendAndAwardEntity.class));
|
|
|
}
|
|
|
});
|
|
|
- else if(action1 != null)
|
|
|
+ else if (action1 != null)
|
|
|
action1.call(friendAndAwardEntity);
|
|
|
|
|
|
}
|
|
|
@@ -2387,11 +2398,11 @@ public class CommonUtil {
|
|
|
/**
|
|
|
* 获取时间
|
|
|
*/
|
|
|
- public long[] getLastMonth(){
|
|
|
- Calendar c=Calendar.getInstance();
|
|
|
+ public long[] getLastMonth() {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
c.add(Calendar.MONTH, -1);
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- int lastMonthMaxDay=c.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
+ int lastMonthMaxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), lastMonthMaxDay, 23, 59, 59);
|
|
|
//按格式输出
|
|
|
String endtime = sdf.format(c.getTime()); //上月最后一天
|
|
|
@@ -2401,7 +2412,7 @@ public class CommonUtil {
|
|
|
Date dateStart = sdf.parse(starttime);
|
|
|
Date datEnd = sdf.parse(endtime);
|
|
|
return new long[]{dateStart.getTime(), datEnd.getTime()};
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
return null;
|
|
|
@@ -2409,6 +2420,7 @@ public class CommonUtil {
|
|
|
|
|
|
/**
|
|
|
* 幂动btn赋值
|
|
|
+ *
|
|
|
* @param activity
|
|
|
* @param btnInstall
|
|
|
* @param data
|