对比新文件 |
| | |
| | | package com.doumee.keyCabinet.ui.face; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.lifecycle.Observer; |
| | | |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | |
| | | import com.doumee.keyCabinet.R; |
| | | import com.doumee.keyCabinet.base.MyBaseActivity; |
| | | import com.doumee.keyCabinet.databinding.ErrActivityBinding; |
| | | import com.doumee.keyCabinet.ui.face.adapter.ErrRcvAdapter; |
| | | import com.doumee.keyCabinet.ui.view.TipDialog; |
| | | import com.doumee.lib_coremodel.bean.event.ActionEventData; |
| | | import com.doumee.lib_coremodel.util.RecyclerHelp; |
| | | import com.doumee.lib_coremodel.util.SpUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | import dagger.hilt.android.AndroidEntryPoint; |
| | | |
| | | @AndroidEntryPoint |
| | | public class ErrActivity extends MyBaseActivity<ErrVM, ErrActivityBinding> { |
| | | private ErrRcvAdapter adapter; |
| | | |
| | | @Override |
| | | public int getLayoutId() { |
| | | return R.layout.err_activity; |
| | | } |
| | | |
| | | @Override |
| | | public void initView(@Nullable Bundle savedInstanceState) { |
| | | isAddCountTimer = false; |
| | | normalConfig(); |
| | | getDB().setModel(getVM()); |
| | | |
| | | adapter = new ErrRcvAdapter(this, R.layout.err_rcv_item, new ErrRcvAdapter.OnItemClick() { |
| | | @Override |
| | | public void onItemClick(SpUtil.SPBean item) { |
| | | spBean = item; |
| | | showDialog(); |
| | | } |
| | | }); |
| | | RecyclerHelp.bindVL(this,getDB().recyclerView,30,false); |
| | | getDB().recyclerView.setAdapter(adapter); |
| | | } |
| | | |
| | | @Override |
| | | public void initData(@Nullable Bundle savedInstanceState) { |
| | | getVM().getDatasLD().observe(this, new Observer<List<SpUtil.SPBean>>() { |
| | | @Override |
| | | public void onChanged(List<SpUtil.SPBean> datas) { |
| | | adapter.refreshData(datas); |
| | | if(datas.size()>0){ |
| | | getVM().emptyVisibility.set(View.GONE); |
| | | }else { |
| | | getVM().emptyVisibility.set(View.VISIBLE); |
| | | } |
| | | } |
| | | }); |
| | | getVM().getDatas(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | protected void doRegister(int type, ActionEventData data) { |
| | | switch (type){ |
| | | case 1: |
| | | finish(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private TipDialog mTipDialog; |
| | | private SpUtil.SPBean spBean; |
| | | private void showDialog(){ |
| | | if(mTipDialog!=null&&mTipDialog.isShowing()){ |
| | | mTipDialog.dismiss(); |
| | | } |
| | | if(mTipDialog == null) { |
| | | mTipDialog = new TipDialog(this); |
| | | mTipDialog.setOnTipDialogClickListener(new TipDialog.OnTipDialogClickListener() { |
| | | @Override |
| | | public void onCancel() { |
| | | mTipDialog.dismiss(); |
| | | } |
| | | |
| | | @Override |
| | | public void onConfirm(String tipType) { |
| | | if(spBean!=null){ |
| | | SpUtil.remoreString(spBean.getKey()); |
| | | adapter.getListData().remove(spBean.getPos()); |
| | | adapter.notifyDataSetChanged(); |
| | | spBean = null; |
| | | } |
| | | mTipDialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | mTipDialog.show(); |
| | | mTipDialog.setTextTitle(getString(R.string.err_tip1)); |
| | | mTipDialog.setTextMessage(getString(R.string.err_tip2)); |
| | | mTipDialog.setTextConfirm(getString(R.string.deleted)); |
| | | mTipDialog.setCancelable(false); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if(mTipDialog!=null&&mTipDialog.isShowing()){ |
| | | mTipDialog.dismiss(); |
| | | } |
| | | mTipDialog = null; |
| | | } |
| | | } |