billyyoyo лет назад: 6
Родитель
Сommit
51e0f4b43b

+ 2 - 0
app/src/main/java/com/sheep/gamegroup/event/EventTypes.java

@@ -57,4 +57,6 @@ public enum EventTypes {
     ASK_GETMONEY_FRIEND_REFRESH , //邀请赚钱刷新
     ASK_GETMONEY_FRIEND_REFRESH , //邀请赚钱刷新
     FGT_SHEEP_HOME_MESSAGE_COUNT, //刷新消息数量
     FGT_SHEEP_HOME_MESSAGE_COUNT, //刷新消息数量
     COMMENT_REFRESH, //刷新消息数量
     COMMENT_REFRESH, //刷新消息数量
+
+    CHECK_VIP,
 }
 }

+ 49 - 13
app/src/main/java/com/sheep/gamegroup/util/DataUtil.java

@@ -35,6 +35,7 @@ import java.util.Map;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import rx.functions.Action1;
 import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
 import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action2;
 
 
 import static android.app.Activity.RESULT_OK;
 import static android.app.Activity.RESULT_OK;
 
 
@@ -50,7 +51,7 @@ public class DataUtil {
     private DataUtil() {
     private DataUtil() {
         UserEntity cacheUser = getCacheResult(ApiKey.get_info, UserEntity.class);//先从缓存中初始化用户信息
         UserEntity cacheUser = getCacheResult(ApiKey.get_info, UserEntity.class);//先从缓存中初始化用户信息
         initUserEntity(cacheUser);
         initUserEntity(cacheUser);
-        if(!TextUtils.isEmpty(token)){//如果有token,启动后台进程并初始化正在运行的自动审核任务列表
+        if (!TextUtils.isEmpty(token)) {//如果有token,启动后台进程并初始化正在运行的自动审核任务列表
             CommonUtil.getInstance().reloadAutoTaskList();
             CommonUtil.getInstance().reloadAutoTaskList();
         }
         }
         if (userEntity != null && !TextUtils.equals(userEntity.getId(), uid)) {//当前用户id与缓存的用户信息不符时,清除缓存
         if (userEntity != null && !TextUtils.equals(userEntity.getId(), uid)) {//当前用户id与缓存的用户信息不符时,清除缓存
@@ -58,8 +59,9 @@ public class DataUtil {
         }
         }
         initScreenShotConfig();
         initScreenShotConfig();
     }
     }
+
     //初始化用户相关信息
     //初始化用户相关信息
-    public void initUserEntity(UserEntity userEntity){
+    public void initUserEntity(UserEntity userEntity) {
         this.userEntity = userEntity;
         this.userEntity = userEntity;
         token = SpUtils.getToken(SheepApp.getInstance());
         token = SpUtils.getToken(SheepApp.getInstance());
         uid = TextUtils.isEmpty(token) ? "" : token.split("@")[0];
         uid = TextUtils.isEmpty(token) ? "" : token.split("@")[0];
@@ -80,6 +82,7 @@ public class DataUtil {
         userEntity = null;
         userEntity = null;
         aCache.clear();
         aCache.clear();
     }
     }
+
     /**
     /**
      * 清除aCache
      * 清除aCache
      */
      */
@@ -206,6 +209,16 @@ public class DataUtil {
 
 
     }
     }
 
 
+    public void getUserVIPDays(Action2<String, Integer> action) {
+        CommonUtil.getInstance().getUserInfo(false, (user) -> {
+            if (!user.isVIP()) return;
+            long days = (user.getVip_time() - System.currentTimeMillis() / 1000) / (24 * 60 * 60);
+            if (days >= 0 && days <= 7) {
+                action.call(user.getId() + "_" + user.getVip_time(), (int) days);
+            }
+        });
+    }
+
     //-----------------------------------------用户信息部分-----------------------------------------------------结束
     //-----------------------------------------用户信息部分-----------------------------------------------------结束
 
 
     //-----------------------------------------缓存数据部分-----------------------------------------------------开始
     //-----------------------------------------缓存数据部分-----------------------------------------------------开始
@@ -263,6 +276,7 @@ public class DataUtil {
             return ListUtil.emptyList();
             return ListUtil.emptyList();
         }
         }
     }
     }
