|
|
@@ -16,11 +16,6 @@ import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.bumptech.glide.Glide;
|
|
|
-import com.bumptech.glide.request.RequestOptions;
|
|
|
-import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
-import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
-import com.google.gson.Gson;
|
|
|
import com.kfzs.duanduan.utils.ApkUtils;
|
|
|
import com.sheep.gamegroup.model.entity.AgentEntity;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
@@ -33,24 +28,21 @@ 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.LogUtil;
|
|
|
import com.sheep.gamegroup.util.SysAppUtil;
|
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.activity.ActMsg;
|
|
|
import com.sheep.gamegroup.view.activity.PersonalCenterAct;
|
|
|
+import com.sheep.gamegroup.view.adapter.AdpUserCenterModule;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogShare;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
import com.sheep.jiuyan.samllsheep.bean.UserCenterModule;
|
|
|
-import com.sheep.jiuyan.samllsheep.net.Network;
|
|
|
-import com.sheep.jiuyan.samllsheep.net.Scheduler;
|
|
|
-import com.sheep.jiuyan.samllsheep.ui.activity.SignActivity;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
-import com.trello.rxlifecycle2.android.FragmentEvent;
|
|
|
|
|
|
import org.afinal.simplecache.ACache;
|
|
|
+import org.afinal.simplecache.ApiKey;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -58,8 +50,6 @@ import java.util.Locale;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.OnClick;
|
|
|
-import io.reactivex.Observer;
|
|
|
-import io.reactivex.disposables.Disposable;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
@@ -162,6 +152,7 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
ViewUtil.setVisibility(audit_success_oval, false);
|
|
|
ViewUtil.setText(audit_failed, getString(R.string.audit_failed, ViewUtil.INDENT));
|
|
|
ViewUtil.setVisibility(audit_failed_oval, false);
|
|
|
+ initUserModuleItemView();
|
|
|
}
|
|
|
|
|
|
private void initData() {
|
|
|
@@ -214,33 +205,54 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
}
|
|
|
});
|
|
|
+ initUserModuleItemByACache();
|
|
|
initUserModuleItem();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //用户中心模块数据
|
|
|
+ private List<UserCenterModule> userCenterModuleList = ListUtil.emptyList();
|
|
|
+ //初始化用户中心模块界面
|
|
|
+ private void initUserModuleItemView() {
|
|
|
+ GridLayoutManager manager = new GridLayoutManager(SheepApp.getInstance(), 4);
|
|
|
+ moduleList.setHasFixedSize(true);
|
|
|
+ moduleList.setNestedScrollingEnabled(false);
|
|
|
+ moduleList.setLayoutManager(manager);
|
|
|
+ moduleList.setAdapter(new AdpUserCenterModule(userCenterModuleList));
|
|
|
+ }
|
|
|
+
|
|
|
+ //通过缓存数据初始化用户中心模块列表
|
|
|
+ private void initUserModuleItemByACache() {
|
|
|
+ List<UserCenterModule> cacheList = DataUtil.getInstance().getCacheList(ApiKey.user_module, UserCenterModule.class);
|
|
|
+ loadUserModuleList(cacheList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //加载用户中心模块数据并刷新、设置显示状态
|
|
|
+ private void loadUserModuleList(List<UserCenterModule> newList) {
|
|
|
+ if (!ListUtil.isEmpty(newList)) {
|
|
|
+ userCenterModuleList.clear();
|
|
|
+ userCenterModuleList.addAll(newList);
|
|
|
+ moduleList.getAdapter().notifyDataSetChanged();
|
|
|
+ ViewUtil.setVisibility(moduleLayout, true);
|
|
|
+ } else {
|
|
|
+ ViewUtil.setVisibility(moduleLayout, !userCenterModuleList.isEmpty());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 初始化用户中心模块列表
|
|
|
*/
|
|
|
private void initUserModuleItem() {
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().userModule()
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getUserModule()
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
- ArrayList<UserCenterModule> newList = baseMessage.getDataList(UserCenterModule.class);
|
|
|
- if (!ListUtil.isEmpty(newList)) {
|
|
|
- moduleLayout.setVisibility(View.VISIBLE);
|
|
|
- GridLayoutManager manager = new GridLayoutManager(getContext(), 4);
|
|
|
- BaseQuickAdapter<UserCenterModule, BaseViewHolder> adapter = new BaseQuickAdapter<UserCenterModule, BaseViewHolder>(R.layout.item_my_list_but, newList) {
|
|
|
- @Override
|
|
|
- protected void convert(BaseViewHolder helper, UserCenterModule item) {
|
|
|
- bindUserCenterModule(helper, item);
|
|
|
- }
|
|
|
- };
|
|
|
- moduleList.setHasFixedSize(true);
|
|
|
- moduleList.setNestedScrollingEnabled(false);
|
|
|
- moduleList.setLayoutManager(manager);
|
|
|
- moduleList.setAdapter(adapter);
|
|
|
+ boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.user_module);
|
|
|
+ if (isNewData) {
|
|
|
+ ArrayList<UserCenterModule> newList = baseMessage.getDataList(UserCenterModule.class);
|
|
|
+ loadUserModuleList(newList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -250,26 +262,6 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 绑定数据处理
|
|
|
- *
|
|
|
- * @param helper ViewHolder
|
|
|
- * @param item 数据对象
|
|
|
- */
|
|
|
- private void bindUserCenterModule(BaseViewHolder helper, final UserCenterModule item) {
|
|
|
- if (item.getDisplay() == 1) {
|
|
|
- helper.setText(R.id.my_item_text, item.getTitle());
|
|
|
- ViewUtil.updateTag((TextView) helper.getView(R.id.my_item_tag), item);
|
|
|
- Glide.with(this).load(item.getIcon()).into((ImageView) helper.getView(R.id.my_item_img));
|
|
|
- helper.getView(R.id.my_item_but).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- CommonUtil.getInstance().goNative(activity, item, "个人中心");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void initUserInfo() {
|
|
|
CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
@Override
|
|
|
@@ -332,7 +324,7 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
- LogUtil.logI("0------" + new Gson().toJson(baseMessage));
|
|
|
+// LogUtil.logI("0------" + new Gson().toJson(baseMessage));
|
|
|
G.showToast(baseMessage.getMsg());
|
|
|
}
|
|
|
|