|
@@ -2,9 +2,6 @@ package com.tofly.yxpc.ui.fragment;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
import android.text.TextUtils;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.TextView;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
@@ -14,31 +11,24 @@ import com.tofly.latte_core.utils.AccountManager;
|
|
|
import com.tofly.yxpc.R;
|
|
|
import com.tofly.yxpc.base.MyApp;
|
|
|
import com.tofly.yxpc.base.NetWorkUrl;
|
|
|
+import com.tofly.yxpc.databinding.FragmentMyBinding;
|
|
|
+import com.tofly.yxpc.entity.WaterMeterEntity;
|
|
|
+import com.tofly.yxpc.greenDao.WaterMeterEntityDao;
|
|
|
import com.tofly.yxpc.ui.activity.AboutSystemActivity;
|
|
|
import com.tofly.yxpc.ui.activity.LoginActivity;
|
|
|
import com.tofly.yxpc.ui.activity.SettingActivity;
|
|
|
import com.tofly.yxpc.ui.impl.MyImpl;
|
|
|
import com.tofly.yxpc.utils.DialogUtils;
|
|
|
-import com.tofly.yxpc.widget.CircleImageView;
|
|
|
+import com.tofly.yxpc.utils.db.DaoUtilsStore;
|
|
|
|
|
|
-import butterknife.BindView;
|
|
|
-import butterknife.OnClick;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
* @author ychk
|
|
|
*/
|
|
|
public class MeFragment extends LatteDelegate {
|
|
|
|
|
|
- @BindView(R.id.cimg_head_portrait)
|
|
|
- CircleImageView cimgHeadPortrait;
|
|
|
- @BindView(R.id.ll_head_portrait)
|
|
|
- LinearLayout llHeadPortrait;
|
|
|
- @BindView(R.id.tv_user_name)
|
|
|
- TextView tvUserName;
|
|
|
- @BindView(R.id.ll_about_system)
|
|
|
- LinearLayout llAboutSystem;
|
|
|
- @BindView(R.id.tv_login_out)
|
|
|
- TextView tvLoginOut;
|
|
|
+ private FragmentMyBinding binding;
|
|
|
|
|
|
@Override
|
|
|
protected LatteContract.LattePresenter createPresenter() {
|
|
@@ -47,11 +37,69 @@ public class MeFragment extends LatteDelegate {
|
|
|
|
|
|
@Override
|
|
|
public Object setLayout() {
|
|
|
- return R.layout.fragment_my;
|
|
|
+ binding = FragmentMyBinding.inflate(getLayoutInflater());
|
|
|
+ return binding.getRoot();
|
|
|
}
|
|
|
|
|
|
+ private void initListener() {
|
|
|
+ binding.llHeadPortrait.setOnClickListener(v -> {
|
|
|
+ if (MyApp.getInstance().isOverTime()) {
|
|
|
+ Intent intent = new Intent(requireContext(), SettingActivity.class);
|
|
|
+ requireContext().startActivity(intent);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ binding.llClear.setOnClickListener(v -> {
|
|
|
+ if (MyApp.getInstance().isOverTime()) {
|
|
|
+ List<WaterMeterEntity> list = DaoUtilsStore.getInstance().getWaterMeterEntityDbUtils().queryByQueryBuilder(
|
|
|
+ WaterMeterEntityDao.Properties.CheckUser.eq(AccountManager.getUserId()));
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ onMessage("本地无缓存数据,无需清理缓存");
|
|
|
+ } else {
|
|
|
+ long draftSize = DaoUtilsStore.getInstance().getWaterMeterEntityDbUtils().queryCountByQueryBuilder(
|
|
|
+ WaterMeterEntityDao.Properties.CheckUser.eq(AccountManager.getUserId()),
|
|
|
+ WaterMeterEntityDao.Properties.State.eq(1)
|
|
|
+ );
|
|
|
+ long localSize = DaoUtilsStore.getInstance().getWaterMeterEntityDbUtils().queryCountByQueryBuilder(
|
|
|
+ WaterMeterEntityDao.Properties.CheckUser.eq(AccountManager.getUserId()),
|
|
|
+ WaterMeterEntityDao.Properties.State.eq(2)
|
|
|
+ );
|
|
|
+ String message;
|
|
|
+ if (draftSize > 0) {
|
|
|
+ message = "本地存在草稿数据,是否确定清除缓存?";
|
|
|
+ } else if (localSize > 0) {
|
|
|
+ message = "本地存在已稽查未上传数据,是否确定清除缓存?";
|
|
|
+ } else {
|
|
|
+ message = "是否确定清理本地缓存?";
|
|
|
+ }
|
|
|
+ DialogUtils.showDialog(requireContext(), "提示", message, false, (dialog, which) -> {
|
|
|
+ DaoUtilsStore.getInstance().getWaterMeterEntityDbUtils().delete(list);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ binding.llAboutSystem.setOnClickListener(v -> {
|
|
|
+ if (MyApp.getInstance().isOverTime()) {
|
|
|
+ Intent intent = new Intent(requireContext(), AboutSystemActivity.class);
|
|
|
+ requireContext().startActivity(intent);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ binding.tvLoginOut.setOnClickListener(v -> {
|
|
|
+ if (MyApp.getInstance().isOverTime()) {
|
|
|
+ DialogUtils.showDialog(requireContext(), "是否确定退出", "", true, (dialog, which) -> {
|
|
|
+ requireActivity().finish();
|
|
|
+ startActivity(new Intent(getContext(), LoginActivity.class));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
+ initListener();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -60,32 +108,6 @@ public class MeFragment extends LatteDelegate {
|
|
|
loadData();
|
|
|
}
|
|
|
|
|
|
- @OnClick({R.id.ll_head_portrait, R.id.ll_about_system, R.id.tv_login_out})
|
|
|
- public void onClick(View view) {
|
|
|
- if (!MyApp.getInstance().isOverTime()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Intent intent = null;
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.ll_head_portrait:
|
|
|
- intent = new Intent(requireContext(), SettingActivity.class);
|
|
|
- requireContext().startActivity(intent);
|
|
|
- break;
|
|
|
- case R.id.ll_about_system:
|
|
|
- intent = new Intent(requireContext(), AboutSystemActivity.class);
|
|
|
- requireContext().startActivity(intent);
|
|
|
- break;
|
|
|
- case R.id.tv_login_out:
|
|
|
- DialogUtils.showDialog(requireContext(), "是否确定退出", "", true, (dialog, which) -> {
|
|
|
- requireActivity().finish();
|
|
|
- startActivity(new Intent(getContext(), LoginActivity.class));
|
|
|
- });
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
* 加载基础信息
|
|
|
*/
|
|
@@ -94,11 +116,11 @@ public class MeFragment extends LatteDelegate {
|
|
|
Glide.with(requireContext())
|
|
|
.load(NetWorkUrl.getFileUrl(AccountManager.getAvatar()))
|
|
|
.apply(new RequestOptions().error(R.mipmap.icon_head_portrait))
|
|
|
- .into(cimgHeadPortrait);
|
|
|
+ .into(binding.cimgHeadPortrait);
|
|
|
} else {
|
|
|
- cimgHeadPortrait.setBackgroundResource(R.mipmap.icon_head_portrait);
|
|
|
+ binding.cimgHeadPortrait.setBackgroundResource(R.mipmap.icon_head_portrait);
|
|
|
}
|
|
|
- tvUserName.setText(AccountManager.getUserRealName() == null ? "" : AccountManager.getUserRealName());
|
|
|
+ binding.tvUserName.setText(AccountManager.getUserRealName() == null ? "" : AccountManager.getUserRealName());
|
|
|
}
|
|
|
|
|
|
@Override
|