/* * (non-Javadoc) * * @see android.view.View.OnClickListener#onClick(android.view.View) */ public void onClick(final View v) { if (v.getId() == R.id.btnJobStartDate) { showDialog(ID_START_DATEPICKER); } else if (v.getId() == R.id.btnJobStartTime) { showDialog(ID_START_TIMEPICKER); } else if (v.getId() == R.id.btnJobEndDate) { showDialog(ID_END_DATEPICKER); } else if (v.getId() == R.id.btnJobEndTime) { showDialog(ID_END_TIMEPICKER); } else if (v.getId() == R.id.btnJobDiscard) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Discard, Are you sure?"); alertDialog.setButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent home = new Intent(v.getContext(), HomeActivity.class); startActivityForResult(home, CommonConstants.HOME_REQ_ID); return; } }); alertDialog.setButton2( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); } else if (v.getId() == R.id.btnJobReset) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Reset fields, Are you sure?"); alertDialog.setButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { editTxtLatitude.setText(""); editTxtLongitude.setText(""); editTxtLocRange.setText(""); editTxtNodes.setText(""); editTxtFreq.setText(""); editTxtTimePeriod.setText(""); editTxtDesc.setText(""); return; } }); alertDialog.setButton2( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); } else if (v.getId() == R.id.btnJobSave) { Calendar startDatetime = null; Calendar endDatetime = null; boolean validStartEndTime = true; if (chkBxStarttime.isChecked()) { startDatetime = Calendar.getInstance(); startDatetime.set(startYear, startMonth, startDay, startHour, startMinute); } if (chkBxEndtime.isChecked()) { endDatetime = Calendar.getInstance(); endDatetime.set(endYear, endMonth, endDay, endHour, endMinute); validStartEndTime = Calendar.getInstance().before(endDatetime); } if (validStartEndTime && startDatetime != null && endDatetime != null) { validStartEndTime = startDatetime.before(endDatetime); } if (validStartEndTime) { if (spinSensorType.getSelectedItem().toString().length() == 0 || editTxtLatitude.getText().length() == 0 || editTxtLongitude.getText().length() == 0 || editTxtLocRange.getText().length() == 0 || editTxtNodes.getText().length() == 0 || editTxtFreq.getText().length() == 0 || editTxtTimePeriod.getText().length() == 0) { Toast.makeText( AddJobActivity.this, "Input Validation failed! All fields should be not null and the end date should be after the start date.", Toast.LENGTH_LONG) .show(); } else { boolean issuccess = serviceInvoker.addJob( 1, Float.parseFloat(editTxtLatitude.getText().toString()), Float.parseFloat(editTxtLongitude.getText().toString()), Float.parseFloat(editTxtLocRange.getText().toString()), (startDatetime != null) ? startDatetime.getTimeInMillis() : 0, (endDatetime != null) ? endDatetime.getTimeInMillis() : 0, Integer.parseInt(editTxtFreq.getText().toString()), Integer.parseInt(editTxtTimePeriod.getText().toString()), Integer.parseInt(editTxtNodes.getText().toString()), imei, editTxtDesc.getText().toString(), username); if (issuccess) { // when add job completes go back to the previous step or viewjob. Toast.makeText(AddJobActivity.this, "Job Added Successfully.", Toast.LENGTH_LONG) .show(); Intent home = new Intent(v.getContext(), HomeActivity.class); startActivityForResult(home, CommonConstants.HOME_REQ_ID); } else { Toast.makeText(AddJobActivity.this, "Could not add job! Try again.", Toast.LENGTH_LONG) .show(); } } } else { Toast.makeText(AddJobActivity.this, "Invalid StartTime or ExpireTime!", Toast.LENGTH_LONG) .show(); } } }
public void onClick(View view) { try { Context context = getApplicationContext(); // get username and role coming from previous page String userName = this.getIntent().getStringExtra("name"); String role = this.getIntent().getStringExtra("role"); String password = ((EditText) findViewById(R.id.pswd)).getText().toString(); String confirmPassword = ((EditText) findViewById(R.id.confpswd)).getText().toString(); if ((password.length() == 0) || (confirmPassword.length() == 0)) { Toast.makeText( getApplicationContext(), "password or confirm password can not be Empty", Toast.LENGTH_SHORT) .show(); Log.i("password and conf password", password + ":::" + confirmPassword); return; } if (password.equals(confirmPassword)) { if (!confirmPassword.equalsIgnoreCase("password")) { // do our job here ServiceInvoker.changePassword(session.getToken(), confirmPassword); // password is changed so new token need tobe set session.setAuthenticationToken(userName, confirmPassword); // DO Navigation Here if (role.equals("ROLE_ADMIN")) { Intent intent = new Intent(context, AdminHomePage.class); intent.putExtra("name", userName); startActivity(intent); } else if (role.equals("ROLE_MANAGER")) { Intent intent = new Intent(context, ManagerHomePage.class); intent.putExtra("name", userName); startActivity(intent); } else if (role.equals("ROLE_STAFF")) { Intent intent = new Intent(context, StaffHomePage.class); intent.putExtra("name", userName); startActivity(intent); } else { Intent intent = new Intent(context, LoginPage.class); startActivity(intent); Toast.makeText(getApplicationContext(), "User Not Found", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText( getApplicationContext(), "password can not be password", Toast.LENGTH_SHORT) .show(); } } else { Toast.makeText(getApplicationContext(), "password mismatched", Toast.LENGTH_SHORT).show(); } } catch (Exception ee) { Log.i("Error In Reset Password", ee.getMessage()); } }