@Override public void onClick(View view) { switch (view.getId()) { case R.id.back: finish(); break; case R.id.button_djs: // 点击获得验证码 try { isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext()); isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext()); if (!isMobileNet && !isWifiNet) { Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show(); return; } } catch (Exception e) { e.printStackTrace(); } mobile_str = mobile.getText().toString(); if (StringUtil.isNullOrEmpty(mobile_str)) { Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show(); return; } button_djs.setClickable(false); // 不可点击 MyTimer myTimer = new MyTimer(60000, 1000); myTimer.start(); getCard(); break; case R.id.next: // 下一步 try { isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext()); isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext()); if (!isMobileNet && !isWifiNet) { Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show(); return; } } catch (Exception e) { e.printStackTrace(); } mobile_str = mobile.getText().toString(); card_str = card.getText().toString(); if (StringUtil.isNullOrEmpty(mobile_str)) { Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show(); return; } if (StringUtil.isNullOrEmpty(card_str)) { Toast.makeText(this, R.string.reg_error_five, Toast.LENGTH_SHORT).show(); return; } getReg(); break; case R.id.quest: // 问题 break; } }
public void setLife(float time) { life = new MyTimer(time) { @Override protected void perform() { alive = false; } }; life.reset(); life.start(); }
/** * Schedule a check changes after a key down a short way into the future, to reduce UI stress. * Only call from onKeyDown, because it assumes the monitored object implements HasAllKeyHandlers. */ private void scheduleCheckChanges() { handlerRegistration.removeHandler(); handlerRegistration = null; timer.start(); }