Просмотр исходного кода

search support game mall goods

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

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

@@ -1939,7 +1939,7 @@ public interface ApiService {
     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("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);
+    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("app/search/keywords")
     Observable<BaseMessage> keywords();

+ 113 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/GameAvatar.java

@@ -0,0 +1,113 @@
+package com.sheep.gamegroup.model.entity;
+
+public class GameAvatar {
+
+    private int id;
+    private String game_name;
+    private String title;
+    private String icon;
+    private int is_system;
+    private float price;
+    private String pic;
+    private String game_user_name;
+    private String nick_name;
+    private String package_type_name;
+    private String game_area;
+    private long create_time;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getGame_name() {
+        return game_name;
+    }
+
+    public void setGame_name(String game_name) {
+        this.game_name = game_name;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public int getIs_system() {
+        return is_system;
+    }
+
+    public void setIs_system(int is_system) {
+        this.is_system = is_system;
+    }
+
+    public float getPrice() {
+        return price;
+    }
+
+    public void setPrice(float price) {
+        this.price = price;
+    }
+
+    public String getPic() {
+        return pic;
+    }
+
+    public void setPic(String pic) {
+        this.pic = pic;
+    }
+
+    public String getGame_user_name() {
+        return game_user_name;
+    }
+
+    public void setGame_user_name(String game_user_name) {
+        this.game_user_name = game_user_name;
+    }
+
+    public String getNick_name() {
+        return nick_name;
+    }
+
+    public void setNick_name(String nick_name) {
+        this.nick_name = nick_name;
+    }
+
+    public String getPackage_type_name() {
+        return package_type_name;
+    }
+
+    public void setPackage_type_name(String package_type_name) {
+        this.package_type_name = package_type_name;
+    }
+
+    public String getGame_area() {
+        return game_area;
+    }
+
+    public void setGame_area(String game_area) {
+        this.game_area = game_area;
+    }
+
+    public long getCreate_time() {
+        return create_time;
+    }
+
+    public void setCreate_time(long create_time) {
+        this.create_time = create_time;
+    }
+}

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/module/search/AdpSearchResult.java

@@ -54,6 +54,9 @@ public class AdpSearchResult extends RecyclerView.Adapter<SearchResultHolder> {
         } else if (i == 5) {
             itemView = LayoutInflater.from(mContext).inflate(R.layout.shop_goods_item, viewGroup, false);
             holder = new GoodsHolder(itemView);
+        } else if (i == 6) {
+            itemView = LayoutInflater.from(mContext).inflate(R.layout.item_game_avater, viewGroup, false);
+            holder = new GameAvatarHolder(itemView);
         } else {
             itemView = new TextView(mContext);
             holder = new SearchResultHolder(itemView) {

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

@@ -11,6 +11,7 @@ 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.GameEntity;
 import com.sheep.gamegroup.model.entity.GameSimple;
 import com.sheep.gamegroup.model.entity.GiftBag;
@@ -43,6 +44,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
     private int giftCount = 0;
     private int articleCount = 0;
     private int goodsCount = 0;
+    private int roleCount = 0;
 
     private String keyword;
 
@@ -103,6 +105,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
         giftCount = 0;
         articleCount = 0;
         goodsCount = 0;
+        roleCount = 0;
         hideEmpty();
         search(true);
     }
@@ -113,7 +116,7 @@ public class FgtSearch extends BaseFragment implements ISearch {
 
     private void search(boolean isRefresh) {
         SheepApp.getInstance().getNetComponent().getApiService()
-                .search(keyword, gameCount, taskCount, giftCount, articleCount, goodsCount)
+                .search(keyword, gameCount, taskCount, giftCount, articleCount, goodsCount, roleCount)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
@@ -130,6 +133,9 @@ public class FgtSearch extends BaseFragment implements ISearch {
                             if (base.has("goods_count")) {
                                 goodsCount += base.getInt("goods_count");
                             }
+                            if (base.has("role_count")) {
+                                roleCount += base.getInt("role_count");
+                            }
                             JSONArray array = base.getJSONArray("list");
                             for (int i = 0; i < array.length(); i++) {
                                 JSONObject object = array.getJSONObject(i);
@@ -146,6 +152,8 @@ public class FgtSearch extends BaseFragment implements ISearch {
                                     item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, Article.class);
                                 } else if (item.type == 5) {
                                     item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, ShopGoodsInfo.class);
+                                } else if (item.type == 6) {
+                                    item.object = com.alibaba.fastjson.JSONObject.parseObject(item.data, GameAvatar.class);
                                 } else {
                                     continue;
                                 }

+ 56 - 0
app/src/main/java/com/sheep/gamegroup/module/search/GameAvatarHolder.java

@@ -0,0 +1,56 @@
+package com.sheep.gamegroup.module.search;
+
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.sheep.gamegroup.model.entity.GameAvatar;
+import com.sheep.gamegroup.model.entity.GiftBagApp;
+import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.jiuyan.samllsheep.Config;
+import com.sheep.jiuyan.samllsheep.R;
+
+import butterknife.BindView;
+
+public class GameAvatarHolder extends SearchResultHolder<GameAvatar> {
+
+    @BindView(R.id.icon_view)
+    ImageView iconView;
+    @BindView(R.id.name_view)
+    TextView nameView;
+    @BindView(R.id.no_view)
+    TextView noView;
+    @BindView(R.id.game_view)
+    TextView gameView;
+    @BindView(R.id.server_view)
+    TextView serverView;
+    @BindView(R.id.sales_view)
+    TextView salesView;
+    @BindView(R.id.price_view)
+    TextView priceView;
+
+    public GameAvatarHolder(@NonNull View itemView) {
+        super(itemView);
+        itemView.setOnClickListener((v) -> {
+            Jump2View.getInstance().goWeb(itemView.getContext(), new WebParams(Config.getUrlByPath(Config.PATH_GAME_SHOP_GOODS_DETAIL, "id", item.getId())).setTitle(item.getTitle()));
+        });
+    }
+
+    @Override
+    public void configView() {
+        ViewUtil.setImage(iconView, item.getIcon());
+        ViewUtil.setText(nameView, item.getTitle());
+        ViewUtil.setText(noView, "游戏号:" + item.getGame_user_name());
+        ViewUtil.setText(gameView, item.getGame_name() + "[" + item.getPackage_type_name() + "]");
+        ViewUtil.setText(serverView, "区服:" + item.getGame_area());
+        ViewUtil.setText(salesView, "卖家:" + (TextUtils.isEmpty(item.getNick_name()) ? "***" : item.getNick_name().substring(0, 1) + "**"));
+        ViewUtil.setText(priceView, "¥" + NumberFormatUtils.retain1(item.getPrice()));
+    }
+
+}

+ 1 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java

@@ -97,6 +97,7 @@ public class Config {
     //游戏商城
     public static final String PATH_GAME_SHOP_HOME = STATION_GAME_SHOP + "/gameMallHome";
     public static final String PATH_GAME_SHOP_MY_GAME = STATION_GAME_SHOP + "/myGameRole";
+    public static final String PATH_GAME_SHOP_GOODS_DETAIL = STATION_GAME_SHOP + "/goodsDetail";
     //遇见预约
     public static final String PATH_YY_SHOP_FOCUS = STATION_YY_SHOP + "/pages/cart/collection";
     public static final String PATH_YY_SHOP_CART = STATION_YY_SHOP + "/pages/cart/myCart";

+ 114 - 0
app/src/main/res/layout/item_game_avater.xml

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:background="@color/white"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <ImageView
+        android:id="@+id/icon_view"
+        android:layout_width="84dp"
+        android:layout_height="84dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginTop="16dp"
+        android:layout_marginBottom="16dp"
+        android:src="@mipmap/ic_launcher"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/name_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:text="永恒仙域游戏周边"
+        android:textColor="#ff333333"
+        android:textSize="14sp"
+        android:lines="1"
+        android:ellipsize="end"
+        app:layout_constraintLeft_toRightOf="@+id/icon_view"
+        app:layout_constraintTop_toTopOf="@+id/icon_view" />
+
+    <TextView
+        android:id="@+id/no_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginTop="4dp"
+        android:text="游戏号:142536"
+        android:textColor="#ff999999"
+        android:textSize="10sp"
+        app:layout_constraintLeft_toRightOf="@+id/icon_view"
+        app:layout_constraintTop_toBottomOf="@+id/name_view" />
+
+    <TextView
+        android:id="@+id/game_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginTop="4dp"
+        android:text="永恒仙域-【凌霄殿】"
+        android:textColor="#ff8e8e8e"
+        android:textSize="8sp"
+        app:layout_constraintLeft_toRightOf="@+id/icon_view"
+        app:layout_constraintTop_toBottomOf="@+id/no_view" />
+
+    <TextView
+        android:id="@+id/server_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginTop="4dp"
+        android:text="区服:112区"
+        android:textColor="#ff8e8e8e"
+        android:textSize="10sp"
+        app:layout_constraintLeft_toRightOf="@+id/icon_view"
+        app:layout_constraintTop_toBottomOf="@+id/game_view" />
+
+    <TextView
+        android:id="@+id/sales_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginTop="2dp"
+        android:text="卖家:小xx"
+        android:textColor="#ff8e8e8e"
+        android:textSize="10sp"
+        app:layout_constraintLeft_toRightOf="@+id/icon_view"
+        app:layout_constraintTop_toBottomOf="@+id/server_view" />
+
+    <View
+        android:background="#f2f2f2"
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:layout_marginTop="16dp"
+        app:layout_constraintTop_toBottomOf="@+id/icon_view" />
+
+    <TextView
+        android:id="@+id/price_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="¥150.0"
+        android:textColor="#ffff3366"
+        android:textSize="15sp"
+        android:gravity="center"
+        android:minWidth="80dp"
+        android:layout_marginTop="36dp"
+        android:layout_marginRight="16dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintRight_toRightOf="parent"/>
+    
+    <TextView
+        android:text="立即购买"
+        android:textSize="12sp"
+        android:textColor="@color/white"
+        android:background="@drawable/shape_blue_solid_rectangle_15"
+        android:gravity="center"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_marginBottom="20dp"
+        android:layout_marginRight="18dp"
+        android:layout_width="72dp"
+        android:layout_height="30dp" />
+
+</android.support.constraint.ConstraintLayout>