Quellcode durchsuchen

添加游戏中心抢任务模块;
修复限时抢购价格写反的bug

zengjiebin vor 7 Jahren
Ursprung
Commit
12a10724dc

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

@@ -12,7 +12,6 @@ import com.bumptech.glide.Glide;
 import com.bumptech.glide.request.RequestOptions;
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.scwang.smartrefresh.layout.SmartRefreshLayout;
-import com.sheep.gamegroup.absBase.AbsObserver;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.GameListType;
@@ -24,6 +23,7 @@ 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.util.HpRefreshWelfareHelper;
+import com.sheep.gamegroup.module.game.util.OneTaskHelper;
 import com.sheep.gamegroup.module.game.util.PromoteGoodsHelper;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
@@ -48,9 +48,7 @@ import java.util.Comparator;
 import java.util.List;
 
 import butterknife.BindView;
-import io.reactivex.Observable;
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.functions.Function;
 import io.reactivex.schedulers.Schedulers;
 
 /**
@@ -65,6 +63,8 @@ public class FgtPlayGame extends BaseFragment {
     RecyclerView play_game_center_type_list;
     @BindView(R.id.play_game_list_2_rv)
     RecyclerView play_game_list_2_rv;
+    @BindView(R.id.play_game_list_2_rv2)
+    RecyclerView play_game_list_2_rv2;
     @BindView(R.id.play_game_list_x_rv)
     RecyclerView play_game_list_x_rv;
     @BindView(R.id.refresh)
@@ -77,6 +77,7 @@ public class FgtPlayGame extends BaseFragment {
     public static final int[] GAME_CENTER_TYPE_ID = {1, 3, 2, -1};//1:绵羊新游 2:绵羊推荐 3:免费道具
     //预下载和tag列表的数据
     private List<ListTypeList<GameEntity, GameListType>> gameEntityList2 = new ArrayList<>();
+    private List<ListTypeList<GameEntity, GameListType>> gameEntityList22 = new ArrayList<>();
     private List<ListTypeList<GameEntity, GameListType>> gameEntityListx = new ArrayList<>();
     private List<SlideshowEty> slideshowEtyLists = new ArrayList<>();
     private List<String> slideshowTitleList = new ArrayList<>();
@@ -91,6 +92,10 @@ public class FgtPlayGame extends BaseFragment {
     @BindView(R.id.hp_refresh_welfare_box)
     View hp_refresh_welfare_box;
     private HpRefreshWelfareHelper mHpRefreshWelfareHelper;//刷新福利的帮助类
+    //单个任务的入口与刷新任务
+    @BindView(R.id.play_game_task)
+    View play_game_task;
+    private OneTaskHelper mOneTaskHelper;//的帮助类
     //商品限时抢购入口与刷新商品
     @BindView(R.id.play_game_promote_goods)
     View play_game_promote_goods;
@@ -105,6 +110,8 @@ public class FgtPlayGame extends BaseFragment {
         //玩转游戏  游戏福利专区入口
         mHpRefreshWelfareHelper = new HpRefreshWelfareHelper(hp_refresh_welfare_box);
         //玩转游戏  商城限时抢购入口
+        mOneTaskHelper = new OneTaskHelper(play_game_task);
+        //玩转游戏  商城限时抢购入口
         mPromoteGoodsHelper = new PromoteGoodsHelper(play_game_promote_goods);
 
 
@@ -124,12 +131,17 @@ public class FgtPlayGame extends BaseFragment {
         BaseQuickAdapter baseQuickAdapter = new AdpGameCenterType(gameCenterList);
         baseQuickAdapter.bindToRecyclerView(play_game_center_type_list);
         baseQuickAdapter.setOnItemClickListener((adapter, view, position) -> Jump2View.getInstance().goActGameCenterType(getActivity(), ListUtil.getItem(gameCenterList, position)));
-        //x列表前2个
+        //前2个
         play_game_list_2_rv.setHasFixedSize(true);
         play_game_list_2_rv.setNestedScrollingEnabled(false);
         play_game_list_2_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
         new AdpGameCenter4_3List(gameEntityList2).bindToRecyclerView(play_game_list_2_rv);
-        //x列表从第2个开始
+        //前2-4个
+        play_game_list_2_rv2.setHasFixedSize(true);
+        play_game_list_2_rv2.setNestedScrollingEnabled(false);
+        play_game_list_2_rv2.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
+        new AdpGameCenter4_3List(gameEntityList22).bindToRecyclerView(play_game_list_2_rv2);
+        //x列表从第4个开始
         play_game_list_x_rv.setHasFixedSize(true);
         play_game_list_x_rv.setNestedScrollingEnabled(false);
         play_game_list_x_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
@@ -154,6 +166,7 @@ public class FgtPlayGame extends BaseFragment {
     //获取出包类型列表 的tagList
     private void initGameTagList() {
         gameEntityList2.clear();
+        gameEntityList22.clear();
         gameEntityListx.clear();
         ViewUtil.notifyDataSetChanged(play_game_list_2_rv);
         ViewUtil.notifyDataSetChanged(play_game_list_x_rv);
@@ -171,11 +184,13 @@ public class FgtPlayGame extends BaseFragment {
                         ArrayList<GamePortTypes> gamePortTypeList = baseMessage.getDataList(GamePortTypes.class);
                         Collections.sort(gamePortTypeList, comparator2);
                         int size = gamePortTypeList.size();
-                        int d = size / 2;
+                        int d = size / 3;
                         for (int i = 0; i < size; i++) {
                             GamePortTypes item = gamePortTypeList.get(i);
                             if(i < d ){
                                 initGameList(play_game_list_2_rv, gameEntityList2, item);
+                            } else if(i < 2d ){
+                                initGameList(play_game_list_2_rv2, gameEntityList22, item);
                             } else {
                                 initGameList(play_game_list_x_rv, gameEntityListx, item);
                             }

+ 1 - 8
app/src/main/java/com/sheep/gamegroup/module/game/util/HpRefreshWelfareHelper.java

@@ -53,14 +53,7 @@ public class HpRefreshWelfareHelper {
         hp_refresh_welfare.setHasFixedSize(true);
         hp_refresh_welfare.setNestedScrollingEnabled(false);
         hp_refresh_welfare.setAdapter(new AdpRefreshWelfare(R.layout.item_hp_refresh_welfare, refreshWelfareList).setChangeOne(view -> {
-            refreshWelfareList.clear();
-            ViewUtil.notifyDataSetChanged(hp_refresh_welfare);
-            ViewUtil.delay2(new AbsObserver<Integer>(){
-                @Override
-                public void onNext(Integer o) {
-                    refreshData();
-                }
-            }, 100L);
+            refreshData();
         }));
     }
 

+ 134 - 0
app/src/main/java/com/sheep/gamegroup/module/game/util/OneTaskHelper.java

@@ -0,0 +1,134 @@
+package com.sheep.gamegroup.module.game.util;
+
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.sheep.gamegroup.absBase.AbsObserver;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.CommendTask;
+import com.sheep.gamegroup.model.entity.Release_task;
+import com.sheep.gamegroup.model.entity.TaskEty;
+import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.yf_shop.model.GetPromoteGoodsUrl;
+import com.sheep.gamegroup.module.yf_shop.model.PromoteGoods;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DataKey;
+import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.TestUtil;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
+
+import java.util.Locale;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
+
+/**
+ * Created by realicing on 2019/3/27.
+ * realicing@sina.com
+ * 小绵羊3.5.3新增 -- 商品限时抢购
+ */
+public class OneTaskHelper {
+
+    private View rootView;
+
+    public OneTaskHelper(View rootView) {
+        this.rootView = rootView;
+        ButterKnife.bind(this, rootView);
+        initView();
+    }
+
+    @BindView(R.id.hp_gwe_tv1)
+    TextView hp_gwe_tv1;
+    @BindView(R.id.hp_gwe_tv2)
+    TextView hp_gwe_tv2;
+
+    @OnClick(R.id.hp_gwe_tv2)
+    public void toPromoteGoodsList() {//跳转去赚钱界面
+        Jump2View.getInstance().goTryplayView(SheepApp.getInstance().getCurrentActivity(), null);
+    }
+    @OnClick(R.id.item_look_more)
+    public void toLookMore() {//跳转到商城列表
+        toPromoteGoodsList();
+    }
+    @OnClick(R.id.item_change_one_tv)
+    public void toChangeOne() {//切换到下一个
+        loadMore();
+    }
+
+    //初始化刷新福利
+    private void initView() {
+        ViewUtil.setText(hp_gwe_tv1, "试玩奖励");
+        ViewUtil.setText(hp_gwe_tv2, "去赚钱");
+        ViewUtil.setVisibility(rootView, false);
+        refreshData();
+    }
+
+    public void refreshData() {
+        initData();
+    }
+    public void loadMore() {
+        initData();
+    }
+    public void initData() {
+        CommonUtil.getInstance().robTask(robTask -> {
+            if (robTask != null) {
+                DataUtil.putAsInt(DataKey.KEY_ORDER, robTask.getOrder());
+                try {
+                    loadData(robTask);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    if(TestUtil.isDev())
+                        G.showToast(e.getMessage());
+                }
+            } else {
+                if(TestUtil.isDev())
+                    G.showToast(R.string.task_sold_out_focus_publish);
+            }
+        });
+    }
+
+    @BindView(R.id.item_icon_iv)
+    ImageView item_icon_iv;
+    @BindView(R.id.item_name_tv)
+    TextView item_name_tv;
+    @BindView(R.id.item_time_tv)
+    TextView item_time_tv;
+    @BindView(R.id.item_yuan_jia_tv)
+    TextView item_yuan_jia_tv;
+    @BindView(R.id.item_vip_yuan_jia_tv)
+    TextView item_vip_yuan_jia_tv;
+    private void loadData(CommendTask item){
+        ViewUtil.setVisibility(rootView, item != null);
+        if(item == null){
+            return;
+        }
+        Release_task release_task = item.getM();
+        if(release_task == null){
+            return;
+        }
+        TaskEty taskEty = release_task.getTask();
+        if(taskEty == null){
+            return;
+        }
+        ViewUtil.setGameImage(item_icon_iv, taskEty.getIcon());
+        ViewUtil.setText(item_name_tv, release_task.getName());
+        ViewUtil.setText(item_yuan_jia_tv, "+" + release_task.getBonusText() + "元");
+        ViewUtil.setText(item_vip_yuan_jia_tv, release_task.getVipBonusText());
+        ViewUtil.setText(item_time_tv, "截止时间:" + release_task.getDateText());
+        //tag 标签绘制
+        CommonUtil.getInstance().setTaskTag(SheepApp.getInstance(), rootView, release_task, "game_center");
+        rootView.setOnClickListener(view -> Jump2View.getInstance().goEntity(release_task));
+    }
+}