+
     /**
     /**
      * 获取缓存的数据列表,为空代表没有获取过,为空字符串代表之前获取数据为空列表
      * 获取缓存的数据列表,为空代表没有获取过,为空字符串代表之前获取数据为空列表
      *
      *
@@ -283,7 +297,7 @@ public class DataUtil {
         }
         }
         try {
         try {
             BaseMessage baseMessage = JSON.parseObject(cacheData, BaseMessage.class);
             BaseMessage baseMessage = JSON.parseObject(cacheData, BaseMessage.class);
-            if(baseMessage != null) {
+            if (baseMessage != null) {
                 if (conversion != null) {
                 if (conversion != null) {
                     return conversion.convert(baseMessage, page);
                     return conversion.convert(baseMessage, page);
                 } else {
                 } else {
@@ -318,23 +332,29 @@ public class DataUtil {
         String result = aCache.getAsString(key);
         String result = aCache.getAsString(key);
         return NumberFormatUtils.parseInteger(result, defaultValue);
         return NumberFormatUtils.parseInteger(result, defaultValue);
     }
     }
+
     public static void putAsInt(String key, int value) {
     public static void putAsInt(String key, int value) {
         aCache.put(key, String.valueOf(value));
         aCache.put(key, String.valueOf(value));
     }
     }
+
     public static String getAsString(String key, String defaultValue) {
     public static String getAsString(String key, String defaultValue) {
         String result = aCache.getAsString(key);
         String result = aCache.getAsString(key);
         return result == null ? defaultValue : result;
         return result == null ? defaultValue : result;
     }
     }
+
     public static void putAsString(String key, String value) {
     public static void putAsString(String key, String value) {
         aCache.put(key, value);
         aCache.put(key, value);
     }
     }
+
     public static boolean getAsBoolean(String key, boolean defaultValue) {
     public static boolean getAsBoolean(String key, boolean defaultValue) {
         String result = aCache.getAsString(key);
         String result = aCache.getAsString(key);
         return result == null ? defaultValue : TextUtils.equals(result, "true");
         return result == null ? defaultValue : TextUtils.equals(result, "true");
     }
     }
+
     public static void putAsBoolean(String key, boolean value) {
     public static void putAsBoolean(String key, boolean value) {
         aCache.put(key, Boolean.toString(value));
         aCache.put(key, Boolean.toString(value));
     }
     }
+
     public static boolean toggleAsBoolean(String key, boolean defaultValue) {
     public static boolean toggleAsBoolean(String key, boolean defaultValue) {
         boolean value = !getAsBoolean(key, defaultValue);
         boolean value = !getAsBoolean(key, defaultValue);
         putAsBoolean(key, value);
         putAsBoolean(key, value);
@@ -365,15 +385,17 @@ public class DataUtil {
         }
         }
         return null;
         return null;
     }
     }
+
     //是否使用小绵羊截图方案
     //是否使用小绵羊截图方案
     public static boolean IS_USE_SCREEN_SHOT = false;//默认开启小剪刀截图,有很多问题,调整到单独的后台进程再测试
     public static boolean IS_USE_SCREEN_SHOT = false;//默认开启小剪刀截图,有很多问题,调整到单独的后台进程再测试
     //是否监听媒体库图片变化
     //是否监听媒体库图片变化
     public static boolean IS_LISTEN_SCREEN_SHOT = false;
     public static boolean IS_LISTEN_SCREEN_SHOT = false;
     //是否上传截图时使用所有图片
     //是否上传截图时使用所有图片
     public static boolean IS_USE_ALL_IMAGE = true;
     public static boolean IS_USE_ALL_IMAGE = true;
+
     //初始化是否启用小绵羊两种截图方案
     //初始化是否启用小绵羊两种截图方案
     private void initScreenShotConfig() {
     private void initScreenShotConfig() {
-        if(!IS_USE_ALL_IMAGE) {//不启用上传所有截图时才更新截图方案配置
+        if (!IS_USE_ALL_IMAGE) {//不启用上传所有截图时才更新截图方案配置
             SheepApp.getInstance().getNetComponent().getApiService().needShotScreen()
             SheepApp.getInstance().getNetComponent().getApiService().needShotScreen()
                     .subscribeOn(Schedulers.io())
                     .subscribeOn(Schedulers.io())
                     .observeOn(AndroidSchedulers.mainThread())
                     .observeOn(AndroidSchedulers.mainThread())
@@ -393,6 +415,7 @@ public class DataUtil {
                     });
                     });
         }
         }
     }
     }
+
     /**
     /**
      * 截图路径
      * 截图路径
      *
      *
@@ -400,7 +423,7 @@ public class DataUtil {
      */
      */
     public static File getScreenShotsFile(String packageName) {
     public static File getScreenShotsFile(String packageName) {
         File dir = getScreenShotsDir(packageName);
         File dir = getScreenShotsDir(packageName);
-        return new File(dir, TimeUtil.getDate("yyyy-MM-dd-hh-mm-ss")+".png");
+        return new File(dir, TimeUtil.getDate("yyyy-MM-dd-hh-mm-ss") + ".png");
     }
     }
 
 
     /**
     /**
@@ -411,6 +434,7 @@ public class DataUtil {
     public static File getScreenShotsDir() {
     public static File getScreenShotsDir() {
         return SheepApp.getInstance().getDir("ScreenShots", Context.MODE_PRIVATE);
         return SheepApp.getInstance().getDir("ScreenShots", Context.MODE_PRIVATE);
     }
     }
+
     /**
     /**
      * 指定程序的截图目录
      * 指定程序的截图目录
      *
      *
@@ -418,7 +442,7 @@ public class DataUtil {
      */
      */
     public static File getScreenShotsDir(String packageName) {
     public static File getScreenShotsDir(String packageName) {
         File dir = new File(getScreenShotsDir(), packageName);
         File dir = new File(getScreenShotsDir(), packageName);
-        if(!dir.exists())
+        if (!dir.exists())
             dir.mkdirs();
             dir.mkdirs();
         return dir;
         return dir;
     }
     }
