liujiangyao лет назад: 7
Родитель
Сommit
1f73168409

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

@@ -934,4 +934,17 @@ public interface ApiService {
      */
     @GET("app/find")
     Observable<BaseMessage> playgameDailyOrHotOrTypePlay(@Query("page") int page, @Query("per_page") int per_page, @Query("is_hot") int is_hot, @Query("daily_play") int daily_play, @Query("type") int type);
+
+    /**
+     * platform 平台 1:andriod 2:ios
+     * @return
+     */
+    @GET("app/game_banner")
+    Observable<BaseMessage> gameBanner(@Query("platform") int platform);
+    /**
+     * platform 平台 1:andriod 2:ios
+     * @return
+     */
+    @GET("app/find/{id}")
+    Observable<BaseMessage> playGameDetail(@Path("id") int id);
 }

+ 97 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/GameEntity.java

@@ -0,0 +1,97 @@
+package com.sheep.gamegroup.model.entity;
+
+import java.util.List;
+
+/**
+ * Created by ljy on 2018/9/4.
+ */
+
+public class GameEntity {
+    private int accepted_task_id;//integer($int64)领取福利时使用
+
+    private PlayGameEntity app;
+    private int can_download;//boolean
+    private int is_reservation;//integer($int64)0 不是 1是预约
+
+    private int received_voucher;//boolean是否已经领取了福利
+
+    private int release_task_id;//integer($int64)发布任务id
+
+    private int status;//integer($int64)福利任务时使用,和任务记录一样
+
+    private TaskReleaseEty release_task;
+
+    private List<Object> has_gift_bag;
+
+    public TaskReleaseEty getRelease_task() {
+        return release_task;
+    }
+
+    public void setRelease_task(TaskReleaseEty release_task) {
+        this.release_task = release_task;
+    }
+
+    public List<Object> getHas_gift_bag() {
+        return has_gift_bag;
+    }
+
+    public void setHas_gift_bag(List<Object> has_gift_bag) {
+        this.has_gift_bag = has_gift_bag;
+    }
+
+    public int getAccepted_task_id() {
+        return accepted_task_id;
+    }
+
+    public void setAccepted_task_id(int accepted_task_id) {
+        this.accepted_task_id = accepted_task_id;
+    }
+
+    public PlayGameEntity getApp() {
+        return app;
+    }
+
+    public void setApp(PlayGameEntity app) {
+        this.app = app;
+    }
+
+    public int getCan_download() {
+        return can_download;
+    }
+
+    public void setCan_download(int can_download) {
+        this.can_download = can_download;
+    }
+
+    public int getIs_reservation() {
+        return is_reservation;
+    }
+
+    public void setIs_reservation(int is_reservation) {
+        this.is_reservation = is_reservation;
+    }
+
+    public int getReceived_voucher() {
+        return received_voucher;
+    }
+
+    public void setReceived_voucher(int received_voucher) {
+        this.received_voucher = received_voucher;
+    }
+
+    public int getRelease_task_id() {
+        return release_task_id;
+    }
+
+    public void setRelease_task_id(int release_task_id) {
+        this.release_task_id = release_task_id;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+}

+ 4 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/ActEverydayPlayGame.java

@@ -4,6 +4,7 @@ import android.support.v7.widget.RecyclerView;
 
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.PlayGameEntity;
 import com.sheep.gamegroup.view.adapter.PlayGameItemAdapter;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
@@ -17,7 +18,7 @@ import rx.Observable;
  * Created by ljy on 2018/9/3.
  */
 
-public class ActEverydayPlayGame extends BaseListActivity<PlayGameEntity> {
+public class ActEverydayPlayGame extends BaseListActivity<GameEntity> {
     private int type;
     @Override
     protected RecyclerView.Adapter getAdapter() {
@@ -37,8 +38,8 @@ public class ActEverydayPlayGame extends BaseListActivity<PlayGameEntity> {
     }
 
     @Override
-    protected Class<PlayGameEntity> getTClass() {
-            return PlayGameEntity.class;
+    protected Class<GameEntity> getTClass() {
+            return GameEntity.class;
     }
 
     @Override

+ 213 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActPlayGameDetail.java

@@ -0,0 +1,213 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.os.Bundle;
+import android.support.design.widget.AppBarLayout;
+import android.support.v7.widget.AppCompatRatingBar;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.arialyy.aria.core.Aria;
+import com.kfzs.duanduan.utils.dlg.HelperUtils;
+import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.helper.ImageListHelper;
+import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.MyListview;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+import com.tencent.smtt.sdk.WebView;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.ArrayList;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import rx.functions.Action1;
+
+/**
+ * Created by ljy on 2018/9/4.
+ */
+
+public class ActPlayGameDetail extends BaseActivity implements Action1<Integer> {
+    @BindView(R.id.appbar_act_game_details)
+    AppBarLayout appbarActGameDetails;
+    @BindView(R.id.find_game_list)
+    RecyclerView find_game_list;
+    @BindView(R.id.find_game_info_wv)
+    WebView findGameInfoWv;
+    @BindView(R.id.item_detail_listview)
+    MyListview itemDetailListview;
+    @BindView(R.id.bottom_line_text)
+    TextView bottomLineText;
+    @BindView(R.id.bottom_line)
+    LinearLayout bottomLine;
+    @BindView(R.id.status_height_view)
+    View statusHeightView;
+    @BindView(R.id.find_game_bar)
+    View find_game_bar;
+    @BindView(R.id.title_bottom_line)
+    LinearLayout title_bottom_line;
+    @BindView(R.id.img_baseactivity_title)
+    ImageView img_baseactivity_title;
+    @BindView(R.id.txt_baseactivity_title)
+    TextView txt_baseactivity_title;
+    @BindView(R.id.ibtn_baseactivity_right)
+    ImageButton ibtn_baseactivity_right;
+    @BindView(R.id.find_game_iv)
+    ImageView find_game_iv;
+    @BindView(R.id.find_game_name_tv)
+    TextView find_game_name_tv;
+    @BindView(R.id.find_game_info_tv)
+    TextView find_game_info_tv;
+    @BindView(R.id.find_game_xin)
+    AppCompatRatingBar find_game_xin;
+    @BindView(R.id.find_game_down_tv)
+    TextView find_game_down_tv;
+
+    private int id;
+    private boolean mIsExpanded = false;//是否是折叠状态
+    private ArrayList<String> pictureList = ListUtil.emptyList();
+    private ImageListHelper imageListHelper = new ImageListHelper();
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.act_play_game_detail_layout;
+    }
+
+    @Override
+    public void initView() {
+        id = getIntent().getIntExtra("id", 0);
+
+        TitleBarUtils.getInstance()
+                .setTitle(this, "详情")
+                .setTitleFinish(this);
+        EventBus.getDefault().register(this);
+        Aria.download(this).register();
+
+        txt_baseactivity_title.setVisibility(View.INVISIBLE);//不显示标题栏
+
+        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, HelperUtils.BAR_HEIGH);
+        statusHeightView.setLayoutParams(params);
+
+        appbarActGameDetails.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
+            @Override
+            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
+                int nameWidth = find_game_name_tv.getWidth();
+                if (nameWidth == 0) {
+                    find_game_name_tv.measure(0, 0);
+                    nameWidth = find_game_name_tv.getMeasuredWidth();
+                }
+                int infoWidth = find_game_info_tv.getWidth();
+                if (infoWidth == 0) {
+                    find_game_info_tv.measure(0, 0);
+                    infoWidth = find_game_info_tv.getMeasuredWidth();
+                }
+                //图标位置变化
+                int find_game_top = getResources().getDimensionPixelSize(R.dimen.find_game_top);
+                int find_icon_with = getResources().getDimensionPixelSize(R.dimen.find_icon_with);
+//                int leftMargin = getResources().getDimensionPixelSize(R.dimen.content_padding_5);
+                int titleHeight = img_baseactivity_title.getHeight();
+                int titleWidth = img_baseactivity_title.getWidth();
+                int topRow = (titleHeight - find_game_name_tv.getHeight() - find_game_info_tv.getHeight()) / 5;
+                int topRow2 = (titleHeight - find_game_name_tv.getHeight()) / 2;
+                int leftRow = topRow2 / 4;//isNeedReservation ? topRow : 5 * topRow;
+
+                int willTop = Math.max(topRow/2, find_game_top + verticalOffset);
+                int row = (find_icon_with * willTop + titleHeight * (find_game_top - willTop)) / find_game_top - topRow;
+                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) find_game_iv.getLayoutParams();
+                layoutParams.leftMargin = Math.max(titleWidth, (G.WIDTH - find_icon_with) / 2 + verticalOffset);
+                layoutParams.topMargin = willTop;
+                layoutParams.width = row;
+                layoutParams.height = row;
+                find_game_iv.setLayoutParams(layoutParams);
+                //名字位置变化
+                RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) find_game_name_tv.getLayoutParams();
+                layoutParams2.leftMargin = Math.max(titleWidth + row + 2 * leftRow, (G.WIDTH - nameWidth) / 2 + verticalOffset);
+                layoutParams2.topMargin = Math.max(topRow2, getResources().getDimensionPixelSize(R.dimen.find_game_top2) + verticalOffset);
+                find_game_name_tv.setLayoutParams(layoutParams2);
+                //信息位置变化
+                RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) find_game_info_tv.getLayoutParams();
+                int left1 = (G.WIDTH - infoWidth) / 2;
+                int left2 = titleWidth + row + 2 * leftRow;
+                layoutParams3.leftMargin = left1;//left2 > left1 ? Math.min(left2, left1 - verticalOffset) : Math.max(left2, left1 + verticalOffset);
+                layoutParams3.topMargin = /*Math.max(find_game_name_tv.getHeight() + 4 * topRow, */getResources().getDimensionPixelSize(R.dimen.find_game_top3) + verticalOffset/*)*/;
+                find_game_info_tv.setLayoutParams(layoutParams3);
+                //下载按钮位置变化
+                RelativeLayout.LayoutParams layoutParams4 = (RelativeLayout.LayoutParams) find_game_down_tv.getLayoutParams();
+                layoutParams4.setMarginEnd(Math.max(ibtn_baseactivity_right.getWidth(), (G.WIDTH - find_game_down_tv.getWidth()) / 2 + verticalOffset));
+                layoutParams4.topMargin = Math.max((titleHeight - find_game_down_tv.getHeight()) / 2, getResources().getDimensionPixelSize(R.dimen.find_game_top4) + verticalOffset);// Math.max(topRow, getResources().getDimensionPixelSize(R.dimen.find_game_top4) + verticalOffset);
+                find_game_down_tv.setLayoutParams(layoutParams4);
+                //星级位置变化
+                RelativeLayout.LayoutParams layoutParams5 = (RelativeLayout.LayoutParams) find_game_xin.getLayoutParams();
+                layoutParams5.topMargin = getResources().getDimensionPixelSize(R.dimen.find_game_top5) + verticalOffset;
+                find_game_xin.setLayoutParams(layoutParams5);
+                if (willTop == topRow/2) {
+                    if (mIsExpanded) {
+//                        txt_baseactivity_title.setVisibility(View.INVISIBLE);
+                        find_game_bar.setVisibility(View.VISIBLE);
+                        title_bottom_line.setVisibility(View.VISIBLE);
+                        img_baseactivity_title.setImageLevel(1);
+                        mIsExpanded = false;//修改状态标记为折叠
+                    }
+                } else {
+                    if (!mIsExpanded) {
+                        mIsExpanded = true;//修改状态标记为展开
+//                        txt_baseactivity_title.setVisibility(View.VISIBLE);
+                        find_game_bar.setVisibility(View.INVISIBLE);
+                        title_bottom_line.setVisibility(View.INVISIBLE);
+                        img_baseactivity_title.setImageLevel(0);
+                    }
+                }
+            }
+        });
+
+        imageListHelper.initList(this, find_game_list, pictureList);
+        resetData();
+
+    }
+
+    private void resetData() {
+        //游戏简介与下载
+        ViewUtil.setText(find_game_name_tv);
+        ViewUtil.setText(find_game_info_tv);
+        ViewUtil.setText(find_game_down_tv);
+        find_game_xin.setRating(0.0f);
+        //游戏介绍
+    }
+
+    @Override
+    public void initListener() {
+
+    }
+
+    @Override
+    public void initData() {
+
+    }
+
+    @Override
+    public void call(Integer integer) {
+
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        Aria.download(this).unRegister();
+        EventBus.getDefault().unregister(this);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        // TODO: add setContentView(...) invocation
+        ButterKnife.bind(this);
+    }
+}

