소스 검색

修复游戏详情中tag没有显示出来的问题

zengjiebin 7 년 전
부모
커밋
952d102e06

+ 6 - 16
app/src/main/java/com/sheep/gamegroup/model/entity/Applications.java

@@ -1,14 +1,11 @@
 package com.sheep.gamegroup.model.entity;
 
-import android.text.TextUtils;
-
 import com.sheep.gamegroup.helper.DownloadHelper;
 import com.sheep.gamegroup.helper.FindAppHelper;
 import com.sheep.gamegroup.model.api.IDownload;
-import com.sheep.gamegroup.util.ListUtil;
 
 import java.io.Serializable;
-import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Created by realicing on 2018/6/28.
@@ -69,7 +66,7 @@ public class Applications implements IDownload, Serializable {
 
     private int is_recommend;
 
-    private String game_tag;
+    private List<GameListTag> tags;
 
     private String ext_detail;
 
@@ -305,12 +302,12 @@ public class Applications implements IDownload, Serializable {
         return this.is_recommend;
     }
 
-    public void setGame_tag(String game_tag) {
-        this.game_tag = game_tag;
+    public List<GameListTag> getTags() {
+        return tags;
     }
 
-    public String getGame_tag() {
-        return this.game_tag;
+    public void setTags(List<GameListTag> tags) {
+        this.tags = tags;
     }
 
     public void setSort(int sort) {
@@ -422,11 +419,4 @@ public class Applications implements IDownload, Serializable {
         findAppHelper.getDownloadHelper().updateState(status);
     }
 
-    //从game_tag中获取tagList
-    public ArrayList<String> getTagList() {
-        if (!TextUtils.isEmpty(game_tag)) {
-            return ListUtil.asList(game_tag.split(","));
-        }
-        return ListUtil.emptyList();
-    }
 }

+ 5 - 5
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -48,6 +48,7 @@ import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
 import com.sheep.gamegroup.model.entity.GameAccountEntity;
 import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.GameEntity;
+import com.sheep.gamegroup.model.entity.GameListTag;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
 import com.sheep.gamegroup.model.entity.RobTask;
@@ -2462,13 +2463,12 @@ public class CommonUtil {
      * @param i -1:不限制 否者限制tag 个数
      */
     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)) {
+        List<GameListTag> gameListTagList = gameEntity.getApp().getTags();
+        if (!ListUtil.isEmpty(gameListTagList)) {
             ll_game_tag.removeAllViews();
-            ArrayList<String> gameTagList = ListUtil.asList(game_tag.split(","));
-            for (int j = 0; j < gameTagList.size(); j++) {
+            for (int j = 0; j < gameListTagList.size(); j++) {
                 if (i == -1 || i > j) {
-                    String tag = gameTagList.get(j);
+                    String tag = gameListTagList.get(j).getName();
                     switch (tag) {
                         case "礼包":
                             color = R.color.red_FD2D54;

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -27,6 +27,7 @@ import com.sheep.gamegroup.model.entity.Container;
 import com.sheep.gamegroup.model.entity.CreditCard;
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.DialogEntity;
+import com.sheep.gamegroup.model.entity.GameListTag;
 import com.sheep.gamegroup.model.entity.GameListType;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
 import com.sheep.gamegroup.model.entity.LoginEntity;
@@ -1856,6 +1857,15 @@ public class Jump2View {
         activity.startActivity(intent);
         GAME_EVERY_DAY_MORE.onEvent("title", gameListType.getTitle());
     }
+    /**
+     * 点击游戏标签
+     */
+    public void goActPlayGameList(Activity activity, GameListTag item) {
+        Intent intent = new Intent(activity, ActPlayGameList.class);
+        DataUtil.putObject(intent, item.toGameListType());
+        activity.startActivity(intent);
+        GAME_EVERY_DAY_MORE.onEvent("title", item.getName());
+    }
 
     /**
      * 游戏详情

+ 14 - 4
app/src/main/java/com/sheep/gamegroup/util/TagListUtil.java

@@ -2,10 +2,12 @@ package com.sheep.gamegroup.util;
 
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.view.View;
 import android.widget.TextView;
 
 import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
 import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
+import com.sheep.gamegroup.model.entity.GameListTag;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
@@ -18,17 +20,25 @@ import java.util.List;
 public class TagListUtil {
 
     //设置tag标签横向列表
-    public static void setTagList(RecyclerView recyclerView, List<String> tagList) {
+    public static void setTagList(RecyclerView recyclerView, List<GameListTag> tagList) {
         LinearLayoutManager playGameActManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
         recyclerView.setHasFixedSize(true);
         recyclerView.setNestedScrollingEnabled(false);
         recyclerView.setLayoutManager(playGameActManager);
-        recyclerView.setAdapter(new RecyclerViewAdapter<String>(SheepApp.getInstance(), R.layout.item_tag, tagList) {
+        recyclerView.setAdapter(new RecyclerViewAdapter<GameListTag>(SheepApp.getInstance(), R.layout.item_tag, tagList) {
             @Override
-            public void convert(ViewHolder viewHolder, String name, int position) {
+            public void convert(ViewHolder viewHolder, final GameListTag item, int position) {
+                if(item == null)
+                    return;
                 if(viewHolder.itemView instanceof TextView){
-                    ViewUtil.setText((TextView) viewHolder.itemView, name);
+                    ViewUtil.setText((TextView) viewHolder.itemView, item.getName());
                 }
+                viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        Jump2View.getInstance().goActPlayGameList(ActivityManager.getInstance().currentActivity(), item);
+                    }
+                });
             }
         });
 

+ 3 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActGcGameAppDetail.java

@@ -25,6 +25,7 @@ import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.helper.DownloadHelper;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.GameEntity;
+import com.sheep.gamegroup.model.entity.GameListTag;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.ApiUtil;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -134,7 +135,7 @@ public class ActGcGameAppDetail extends BaseActivity {
         RefreshUtil.newInstance().publicParameterLoadMore(refresh, this);
     }
 
-    private List<String> tagList = ListUtil.emptyList();
+    private List<GameListTag> tagList = ListUtil.emptyList();
 
     //重置view
     private void resetView() {
@@ -177,7 +178,7 @@ public class ActGcGameAppDetail extends BaseActivity {
         //加载游戏名字
         ViewUtil.setText(gc_game_app_detail_name, gameEntity.getApp().getName());
         //加载游戏标签
-        tagList.addAll(gameEntity.getApp().getTagList());
+        tagList.addAll(gameEntity.getApp().getTags());
         ListUtil.removeNull(tagList);
         recyclerView.getAdapter().notifyDataSetChanged();
         //下载按钮