|
@@ -3,6 +3,8 @@ package com.xwkj.jcjcgz.mvp.ui.fragment;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Message;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
@@ -35,6 +37,7 @@ import com.scwang.smart.refresh.layout.constant.RefreshState;
|
|
|
import com.scwang.smart.refresh.layout.simple.SimpleMultiListener;
|
|
|
import com.squareup.picasso.Picasso;
|
|
|
import com.xwkj.jcjcgz.R;
|
|
|
+import com.xwkj.jcjcgz.app.Event;
|
|
|
import com.xwkj.jcjcgz.di.component.DaggerRwzxComponent;
|
|
|
import com.xwkj.jcjcgz.mvp.contract.RwzxContract;
|
|
|
import com.xwkj.jcjcgz.mvp.model.api.CommonInterFace;
|
|
@@ -43,6 +46,11 @@ import com.xwkj.jcjcgz.mvp.model.entity.ChannelEntity;
|
|
|
import com.xwkj.jcjcgz.mvp.model.entity.TaskEntity;
|
|
|
import com.xwkj.jcjcgz.mvp.presenter.RwzxPresenter;
|
|
|
import com.xwkj.jcjcgz.mvp.ui.activity.MainActivity;
|
|
|
+import com.zkjc.common.base.ZkjcBaseFragment;
|
|
|
+import com.zkjc.common.event.IEvent;
|
|
|
+
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
+import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -68,7 +76,7 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
|
|
|
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
|
|
|
* ================================================
|
|
|
*/
|
|
|
-public class RwzxFragment extends BaseFragment<RwzxPresenter> implements RwzxContract.View {
|
|
|
+public class RwzxFragment extends ZkjcBaseFragment<RwzxPresenter> implements RwzxContract.View {
|
|
|
|
|
|
@BindView(R.id.rwzx_tv_search)
|
|
|
TextView tvSearch;
|
|
@@ -416,8 +424,19 @@ public class RwzxFragment extends BaseFragment<RwzxPresenter> implements RwzxCon
|
|
|
for (ChannelEntity.Task task1: task.getChildren()) {
|
|
|
num = num + task1.getNum();
|
|
|
}
|
|
|
- tvTaskNum1.setText(num + "");
|
|
|
+ if (num <= 0) {
|
|
|
+ tvTaskNum1.setVisibility(View.GONE);
|
|
|
+ tvTaskNum1.setText("0");
|
|
|
+ } else {
|
|
|
+ tvTaskNum1.setVisibility(View.VISIBLE);
|
|
|
+ if (num > 99) {
|
|
|
+ tvTaskNum1.setText("99+");
|
|
|
+ } else {
|
|
|
+ tvTaskNum1.setText(num + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
tvTask1.setText(task.getDictValue());
|
|
|
+ tvTaskNum1.setTag(task.getId());
|
|
|
Picasso.with(getActivity()).load(task.getRemark()).into(ivTask1);
|
|
|
taskTypeFragment1.initFragment(task.getChildren());
|
|
|
}
|
|
@@ -425,27 +444,80 @@ public class RwzxFragment extends BaseFragment<RwzxPresenter> implements RwzxCon
|
|
|
case 1: {
|
|
|
// taskTypeFragment2 = TaskTypeFragment.newInstance(task.getChildren());
|
|
|
tvTask2.setText(task.getDictValue());
|
|
|
+ tvTaskNum2.setTag(task.getId());
|
|
|
Picasso.with(getActivity()).load(task.getRemark()).into(ivTask2);
|
|
|
int num = 0;
|
|
|
for (ChannelEntity.Task task1: task.getChildren()) {
|
|
|
num = num + task1.getNum();
|
|
|
}
|
|
|
- tvTaskNum2.setText(num + "");
|
|
|
+ if (num <= 0) {
|
|
|
+ tvTaskNum2.setVisibility(View.GONE);
|
|
|
+ tvTaskNum2.setText("0");
|
|
|
+ } else {
|
|
|
+ tvTaskNum2.setVisibility(View.VISIBLE);
|
|
|
+ if (num > 99) {
|
|
|
+ tvTaskNum2.setText("99+");
|
|
|
+ } else {
|
|
|
+ tvTaskNum2.setText(num + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case 2: {
|
|
|
// taskTypeFragment3 = TaskTypeFragment.newInstance(task.getChildren());
|
|
|
tvTask3.setText(task.getDictValue());
|
|
|
+ tvTaskNum3.setTag(task.getId());
|
|
|
Picasso.with(getActivity()).load(task.getRemark()).into(ivTask3);
|
|
|
int num = 0;
|
|
|
for (ChannelEntity.Task task1: task.getChildren()) {
|
|
|
num = num + task1.getNum();
|
|
|
}
|
|
|
- tvTaskNum3.setText(num + "");
|
|
|
+ if (num <= 0) {
|
|
|
+ tvTaskNum3.setVisibility(View.GONE);
|
|
|
+ tvTaskNum3.setText("0");
|
|
|
+ } else {
|
|
|
+ tvTaskNum3.setVisibility(View.VISIBLE);
|
|
|
+ if (num > 99) {
|
|
|
+ tvTaskNum3.setText("99+");
|
|
|
+ } else {
|
|
|
+ tvTaskNum3.setText(num + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ @Override
|
|
|
+ public void onThisEvent(IEvent iEvent) {
|
|
|
+ if (iEvent instanceof Event) {
|
|
|
+ Event event = (Event) iEvent;
|
|
|
+ if (event.getEvent() == Event.E_REFRESH_TASK_MENU) {
|
|
|
+ setTvNum(event, tvTaskNum1);
|
|
|
+ setTvNum(event, tvTaskNum2);
|
|
|
+ setTvNum(event, tvTaskNum3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setTvNum(Event event, TextView tvTaskNum) {
|
|
|
+ if (!TextUtils.isEmpty(tvTaskNum.getTag().toString()) && tvTaskNum.getTag().toString().equals(event.getId())) {
|
|
|
+ tvTaskNum.setVisibility(View.VISIBLE);
|
|
|
+ String num;
|
|
|
+ try {
|
|
|
+ int i = Integer.parseInt(tvTaskNum.getText().toString()) + 1;
|
|
|
+ if (i > 99) {
|
|
|
+ num = "99+";
|
|
|
+ } else {
|
|
|
+ num = i + "";
|
|
|
+ }
|
|
|
+ tvTaskNum.setText(num);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ tvTaskNum.setText("99+");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|