|
@@ -5,14 +5,20 @@ import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.graphics.Color;
|
|
import android.graphics.Color;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
|
+import android.support.v7.widget.GridLayoutManager;
|
|
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.view.Gravity;
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.bumptech.glide.Glide;
|
|
|
|
|
+import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
|
|
+import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import com.kfzs.duanduan.utils.ApkUtils;
|
|
import com.kfzs.duanduan.utils.ApkUtils;
|
|
|
import com.sheep.gamegroup.model.entity.AgentEntity;
|
|
import com.sheep.gamegroup.model.entity.AgentEntity;
|
|
@@ -35,14 +41,22 @@ import com.sheep.gamegroup.view.dialog.DialogShare;
|
|
|
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.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.sheep.jiuyan.samllsheep.utils.G;
|
|
|
|
|
+import com.trello.rxlifecycle2.android.FragmentEvent;
|
|
|
|
|
|
|
|
import org.afinal.simplecache.ACache;
|
|
import org.afinal.simplecache.ACache;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
import butterknife.OnClick;
|
|
import butterknife.OnClick;
|
|
|
|
|
+import io.reactivex.Observer;
|
|
|
|
|
+import io.reactivex.disposables.Disposable;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
import rx.schedulers.Schedulers;
|
|
@@ -97,6 +111,10 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
View audit_success_oval;
|
|
View audit_success_oval;
|
|
|
@BindView(R.id.audit_failed_oval)
|
|
@BindView(R.id.audit_failed_oval)
|
|
|
View audit_failed_oval;
|
|
View audit_failed_oval;
|
|
|
|
|
+ @BindView(R.id.my_module_layout)
|
|
|
|
|
+ LinearLayout moduleLayout;
|
|
|
|
|
+ @BindView(R.id.my_module_list)
|
|
|
|
|
+ RecyclerView moduleList;
|
|
|
|
|
|
|
|
public UserEntity userEntity;
|
|
public UserEntity userEntity;
|
|
|
private String faqUrl;
|
|
private String faqUrl;
|
|
@@ -172,34 +190,96 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
getUnReadMessageCounts();
|
|
getUnReadMessageCounts();
|
|
|
//获取未查看的任务成功或失败的记录
|
|
//获取未查看的任务成功或失败的记录
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().getUserTaskExistsNew()
|
|
SheepApp.getInstance().getNetComponent().getApiService().getUserTaskExistsNew()
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
- UserTaskExistsNew userTaskExistsNew = baseMessage.getData(UserTaskExistsNew.class);
|
|
|
|
|
- if(userTaskExistsNew != null){
|
|
|
|
|
- ViewUtil.setText(audit_activity, getString(R.string.audit_activity, String.valueOf(userTaskExistsNew.getActivity_task_num())));
|
|
|
|
|
- ViewUtil.setVisibility(audit_activity_oval, userTaskExistsNew.getActivity_new_num() > 0);
|
|
|
|
|
- ViewUtil.setText(audit_success, getString(R.string.audit_success, String.valueOf(userTaskExistsNew.getSuccess_task_num())));
|
|
|
|
|
- ViewUtil.setVisibility(audit_success_oval, userTaskExistsNew.getSuccess_new_num() > 0);
|
|
|
|
|
- ViewUtil.setText(audit_failed, getString(R.string.audit_failed, String.valueOf(userTaskExistsNew.getFailed_task_num())));
|
|
|
|
|
- ViewUtil.setVisibility(audit_failed_oval, userTaskExistsNew.getFailed_new_num() > 0);
|
|
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ UserTaskExistsNew userTaskExistsNew = baseMessage.getData(UserTaskExistsNew.class);
|
|
|
|
|
+ if (userTaskExistsNew != null) {
|
|
|
|
|
+ ViewUtil.setText(audit_activity, getString(R.string.audit_activity, String.valueOf(userTaskExistsNew.getActivity_task_num())));
|
|
|
|
|
+ ViewUtil.setVisibility(audit_activity_oval, userTaskExistsNew.getActivity_new_num() > 0);
|
|
|
|
|
+ ViewUtil.setText(audit_success, getString(R.string.audit_success, String.valueOf(userTaskExistsNew.getSuccess_task_num())));
|
|
|
|
|
+ ViewUtil.setVisibility(audit_success_oval, userTaskExistsNew.getSuccess_new_num() > 0);
|
|
|
|
|
+ ViewUtil.setText(audit_failed, getString(R.string.audit_failed, String.valueOf(userTaskExistsNew.getFailed_task_num())));
|
|
|
|
|
+ ViewUtil.setVisibility(audit_failed_oval, userTaskExistsNew.getFailed_new_num() > 0);
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ initUserModuleItem();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 初始化用户中心模块列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private void initUserModuleItem() {
|
|
|
|
|
+ Network.api().userModule(null, "android")
|
|
|
|
|
+ .compose(Scheduler.apply(this.<List<UserCenterModule>>bindUntilEvent(FragmentEvent.DESTROY)))
|
|
|
|
|
+ .subscribe(new Observer<List<UserCenterModule>>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSubscribe(Disposable d) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(List<UserCenterModule> userCenterModules) {
|
|
|
|
|
+ if (userCenterModules != null) {
|
|
|
|
|
+ moduleLayout.setVisibility(View.VISIBLE);
|
|
|
|
|
+ GridLayoutManager manager = new GridLayoutManager(getContext(), 4);
|
|
|
|
|
+ BaseQuickAdapter<UserCenterModule, BaseViewHolder> adapter = new BaseQuickAdapter<UserCenterModule, BaseViewHolder>(R.layout.item_my_list_but, userCenterModules) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void convert(BaseViewHolder helper, UserCenterModule item) {
|
|
|
|
|
+ bindUserCenterModule(helper, item);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ moduleList.setLayoutManager(manager);
|
|
|
|
|
+ moduleList.setAdapter(adapter);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(Throwable e) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onComplete() {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 绑定数据处理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @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());
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ startActivity(new Intent(getContext(), SignActivity.class));
|
|
|
|
|
+ G.showToast("点击测试");
|
|
|
|
|
+ // TODO: 2018/11/1 zhoujuncai: Item点击事件,跳转处理,显示隐藏等
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initUserInfo() {
|
|
private void initUserInfo() {
|
|
|
CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
@Override
|
|
@Override
|
|
|
public void call(UserEntity userEntity) {
|
|
public void call(UserEntity userEntity) {
|
|
|
- if(userEntity != null){
|
|
|
|
|
|
|
+ if (userEntity != null) {
|
|
|
FgtPersonalCenter.this.userEntity = userEntity;
|
|
FgtPersonalCenter.this.userEntity = userEntity;
|
|
|
ivRedpackage.setVisibility(userEntity.isKfzsPackageUser() ? View.GONE : View.VISIBLE);
|
|
ivRedpackage.setVisibility(userEntity.isKfzsPackageUser() ? View.GONE : View.VISIBLE);
|
|
|
initWidget();
|
|
initWidget();
|
|
@@ -451,10 +531,11 @@ public class FgtPersonalCenter extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean isFirstOnResume = true;//第一次onResume
|
|
private boolean isFirstOnResume = true;//第一次onResume
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onResume() {
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
super.onResume();
|
|
|
- if(!isFirstOnResume) {
|
|
|
|
|
|
|
+ if (!isFirstOnResume) {
|
|
|
try {
|
|
try {
|
|
|
initData();
|
|
initData();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|