|
|
@@ -3,8 +3,6 @@ package com.sheep.gamegroup.view.fragment;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
import android.support.annotation.NonNull;
|
|
|
-import android.support.design.widget.TabLayout;
|
|
|
-import android.support.v4.view.ViewPager;
|
|
|
import android.support.v4.widget.NestedScrollView;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
@@ -15,24 +13,28 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
+import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
|
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
-import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
|
|
+import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
-import com.sheep.gamegroup.model.entity.FindTag;
|
|
|
import com.sheep.gamegroup.model.entity.GameEntity;
|
|
|
+import com.sheep.gamegroup.model.entity.GameEntityList;
|
|
|
+import com.sheep.gamegroup.model.entity.GameListTag;
|
|
|
+import com.sheep.gamegroup.model.entity.GameListType;
|
|
|
+import com.sheep.gamegroup.model.entity.GameListTypeList;
|
|
|
+import com.sheep.gamegroup.model.entity.GameRecommend;
|
|
|
import com.sheep.gamegroup.model.entity.SlideshowEty;
|
|
|
+import com.sheep.gamegroup.model.util.AbsSubscriber;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
|
-import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
-import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.ObservableUtil;
|
|
|
import com.sheep.gamegroup.util.RefreshUtil;
|
|
|
-import com.sheep.gamegroup.util.ViewHolder;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
-import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
-import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
|
|
|
+import com.sheep.gamegroup.view.adapter.AdpGameCenter1_2List;
|
|
|
+import com.sheep.gamegroup.view.adapter.AdpGameCenter3_3List;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
@@ -48,36 +50,27 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
-import butterknife.OnClick;
|
|
|
import butterknife.Unbinder;
|
|
|
+import rx.Observable;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
+import rx.functions.Func1;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
-import static com.sheep.gamegroup.model.entity.TaskEty.TASK_TYPE_GAME_OTHER;
|
|
|
-import static com.sheep.gamegroup.model.entity.TaskEty.TASK_TYPE_GAME_SHEEP;
|
|
|
-import static com.sheep.gamegroup.model.entity.TaskEty.TASK_TYPE_GAME_TECENT;
|
|
|
-import static com.sheep.gamegroup.model.entity.TaskEty.TASK_TYPE_GAME_XIAO_MI;
|
|
|
-import static com.sheep.gamegroup.view.adapter.PlayGameListAdapter.setOnClickGameEntity;
|
|
|
-
|
|
|
/**
|
|
|
- * Created by ljy on 2018/9/3.
|
|
|
+ * Created by realicing on 2018/10/30.
|
|
|
+ * realicing@sina.com
|
|
|
*/
|
|
|
-
|
|
|
public class FgtPlayGame extends BaseFragment {
|
|
|
@BindView(R.id.banner)
|
|
|
Banner banner;
|
|
|
- @BindView(R.id.every_day_more_tv)
|
|
|
- TextView everyDayMoreTv;
|
|
|
- @BindView(R.id.every_day_play_list)
|
|
|
- RecyclerView everyDayPlayList;
|
|
|
- @BindView(R.id.recent_hot_more_tv)
|
|
|
- TextView recentHotMoreTv;
|
|
|
- @BindView(R.id.recent_hoe_list)
|
|
|
- RecyclerView recentHoeList;
|
|
|
- @BindView(R.id.tabLayout)
|
|
|
- TabLayout indicator;
|
|
|
- @BindView(R.id.viewpager_act_game_details)
|
|
|
- ViewPager pager;
|
|
|
+ @BindView(R.id.play_game_act)
|
|
|
+ RecyclerView play_game_act;
|
|
|
+ @BindView(R.id.play_game_list_3_rv)
|
|
|
+ RecyclerView play_game_list_3_rv;
|
|
|
+ @BindView(R.id.play_game_list_2_rv)
|
|
|
+ RecyclerView play_game_list_2_rv;
|
|
|
+ @BindView(R.id.play_game_list_x_rv)
|
|
|
+ RecyclerView play_game_list_x_rv;
|
|
|
@BindView(R.id.refresh)
|
|
|
SmartRefreshLayout refresh;
|
|
|
@BindView(R.id.scrollView)
|
|
|
@@ -85,21 +78,27 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
Unbinder unbinder;
|
|
|
|
|
|
private Activity activity;
|
|
|
- private List<GameEntity> everyDayPlayListData = new ArrayList<>();
|
|
|
- private List<GameEntity> hotListData = new ArrayList<>();
|
|
|
-
|
|
|
+ //游戏首页活动列表
|
|
|
+ private List<SlideshowEty> gameActList = new ArrayList<>();
|
|
|
+ //每日必玩", "近期最热", "猜你喜欢
|
|
|
+ private List<GameListType> gameListTypeList3 = new ArrayList<>();
|
|
|
+ private List<GameEntityList> gameEntityList3 = new ArrayList<>();
|
|
|
+ //天天更新与重点推荐
|
|
|
+ private List<GameListType> gameListTypeList2 = new ArrayList<>();
|
|
|
+ private List<GameListTypeList<GameRecommend>> gameListTypeList2List = new ArrayList<>();
|
|
|
+ //预下载和tag列表的数据
|
|
|
+ private List<GameEntityList> gameEntityListx = new ArrayList<>();
|
|
|
private List<SlideshowEty> slideshowEtyLists = new ArrayList<>();
|
|
|
private List<String> slideshowTitleList = new ArrayList<>();
|
|
|
|
|
|
- private List<FindTag> list = ListUtil.emptyList();
|
|
|
- private TitleFragmentListAdapter mAdapter;
|
|
|
- private int curPosition = 0;
|
|
|
|
|
|
@Override
|
|
|
public int getLayoutId() {
|
|
|
return R.layout.fgt_play_game;
|
|
|
}
|
|
|
|
|
|
+ public static final int[] gameActBgIds = {R.drawable.shape_purple_gradient_solid_rectangle_5, R.drawable.shape_orange_gradient_solid_rectangle_5, R.drawable.shape_light_blue_gradient_solid_rectangle_5};
|
|
|
+
|
|
|
@Override
|
|
|
public void onViewCreated() {
|
|
|
activity = getActivity();
|
|
|
@@ -109,129 +108,205 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
bannerLayoutParams.height = G.WIDTH * 25 / 72;
|
|
|
banner.setLayoutParams(bannerLayoutParams);
|
|
|
|
|
|
- //每日必玩、近期最热
|
|
|
- LinearLayoutManager playHotManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
|
|
|
- //每日必玩
|
|
|
- everyDayPlayList.setHasFixedSize(true);
|
|
|
- everyDayPlayList.setNestedScrollingEnabled(false);
|
|
|
- everyDayPlayList.setLayoutManager(playHotManager);
|
|
|
- everyDayPlayList.setAdapter(new AdbCommonRecycler<GameEntity>(SheepApp.getInstance(), everyDayPlayListData) {
|
|
|
+ //游戏首页活动列表
|
|
|
+ LinearLayoutManager playGameActManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
|
|
|
+ play_game_act.setHasFixedSize(true);
|
|
|
+ play_game_act.setNestedScrollingEnabled(false);
|
|
|
+ play_game_act.setLayoutManager(playGameActManager);
|
|
|
+ play_game_act.setAdapter(new RecyclerViewAdapter<SlideshowEty>(SheepApp.getInstance(), R.layout.item_game_act, gameActList) {
|
|
|
@Override
|
|
|
- public int getViewIdByType(int type) {
|
|
|
- return R.layout.item_hot_welfare;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- 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);
|
|
|
+ public void convert(com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder viewHolder, final SlideshowEty item, int position) {
|
|
|
+ View item_game_act_start = viewHolder.itemView.findViewById(R.id.item_game_act_start);
|
|
|
+ View item_game_act_content = viewHolder.itemView.findViewById(R.id.item_game_act_content);
|
|
|
+ View item_game_act_end = viewHolder.itemView.findViewById(R.id.item_game_act_end);
|
|
|
+ ImageView item_game_act_iv = viewHolder.itemView.findViewById(R.id.item_game_act_iv);
|
|
|
+ TextView item_game_act_tv = viewHolder.itemView.findViewById(R.id.item_game_act_tv);
|
|
|
+ ViewUtil.setVisibility(item_game_act_start, position == 0);
|
|
|
+ ViewUtil.setVisibility(item_game_act_end, position + 1 == gameActList.size());
|
|
|
+ item_game_act_content.setBackgroundResource(gameActBgIds[position % gameActBgIds.length]);
|
|
|
+ if (item == null) {
|
|
|
+ ViewUtil.setDefaultText(item_game_act_tv);
|
|
|
} else {
|
|
|
- // 加载数据
|
|
|
- ViewUtil.setText(item_hot_welfare_tv, welfareCenter.getApp().getName());
|
|
|
- GlideImageLoader.setGameImage(item_hot_welfare_iv, welfareCenter.getApp().getIcon());
|
|
|
- setOnClickGameEntity(activity, holder.itemView, welfareCenter);
|
|
|
+ ViewUtil.setImage(item_game_act_iv, item.getUrl());
|
|
|
+ ViewUtil.setText(item_game_act_tv, item.getTitle());
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- //近期最热
|
|
|
- LinearLayoutManager hotManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
|
|
|
- recentHoeList.setHasFixedSize(true);
|
|
|
- recentHoeList.setNestedScrollingEnabled(false);
|
|
|
- recentHoeList.setLayoutManager(hotManager);
|
|
|
- recentHoeList.setAdapter(new AdbCommonRecycler<GameEntity>(SheepApp.getInstance(), hotListData) {
|
|
|
- @Override
|
|
|
- public int getViewIdByType(int type) {
|
|
|
- return R.layout.item_hot_welfare;
|
|
|
- }
|
|
|
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ try {
|
|
|
+ CommonUtil.getInstance().clickBanner(activity, item);
|
|
|
+ } catch (Exception e) {
|
|
|
+ G.showToast(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- @Override
|
|
|
- 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 {
|
|
|
- // 加载数据
|
|
|
- ViewUtil.setText(item_hot_welfare_tv, welfareCenter.getApp().getName());
|
|
|
- GlideImageLoader.setGameImage(item_hot_welfare_iv, welfareCenter.getApp().getIcon());
|
|
|
- setOnClickGameEntity(activity, holder.itemView, welfareCenter);
|
|
|
- }
|
|
|
}
|
|
|
});
|
|
|
- refresh.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
|
|
- @Override
|
|
|
- public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
|
|
- FgtPlayGameSon item = (FgtPlayGameSon) mAdapter.getItem(curPosition);
|
|
|
- if (item == null) {
|
|
|
- notifyDataSetChanged();
|
|
|
- return;
|
|
|
- }
|
|
|
- item.loadMoreData();
|
|
|
- notifyDataSetChanged();
|
|
|
- }
|
|
|
+
|
|
|
+ //每日必玩、近期最热、猜你喜欢
|
|
|
+ play_game_list_3_rv.setHasFixedSize(true);
|
|
|
+ play_game_list_3_rv.setNestedScrollingEnabled(false);
|
|
|
+ play_game_list_3_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
+ play_game_list_3_rv.setAdapter(new AdpGameCenter3_3List(activity, gameEntityList3).setShowFirstTop(false));
|
|
|
+ //天天更新、重点推荐
|
|
|
+ play_game_list_2_rv.setHasFixedSize(true);
|
|
|
+ play_game_list_2_rv.setNestedScrollingEnabled(false);
|
|
|
+ play_game_list_2_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
+ play_game_list_2_rv.setAdapter(new AdpGameCenter1_2List(activity, gameListTypeList2List));
|
|
|
+ //预下载与其它列表
|
|
|
+ play_game_list_x_rv.setHasFixedSize(true);
|
|
|
+ play_game_list_x_rv.setNestedScrollingEnabled(false);
|
|
|
+ play_game_list_x_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
+ play_game_list_x_rv.setAdapter(new AdpGameCenter3_3List(activity, gameEntityListx));
|
|
|
+
|
|
|
+ refresh.setOnRefreshListener(new OnRefreshListener() {
|
|
|
|
|
|
@Override
|
|
|
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
|
|
initData();
|
|
|
}
|
|
|
});
|
|
|
- RefreshUtil.newInstance().publicParameterRefresh(refresh, activity);
|
|
|
-
|
|
|
- mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
|
|
|
+ RefreshUtil.newInstance().publicParameter(refresh, activity);
|
|
|
+ initGameListType3List();
|
|
|
+ initGameListType2List();
|
|
|
+ refresh.autoRefresh();
|
|
|
+ }
|
|
|
|
|
|
- //tab
|
|
|
- initTab();
|
|
|
- initData();
|
|
|
+ public static final String[] gameListType3Titles = {"每日必玩", "近期最热", "猜你喜欢"};
|
|
|
+ public static final int[] gameListType3IsHots = {1, 0, 0};
|
|
|
+ public static final int[] gameListType3DailyPlays = {0, 1, 0};
|
|
|
+
|
|
|
+ private void initGameListType3List() {
|
|
|
+ //每日必玩", "近期最热", "猜你喜欢
|
|
|
+ for (int i = 0; i < gameListType3Titles.length; i++) {
|
|
|
+ GameListType gameListType = new GameListType();
|
|
|
+ gameListType.setTitle(gameListType3Titles[i]);
|
|
|
+ gameListType.setPer_page(20);
|
|
|
+ gameListType.setIs_hot(gameListType3IsHots[i]);
|
|
|
+ gameListType.setDaily_play(gameListType3DailyPlays[i]);
|
|
|
+ gameListTypeList3.add(gameListType);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onStart() {
|
|
|
- super.onStart();
|
|
|
- //结束轮播
|
|
|
- banner.startAutoPlay();
|
|
|
+ public static final String[] gameListType2Titles = {"天天更新", "重点推荐"};
|
|
|
+ public static final int[] gameListType2DisplayTypes = {1, 2};
|
|
|
+
|
|
|
+ private void initGameListType2List() {
|
|
|
+ //天天更新", "重点推荐
|
|
|
+ for (int i = 0; i < gameListType2Titles.length; i++) {
|
|
|
+ GameListType gameListType = new GameListType();
|
|
|
+ gameListType.setTitle(gameListType2Titles[i]);
|
|
|
+ gameListType.setDisplay_type(gameListType2DisplayTypes[i]);
|
|
|
+ gameListTypeList2.add(gameListType);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onStop() {
|
|
|
- super.onStop();
|
|
|
- //结束轮播
|
|
|
- banner.stopAutoPlay();
|
|
|
+ private void initData() {
|
|
|
+ initBanner();
|
|
|
+ initBannerAct();
|
|
|
+ initGameList3();
|
|
|
+ initRecommendList();
|
|
|
+ initGameTagList();
|
|
|
}
|
|
|
|
|
|
- private void bindBanner() {
|
|
|
- //结束轮播
|
|
|
- banner.stopAutoPlay();
|
|
|
- banner.setVisibility(View.VISIBLE);
|
|
|
- //设置图片加载器
|
|
|
- banner.setImageLoader(new ImageLoader() {
|
|
|
- @Override
|
|
|
- public void displayImage(Context context, Object o, ImageView imageView) {
|
|
|
- if (o instanceof SlideshowEty)
|
|
|
- Glide.with(context).load(((SlideshowEty) o).getUrl()).apply(new RequestOptions().dontAnimate()).into(imageView);
|
|
|
- }
|
|
|
- })
|
|
|
- .setDelayTime(4000)
|
|
|
- .setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
|
|
|
- //设置图片集合
|
|
|
- .setImages(slideshowEtyLists).setBannerTitles(slideshowTitleList)
|
|
|
- .setOnBannerListener(new OnBannerListener() {
|
|
|
+ private void initBannerAct() {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().gameBannerAct()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
- public void OnBannerClick(int i) {
|
|
|
- try {
|
|
|
- CommonUtil.getInstance().clickBanner(activity, i, slideshowEtyLists);
|
|
|
- } catch (Exception e) {
|
|
|
- G.showToast(e.getMessage());
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ ArrayList<SlideshowEty> newList = baseMessage.getDataList(SlideshowEty.class);
|
|
|
+ gameActList.clear();
|
|
|
+ if (ListUtil.isEmpty(newList)) {
|
|
|
+ gameActList.addAll(newList);
|
|
|
}
|
|
|
+ play_game_act.getAdapter().notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ notifyDataSetChanged();
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
|
|
|
- //banner设置方法全部调用完毕时最后调用
|
|
|
- banner.start();
|
|
|
+ //天天更新、重点推荐
|
|
|
+ private void initRecommendList() {
|
|
|
+ Observable.from(gameListTypeList2)
|
|
|
+ .subscribe(new AbsSubscriber<GameListType>() {
|
|
|
+ @Override
|
|
|
+ public void onNext(final GameListType gameListType) {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getRecommendList(gameListType.getDisplay_type())
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ List<GameRecommend> newList = baseMessage.getDatas(GameRecommend.class);
|
|
|
+ if (!ListUtil.isEmpty(newList)) {
|
|
|
+ gameListTypeList2List.add(new GameListTypeList<>(gameListType, newList));
|
|
|
+ play_game_list_2_rv.getAdapter().notifyDataSetChanged();
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //预下载下面的tagList
|
|
|
+ private void initGameTagList() {
|
|
|
+ gameEntityListx.clear();
|
|
|
+ //预下载
|
|
|
+ GameListType gameListType = new GameListType();
|
|
|
+ gameListType.setTitle("预下载");
|
|
|
+ gameListType.setDownload_type(1);
|
|
|
+ initGameList(play_game_list_x_rv, gameEntityListx, gameListType);
|
|
|
+ //其它tag
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getGameTagList()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .map(new Func1<BaseMessage, List<GameListTag>>() {
|
|
|
+ @Override
|
|
|
+ public List<GameListTag> call(BaseMessage baseMessage) {
|
|
|
+ return baseMessage.getDataList(GameListTag.class);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .filter(new Func1<List<GameListTag>, Boolean>() {
|
|
|
+ @Override
|
|
|
+ public Boolean call(List<GameListTag> gameListTags) {
|
|
|
+ return !ListUtil.isEmpty(gameListTags);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .flatMap(new Func1<List<GameListTag>, Observable<GameListTag>>() {
|
|
|
+ @Override
|
|
|
+ public Observable<GameListTag> call(List<GameListTag> gameListTagList) {
|
|
|
+ return Observable.from(gameListTagList);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .filter(new Func1<GameListTag, Boolean>() {
|
|
|
+ @Override
|
|
|
+ public Boolean call(GameListTag gameListTag) {
|
|
|
+ return gameListTag != null;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .subscribe(new AbsSubscriber<GameListTag>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(GameListTag gameListTag) {
|
|
|
+ initGameList(play_game_list_x_rv, gameEntityListx, gameListTag.toGameListType());
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- private void initData(){
|
|
|
+ //刷新banner数据
|
|
|
+ private void initBanner() {
|
|
|
//轮播
|
|
|
List<SlideshowEty> cacheSlideshowEtyList = DataUtil.getInstance().getCacheList(ApiKey.slideshowGame, SlideshowEty.class);
|
|
|
if (ListUtil.isEmpty(cacheSlideshowEtyList)) {
|
|
|
@@ -277,41 +352,79 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
notifyDataSetChanged();
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
|
|
|
- //每日必玩
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().playgameDailyOrHotOrTypePlay(1, 10, 0,1,0)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ private void bindBanner() {
|
|
|
+ //结束轮播
|
|
|
+ banner.stopAutoPlay();
|
|
|
+ banner.setVisibility(View.VISIBLE);
|
|
|
+ //设置图片加载器
|
|
|
+ banner.setImageLoader(new ImageLoader() {
|
|
|
+ @Override
|
|
|
+ public void displayImage(Context context, Object o, ImageView imageView) {
|
|
|
+ if (o instanceof SlideshowEty)
|
|
|
+ Glide.with(context).load(((SlideshowEty) o).getUrl()).apply(new RequestOptions().dontAnimate()).into(imageView);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setDelayTime(4000)
|
|
|
+ .setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
|
|
|
+ //设置图片集合
|
|
|
+ .setImages(slideshowEtyLists).setBannerTitles(slideshowTitleList)
|
|
|
+ .setOnBannerListener(new OnBannerListener() {
|
|
|
@Override
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
- List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
|
|
|
- if(!ListUtil.isEmpty(newList)) {//有缓存时不会加载,没有缓存时获取到数据会加载
|
|
|
- everyDayPlayListData.clear();
|
|
|
- everyDayPlayListData.addAll(newList);
|
|
|
- everyDayPlayList.getAdapter().notifyDataSetChanged();
|
|
|
- notifyDataSetChanged();
|
|
|
+ public void OnBannerClick(int i) {
|
|
|
+ try {
|
|
|
+ CommonUtil.getInstance().clickBanner(activity, i, slideshowEtyLists);
|
|
|
+ } catch (Exception e) {
|
|
|
+ G.showToast(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ //banner设置方法全部调用完毕时最后调用
|
|
|
+ banner.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStart() {
|
|
|
+ super.onStart();
|
|
|
+ //结束轮播
|
|
|
+ banner.startAutoPlay();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStop() {
|
|
|
+ super.onStop();
|
|
|
+ //结束轮播
|
|
|
+ banner.stopAutoPlay();
|
|
|
+ }
|
|
|
+
|
|
|
+ //刷新每日必玩、近期最热、猜你喜欢的数据
|
|
|
+ private void initGameList3() {
|
|
|
+ gameEntityList3.clear();
|
|
|
+ Observable.from(gameListTypeList3)
|
|
|
+ .subscribe(new AbsSubscriber<GameListType>() {
|
|
|
|
|
|
@Override
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
- notifyDataSetChanged();
|
|
|
+ public void onNext(final GameListType gameListType) {
|
|
|
+ initGameList(play_game_list_3_rv, gameEntityList3, gameListType);
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
|
|
|
- //近期最热
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().playgameDailyOrHotOrTypePlay(1, 10, 1,0,0)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
+ private void initGameList(final RecyclerView playGameListRv, final List<GameEntityList> gameEntityListList, final GameListType gameListType) {
|
|
|
+ if (gameListType == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ObservableUtil.getObservable(SheepApp.getInstance().getNetComponent().getApiService(), gameListType).subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
|
|
|
- if(!ListUtil.isEmpty(newList)) {//有缓存时不会加载,没有缓存时获取到数据会加载
|
|
|
- hotListData.clear();
|
|
|
- hotListData.addAll(newList);
|
|
|
- recentHoeList.getAdapter().notifyDataSetChanged();
|
|
|
+ if (!ListUtil.isEmpty(newList)) {
|
|
|
+ gameEntityListList.add(new GameEntityList(gameListType, newList));
|
|
|
+ playGameListRv.getAdapter().notifyDataSetChanged();
|
|
|
notifyDataSetChanged();
|
|
|
}
|
|
|
}
|
|
|
@@ -321,79 +434,11 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
notifyDataSetChanged();
|
|
|
}
|
|
|
});
|
|
|
- if (!isFirst) {
|
|
|
- for (int i = 0; i < mAdapter.getCount(); i++) {
|
|
|
- FgtPlayGameSon item = (FgtPlayGameSon) mAdapter.getItem(i);
|
|
|
- item.refreshData();
|
|
|
- }
|
|
|
- }
|
|
|
- isFirst = false;
|
|
|
}
|
|
|
|
|
|
- private boolean isFirst = true;
|
|
|
private void notifyDataSetChanged() {
|
|
|
- if(refresh != null) {
|
|
|
+ if (refresh != null) {
|
|
|
refresh.finishRefresh();
|
|
|
- refresh.finishLoadMore();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * tab
|
|
|
- * @param
|
|
|
- */
|
|
|
- private void initTab(){
|
|
|
- List<FindTag> newList = new ArrayList<>();
|
|
|
- newList.add(new FindTag(TASK_TYPE_GAME_SHEEP, "平台游戏"));
|
|
|
- newList.add(new FindTag(TASK_TYPE_GAME_XIAO_MI, "小米游戏"));
|
|
|
- newList.add(new FindTag(TASK_TYPE_GAME_TECENT, "腾讯游戏"));
|
|
|
- newList.add(new FindTag(TASK_TYPE_GAME_OTHER, "其他"));
|
|
|
- if (!ListUtil.isEmpty(newList)) {
|
|
|
- list.clear();
|
|
|
- ListUtil.addAll(list, newList);
|
|
|
- int position = 0;
|
|
|
- for(FindTag findTag:list){
|
|
|
- FgtPlayGameSon item = FgtPlayGameSon.newInstance(findTag.getId());
|
|
|
- item.setViewPager(pager);
|
|
|
- item.setSmartRefreshLayout(refresh);
|
|
|
- if(position == 0)
|
|
|
- item.setFirstPage(true);
|
|
|
- mAdapter.add(item, findTag.getName());
|
|
|
- position ++;
|
|
|
- }
|
|
|
- pager.setAdapter(mAdapter);
|
|
|
- indicator.setupWithViewPager(pager);
|
|
|
- pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
|
- @Override
|
|
|
- public void onPageScrolled(int i, float v, int i1) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onPageSelected(int i) {
|
|
|
- curPosition = i;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onPageScrollStateChanged(int i) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- CommonUtil.getInstance().reflex(indicator, activity);
|
|
|
- pager.setOffscreenPageLimit(list.size());
|
|
|
- notifyDataSetChanged();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @OnClick({R.id.every_day_more_tv, R.id.recent_hot_more_tv})
|
|
|
- public void onViewClicked(View view) {
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.every_day_more_tv:
|
|
|
- Jump2View.getInstance().goEverydayOrCurrentHotGame(activity, 0);
|
|
|
- break;
|
|
|
- case R.id.recent_hot_more_tv:
|
|
|
- Jump2View.getInstance().goEverydayOrCurrentHotGame(activity, 1);
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
}
|