Pārlūkot izejas kodu

游戏来源调整

zengjiebin 7 gadi atpakaļ
vecāks
revīzija
c9b1bd1205

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

@@ -1696,12 +1696,18 @@ public interface ApiService {
     @GET("app/game_group/{id}")
     Observable<BaseMessage> getGameGroupById(@Path("id") int id);
     /**
-     * 获取出包类型列表
+     * 获取下游(出包类型列表
      * 返回 PackageTypes 列表
      */
     @GET("app/find/package_type/list")
     Observable<BaseMessage> getFindPackageTypeList();
     /**
+     * 获取上游列表
+     * 返回 GamePortType 列表
+     */
+    @GET("app/game_port_type")
+    Observable<BaseMessage> getGamePortType();
+    /**
      * 获取游戏排行
      * 返回 GameEntity 列表
      */

+ 40 - 4
app/src/main/java/com/sheep/gamegroup/model/entity/Applications.java

@@ -1,11 +1,14 @@
 package com.sheep.gamegroup.model.entity;
 
+import android.text.TextUtils;
+
 import com.kfzs.duanduan.utils.NumberFormatUtils;
 import com.sheep.gamegroup.helper.DownloadHelper;
 import com.sheep.gamegroup.helper.FindAppHelper;
 import com.sheep.gamegroup.model.api.IDownload;
 import com.sheep.gamegroup.module.game.api.IGameGroup;
 import com.sheep.gamegroup.util.string.SpannableSb;
+import com.sheep.jiuyan.samllsheep.R;
 
 import java.io.Serializable;
 import java.util.List;
@@ -84,8 +87,10 @@ public class Applications implements IDownload, IGameGroup, Serializable {
     private int comment_num;
 
     private int game_discount_id = 0;
-    //游戏组类型
+    //游类型
     private String package_type_name;
+    //上游类型
+    private String port_type_name;
 
     public int getGame_discount_id() {
         return game_discount_id;
@@ -383,6 +388,14 @@ public class Applications implements IDownload, IGameGroup, Serializable {
         return package_type_name;
     }
 
+    public void setPort_type_name(String port_type_name) {
+        this.port_type_name = port_type_name;
+    }
+
+    public String getPort_type_name() {
+        return port_type_name;
+    }
+
 
 
 
@@ -464,9 +477,32 @@ public class Applications implements IDownload, IGameGroup, Serializable {
     }
 
     public CharSequence getInfo() {
-        return new SpannableSb().append(package_size+"M\u3000", "#999999").append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").append("人在玩", "#999999").getSsb();
-    }
-    public CharSequence getInfo1() {
+        return new SpannableSb(R.dimen.text_size_12).append(package_size+"M", "#999999").defaultTextSize()
+                .kgz().append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").defaultTextSize()
+                .append("人在玩", "#999999").defaultTextSize()
+                .getSsb();
+    }
+    public CharSequence getInfoContainGameFrom() {
+        if(TextUtils.isEmpty(getGameFrom())){
+            return getInfo();
+        }
+        return new SpannableSb(R.dimen.text_size_12).append("来源:" + getGameFrom(), R.dimen.text_size_11, "#000000")
+                .br().append(package_size+"M", "#999999").defaultTextSize()
+                .kgz().append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").defaultTextSize()
+                .append("人在玩", "#999999").defaultTextSize()
+                .getSsb();
+    }
+    public CharSequence getSimpleInfo() {
         return new SpannableSb().append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").append("人在玩", "#999999").getSsb();
     }
+
+    //游戏来源
+    public String getGameFrom() {
+        if(TextUtils.isEmpty(package_type_name)){
+            return port_type_name;
+        } else if(TextUtils.isEmpty(port_type_name)){
+            return package_type_name;
+        }
+        return port_type_name + "·" + package_type_name;
+    }
 }

+ 21 - 1
app/src/main/java/com/sheep/gamegroup/model/entity/GameEntity.java

@@ -218,7 +218,7 @@ public class GameEntity implements Serializable, ISearchRecord {
     }
 
     /**
-     * 获取平台
+     * 获取下游
      * @return
      */
     public String getPackage_type_name() {
@@ -227,6 +227,26 @@ public class GameEntity implements Serializable, ISearchRecord {
         }
         return "";
     }
+    /**
+     * 获取上游戏
+     * @return
+     */
+    public String getPort_type_name() {
+        if (app != null) {
+            return app.getPort_type_name();
+        }
+        return "";
+    }
+    /**
+     * 获取来源(上游戏·下游)
+     * @return
+     */
+    public String getGameFrom() {
+        if (app != null) {
+            return app.getGameFrom();
+        }
+        return "";
+    }
 
     @Override
     public String getInput() {

+ 12 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/GameListType.java

@@ -16,6 +16,7 @@ public class GameListType implements Serializable {
     private int download_type;
     private int tag_id;
     private int type;
+    private int port_type;
     private int display_type;
     private boolean isGameGroup;
 
@@ -83,6 +84,14 @@ public class GameListType implements Serializable {
         this.type = type;
     }
 
+    public void setPort_type(int port_type) {
+        this.port_type = port_type;
+    }
+
+    public int getPort_type() {
+        return port_type;
+    }
+
     public int getDisplay_type() {
         return display_type;
     }
@@ -104,6 +113,9 @@ public class GameListType implements Serializable {
         if(type > 0){
             map.put("type", type);
         }
+        if(port_type > 0){
+            map.put("port_type", port_type);
+        }
         return map;
     }
 

+ 4 - 9
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActGameGroupOrGameDetail.java

@@ -175,12 +175,12 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
         ViewUtil.setImage(write_comment, ViewUtil.getNetImgByName("write_comment"));
         if(gameGroup == null){
             ViewUtil.setVisibility(gc_game_app_detail_game_list, false);
-        } else {
+        } else {//游戏组,不显示下载按钮
             ViewUtil.setVisibility(gc_game_app_detail_game_list, true);
             ViewUtil.setVisibility(item_gc_game_app_list_bottom, true);
             ViewUtil.setVisibility(item_gc_game_app_list_top, false);
+            ViewUtil.setVisibility(gc_game_app_detail_bt2, false);
             ViewUtil.setText(item_gc_game_app_list_tv, "比一比");
-            ViewUtil.setText(gc_game_app_detail_bt2, "推荐下载");
             item_gc_game_app_list_rv.setHasFixedSize(true);
             item_gc_game_app_list_rv.setNestedScrollingEnabled(false);
             item_gc_game_app_list_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
@@ -245,12 +245,7 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
             ViewUtil.setVisibility(gc_game_app_detail_iv2, true);
             if (gameEntity.getApp().getMain_publicize().endsWith(".mp4")) {
                 gc_game_app_detail_play_iv.setVisibility(View.VISIBLE);
-                gc_game_app_detail_play_iv.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View view) {
-                        Jump2View.getInstance().goActPlayVideo(gameEntity.getApp().getMain_publicize(), true);
-                    }
-                });
+                gc_game_app_detail_play_iv.setOnClickListener(view -> Jump2View.getInstance().goActPlayVideo(gameEntity.getApp().getMain_publicize(), true));
             }
         }
         //加载游戏图标
@@ -258,7 +253,7 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
         //加载游戏名字
         ViewUtil.setText(gc_game_app_detail_name, gameEntity.getApp().getName());
         //加载游戏大小与多少人在玩信息
-        ViewUtil.setText(gc_game_app_detail_info_tv, gameEntity.getApp().getInfo());
+        ViewUtil.setText(gc_game_app_detail_info_tv, gameGroup == null ? gameEntity.getApp().getInfo() : gameEntity.getApp().getInfoContainGameFrom());
         //加载游戏标签
         if (gameEntity.getApp().getTags() != null) {
             tagList.clear();

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameCenterTypeList.java

@@ -43,7 +43,7 @@ public class AdpGameCenterTypeList extends BaseQuickAdapter<GameEntity, BaseView
             ViewUtil.setText(item_dm_name_tv, download.getTask_name());
             String info = String.format(Locale.CHINA, "人在玩\u0020%sM\u3000", download.getPackage_size());
             ViewUtil.setText(item_dm_info_tv, new SpannableSb().append(item.getDownload_count(), "#2EBEF2").append(info, "#8E8E8E")
-                    .append(item.getPackage_type_name(), "#FD2D54")
+                    .append(item.getGameFrom(), "#FD2D54")
                     .getSsb());
 
             item_dm_btn_tv.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + download.getDownload_link());

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameGroupGameCompare.java

@@ -35,8 +35,8 @@ public class AdpGameGroupGameCompare extends BaseQuickAdapter<Applications, Base
         View item_gggc_line = helper.itemView.findViewById(R.id.item_gggc_line);
 
         item_gggc_vip_tv.setOnClickListener(view -> Jump2View.getInstance().gotoGameVipRecharge(item));
-        ViewUtil.setText(item_gggc_name_tv, item.getPackage_type_name());
-        ViewUtil.setText(item_gggc_info_tv, item.getInfo1());
+        ViewUtil.setText(item_gggc_name_tv, item.getGameFrom());
+        ViewUtil.setText(item_gggc_info_tv, item.getSimpleInfo());
         ViewUtil.setText(item_gggc_score_tv, NumberFormatUtils.retain1(item.getScore())+"分");
         item_gggc_score_acrb.setMax(10);
         item_gggc_score_acrb.setProgress((int) item.getScore());

+ 6 - 5
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtPlayGame.java

@@ -22,6 +22,7 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.module.game.adapter.AdpGameCenter4_3List;
 import com.sheep.gamegroup.module.game.adapter.AdpGameCenterType;
 import com.sheep.gamegroup.module.game.model.GameCenterType;
+import com.sheep.gamegroup.module.game.model.GamePortTypes;
 import com.sheep.gamegroup.module.game.model.PackageTypes;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
@@ -130,14 +131,14 @@ public class FgtPlayGame extends BaseFragment {
         gameEntityListx.clear();
         ViewUtil.notifyDataSetChanged(play_game_list_x_rv);
         //其它tag
-        SheepApp.getInstance().getNetComponent().getApiService().getFindPackageTypeList()
+        SheepApp.getInstance().getNetComponent().getApiService().getGamePortType()
                 .subscribeOn(Schedulers.io())
-                .flatMap((Function<BaseMessage, Observable<PackageTypes>>) baseMessage -> Observable.fromIterable(baseMessage.getDataList(PackageTypes.class)))
+                .flatMap((Function<BaseMessage, Observable<GamePortTypes>>) baseMessage -> Observable.fromIterable(baseMessage.getDataList(GamePortTypes.class)))
                 .filter(gameListTag -> gameListTag != null)
-                .subscribe(new AbsObserver<PackageTypes>() {
+                .subscribe(new AbsObserver<GamePortTypes>() {
 
                     @Override
-                    public void onNext(PackageTypes gameListTag) {
+                    public void onNext(GamePortTypes gameListTag) {
                         initGameList(play_game_list_x_rv, gameEntityListx, gameListTag);
                     }
                 });
@@ -235,7 +236,7 @@ public class FgtPlayGame extends BaseFragment {
         banner.stopAutoPlay();
     }
     private Comparator<ListTypeList<GameEntity, GameListType>> comparator = (item1, item2) -> item2.getSort() - item1.getSort();
-    private void initGameList(final RecyclerView playGameListRv, final List<ListTypeList<GameEntity, GameListType>> gameEntityListList, PackageTypes packageTypes) {
+    private void initGameList(final RecyclerView playGameListRv, final List<ListTypeList<GameEntity, GameListType>> gameEntityListList, GamePortTypes packageTypes) {
         GameListType gameListType = packageTypes.toGameListType();
         if (gameListType == null) {
             return;

+ 84 - 0
app/src/main/java/com/sheep/gamegroup/module/game/model/GamePortTypes.java

@@ -0,0 +1,84 @@
+package com.sheep.gamegroup.module.game.model;
+
+import com.sheep.gamegroup.model.entity.GameListType;
+
+/**
+ * Created by realicing on 2019/1/31.
+ * realicing@sina.com
+ *  上游
+ *
+ * abbreviation:	string  简称如 M , G
+ * alias:	string  别名
+ * created_at:	string 创建时间
+ * id:	integer ($int64) 主键自增ID
+ * name:	string  名称
+ * sort:	integer ($int64) 排序倒序
+ */
+public class GamePortTypes {
+    private String abbreviation;
+
+    private String alias;
+
+    private String created_at;
+
+    private int id;
+
+    private String name;
+
+    private int sort;
+
+    public String getAbbreviation() {
+        return abbreviation;
+    }
+
+    public void setAbbreviation(String abbreviation) {
+        this.abbreviation = abbreviation;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public String getCreated_at() {
+        return created_at;
+    }
+
+    public void setCreated_at(String created_at) {
+        this.created_at = created_at;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getSort() {
+        return sort;
+    }
+
+    public void setSort(int sort) {
+        this.sort = sort;
+    }
+
+    public GameListType toGameListType() {
+        GameListType gameListType = new GameListType();
+        gameListType.setPort_type(id);
+        gameListType.setTitle(name);
+        return gameListType;
+    }
+}

+ 22 - 0
app/src/main/java/com/sheep/gamegroup/util/string/SpannableSb.java

@@ -25,6 +25,13 @@ public class SpannableSb {
     private String appendText;
     private int start;
     private int end;
+    private @DimenRes int defaultTextSize;
+    public SpannableSb(){
+
+    }
+    public SpannableSb(@DimenRes int defaultTextSize){
+        this.defaultTextSize = defaultTextSize;
+    }
 
     public SpannableSb append(Object object) {
         String text = object.toString();
@@ -38,6 +45,13 @@ public class SpannableSb {
         end += text.length();
         return this;
     }
+    //设置了默认大小的可以直接调用这个来设置大小
+    public SpannableSb defaultTextSize(){
+        if(defaultTextSize == 0){
+            return this;
+        }
+        return setTextSize(defaultTextSize);
+    }
 
     //前面有内容才换行
     public SpannableSb checkAndBr() {
@@ -50,6 +64,14 @@ public class SpannableSb {
     public SpannableSb br() {
         return append("\n");
     }
+    //添加一个中文大小的空格
+    public SpannableSb kgz() {
+        return append("\u3000");
+    }
+    //添加一个英文大小的空格
+    public SpannableSb kgy() {
+        return append("\u0020");
+    }
 
     public SpannableSb setTextSize(@DimenRes int textSize) {
         if(appendText == null){//无效添加

+ 21 - 13
app/src/main/res/layout/act_game_group_or_game_detail.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
@@ -10,21 +10,30 @@
     <TextView
         android:id="@+id/gc_game_app_detail_bt2"
         style="@style/style_button"
-        android:layout_alignParentBottom="true"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/gc_game_app_detail_line"
         android:text="下载" />
 
     <View
         android:id="@+id/gc_game_app_detail_line"
         android:layout_width="match_parent"
         android:layout_height="1dp"
-        android:layout_above="@id/gc_game_app_detail_bt2"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toTopOf="@id/gc_game_app_detail_bt2"
+        app:layout_constraintTop_toBottomOf="@id/refresh"
         android:background="#F2F2F2" />
 
     <com.scwang.smartrefresh.layout.SmartRefreshLayout
         android:id="@+id/refresh"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_above="@id/gc_game_app_detail_line">
+        android:layout_height="0dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toTopOf="@id/gc_game_app_detail_line">
 
         <android.support.v4.widget.NestedScrollView
             android:layout_width="match_parent"
@@ -144,15 +153,14 @@
                         app:layout_constraintBottom_toTopOf="@id/gc_game_app_detail_tag_list"
                         app:layout_constraintEnd_toEndOf="parent"
                         app:layout_constraintStart_toEndOf="@id/gc_game_app_detail_icon"
-                        app:layout_constraintTop_toTopOf="@+id/gc_game_app_detail_icon" />
+                        app:layout_constraintTop_toTopOf="@id/gc_game_app_detail_icon" />
 
                     <android.support.v7.widget.RecyclerView
                         android:id="@+id/gc_game_app_detail_tag_list"
                         android:layout_width="0dp"
                         android:layout_height="wrap_content"
-                        android:layout_marginEnd="16dp"
                         app:layout_constraintBottom_toTopOf="@id/gc_game_app_detail_info_tv"
-                        app:layout_constraintEnd_toEndOf="parent"
+                        app:layout_constraintEnd_toEndOf="@id/gc_game_app_detail_name"
                         app:layout_constraintStart_toStartOf="@id/gc_game_app_detail_name"
                         app:layout_constraintTop_toBottomOf="@id/gc_game_app_detail_name" />
 
@@ -160,12 +168,12 @@
                         android:id="@+id/gc_game_app_detail_info_tv"
                         android:layout_width="0dp"
                         android:layout_height="wrap_content"
-                        android:layout_marginEnd="16dp"
+                        android:lineSpacingExtra="5dp"
                         android:text="418M     230万人在玩"
                         android:textColor="#ff999999"
                         android:textSize="12sp"
                         app:layout_constraintBottom_toTopOf="@id/gc_game_app_detail_bt1"
-                        app:layout_constraintEnd_toEndOf="parent"
+                        app:layout_constraintEnd_toEndOf="@id/gc_game_app_detail_name"
                         app:layout_constraintStart_toStartOf="@id/gc_game_app_detail_name"
                         app:layout_constraintTop_toBottomOf="@id/gc_game_app_detail_tag_list" />
 
@@ -228,9 +236,9 @@
     <com.kfzs.duanduan.view.DragRelativeLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentEnd="true"
         android:layout_marginTop="300dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
         android:onClick="onClickPlusDrag"
         android:paddingTop="@dimen/content_padding_10"
         android:paddingBottom="@dimen/content_padding_10">
@@ -243,4 +251,4 @@
             android:scaleType="fitXY" />
     </com.kfzs.duanduan.view.DragRelativeLayout>
 
-</RelativeLayout>
+</android.support.constraint.ConstraintLayout>

+ 2 - 3
app/src/main/res/layout/item_game_group_game_compare.xml

@@ -19,7 +19,6 @@
         android:id="@+id/item_gggc_ll1"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:layout_marginStart="20dp"
         android:layout_marginEnd="10dp"
         android:gravity="center_vertical"
         android:orientation="horizontal"
@@ -41,7 +40,7 @@
             android:id="@+id/item_gggc_info_tv"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_weight="2"
+            android:layout_weight="1"
             android:text="230万人在玩"
             android:textColor="#ff2ebef2"
             android:textSize="12sp" />
@@ -73,7 +72,7 @@
         <RelativeLayout
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_weight="2">
+            android:layout_weight="1">
 
             <android.support.v7.widget.AppCompatRatingBar
                 android:id="@+id/item_gggc_score_acrb"

+ 1 - 0
app/src/main/res/values/common.xml

@@ -22,6 +22,7 @@
     <dimen name="text_size_5">18sp</dimen>
     <dimen name="text_size_9">9sp</dimen>
     <dimen name="text_size_10">10sp</dimen>
+    <dimen name="text_size_11">11sp</dimen>
     <dimen name="text_size_12">12sp</dimen>
     <dimen name="text_size_15">15sp</dimen>
     <dimen name="text_size_16">16sp</dimen>