@@ -431,13 +455,13 @@ public class DataUtil {
     public static ArrayList<String> getAllScreenShotList() {
     public static ArrayList<String> getAllScreenShotList() {
         File[] dirs = getScreenShotsDir().listFiles();
         File[] dirs = getScreenShotsDir().listFiles();
         ArrayList<String> list = ListUtil.emptyList();
         ArrayList<String> list = ListUtil.emptyList();
-        if(dirs != null) {
+        if (dirs != null) {
             for (File dir : dirs) {
             for (File dir : dirs) {
                 if (dir.exists() && dir.isDirectory()) {
                 if (dir.exists() && dir.isDirectory()) {
                     File[] files = dir.listFiles();
                     File[] files = dir.listFiles();
-                    if(files != null){
+                    if (files != null) {
                         for (File file : files) {
                         for (File file : files) {
-                            if(file.exists() && file.isFile()){
+                            if (file.exists() && file.isFile()) {
                                 list.add(file.getAbsolutePath());
                                 list.add(file.getAbsolutePath());
                             }
                             }
                         }
                         }
@@ -454,6 +478,7 @@ public class DataUtil {
     public void clearScreenShots() {
     public void clearScreenShots() {
         FileUtil.deleteFile(getScreenShotsDir(), false);
         FileUtil.deleteFile(getScreenShotsDir(), false);
     }
     }
+
     /**
     /**
      * 删除指定应用下所有截图
      * 删除指定应用下所有截图
      */
      */
@@ -467,7 +492,7 @@ public class DataUtil {
     private Action1<Integer> action1;
     private Action1<Integer> action1;
 
 
     public void requestCapturePermission(Activity activity, Action1<Integer> action1) {
     public void requestCapturePermission(Activity activity, Action1<Integer> action1) {
-        if(IS_USE_SCREEN_SHOT) {//使用小绵羊截图方案
+        if (IS_USE_SCREEN_SHOT) {//使用小绵羊截图方案
             if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
             if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                 this.action1 = action1;
                 this.action1 = action1;
                 //5.0 之后才允许使用屏幕截图
                 //5.0 之后才允许使用屏幕截图
@@ -499,6 +524,7 @@ public class DataUtil {
     //-----------------------------------------其它数据部分-----------------------------------------------------结束
     //-----------------------------------------其它数据部分-----------------------------------------------------结束
     //-----------------------------------------引导页中用到的是否为新版部分-----------------------------------------------------开始
     //-----------------------------------------引导页中用到的是否为新版部分-----------------------------------------------------开始
     private int versionType = 0;
     private int versionType = 0;
+
     public boolean notInitVersion() {
     public boolean notInitVersion() {
         return versionType == 0;
         return versionType == 0;
     }
     }
@@ -510,6 +536,7 @@ public class DataUtil {
     public boolean isNewSmallSheep() {
     public boolean isNewSmallSheep() {
         return versionType == 1;
         return versionType == 1;
     }
     }
+
     public void resetIsNewSmallSheep() {
     public void resetIsNewSmallSheep() {
         versionType = 0;
         versionType = 0;
     }
     }
@@ -519,13 +546,14 @@ public class DataUtil {
 
 
     /**
     /**
      * 获取bundle中的数据并转换为对应的类
      * 获取bundle中的数据并转换为对应的类
+     *
      * @param bundle
      * @param bundle
      * @param tClass
      * @param tClass
      * @param <T>
      * @param <T>
      * @return
      * @return
      */
      */
     public static <T> T getObject(Bundle bundle, Class<T> tClass) {
     public static <T> T getObject(Bundle bundle, Class<T> tClass) {
-        if(bundle != null) {
+        if (bundle != null) {
             String data = bundle.getString(tClass.getSimpleName());
             String data = bundle.getString(tClass.getSimpleName());
             try {
             try {
                 return JSONObject.parseObject(data, tClass);
                 return JSONObject.parseObject(data, tClass);
@@ -538,6 +566,7 @@ public class DataUtil {
 
 
     /**
     /**
      * 设置数据到bundle中,注意,其key是类名,所以同一个类只支持一条
      * 设置数据到bundle中,注意,其key是类名,所以同一个类只支持一条
+     *
      * @param bundle
      * @param bundle
      * @param t
      * @param t
      * @param <T>
      * @param <T>
@@ -545,15 +574,17 @@ public class DataUtil {
     public static <T> void putObject(Bundle bundle, T t) {
     public static <T> void putObject(Bundle bundle, T t) {
         bundle.putString(t.getClass().getSimpleName(), JSONObject.toJSONString(t));
         bundle.putString(t.getClass().getSimpleName(), JSONObject.toJSONString(t));
     }
     }
+
     /**
     /**
      * 获取bundle中的数据并转换为对应的类
      * 获取bundle中的数据并转换为对应的类
+     *
      * @param intent
      * @param intent
      * @param tClass
      * @param tClass
      * @param <T>
      * @param <T>
      * @return
      * @return
      */
      */
     public static <T> T getObject(Intent intent, Class<T> tClass) {
     public static <T> T getObject(Intent intent, Class<T> tClass) {
-        if(intent != null) {
+        if (intent != null) {
             String data = intent.getStringExtra(tClass.getSimpleName());
             String data = intent.getStringExtra(tClass.getSimpleName());
             try {
             try {
                 return JSONObject.parseObject(data, tClass);
                 return JSONObject.parseObject(data, tClass);
@@ -566,6 +597,7 @@ public class DataUtil {
 
 
     /**
     /**
      * 设置数据到bundle中,注意,其key是类名,所以同一个类只支持一条
      * 设置数据到bundle中,注意,其key是类名,所以同一个类只支持一条
+     *
      * @param <T>
      * @param <T>
      * @param intent
      * @param intent
      * @param t
      * @param t
@@ -573,8 +605,10 @@ public class DataUtil {
     public static <T> Intent putObject(Intent intent, T t) {
     public static <T> Intent putObject(Intent intent, T t) {
         return intent.putExtra(t.getClass().getSimpleName(), JSONObject.toJSONString(t));
         return intent.putExtra(t.getClass().getSimpleName(), JSONObject.toJSONString(t));
     }
     }
+
     /**
     /**
      * 设置数据到bundle中
      * 设置数据到bundle中
+     *
      * @param <T>
      * @param <T>
      * @param intent
      * @param intent
      * @param t
      * @param t
@@ -586,13 +620,14 @@ public class DataUtil {
 
 
     public static final String KEY_HAS_READ_AATI_LIST = "hasReadAppointAcceptedTaskIdList";
     public static final String KEY_HAS_READ_AATI_LIST = "hasReadAppointAcceptedTaskIdList";
     public static final String KEY_NOT_READ_AATI_LIST = "notReadAppointAcceptedTaskIdList";
     public static final String KEY_NOT_READ_AATI_LIST = "notReadAppointAcceptedTaskIdList";
+
     //检查是否有未读取的列表
     //检查是否有未读取的列表
     public boolean checkAppointList(List<TaskAcceptedEty> list) {
     public boolean checkAppointList(List<TaskAcceptedEty> list) {
         List<String> idList = JSON.parseArray(DataUtil.getAsString(KEY_HAS_READ_AATI_LIST, "[]"), String.class);
         List<String> idList = JSON.parseArray(DataUtil.getAsString(KEY_HAS_READ_AATI_LIST, "[]"), String.class);
         List<String> notReadIdList = JSON.parseArray(DataUtil.getAsString(KEY_NOT_READ_AATI_LIST, "[]"), String.class);
         List<String> notReadIdList = JSON.parseArray(DataUtil.getAsString(KEY_NOT_READ_AATI_LIST, "[]"), String.class);
         ListUtil.findIList(list, item -> {
         ListUtil.findIList(list, item -> {
             boolean result = item != null && item.getRelease_task() != null && item.getRelease_task().isAppointTask() && item.isFinish() && !idList.contains(String.valueOf(item.getId()));//是定向奖励,且可以兑换,且已经忽略的列表不包含它
             boolean result = item != null && item.getRelease_task() != null && item.getRelease_task().isAppointTask() && item.isFinish() && !idList.contains(String.valueOf(item.getId()));//是定向奖励,且可以兑换,且已经忽略的列表不包含它
-            if(result) {
+            if (result) {
                 notReadIdList.add(String.valueOf(item.getId()));
                 notReadIdList.add(String.valueOf(item.getId()));
             }
             }
             return result;
             return result;
@@ -600,6 +635,7 @@ public class DataUtil {
         DataUtil.putAsString(KEY_NOT_READ_AATI_LIST, JSON.toJSONString(notReadIdList));
         DataUtil.putAsString(KEY_NOT_READ_AATI_LIST, JSON.toJSONString(notReadIdList));
         return !notReadIdList.isEmpty();//未读的不为空就显示红点
         return !notReadIdList.isEmpty();//未读的不为空就显示红点
     }
     }
+
     //将未读取的列表添加到已经读取的列表
     //将未读取的列表添加到已经读取的列表
     public void readAppointList() {
     public void readAppointList() {
         List<String> idList = JSON.parseArray(DataUtil.getAsString(KEY_HAS_READ_AATI_LIST, "[]"), String.class);
         List<String> idList = JSON.parseArray(DataUtil.getAsString(KEY_HAS_READ_AATI_LIST, "[]"), String.class);

+ 17 - 1
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -1377,6 +1377,7 @@ public class ViewUtil {
         TextView contentView = new TextView(mContext);
         TextView contentView = new TextView(mContext);
         contentView.setText(content);
         contentView.setText(content);
         contentView.setTextSize(15f);
         contentView.setTextSize(15f);
+        contentView.setLineSpacing(5.0f, 1.5f);
 //        contentView.setTextColor(0x999999);
 //        contentView.setTextColor(0x999999);
 //        contentView.setBackgroundColor(0xff0000);
 //        contentView.setBackgroundColor(0xff0000);
         int padding = ScreenUtil.dip2px(mContext, 16);
         int padding = ScreenUtil.dip2px(mContext, 16);
@@ -1729,7 +1730,7 @@ public class ViewUtil {
                 RequestBuilder<Drawable> builder = Glide.with(activity).load(advertising.getAd_img());
                 RequestBuilder<Drawable> builder = Glide.with(activity).load(advertising.getAd_img());
                 builder.apply(new RequestOptions().transform(new RoundedCornersTransformation(activity.getResources().getDimensionPixelSize(R.dimen.content_padding_36), 0, RoundedCornersTransformation.CornerType.BOTTOM)));
                 builder.apply(new RequestOptions().transform(new RoundedCornersTransformation(activity.getResources().getDimensionPixelSize(R.dimen.content_padding_36), 0, RoundedCornersTransformation.CornerType.BOTTOM)));
                 builder.into(ad_iv);
                 builder.into(ad_iv);
-                if(advertising.getAd_img().toLowerCase().endsWith("gif")){
+                if (advertising.getAd_img().toLowerCase().endsWith("gif")) {
                     ViewUtil.setGif(ad_iv, advertising.getAd_img());
                     ViewUtil.setGif(ad_iv, advertising.getAd_img());
                 } else {
                 } else {
                     ViewUtil.setImage(ad_iv, advertising.getAd_img());
                     ViewUtil.setImage(ad_iv, advertising.getAd_img());
@@ -1795,6 +1796,7 @@ public class ViewUtil {
                     aCache.put(advertising.getAd_img(), String.format(Locale.CHINA, "%d;%d", dialog_center_ll.getWidth(), dialog_center_ll.getHeight()));
                     aCache.put(advertising.getAd_img(), String.format(Locale.CHINA, "%d;%d", dialog_center_ll.getWidth(), dialog_center_ll.getHeight()));
                     Jump2View.getInstance().tryShowYfShopAskDialog(activity);
                     Jump2View.getInstance().tryShowYfShopAskDialog(activity);
                     EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.GUIDE_NEXT));
                     EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.GUIDE_NEXT));
+                    EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.CHECK_VIP));
                 }
                 }
             });
             });
             setVisibility(ad_flag, advertising.getUser_type() == 2);
             setVisibility(ad_flag, advertising.getUser_type() == 2);
@@ -1815,6 +1817,20 @@ public class ViewUtil {
         }
         }
     }
     }
 
 
+    public static void showVipWillOver(Context context, String flag, int days) {
+        int curr = DataUtil.getAsInt("vip_" + flag, -1);
+        if (curr == -1 || days < curr) {
+            DataUtil.putAsInt("vip_" + flag, days);
+            showConfirmDialog(context, "温馨提示", "您的会员剩余" + days + "天过期, 为保障您的会员权益请立即续费~!",
+                    "下次再说", "立即续费", diag -> {
+
+                    },
+                    dialog -> {
+                        Jump2View.getInstance().gotoVip(context);
+                    }).show();
+        }
+    }
+
     //3.4.7添加 -- 展示商城优惠券领取对话框
     //3.4.7添加 -- 展示商城优惠券领取对话框
     public static void showYfShopAd(final Activity activity, ReceiveCouponsCheckResq receiveCouponsCheckResq) {
     public static void showYfShopAd(final Activity activity, ReceiveCouponsCheckResq receiveCouponsCheckResq) {
         if (activity != null) {
         if (activity != null) {

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -478,6 +478,9 @@ public class ActMain extends BaseActYmPermissionCheck {
     @Subscribe
     @Subscribe
     public void onEventMainThread(BigEvent event) {
     public void onEventMainThread(BigEvent event) {
         switch (event.getEventTypes()) {
         switch (event.getEventTypes()) {
+            case CHECK_VIP:
+                DataUtil.getInstance().getUserVIPDays((flag, days) -> ViewUtil.showVipWillOver(this, flag, days));
+                break;
             case STORAGE_LOW:
             case STORAGE_LOW:
                 DialogStorageLow.showDialog(null);
                 DialogStorageLow.showDialog(null);
                 break;
                 break;