Bladeren bron

添加定向任务中判断小红点

zengjiebin 7 jaren geleden
bovenliggende
commit
4970329c8f

+ 17 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/Release_task.java

@@ -88,6 +88,8 @@ public class Release_task implements Serializable {
     private int gift_ratio;//赠送比例,取值0-100
     private int user_task_status;//备注:和任务记录状态一样
 
+    private int is_appoint;// int(11) NOT NULL DEFAULT '0' COMMENT '是否指定任务 1:是 0:不指定'
+
     public int getDemo_time() {
         return demo_time;
     }
@@ -331,6 +333,14 @@ public class Release_task implements Serializable {
         this.consume_amount = consume_amount;
     }
 
+    public void setIs_appoint(int is_appoint) {
+        this.is_appoint = is_appoint;
+    }
+
+    public int getIs_appoint() {
+        return is_appoint;
+    }
+
     @Override
     public boolean equals(Object obj) {
         return obj instanceof Release_task && ((Release_task) obj).getId() == id;
@@ -429,4 +439,11 @@ public class Release_task implements Serializable {
     public String getFuliContent() {
         return  String.format(Locale.CHINA, "恭喜您已获得%s元奖励,需最低消费%d,可抵奖励%s。羊羊给的奖励,赶紧前往购买吧!", getBonusText(), consume_amount, NumberFormatUtils.retainMost2(gift_ratio * consume_amount / 100));
     }
+
+    /**
+     * 是否是定向任务
+     */
+    public boolean isAppointTask() {
+        return is_appoint == 1;
+    }
 }

+ 35 - 0
app/src/main/java/com/sheep/gamegroup/model/util/ShowRedDot.java

@@ -0,0 +1,35 @@
+package com.sheep.gamegroup.model.util;
+
+/**
+ * Created by realicing on 2019/3/15.
+ * realicing@sina.com
+ * 是否显示红点 数据类型
+ */
+public class ShowRedDot {
+    public static final String WHERE_PERSONAL_CENTER = "personal_center";//个人中心
+
+    private String where;//在哪里显示
+    private boolean isShow;//是否显示
+
+    public ShowRedDot(String where) {
+        this.where = where;
+    }
+
+    public String getWhere() {
+        return where;
+    }
+
+    public ShowRedDot setWhere(String where) {
+        this.where = where;
+        return this;
+    }
+
+    public boolean isShow() {
+        return isShow;
+    }
+
+    public ShowRedDot setShow(boolean show) {
+        isShow = show;
+        return this;
+    }
+}

+ 9 - 0
app/src/main/java/com/sheep/gamegroup/util/ListUtil.java

@@ -28,6 +28,15 @@ public class ListUtil {
                 action1.call(t);
             }
     }
+    public static <T> T findItem(List<T> list, CallBack<T, Boolean> action1) {
+        if(list != null)
+            for (T t : list) {
+                if(action1.call(t)){
+                    return t;
+                }
+            }
+        return null;
+    }
 
     public static <T> T getItem(List<T> list, int index) {
         return hasIndex(list, index) ? list.get(index) : null;

+ 10 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -1,7 +1,6 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.content.Intent;
-import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
@@ -23,6 +22,7 @@ import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.helper.DownloadHelper;
 import com.sheep.gamegroup.model.entity.Container;
 import com.sheep.gamegroup.model.entity.UserEntity;
+import com.sheep.gamegroup.model.util.ShowRedDot;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.ChannelContent;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -52,7 +52,6 @@ import java.util.Locale;
 import java.util.concurrent.TimeUnit;
 
 import butterknife.BindView;
-import butterknife.OnClick;
 import io.reactivex.Observable;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.schedulers.Schedulers;
@@ -443,6 +442,15 @@ public class ActMain extends BaseActYmPermissionCheck {
     }
 
     @Subscribe
+    public void onEventMainThread(ShowRedDot showRedDot) {
+        switch (showRedDot.getWhere()){
+            case ShowRedDot.WHERE_PERSONAL_CENTER://个人中心是否显示红点
+                ViewUtil.setVisibility(person_center_red_dot, showRedDot.isShow() || SpUtils.isVoucherFirst());
+                break;
+        }
+    }
+
+    @Subscribe
     public void onEventMainThread(Intent intent) {
         if (intent != null && intent.getAction() != null && intent.getDataString() != null && intent.getDataString().contains("package:")) {
             String packageName = intent.getDataString().replace("package:", "");

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSmallSheep.java

@@ -66,6 +66,7 @@ import com.sheep.gamegroup.model.entity.SlideshowEty;
 import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.model.util.ShowRedDot;
 import com.sheep.gamegroup.module.home.adapter.AdpHomeList;
 import com.sheep.gamegroup.module.plugin.model.Plugin;
 import com.sheep.gamegroup.module.skin.util.SkinUtil;
@@ -1038,6 +1039,10 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
             BaseMessage baseMessage = (BaseMessage) object;
             allTaskAcceptedTaskList = baseMessage.getDataList(TaskAcceptedEty.class);
             CommonUtil.getInstance().reloadAutoTaskList(allTaskAcceptedTaskList);
+            TaskAcceptedEty findItem = ListUtil.findItem(allTaskAcceptedTaskList, taskAcceptedEty -> taskAcceptedEty != null && taskAcceptedEty.getRelease_task() != null && taskAcceptedEty.getRelease_task().isAppointTask());
+            if(findItem != null){
+                EventBus.getDefault().post(new ShowRedDot(ShowRedDot.WHERE_PERSONAL_CENTER).setShow(true));
+            }
         } else {
             allTaskAcceptedTaskList.clear();
         }