+ 3 - 9
app/src/main/java/com/sheep/gamegroup/module/game/util/PromoteGoodsHelper.java

@@ -77,13 +77,7 @@ public class PromoteGoodsHelper {
     }
     @OnClick(R.id.item_change_one_tv)
     public void toChangeOne() {//切换到下一个
-        ViewUtil.setVisibility(play_game_promote_goods, false);
-        ViewUtil.delay2(new AbsObserver<Integer>(){
-            @Override
-            public void onNext(Integer o) {
-                loadMore();
-            }
-        }, 100L);
+        loadMore();
     }
 
     //初始化刷新福利
@@ -141,8 +135,8 @@ public class PromoteGoodsHelper {
         ViewUtil.setImage(item_icon_iv, item.getGoods_thumb());
         ViewUtil.setText(item_name_tv, item.getGoods_name());
         ViewUtil.setText(item_remainder_time, item.getRemainderTime());
-        ViewUtil.setText(item_yuan_jia_tv, item.getPromotePriceText());
-        ViewUtil.setText(item_xian_jia_tv, item.getMarketPriceText());
+        ViewUtil.setText(item_xian_jia_tv, item.getPromotePriceText());
+        ViewUtil.setText(item_yuan_jia_tv, item.getMarketPriceText());
         ViewUtil.setText(item_discount_tv, item.getDiscountText());
         item_discount_box.setOnClickListener(view -> {
             String url = String.format(Locale.CHINA, "%s?id=%s", getPromoteGoodsUrl.getGoods_url(), item.getGoods_id());

+ 9 - 0
app/src/main/res/layout/fgt_play_game.xml

@@ -52,6 +52,15 @@
                 android:layout_height="wrap_content" />
 
             <include
+                android:id="@+id/play_game_task"
+                layout="@layout/item_game_task"/>
+
+            <android.support.v7.widget.RecyclerView
+                android:id="@+id/play_game_list_2_rv2"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <include
                 android:id="@+id/play_game_promote_goods"
                 layout="@layout/item_game_promote_goods"/>
 

+ 22 - 0
app/src/main/res/layout/item_game_task.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="10dp"
+        android:background="@color/bg_home_color"/>
+    <include layout="@layout/hp_game_welfare_entrance"/>
+    <include
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="-7dp"
+        layout="@layout/item_hp_one_task"/>
+    <include
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="-11dp"
+        android:layout_marginBottom="7dp"
+        layout="@layout/include_look_more_and_change"/>
+</LinearLayout>

+ 128 - 0
app/src/main/res/layout/item_hp_one_task.xml

@@ -0,0 +1,128 @@
+<?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:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <ImageView
+        android:id="@+id/item_icon_iv"
+        android:layout_width="63dp"
+        android:layout_height="63dp"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="19dp"
+        android:layout_marginBottom="11dp"
+        android:src="@mipmap/sheep_logo"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/item_name_tv"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="11dp"
+        android:layout_marginTop="20dp"
+        android:layout_marginEnd="94dp"
+        android:ellipsize="end"
+        android:singleLine="true"
+        android:text="永恒仙域"
+        android:textColor="#ff333333"
+        android:textSize="14sp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toEndOf="@id/item_icon_iv"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <LinearLayout
+        android:id="@+id/item_game_tags"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        android:layout_marginBottom="3dp"
+        app:layout_constraintBottom_toTopOf="@id/item_time_tv"
+        app:layout_constraintEnd_toEndOf="@id/item_name_tv"
+        app:layout_constraintStart_toStartOf="@id/item_name_tv" >
+
+
+        <TextView
+            android:id="@+id/item_num_tv"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text=""
+            android:textColor="#cc8e8e8e"
+            android:textSize="10sp" />
+
+        <TextView
+            android:id="@+id/item_num_tv1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/content_padding"
+            android:singleLine="true"
+            android:text=""
+            android:textColor="#cc8e8e8e"
+            android:textSize="10sp"
+            android:visibility="gone" />
+
+        <TextView
+            android:id="@+id/item_num_tv2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/content_padding"
+            android:singleLine="true"
+            android:text=""
+            android:textColor="#cc8e8e8e"
+            android:textSize="10sp"
+            android:visibility="gone" />
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/item_time_tv"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="10dp"
+        android:singleLine="true"
+        android:text="截止时间:2018/04/30 23:59"
+        android:textColor="#ff8e8e8e"
+        android:textSize="10sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="@id/item_name_tv"
+        app:layout_constraintStart_toStartOf="@id/item_name_tv" />
+
+    <TextView
+        android:id="@+id/item_yuan_jia_tv"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:gravity="center"
+        android:singleLine="true"
+        android:text="+1.5元"
+        android:textColor="#ffff2d4b"
+        android:textSize="18sp"
+        app:layout_constraintEnd_toEndOf="@id/item_btn_tv"
+        app:layout_constraintStart_toStartOf="@id/item_btn_tv"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/item_vip_yuan_jia_tv"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:singleLine="true"
+        android:gravity="center"
+        android:text="会员: +2元"
+        android:textColor="#ffcbb550"
+        android:textSize="10sp"
+        app:layout_constraintBottom_toTopOf="@id/item_btn_tv"
+        app:layout_constraintEnd_toEndOf="@id/item_btn_tv"
+        app:layout_constraintStart_toStartOf="@id/item_btn_tv"
+        app:layout_constraintTop_toBottomOf="@id/item_yuan_jia_tv" />
+
+    <TextView
+        android:id="@+id/item_btn_tv"
+        style="@style/style_button_find"
+        android:layout_marginEnd="17dp"
+        android:layout_marginBottom="10dp"
+        android:text="开始赚钱"
+        android:textSize="13sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent" />
+</android.support.constraint.ConstraintLayout>