Переглянути джерело

功能开发:处理搜索接口问题

Sora 1 рік тому
батько
коміт
ffe8cc6735

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1864,7 +1864,7 @@ public interface ApiService {
      * id * integer (path) 游戏组ID
      * 返回 GameGroup
      */
-    @GET("v1/app/game_group/{id}")
+    @GET("http://10.8.200.244:8080/v1/app/game_group/{id}")
     Observable<BaseMessage> getGameGroupById(@Path("id") int id);
 
     /**
@@ -1950,7 +1950,7 @@ public interface ApiService {
     @GET("v1/app/user/check_authorization")
     Observable<BaseMessage> checkAuth(@Query("Authorization") String token, @Query("game_id") String game_id, @Query("wlan") String wlan, @Query("auto_login") int autoLogin, @Query("face_url") String face_url);
 
-    @GET("v2/app/search")
+    @GET("http://10.8.200.244:8080/v2/app/search")
     Observable<BaseMessage> search(@Query("keyword") String keyword, @Query("game_count") int gameCount, @Query("task_count") int taskCount, @Query("gift_count") int giftCount, @Query("article_count") int articleCount, @Query("goods_count") int goodsCount, @Query("role_count") int roleCount);
 
     @GET("v1/app/search/keywords")

+ 34 - 5
app/src/main/java/com/sheep/gamegroup/model/entity/Applications.java

@@ -109,8 +109,21 @@ public class Applications implements IDownload, IGameGroup, Serializable {
 
     private String activity_url;
     private String game_tag_new;
+    private String game_tag;
+
+    public String getGame_tag() {
+        return game_tag;
+    }
+
+    public void setGame_tag(String game_tag) {
+        this.game_tag = game_tag;
+    }
+
     @JSONField(serialize = false)
     public List<String> getGameTagNewList() {
+        if (game_tag_new == null || game_tag_new.isEmpty()) {
+            return new ArrayList<>();
+        }
         String[] arr = game_tag_new.split(",");
         return Arrays.asList(arr);
     }
@@ -504,6 +517,7 @@ public class Applications implements IDownload, IGameGroup, Serializable {
 
     @JSONField(serialize = false)
     private FindAppHelper findAppHelper = new FindAppHelper();
+
     @JSONField(serialize = false)
     public FindAppHelper getFindAppHelper() {
         return findAppHelper;
@@ -527,10 +541,12 @@ public class Applications implements IDownload, IGameGroup, Serializable {
     public void updateStateRelease(int status) {
         findAppHelper.getDownloadHelper().updateState(status);
     }
+
     @JSONField(serialize = false)
     public CharSequence getInfo() {
         return getInfo(null);
     }
+
     @JSONField(serialize = false)
     public CharSequence getInfo(Action1<SpannableSb> action1) {
         return new SpannableSb("#999999", R.dimen.text_size_12)
@@ -540,6 +556,7 @@ public class Applications implements IDownload, IGameGroup, Serializable {
                 .append("人在玩").defaultTcTs()
                 .getSsb();
     }
+
     @JSONField(serialize = false)
     public CharSequence getInfoContainGameFrom() {
         if (TextUtils.isEmpty(getGameFrom())) {
@@ -547,16 +564,24 @@ public class Applications implements IDownload, IGameGroup, Serializable {
         }
         return getInfo(spannableSb -> spannableSb.append("来源:", R.dimen.text_size_11, "#8e8e8e").kgy().kgy().append(getGameFrom(), R.dimen.text_size_11, "#8e8e8e").br());
     }
+
     @JSONField(serialize = false)
     public CharSequence getPlayInfo() {
         List<GameListTag> tags = getTags();
-        List<String> tagList = new ArrayList<>();
-        for (GameListTag tag : tags) {
-            tagList.add(tag.getName());
+        String tagStr = null;
+        if (tags != null && !tags.isEmpty()) {
+            List<String> tagList = new ArrayList<>();
+            for (GameListTag tag : tags) {
+                tagList.add(tag.getName());
+            }
+            tagStr = String.join("/", tagList);
+        }
+
+        if (TextUtils.isEmpty(tagStr) && !TextUtils.isEmpty(getGame_tag())) {
+            tagStr = getGame_tag().replace(",", "/");
         }
-        String tagStr = String.join("/", tagList);
         SpannableSb sb = new SpannableSb();
-        if (!tagStr.isEmpty()) {
+        if (tagStr != null && !tagStr.isEmpty()) {
             sb.append(tagStr).kgy();
         }
         //显示类型的拼接,再是人数的拼接
@@ -564,10 +589,12 @@ public class Applications implements IDownload, IGameGroup, Serializable {
                 .append("人在玩")
                 .getSsb();
     }
+
     @JSONField(serialize = false)
     public CharSequence getSimpleInfo() {
         return new SpannableSb().append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").append("人在玩", "#999999").getSsb();
     }
+
     @JSONField(serialize = false)
     //游戏来源
     public String getGameFrom() {
@@ -578,11 +605,13 @@ public class Applications implements IDownload, IGameGroup, Serializable {
         }
         return port_type_name + "·" + package_type_name;
     }
+
     @JSONField(serialize = false)
     //有 game_discount_id 就可以跳转vip通过进行3折充值
     public boolean hasGameDiscountId() {
         return game_discount_id > 0;
     }
+
     @JSONField(serialize = false)
     //主宣传图是视频
     public boolean mainPublicizeIsVideo() {

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/module/search/FgtSearch.java

@@ -8,10 +8,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
 
 import com.jcodecraeer.xrecyclerview.XRecyclerView;
 import com.sheep.gamegroup.absBase.ISearch;
+import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.Article;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.GameAvatar;
-import com.sheep.gamegroup.model.entity.GameSimple;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
 import com.sheep.gamegroup.model.entity.ShopGoodsInfo;
 import com.sheep.gamegroup.model.entity.TaskSimple;
@@ -140,7 +140,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
                                 item.type = object.getInt("type");
                                 item.data = object.getString("data");
                                 if (item.type == 1) {
-                                    item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, GameSimple.class);
+                                    item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, Applications.class);
                                 } else if (item.type == 2) {
                                     item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, TaskSimple.class);
                                 } else if (item.type == 3) {

+ 9 - 9
app/src/main/java/com/sheep/gamegroup/module/search/GameHolder.java

@@ -8,41 +8,41 @@ import androidx.recyclerview.widget.LinearLayoutManager;
 
 import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
 import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
+import com.kfzs.duanduan.utils.NumberFormatUtils;
 import com.sheep.gamegroup.model.entity.Applications;
-import com.sheep.gamegroup.model.entity.GameSimple;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.databinding.PlayGameVerticalListItemBinding;
 
-public class GameHolder extends SearchResultHolder<GameSimple> {
+public class GameHolder extends SearchResultHolder<Applications> {
 
 
     public GameHolder(@NonNull View itemView) {
         super(itemView);
         itemView.setOnClickListener((v) -> {
-            Jump2View.getInstance().goActGameGroupDetail(item.getId());
+            Jump2View.getInstance().goPlayGameDetail(item.getId());
         });
     }
 
     @Override
     public void configView() {
         PlayGameVerticalListItemBinding binding = PlayGameVerticalListItemBinding.bind(itemView);
-        Applications app = item.getApplications();
         //加载游戏图标
-        ViewUtil.setGameImage(binding.gcGameAppDetailIcon, app.getIcon());
+        ViewUtil.setGameImage(binding.gcGameAppDetailIcon, item.getIcon());
+        ViewUtil.setText(binding.gcGameAppDetailScoreTv, NumberFormatUtils.retain1(item.getScore()));
         //加载游戏名字
-        ViewUtil.setText(binding.gcGameAppDetailName, app.getName());
+        ViewUtil.setText(binding.gcGameAppDetailName, item.getName());
         //加载游戏大小与多少人在玩信息
-        ViewUtil.setText(binding.gcGameAppDetailInfoTv, app.getPlayInfo());
+        ViewUtil.setText(binding.gcGameAppDetailInfoTv, item.getPlayInfo());
         //加载游戏标签
-        if (app.getGameTagNewList() != null) {
+        if (item.getGameTagNewList() != null) {
             LinearLayoutManager playGameActManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
             binding.gcGameAppDetailTagList.setHasFixedSize(true);
             binding.gcGameAppDetailTagList.setNestedScrollingEnabled(false);
             binding.gcGameAppDetailTagList.setLayoutManager(playGameActManager);
-            binding.gcGameAppDetailTagList.setAdapter(new RecyclerViewAdapter<String>(SheepApp.getInstance(), R.layout.item_tag, app.getGameTagNewList()) {
+            binding.gcGameAppDetailTagList.setAdapter(new RecyclerViewAdapter<String>(SheepApp.getInstance(), R.layout.item_tag, item.getGameTagNewList()) {
                 @Override
                 public void convert(ViewHolder viewHolder, final String item, int position) {
                     if (item == null)

+ 1 - 0
app/src/main/res/layout/act_game_group_or_game_detail.xml

@@ -146,6 +146,7 @@
                         android:drawableStart="@drawable/star_full"
                         android:drawablePadding="2dp"
                         android:textColor="#F39D1D"
+                        android:textStyle="bold"
                         android:textSize="14sp"
                         app:layout_constraintStart_toStartOf="@+id/gc_game_app_detail_name"
                         app:layout_constraintTop_toBottomOf="@+id/gc_game_app_detail_name"

+ 3 - 158
app/src/main/res/layout/play_game_vertical_list_item.xml

@@ -1,145 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
-<!--    xmlns:app="http://schemas.android.com/apk/res-auto"-->
-<!--    android:layout_width="match_parent"-->
-<!--    android:layout_height="wrap_content"-->
-<!--    android:orientation="vertical">-->
-
-<!--    <androidx.constraintlayout.widget.ConstraintLayout-->
-<!--        android:layout_width="match_parent"-->
-<!--        android:layout_height="wrap_content"-->
-<!--        android:layout_marginStart="12dp"-->
-<!--        android:layout_marginTop="@dimen/content_padding_10"-->
-<!--        android:layout_marginEnd="12dp">-->
-
-<!--        <ImageView-->
-<!--            android:id="@+id/item_icon_iv"-->
-<!--            android:layout_width="64dp"-->
-<!--            android:layout_height="64dp"-->
-<!--            android:src="@drawable/icon_lj"-->
-<!--            app:layout_constraintStart_toStartOf="parent"-->
-<!--            app:layout_constraintTop_toTopOf="parent" />-->
-
-
-<!--        <TextView-->
-<!--            android:id="@+id/end_of_time_tv"-->
-<!--            android:layout_width="0dp"-->
-<!--            android:layout_height="wrap_content"-->
-<!--            android:layout_marginStart="@dimen/content_padding_4"-->
-<!--            android:layout_marginTop="55dp"-->
-<!--            android:layout_marginEnd="@dimen/content_padding_4"-->
-<!--            android:background="@drawable/shape_ash_stroke_white_solid_rectangle"-->
-<!--            android:gravity="center"-->
-<!--            android:lines="1"-->
-<!--            android:textColor="#989898"-->
-<!--            android:textSize="12sp"-->
-<!--            android:visibility="gone"-->
-<!--            app:layout_constraintEnd_toEndOf="@+id/item_icon_iv"-->
-<!--            app:layout_constraintStart_toStartOf="@+id/item_icon_iv"-->
-<!--            app:layout_constraintTop_toTopOf="parent" />-->
-
-<!--        <LinearLayout-->
-<!--            android:layout_width="0dp"-->
-<!--            android:layout_height="70dp"-->
-<!--            android:layout_marginStart="@dimen/content_padding"-->
-<!--            android:orientation="vertical"-->
-<!--            app:layout_constraintBottom_toBottomOf="parent"-->
-<!--            app:layout_constraintEnd_toStartOf="@id/detail_task_tv_center"-->
-<!--            app:layout_constraintStart_toEndOf="@id/item_icon_iv"-->
-<!--            app:layout_constraintTop_toTopOf="parent">-->
-
-<!--            <TextView-->
-<!--                android:id="@+id/item_name_tv"-->
-<!--                android:layout_width="match_parent"-->
-<!--                android:layout_height="wrap_content"-->
-<!--                android:ellipsize="middle"-->
-<!--                android:gravity="start"-->
-<!--                android:maxLines="2"-->
-<!--                android:text=""-->
-<!--                android:textColor="#444444"-->
-<!--                android:textSize="14sp" />-->
-
-<!--            <View-->
-<!--                android:layout_width="match_parent"-->
-<!--                android:layout_height="0dp"-->
-<!--                android:layout_weight="3" />-->
-
-<!--            <LinearLayout-->
-<!--                android:layout_width="match_parent"-->
-<!--                android:layout_height="wrap_content"-->
-<!--                android:layout_marginTop="@dimen/content_padding_2"-->
-<!--                android:layout_marginEnd="@dimen/content_padding_8"-->
-<!--                android:orientation="horizontal">-->
-
-<!--                <TextView-->
-<!--                    android:id="@+id/item_date_tv"-->
-<!--                    android:layout_width="0dp"-->
-<!--                    android:layout_height="wrap_content"-->
-<!--                    android:layout_weight="1"-->
-<!--                    android:lines="1"-->
-<!--                    android:text=""-->
-<!--                    android:textColor="#cc8e8e8e"-->
-<!--                    android:textSize="10sp" />-->
-
-<!--                <ImageView-->
-<!--                    android:id="@+id/item_date_question_img"-->
-<!--                    android:layout_width="15dp"-->
-<!--                    android:layout_height="15dp"-->
-<!--                    android:src="@mipmap/task_game_qustion_icon"-->
-<!--                    android:visibility="gone"-->
-<!--                    app:layout_constraintEnd_toEndOf="parent"-->
-<!--                    app:layout_constraintStart_toEndOf="@+id/item_date_tv" />-->
-<!--            </LinearLayout>-->
-
-<!--            <View-->
-<!--                android:layout_width="match_parent"-->
-<!--                android:layout_height="0dp"-->
-<!--                android:layout_weight="1" />-->
-
-<!--            <LinearLayout-->
-<!--                android:id="@+id/ll_game_tag"-->
-<!--                android:layout_width="match_parent"-->
-<!--                android:layout_height="wrap_content"-->
-<!--                android:gravity="center_vertical"-->
-<!--                android:orientation="horizontal" />-->
-
-
-<!--        </LinearLayout>-->
-
-<!--        <TextView-->
-<!--            android:id="@+id/detail_task_tv_center"-->
-<!--            style="@style/style_button_find"-->
-<!--            android:layout_centerInParent="true"-->
-<!--            android:text="@string/task_cancel"-->
-<!--            android:visibility="visible"-->
-<!--            app:layout_constraintBottom_toTopOf="@id/detail_task_tv_center2"-->
-<!--            app:layout_constraintEnd_toEndOf="parent"-->
-<!--            app:layout_constraintTop_toTopOf="parent" />-->
-
-<!--        <TextView-->
-<!--            android:id="@+id/detail_task_tv_center2"-->
-<!--            style="@style/style_vip_td_tv2"-->
-<!--            android:layout_centerInParent="true"-->
-<!--            android:layout_marginTop="16dp"-->
-<!--            android:visibility="gone"-->
-<!--            app:layout_constraintBottom_toBottomOf="@id/item_icon_iv"-->
-<!--            app:layout_constraintEnd_toEndOf="parent"-->
-<!--            app:layout_constraintTop_toBottomOf="@id/detail_task_tv_center" />-->
-
-<!--    </androidx.constraintlayout.widget.ConstraintLayout>-->
-
-<!--    <View-->
-<!--        android:layout_width="match_parent"-->
-<!--        android:layout_height="@dimen/content_padding_10" />-->
-
-<!--    <View-->
-<!--        android:id="@+id/line_tv"-->
-<!--        android:layout_width="match_parent"-->
-<!--        android:layout_height="0.5dp"-->
-<!--        android:layout_marginStart="12dp"-->
-<!--        android:layout_marginEnd="12dp"-->
-<!--        android:background="@color/gray_F0F0F0" />-->
-<!--</LinearLayout>-->
 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
@@ -149,8 +8,8 @@
 
 <ImageView
     android:id="@+id/gc_game_app_detail_icon"
-    android:layout_width="78dp"
-    android:layout_height="78dp"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
     android:layout_marginStart="16dp"
     android:layout_marginTop="16dp"
     android:layout_marginBottom="20dp"
@@ -164,6 +23,7 @@
     tools:text="10.0"
     android:layout_width="0dp"
     android:layout_height="wrap_content"
+    android:textStyle="bold"
     android:layout_marginTop="6dp"
     android:drawableStart="@drawable/star_full"
     android:drawablePadding="2dp"
@@ -214,21 +74,6 @@
     app:layout_constraintStart_toEndOf="@+id/gc_game_app_detail_score_tv"
     app:layout_constraintTop_toTopOf="@+id/gc_game_app_detail_score_tv" />
 
-<!--                    <TextView-->
-<!--                        android:id="@+id/gc_game_app_detail_bt1"-->
-<!--                        android:layout_width="44dp"-->
-<!--                        android:layout_height="17dp"-->
-<!--                        android:layout_marginTop="6dp"-->
-<!--                        android:background="@drawable/selector_button_stroke_main"-->
-<!--                        android:gravity="center"-->
-<!--                        android:onClick="onClickFollowTv"-->
-<!--                        android:text="关注"-->
-<!--                        android:textColor="@color/selector_color_stoke_main_btn"-->
-<!--                        android:textSize="10sp"-->
-<!--                        app:layout_constraintLeft_toLeftOf="@+id/gc_game_app_detail_icon"-->
-<!--                        app:layout_constraintRight_toRightOf="@+id/gc_game_app_detail_icon"-->
-<!--                        app:layout_constraintTop_toBottomOf="@+id/gc_game_app_detail_icon" />-->
-
 <LinearLayout
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"