|
@@ -1,17 +1,37 @@
|
|
|
package com.sheep.gamegroup.module.game.fragment;
|
|
package com.sheep.gamegroup.module.game.fragment;
|
|
|
|
|
|
|
|
|
|
+import android.support.v7.widget.GridLayoutManager;
|
|
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
|
|
|
|
|
|
|
+import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
|
|
+import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.GameEntity;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.GameListType;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.ListTypeList;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
|
|
+import com.sheep.gamegroup.module.game.adapter.AdpGameCenter4_3List;
|
|
|
|
|
+import com.sheep.gamegroup.module.game.adapter.AdpGameCenterType;
|
|
|
|
|
+import com.sheep.gamegroup.module.game.adapter.AdpGiftBagGameGroup;
|
|
|
|
|
+import com.sheep.gamegroup.module.game.adapter.AdpGiftBags;
|
|
|
|
|
+import com.sheep.gamegroup.module.game.model.GameGroup;
|
|
|
|
|
+import com.sheep.gamegroup.module.game.model.GiftTags;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
|
|
+import com.sheep.gamegroup.util.ListUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.RefreshUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.TestUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
@@ -29,6 +49,8 @@ public class FgtGiftCenter extends BaseFragment{
|
|
|
RecyclerView fgt_gift_center_x_list;
|
|
RecyclerView fgt_gift_center_x_list;
|
|
|
@BindView(R.id.fgt_gift_center_input_et)
|
|
@BindView(R.id.fgt_gift_center_input_et)
|
|
|
EditText fgt_gift_center_input_et;
|
|
EditText fgt_gift_center_input_et;
|
|
|
|
|
+ @BindView(R.id.refresh)
|
|
|
|
|
+ SmartRefreshLayout refresh;
|
|
|
@Override
|
|
@Override
|
|
|
public int getLayoutId() {
|
|
public int getLayoutId() {
|
|
|
return R.layout.fgt_gift_center;
|
|
return R.layout.fgt_gift_center;
|
|
@@ -37,30 +59,92 @@ public class FgtGiftCenter extends BaseFragment{
|
|
|
@Override
|
|
@Override
|
|
|
public void onViewCreated() {
|
|
public void onViewCreated() {
|
|
|
initView();
|
|
initView();
|
|
|
- initData();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void initData() {
|
|
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().getGiftBagTag()
|
|
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //绵羊新游、免费道具、绵羊推荐、排行榜
|
|
|
|
|
+ private List<GameGroup> gameGroupList = new ArrayList<>();
|
|
|
|
|
+ private List<GiftTags> giftTagsList = new ArrayList<>();
|
|
|
|
|
+ public void initView() {
|
|
|
|
|
+ View wc_all_gift = findViewById(R.id.wc_all_gift);
|
|
|
|
|
+ wc_all_gift.setOnClickListener(view -> Jump2View.getInstance().goMyWelfare(getActivity()));
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
|
|
- G.showToast(baseMessage);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
|
|
+ fgt_gift_center_type_list.setHasFixedSize(true);
|
|
|
|
|
+ fgt_gift_center_type_list.setNestedScrollingEnabled(false);
|
|
|
|
|
+ fgt_gift_center_type_list.setLayoutManager(new GridLayoutManager(SheepApp.getInstance(), 2));
|
|
|
|
|
+ BaseQuickAdapter baseQuickAdapter = new AdpGiftBags(giftTagsList);
|
|
|
|
|
+ baseQuickAdapter.bindToRecyclerView(fgt_gift_center_type_list);
|
|
|
|
|
+ baseQuickAdapter.setOnItemClickListener((adapter, view, position) -> Jump2View.getInstance().goEntity(ListUtil.getItem(giftTagsList, position)));
|
|
|
|
|
+ //x列表
|
|
|
|
|
+ fgt_gift_center_x_list.setHasFixedSize(true);
|
|
|
|
|
+ fgt_gift_center_x_list.setNestedScrollingEnabled(false);
|
|
|
|
|
+ fgt_gift_center_x_list.setLayoutManager(new GridLayoutManager(SheepApp.getInstance(), 4));
|
|
|
|
|
+ BaseQuickAdapter gameGroupAdp = new AdpGiftBagGameGroup(gameGroupList);
|
|
|
|
|
+ gameGroupAdp.bindToRecyclerView(fgt_gift_center_x_list);
|
|
|
|
|
+ gameGroupAdp.setOnItemClickListener((adapter, view, position) -> Jump2View.getInstance().goEntity(ListUtil.getItem(gameGroupList, position)));
|
|
|
|
|
+
|
|
|
|
|
+ refresh.setOnRefreshListener(refreshLayout -> refreshData());
|
|
|
|
|
+ RefreshUtil.newInstance().publicParameter(refresh, getActivity());
|
|
|
|
|
+ refresh.autoRefresh();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void initView() {
|
|
|
|
|
- View wc_all_gift = findViewById(R.id.wc_all_gift);
|
|
|
|
|
- wc_all_gift.setOnClickListener(view -> Jump2View.getInstance().goMyWelfare(getActivity()));
|
|
|
|
|
|
|
+ private void refreshData() {
|
|
|
|
|
+ initTypeList();
|
|
|
|
|
+ initXList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void initTypeList() {
|
|
|
|
|
+ giftTagsList.clear();
|
|
|
|
|
+ ViewUtil.notifyDataSetChanged(fgt_gift_center_type_list);
|
|
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getGiftBagTag()
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ List<GiftTags> gameGroups = baseMessage.getDataList(GiftTags.class);
|
|
|
|
|
+ ListUtil.addAll(giftTagsList, gameGroups);
|
|
|
|
|
+ ViewUtil.notifyDataSetChanged(fgt_gift_center_type_list);
|
|
|
|
|
+ notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ if(TestUtil.isDev())
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void initXList() {
|
|
|
|
|
+ gameGroupList.clear();
|
|
|
|
|
+ ViewUtil.notifyDataSetChanged(fgt_gift_center_x_list);
|
|
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getGiftBagGameGroup()
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ List<GameGroup> gameGroups = baseMessage.getDataList(GameGroup.class);
|
|
|
|
|
+ ListUtil.addAll(gameGroupList, gameGroups);
|
|
|
|
|
+ ViewUtil.notifyDataSetChanged(fgt_gift_center_x_list);
|
|
|
|
|
+ notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ if(TestUtil.isDev())
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void notifyDataSetChanged() {
|
|
|
|
|
+ if (refresh != null) {
|
|
|
|
|
+ refresh.finishRefresh();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|