| | |
| | | import com.bumptech.glide.request.target.Target; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.doumee.keyCabinet.BuildConfig; |
| | | import com.doumee.keyCabinet.base.BannerPicResponsePara; |
| | | import com.doumee.keyCabinet.bean.CabinetConfigDataBean; |
| | | import com.doumee.keyCabinet.bean.DevConfigBean; |
| | | import com.doumee.keyCabinet.bean.FaceUserBean; |
| | | import com.doumee.keyCabinet.bean.LoginBean; |
| | | import com.doumee.keyCabinet.dao.CabinetGridDo; |
| | | import com.doumee.keyCabinet.dao.DaoManager; |
| | | import com.doumee.keyCabinet.databinding.MainActivityBinding; |
| | |
| | | import com.doumee.keyCabinet.event.OpenGridEvent; |
| | | import com.doumee.keyCabinet.event.OpenGridListEvent; |
| | | import com.doumee.keyCabinet.event.OpenGridOneResultEvent; |
| | | import com.doumee.keyCabinet.event.ReLoginEvent; |
| | | import com.doumee.keyCabinet.event.TimeClockEvent; |
| | | import com.doumee.keyCabinet.ui.face.ActivationActivity; |
| | | import com.doumee.keyCabinet.ui.face.FaceActivity; |
| | | import com.doumee.keyCabinet.ui.keyCabinet.ChangeUrlActivity; |
| | | import com.doumee.keyCabinet.ui.keyCabinet.KeyCabinetActivity; |
| | | import com.doumee.keyCabinet.ui.keyCabinet.ManageLoginActivity; |
| | |
| | | getDB().tvId.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | startActivity(ManageLoginActivity.class); |
| | | //更改url |
| | | if(lastDownTime2!=null){ |
| | | if(System.currentTimeMillis()-lastDownTime2>1000){ |
| | |
| | | lastDownTime2=null; |
| | | startActivity(ChangeUrlActivity.class); |
| | | } |
| | | } |
| | | }); |
| | | getDB().tvVersion.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | //todo 临时代码 |
| | | setJiuConfig(); |
| | | } |
| | | }); |
| | | upErrInfo(); |
| | |
| | | } |
| | | |
| | | private void setJiuConfig(){ |
| | | getVM().addInfo("酒精配置:"+(MApplication.getConfigBean().getCabinetConfigDataVO()!=null)+ |
| | | ",串口开启:"+(jiuPort!=null)); |
| | | if(MApplication.getConfigBean().getCabinetConfigDataVO()!=null&& |
| | | jiuPort!=null){ |
| | | setJiuConfig(0); |
| | |
| | | case 2: |
| | | case 3: { |
| | | //校验是否登录 |
| | | /*if(MApplication.getConfigBean().getId()==null){ |
| | | if(MApplication.getConfigBean().getId()==null){ |
| | | Toast.makeText(mContext, "设备未添加,无法操作", Toast.LENGTH_SHORT).show(); |
| | | getVM().devLogin(); |
| | | return; |
| | | } |
| | | MApplication.getLoginBean().setFlag(type==2?0:1); |
| | | startActivity(FaceActivity.class);*/ |
| | | /*if(type==2){ |
| | | send485(1,"A002010000000003"); |
| | | }else { |
| | | send485(1,"A001010000000002"); |
| | | }*/ |
| | | //send485(1,"A001010000000002"); |
| | | //send485(1,"A002010000000003"); |
| | | //startActivity(KeyCabinetActivity.class,b); |
| | | checkGridStatus(0); |
| | | List<CabinetGridDo> gridDos = getVM().getOpenGrids(); |
| | | if (gridDos.size() > 0) { |
| | | tipDownCount = 10; |
| | | isShowTip = true; |
| | | getDB().tvDjs.setText(tipDownCount + "s"); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for(CabinetGridDo d:gridDos){ |
| | | if (sb.length()>0) { |
| | | sb.append("、"); |
| | | } |
| | | String name = d.getCabinetName(); |
| | | if (TextUtils.isEmpty(name)) { |
| | | name = gridDos.get(0).getGridKey(); |
| | | } |
| | | sb.append(name); |
| | | } |
| | | |
| | | getDB().tvTip22.setText(getTipText(sb.toString()), TextView.BufferType.SPANNABLE); |
| | | getDB().clTip.setVisibility(View.VISIBLE); |
| | | showUnCloseTip(gridDos); |
| | | return; |
| | | } |
| | | MApplication.setLoginBean(null); |
| | | MApplication.getLoginBean().setFlag(type == 2 ? 0 : 1); |
| | | if(type==3){ |
| | | startActivity(ManageLoginActivity.class); |
| | | return; |
| | | } |
| | | startActivity(KeyCabinetActivity.class); |
| | | } |
| | | break; |
| | |
| | | case 5: { |
| | | List<CabinetGridDo> gridDos = getVM().getOpenGrids(); |
| | | if (gridDos.size() > 0) { |
| | | tipDownCount = 10; |
| | | isShowTip = true; |
| | | getDB().tvDjs.setText(tipDownCount + "s"); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for(CabinetGridDo d:gridDos){ |
| | | if (sb.length()>0) { |
| | | sb.append("、"); |
| | | } |
| | | String name = d.getCabinetName(); |
| | | if (TextUtils.isEmpty(name)) { |
| | | name = gridDos.get(0).getGridKey(); |
| | | } |
| | | sb.append(name); |
| | | } |
| | | getDB().tvTip22.setText(getTipText(sb.toString()), TextView.BufferType.SPANNABLE); |
| | | getDB().clTip.setVisibility(View.VISIBLE); |
| | | showUnCloseTip(gridDos); |
| | | }else { |
| | | isShowTip = false; |
| | | getDB().clTip.setVisibility(View.GONE); |
| | |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void showUnCloseTip(List<CabinetGridDo> gridDos){ |
| | | tipDownCount = 10; |
| | | isShowTip = true; |
| | | getDB().tvDjs.setText(tipDownCount + "s"); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for(CabinetGridDo d:gridDos){ |
| | | if (sb.length()>0) { |
| | | sb.append("、"); |
| | | } |
| | | String name = d.getCabinetName(); |
| | | if (TextUtils.isEmpty(name)) { |
| | | name = gridDos.get(0).getGridKey(); |
| | | } |
| | | sb.append(name); |
| | | } |
| | | getDB().tvTip22.setText(getTipText(sb.toString()), TextView.BufferType.SPANNABLE); |
| | | getDB().tvTip23.setText(getErrPhoneText(), TextView.BufferType.SPANNABLE); |
| | | getDB().clTip.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | private SpannableString getErrPhoneText(){ |
| | | String phone = MApplication.getConfigBean().getLinkPhone(); |
| | | String text = "如有问题请联系管理员"+phone; |
| | | SpannableString styledText = new SpannableString(text); |
| | | styledText.setSpan(new TextAppearanceSpan(this, R.style.style_tip3), 0, text.length()-phone.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | styledText.setSpan(new TextAppearanceSpan(this,R.style.style_tip1), text.length()-phone.length()+1, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | return styledText; |
| | | } |
| | | |
| | | private boolean isShowing = false; |
| | |
| | | EventBus.getDefault().post(new OpenGridEvent(Integer.parseInt(e.getKey().substring(2,4), 16)+"", |
| | | Integer.parseInt(e.getKey().substring(0,2), 16)+"")); |
| | | }else { |
| | | //todo 关门成功 |
| | | if(isShowTip){ |
| | | doRegister(5,null); |
| | | } |