1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| public class logon extends AppCompatActivity implements View.OnTouchListener, View.OnClickListener {
private EditText et_login, et_mdp;
/** timer */
private timerTime timerTime = new timerTime(this);
private boolean update = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideNavigationBar();
setContentView(R.layout.logon);
hideNavigationBar();
et_login = (EditText)findViewById(R.id.et_login);
et_mdp = (EditText)findViewById(R.id.et_mdp);
et_login.setOnTouchListener(this);
et_mdp.setOnTouchListener(this);
et_login.addTextChangedListener(verifForTimeLodin);
et_mdp.addTextChangedListener(verifForTimeMdp);
}
@Override
public boolean onTouch(View v, MotionEvent event){
if (v == et_login){
log("et_login: " + stringValue(event));
}
if (v == et_mdp) {
log("et_mdp: " + stringValue(event));
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
log("Activity: " + stringValue(event));
return true;
}
private String stringValue(MotionEvent event) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
timerTime.stopTimer();
timerTime.startTimer();
return "ACTION_DOWN";
case MotionEvent.ACTION_MOVE:
return "ACTION_MOVE";
case MotionEvent.ACTION_UP:
return "ACTION_UP";
case MotionEvent.ACTION_CANCEL:
return "ACTION_CANCEL";
}
return "";
}
@Override
protected void onResume() {
timerTime.startTimer(10000);
super.onResume();
}
TextWatcher verifForTimeLodin = new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
if (update){
update = false;
timerTime.startTimer();
}else {
timerTime.stopTimer();
timerTime.startTimer();
}
}
};
TextWatcher verifForTimeMdp = new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
if (update){
update = false;
timerTime.startTimer();
}else {
timerTime.stopTimer();
timerTime.startTimer();
}
}
};
} |
Partager