+ 12 - 12
app/src/main/java/com/sheep/gamegroup/view/adapter/PlayGameItemAdapter.java

@@ -5,7 +5,7 @@ import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
 
-import com.googlecode.protobuf.format.util.TextUtils;
+import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.PlayGameEntity;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.ViewHolder;
@@ -18,8 +18,8 @@ import java.util.List;
  * Created by ljy on 2018/9/3.
  */
 
-public class PlayGameItemAdapter extends AdbCommonRecycler<PlayGameEntity> implements View.OnClickListener {
-    public PlayGameItemAdapter(Context context, List<PlayGameEntity> list) {
+public class PlayGameItemAdapter extends AdbCommonRecycler<GameEntity> implements View.OnClickListener {
+    public PlayGameItemAdapter(Context context, List<GameEntity> list) {
         super(context, list);
     }
 
@@ -34,16 +34,16 @@ public class PlayGameItemAdapter extends AdbCommonRecycler<PlayGameEntity> imple
     }
 
     @Override
-    public void convert(ViewHolder holder, PlayGameEntity playGameEntity) {
+    public void convert(ViewHolder holder, GameEntity gameEntity) {
         holder.itemView.setOnClickListener(this);
-        View item_download_welfare_line = holder.getView(R.id.line_tv);
-        View detail_task_tv_center = holder.getView(R.id.detail_task_tv_center);
-        TextView item_name_tv = holder.getView(R.id.item_name_tv);
-        TextView item_date_tv = holder.getView(R.id.item_date_tv);
-
-        ViewUtil.setText(item_name_tv, playGameEntity.getName());
-        ViewUtil.setText(item_date_tv, playGameEntity.getPackage_size()+"M");
-        GlideImageLoader.setImage((ImageView) holder.getView(R.id.item_icon_iv), playGameEntity.getIcon());
+        View item_download_welfare_line = holder.itemView.findViewById(R.id.line_tv);
+        View detail_task_tv_center = holder.itemView.findViewById(R.id.detail_task_tv_center);
+        TextView item_name_tv = holder.itemView.findViewById(R.id.item_name_tv);
+        TextView item_date_tv = holder.itemView.findViewById(R.id.item_date_tv);
+
+        ViewUtil.setText(item_name_tv, gameEntity.getApp().getName());
+        ViewUtil.setText(item_date_tv, gameEntity.getApp().getPackage_size()+"M");
+        GlideImageLoader.setImage((ImageView) holder.itemView.findViewById(R.id.item_icon_iv), gameEntity.getApp().getIcon());
 
         item_download_welfare_line.setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
     }

+ 12 - 0
app/src/main/java/com/sheep/gamegroup/view/fragment/BaseListFragment.java

@@ -162,6 +162,18 @@ public abstract class BaseListFragment<T> extends BaseFragment {
         super.onDestroyView();
         unbinder.unbind();
     }
+    public int getDataCount() {
+        return list.size();
+    }
+
+    /**
+     *
+     * @return
+     */
+    public void setNoFresh(){
+        if(view_list != null)
+            view_list.setPullRefreshEnabled(false);
+    }
     protected abstract RecyclerView.Adapter getAdapter();
     protected abstract String getKey(int page, int per_page);
     protected abstract Observable<BaseMessage> getApi(ApiService apiService);

+ 54 - 26
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPlayGame.java

@@ -3,6 +3,8 @@ package com.sheep.gamegroup.view.fragment;
 import android.app.Activity;
 import android.content.Context;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
 import android.support.design.widget.TabLayout;
 import android.support.v4.view.ViewPager;
 import android.support.v4.widget.NestedScrollView;
@@ -21,9 +23,8 @@ import com.bumptech.glide.request.RequestOptions;
 import com.kfzs.duanduan.mine.GiftpackListAdapter;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.FindTag;
-import com.sheep.gamegroup.model.entity.PlayGameEntity;
+import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.SlideshowEty;
-import com.sheep.gamegroup.model.entity.Welfare;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
@@ -54,8 +55,6 @@ import butterknife.Unbinder;
 import rx.android.schedulers.AndroidSchedulers;
 import rx.schedulers.Schedulers;
 
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_TAG;
-
 /**
  * Created by ljy on 2018/9/3.
  */
@@ -85,15 +84,37 @@ public class FgtPlayGame extends BaseFragment {
     NestedScrollView scrollView;
     Unbinder unbinder;
 
+    public static final int WHAT_UPDATE_VP_HEIGHT = 1;//刷新viewpager高度
     private Activity activity;
-    private List<PlayGameEntity> everyDayPlayListData = new ArrayList<>();
-    private List<PlayGameEntity> hotListData = new ArrayList<>();
+    private List<GameEntity> everyDayPlayListData = new ArrayList<>();
+    private List<GameEntity> hotListData = new ArrayList<>();
 
     private List<SlideshowEty> slideshowEtyLists = new ArrayList<>();
     private List<String> slideshowTitleList = new ArrayList<>();
 
     private List<FindTag> list = ListUtil.emptyList();
     private GiftpackListAdapter mAdapter;
+    private int curPosition = 0;
+
+    Handler mHandler = new Handler(){
+        @Override
+        public void handleMessage(Message msg) {
+            super.handleMessage(msg);
+            switch (msg.what) {
+                case WHAT_UPDATE_VP_HEIGHT:
+                    FgtPlayGameSon item = (FgtPlayGameSon) mAdapter.getItem(curPosition);
+                    if (pager == null || item == null) {
+                        return;
+                    }
+                    int count = item.getDataCount();
+                    item.setNoFresh();
+                    ViewGroup.LayoutParams params = pager.getLayoutParams();
+                    params.height = count == 0 ? G.HEIGHT / 2 : (count * getResources().getDimensionPixelSize(R.dimen.content_padding_96) + getResources().getDimensionPixelSize(R.dimen.content_padding));
+                    pager.setLayoutParams(params);
+                    break;
+            }
+        }
+    };
 
     @Override
     public int getLayoutId() {
@@ -115,22 +136,22 @@ public class FgtPlayGame extends BaseFragment {
         everyDayPlayList.setHasFixedSize(true);
         everyDayPlayList.setNestedScrollingEnabled(false);
         everyDayPlayList.setLayoutManager(playHotManager);
-        everyDayPlayList.setAdapter(new AdbCommonRecycler<PlayGameEntity>(SheepApp.getInstance(), everyDayPlayListData) {
+        everyDayPlayList.setAdapter(new AdbCommonRecycler<GameEntity>(SheepApp.getInstance(), everyDayPlayListData) {
             @Override
             public int getViewIdByType(int type) {
                 return R.layout.item_hot_welfare;
             }
 
             @Override
-            public void convert(ViewHolder holder, PlayGameEntity welfareCenter) {
-                ImageView item_hot_welfare_iv = holder.getView(R.id.item_hot_welfare_iv);
-                TextView item_hot_welfare_tv = holder.getView(R.id.item_hot_welfare_tv);
+            public void convert(ViewHolder holder, GameEntity welfareCenter) {
+                ImageView item_hot_welfare_iv =  holder.itemView.findViewById(R.id.item_hot_welfare_iv);
+                TextView item_hot_welfare_tv = holder.itemView.findViewById(R.id.item_hot_welfare_tv);
                 if(welfareCenter == null){
                     ViewUtil.setDefaultText(item_hot_welfare_tv);
                 } else {
                     //TODO 加载数据
-                    ViewUtil.setText(item_hot_welfare_tv, welfareCenter.getName());
-                    GlideImageLoader.setImage(item_hot_welfare_iv, welfareCenter.getIcon());
+                    ViewUtil.setText(item_hot_welfare_tv, welfareCenter.getApp().getName());
+                    GlideImageLoader.setImage(item_hot_welfare_iv, welfareCenter.getApp().getIcon());
                     onClickToPlayGameDetail(holder.itemView, welfareCenter);
                 }
             }
@@ -140,22 +161,22 @@ public class FgtPlayGame extends BaseFragment {
         recentHoeList.setHasFixedSize(true);
         recentHoeList.setNestedScrollingEnabled(false);
         recentHoeList.setLayoutManager(hotManager);
-        everyDayPlayList.setAdapter(new AdbCommonRecycler<PlayGameEntity>(SheepApp.getInstance(), hotListData) {
+        recentHoeList.setAdapter(new AdbCommonRecycler<GameEntity>(SheepApp.getInstance(), hotListData) {
             @Override
             public int getViewIdByType(int type) {
                 return R.layout.item_hot_welfare;
             }
 
             @Override
-            public void convert(ViewHolder holder, PlayGameEntity welfareCenter) {
-                ImageView item_hot_welfare_iv = holder.getView(R.id.item_hot_welfare_iv);
-                TextView item_hot_welfare_tv = holder.getView(R.id.item_hot_welfare_tv);
+            public void convert(ViewHolder holder, GameEntity welfareCenter) {
+                ImageView item_hot_welfare_iv = holder.itemView.findViewById(R.id.item_hot_welfare_iv);
+                TextView item_hot_welfare_tv = holder.itemView.findViewById(R.id.item_hot_welfare_tv);
                 if(welfareCenter == null){
                     ViewUtil.setDefaultText(item_hot_welfare_tv);
                 } else {
                     //TODO 加载数据
-                    ViewUtil.setText(item_hot_welfare_tv, welfareCenter.getName());
-                    GlideImageLoader.setImage(item_hot_welfare_iv, welfareCenter.getIcon());
+                    ViewUtil.setText(item_hot_welfare_tv, welfareCenter.getApp().getName());
+                    GlideImageLoader.setImage(item_hot_welfare_iv, welfareCenter.getApp().getIcon());
                     onClickToPlayGameDetail(holder.itemView, welfareCenter);
                 }
             }
@@ -171,9 +192,10 @@ public class FgtPlayGame extends BaseFragment {
 
         //tab
         initTab();
+        initData();
     }
 
-    private void onClickToPlayGameDetail(View view, PlayGameEntity playGameEntity){
+    private void onClickToPlayGameDetail(View view, GameEntity playGameEntity){
         view.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -245,7 +267,7 @@ public class FgtPlayGame extends BaseFragment {
 
     private void initData(){
 
-        SheepApp.getInstance().getNetComponent().getApiService().slideshow(1)
+        SheepApp.getInstance().getNetComponent().getApiService().gameBanner(1)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
@@ -283,8 +305,10 @@ public class FgtPlayGame extends BaseFragment {
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-                        List<PlayGameEntity> newList = baseMessage.getDatas(PlayGameEntity.class);
-                        if(everyDayPlayListData.isEmpty() && !ListUtil.isEmpty(newList)) {//有缓存时不会加载,没有缓存时获取到数据会加载
+                        List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
+                        if(!ListUtil.isEmpty(newList)) {//有缓存时不会加载,没有缓存时获取到数据会加载
+                            everyDayPlayListData.clear();
+                            everyDayPlayListData.addAll(newList);
                             everyDayPlayList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
@@ -297,14 +321,16 @@ public class FgtPlayGame extends BaseFragment {
                 });
 
         //近期最热
-        SheepApp.getInstance().getNetComponent().getApiService().playgameDailyOrHotOrTypePlay(1, 10, 0,1,0)
+        SheepApp.getInstance().getNetComponent().getApiService().playgameDailyOrHotOrTypePlay(1, 10, 1,0,0)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-                        List<PlayGameEntity> newList = baseMessage.getDatas(PlayGameEntity.class);
-                        if(hotListData.isEmpty() && !ListUtil.isEmpty(newList)) {//有缓存时不会加载,没有缓存时获取到数据会加载
+                        List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
+                        if(!ListUtil.isEmpty(newList)) {//有缓存时不会加载,没有缓存时获取到数据会加载
+                            hotListData.clear();
+                            hotListData.addAll(newList);
                             recentHoeList.getAdapter().notifyDataSetChanged();
                             notifyDataSetChanged();
                         }
@@ -346,7 +372,9 @@ public class FgtPlayGame extends BaseFragment {
 
                 @Override
                 public void onPageSelected(int i) {
-                    FIND_TAG.onEvent("find_tag_name", ListUtil.hasIndex(list, i - 1) );
+//                    FIND_TAG.onEvent("find_tag_name", ListUtil.hasIndex(list, i - 1) );
+                    curPosition = i;
+                    mHandler.sendEmptyMessage(WHAT_UPDATE_VP_HEIGHT);//重新计算viewpager高度
                 }
 
                 @Override

+ 22 - 69
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPlayGameSon.java

@@ -1,45 +1,28 @@
 package com.sheep.gamegroup.view.fragment;
 
-import android.app.Activity;
 import android.os.Bundle;
-import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 
+import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.entity.Welfare;
-import com.sheep.gamegroup.model.util.SheepSubscriber;
-import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.view.adapter.DownloadWelfareAdapter;
-import com.sheep.jiuyan.samllsheep.R;
-import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+import com.sheep.gamegroup.model.entity.GameEntity;
+import com.sheep.gamegroup.model.entity.PlayGameEntity;
+import com.sheep.gamegroup.view.adapter.PlayGameItemAdapter;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Locale;
 
-import butterknife.BindView;
 import butterknife.ButterKnife;
-import butterknife.Unbinder;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
+import rx.Observable;
 
 /**
  * Created by ljy on 2018/9/3.
  */
 
-public class FgtPlayGameSon extends BaseFragment {
-    @BindView(R.id.recyclerview_list)
-    RecyclerView recyclerviewList;
-    Unbinder unbinder;
-
-    private int page = 1;//页数
-    private int per_page = 10;
+public class FgtPlayGameSon extends BaseListFragment<GameEntity> {
     private int type;
-    private Activity activity;
-    private List<Welfare> listData = ListUtil.emptyList();
 
     public static FgtPlayGameSon newInstance(int type){
         FgtPlayGameSon fgt = new FgtPlayGameSon();
@@ -50,65 +33,35 @@ public class FgtPlayGameSon extends BaseFragment {
     }
 
     @Override
-    public int getLayoutId() {
-        return R.layout.recyclerview_layout;
-    }
-
-    @Override
-    public void onViewCreated() {
-        activity = getActivity();
-        LinearLayoutManager downloadLayoutManager = new LinearLayoutManager(SheepApp.getInstance());
-        recyclerviewList.setHasFixedSize(true);
-        recyclerviewList.setNestedScrollingEnabled(false);
-        recyclerviewList.setLayoutManager(downloadLayoutManager);
-        recyclerviewList.setAdapter(new DownloadWelfareAdapter(SheepApp.getInstance(), listData));
-
-        initData();
-    }
-
-    private void initData() {
-        SheepApp.getInstance().getNetComponent().getApiService().getFindList(page, per_page, type)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        ArrayList<Welfare> newList = baseMessage.getDataList(Welfare.class);
-                        listData.clear();
-                        ListUtil.addAll(listData, newList);
-                        recyclerviewList.getAdapter().notifyDataSetChanged();
-                    }
-
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                        listData.clear();
-                        recyclerviewList.getAdapter().notifyDataSetChanged();
-                    }
-                });
-    }
-
-    @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         // TODO: inflate a fragment view
         View rootView = super.onCreateView(inflater, container, savedInstanceState);
         unbinder = ButterKnife.bind(this, rootView);
         Bundle bundle = getArguments();
         if(bundle != null){
-            type = bundle.getInt("type", 0);
+            type = bundle.getInt("type", 1002);
         }
         return rootView;
     }
 
     @Override
-    public void onResume() {
-        super.onResume();
-        initData();
+    protected RecyclerView.Adapter getAdapter() {
+        return new PlayGameItemAdapter(activity, list);
+    }
+
+    @Override
+    protected String getKey(int page, int per_page) {
+        return String.format(Locale.CHINA, "app/find?page=%d&per_page=%d&is_hot=%d&daily_play=%d&type=%d", page, per_page, 0, 0, type);
+    }
+
+    @Override
+    protected Observable<BaseMessage> getApi(ApiService apiService) {
+        return apiService.playgameDailyOrHotOrTypePlay(page, per_page, 0, 0, type);
     }
 
     @Override
-    public void onDestroyView() {
-        super.onDestroyView();
-        unbinder.unbind();
+    protected Class<GameEntity> getTClass() {
+        return GameEntity.class;
     }
 
 }

+ 1 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/TitleBarUtils.java

@@ -392,7 +392,7 @@ public class TitleBarUtils {
         adapter.add(fragment1, tab1);
         adapter.add(fragment2, tab2);
 
-        viewPager.setOffscreenPageLimit(2);
+//        viewPager.setOffscreenPageLimit(2);
         viewPager.setAdapter(adapter);
 
         tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));

+ 264 - 0
app/src/main/res/layout/act_play_game_detail_layout.xml

@@ -0,0 +1,264 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout 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="match_parent"
+    android:background="@color/white_light">
+
+    <android.support.design.widget.CoordinatorLayout 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="match_parent">
+
+        <android.support.design.widget.AppBarLayout
+            android:id="@+id/appbar_act_game_details"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@color/white_light"
+            android:fitsSystemWindows="true">
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="280dp"
+                android:gravity="center_horizontal"
+                android:orientation="vertical"
+                app:expandedTitleTextAppearance="@style/TextAppearance.Design.CollapsingToolbar.Expanded"
+                app:layout_scrollFlags="scroll|exitUntilCollapsed"/>
+
+        </android.support.design.widget.AppBarLayout>
+
+        <android.support.v4.widget.NestedScrollView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:fillViewport="false"
+            app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+                <android.support.v7.widget.RecyclerView
+                    android:id="@+id/find_game_list"
+                    android:layout_width="match_parent"
+                    android:layout_height="200dp"
+                    android:layout_marginTop="@dimen/dp_10"
+                    android:layout_marginBottom="@dimen/dp_10"/>
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:orientation="vertical"
+                    android:layout_margin="@dimen/dp_10"
+                    android:padding="@dimen/content_padding_20"
+                    android:background="@drawable/x_shap_shadow_bg_rectgangle_white">
+                    <LinearLayout
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:gravity="center_vertical"
+                        android:orientation="horizontal">
+
+                        <View
+                            android:layout_width="5dp"
+                            android:layout_height="16dp"
+                            android:background="#2FBCF1" />
+
+                        <TextView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:layout_marginStart="3dp"
+                            android:text="游戏介绍"
+                            android:textColor="@color/black_6_3"
+                            android:textSize="15sp" />
+
+                    </LinearLayout>
+                    <com.tencent.smtt.sdk.WebView
+                        android:id="@+id/find_game_info_wv"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="@dimen/dp_10"/>
+                </LinearLayout>
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:orientation="vertical"
+                    android:layout_margin="@dimen/dp_10"
+                    android:padding="@dimen/content_padding_20"
+                    android:background="@drawable/x_shap_shadow_bg_rectgangle_white">
+                    <LinearLayout
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:gravity="center_vertical"
+                        android:orientation="horizontal">
+
+                        <View
+                            android:layout_width="5dp"
+                            android:layout_height="16dp"
+                            android:background="#2FBCF1" />
+
+                        <TextView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:layout_marginStart="3dp"
+                            android:text="奖励领取步骤"
+                            android:textColor="@color/black_6_3"
+                            android:textSize="15sp" />
+
+                    </LinearLayout>
+
+                    <com.sheep.gamegroup.util.MyListview
+                        android:id="@+id/item_detail_listview"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_marginBottom="@dimen/content_padding_15"
+                        android:layout_marginStart="@dimen/content_padding_15"
+                        android:divider="@null"
+                        android:listSelector="@color/transparent"
+                        android:scrollbars="none" />
+                </LinearLayout>
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:orientation="vertical"
+                    android:layout_margin="@dimen/dp_10"
+                    android:padding="@dimen/content_padding_20"
+                    android:background="@drawable/x_shap_shadow_bg_rectgangle_white">
+                    <LinearLayout
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:gravity="center_vertical"
+                        android:orientation="horizontal">
+
+                        <View
+                            android:layout_width="5dp"
+                            android:layout_height="16dp"
+                            android:background="#2FBCF1" />
+
+                        <TextView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:layout_marginStart="3dp"
+                            android:text="福利剩余数量"
+                            android:textColor="@color/black_6_3"
+                            android:textSize="15sp" />
+
+                    </LinearLayout>
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="进度条"/>
+
+
+                </LinearLayout>
+                <include layout="@layout/find_item_bottom"/>
+            </LinearLayout>
+        </android.support.v4.widget.NestedScrollView>
+    </android.support.design.widget.CoordinatorLayout>
+
+    <View
+        android:id="@+id/status_height_view"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/status_bar_height" />
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="?attr/actionBarSize"
+        android:layout_below="@+id/status_height_view">
+
+        <View
+            android:id="@+id/find_game_bar"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@color/white_F9F9F9"
+            android:visibility="invisible" />
+
+        <include
+            layout="@layout/title_bottom_line"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            android:visibility="invisible" />
+
+        <ImageView
+            android:id="@+id/img_baseactivity_title"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:gravity="center_vertical"
+            android:paddingEnd="@dimen/content_padding"
+            android:paddingStart="@dimen/content_padding"
+            android:scaleType="centerInside"
+            android:src="@drawable/narrow_back_black" />
+
+        <TextView
+            android:id="@+id/txt_baseactivity_title"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="center"
+            android:text="@string/app_name"
+            android:textColor="@color/black_text_deep"
+            android:textSize="@dimen/text_size_4"
+            android:visibility="invisible" />
+        <!--右边图片按钮-->
+        <ImageButton
+            android:id="@+id/ibtn_baseactivity_right"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:paddingEnd="@dimen/content_padding"
+            android:paddingStart="@dimen/content_padding"
+            android:background="@color/translate"
+            android:src="@mipmap/share"
+            android:gravity="center"/>
+    </RelativeLayout>
+
+    <ImageView
+        android:id="@+id/find_game_iv"
+        android:layout_width="@dimen/find_icon_with"
+        android:layout_height="@dimen/find_icon_with"
+        android:layout_marginTop="@dimen/find_game_top"
+        android:src="@drawable/loading_01"
+        android:layout_below="@+id/status_height_view" />
+
+    <TextView
+        android:id="@+id/find_game_name_tv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/find_game_top2"
+        android:layout_below="@+id/status_height_view"
+        android:text="@string/app_name"
+        android:textColor="@color/title"
+        android:textSize="16sp" />
+
+    <TextView
+        android:id="@+id/find_game_info_tv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/find_game_top3"
+        android:layout_below="@+id/status_height_view"
+        android:gravity="center"
+        android:text="厂商:网易 | 版本号:7.9"
+        android:textColor="@color/black_666666"
+        android:textSize="12sp" />
+
+    <android.support.v7.widget.AppCompatRatingBar
+        android:id="@+id/find_game_xin"
+        style="@style/style_rating_bar"
+        android:layout_width="wrap_content"
+        android:layout_marginTop="@dimen/find_game_top5"
+        android:layout_centerHorizontal="true"
+        android:isIndicator="true"
+        android:numStars="5"
+        android:rating="1.5"
+        android:stepSize="0.5" />
+    <TextView
+        android:id="@+id/find_game_down_tv"
+        style="@style/style_button_find"
+        android:layout_marginTop="@dimen/find_game_top4"
+        android:layout_below="@+id/status_height_view"
+        android:layout_alignParentEnd="true"
+        android:text="下载" />
+</RelativeLayout>