List of usage examples for android.text InputType TYPE_CLASS_NUMBER
int TYPE_CLASS_NUMBER
To view the source code for android.text InputType TYPE_CLASS_NUMBER.
Click Source Link
From source file:com.citrus.sample.WalletPaymentFragment.java
@OnClick(R.id.btnMasterpass) public void testMasterPass() { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); String message = null;/*from w w w . j av a 2 s .c o m*/ String positiveButtonText = null; message = "Please enter the transaction amount."; positiveButtonText = "Make Payment"; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); alert.setTitle("Transaction Amount?"); alert.setMessage(message); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); alert.setView(input); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); input.clearFocus(); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); try { MasterPassOption masterPassOption = new MasterPassOption(); PaymentType.PGPayment pgPayment = new PaymentType.PGPayment(new Amount(value), Constants.BILL_URL, masterPassOption, null); mCitrusClient.simpliPay(pgPayment, new Callback<TransactionResponse>() { @Override public void success(TransactionResponse transactionResponse) { Toast.makeText(getActivity(), transactionResponse.getMessage(), Toast.LENGTH_SHORT) .show(); } @Override public void error(CitrusError error) { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); } }); } catch (CitrusException e) { e.printStackTrace(); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); input.requestFocus(); alert.show(); }
From source file:com.citrus.sample.WalletPaymentFragment.java
private void showUpdateSubscriptionPrompt(final boolean isUpdateToHigherValue) { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); // final String message = "Update Subscription to Lowe Amount"; String positiveButtonText = "Update Subscription "; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final TextView labelsubscriptionID = new TextView(getActivity()); final EditText edtAmount = new EditText(getActivity()); final TextView labelAmount = new TextView(getActivity()); final EditText editLoadAmount = new EditText(getActivity()); final TextView labelMobileNo = new TextView(getActivity()); final EditText editThresholdAmount = new EditText(getActivity()); editLoadAmount.setSingleLine(true);/* w w w . j a va2 s . co m*/ editThresholdAmount.setSingleLine(true); edtAmount.setSingleLine(true); edtAmount.setInputType(InputType.TYPE_NULL); labelsubscriptionID.setText("Load Money Amount"); labelAmount.setText("Current Auto Load Amount"); editLoadAmount.setText(String.valueOf(activeSubscription.getLoadAmount())); labelMobileNo.setText("Current Threshold Amount"); editThresholdAmount.setText(String.valueOf(activeSubscription.getThresholdAmount())); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelsubscriptionID.setLayoutParams(layoutParams); edtAmount.setLayoutParams(layoutParams); labelAmount.setLayoutParams(layoutParams); labelMobileNo.setLayoutParams(layoutParams); editLoadAmount.setLayoutParams(layoutParams); editThresholdAmount.setLayoutParams(layoutParams); linearLayout.addView(labelAmount); linearLayout.addView(editLoadAmount); linearLayout.addView(labelMobileNo); linearLayout.addView(editThresholdAmount); linearLayout.addView(labelsubscriptionID); linearLayout.addView(edtAmount); edtAmount.setText("1.00"); int paddingPx = Utils.getSizeInPx(getActivity(), 32); linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); edtAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editLoadAmount.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { /* if (!hasFocus) { if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { labelsubscriptionID.setVisibility(View.VISIBLE); edtAmount.setVisibility(View.VISIBLE); edtAmount.setText("1.00"); } else { labelsubscriptionID.setVisibility(View.INVISIBLE); edtAmount.setVisibility(View.INVISIBLE); } }*/ } }); editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setTitle("Update Subscription "); alert.setMessage("Updating Load amount to higher will require Load Money transactions."); alert.setView(linearLayout); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String trAmount = edtAmount.getText().toString(); final String loadAmount = editLoadAmount.getText().toString(); final String thresHoldAmount = editThresholdAmount.getText().toString(); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edtAmount.getWindowToken(), 0); if (TextUtils.isEmpty(trAmount) && edtAmount.getVisibility() == View.VISIBLE) { Toast.makeText(getActivity(), " load amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(loadAmount)) { Toast.makeText(getActivity(), "Auto Load Amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(thresHoldAmount)) { Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(thresHoldAmount) < new Double("500")) { Toast.makeText(getActivity(), "thresHoldAmount should not be less than 500", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) { Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { //update to higher value mListener.onAutoLoadSelected(AUTO_LOAD_MONEY, new Amount(trAmount), editLoadAmount.getText().toString(), editThresholdAmount.getText().toString(), true); } else { //update to lower value mCitrusClient.updateSubScriptiontoLoweValue(new Amount(thresHoldAmount), new Amount(loadAmount), new Callback<SubscriptionResponse>() { @Override public void success(SubscriptionResponse subscriptionResponse) { Toast.makeText(getActivity(), subscriptionResponse.toString(), Toast.LENGTH_SHORT).show(); Logger.d("updateSubscription response **" + subscriptionResponse.toString()); activeSubscription = subscriptionResponse;//update the active subscription Object } @Override public void error(CitrusError error) { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); Logger.d("ERROR ***updateSubscription" + error.getMessage()); } }); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); editLoadAmount.requestFocus(); alert.show(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.Implementation.UtilityOnClickListeners.java
public OnClickListener getToolEntryEditDialogOnClickListener(final Activity activity, final FragmentManager fragmentManager, final GpsLocationTracker locationTracker, final ToolEntry toolEntry, final User user) { return new OnClickListener() { @Override/* ww w .ja v a2 s . c o m*/ public void onClick(final View editButton) { final DialogInterface dialogInterface = new UtilityDialogs(); final Dialog dialog = dialogInterface.getDialog(editButton.getContext(), R.layout.dialog_register_new_tool, R.string.edit_tool); ((Button) dialog.findViewById(R.id.dialog_register_tool_create_tool_button)) .setText(editButton.getContext().getString(R.string.save)); final Button updateButton = (Button) dialog .findViewById(R.id.dialog_register_tool_create_tool_button); final Button cancelButton = (Button) dialog.findViewById(R.id.dialog_register_tool_cancel_button); final LinearLayout fieldContainer = (LinearLayout) dialog .findViewById(R.id.dialog_register_tool_main_container); final DatePickerRow setupDateRow = new DatePickerRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_set_date_colon), fragmentManager); final TimePickerRow setupTimeRow = new TimePickerRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_set_time_colon), fragmentManager, false); final CoordinatesRow coordinatesRow = new CoordinatesRow(activity, locationTracker); final SpinnerRow toolRow = new SpinnerRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_type), ToolType.getValues()); final CheckBoxRow toolRemovedRow = new CheckBoxRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_removed_row_text), true); final EditTextRow commentRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.comment_field_header), editButton.getContext().getString(R.string.comment_field_hint)); final EditTextRow contactPersonNameRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.contact_person_name), editButton.getContext().getString(R.string.contact_person_name)); final EditTextRow contactPersonPhoneRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.contact_person_phone), editButton.getContext().getString(R.string.contact_person_phone)); final EditTextRow contactPersonEmailRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.contact_person_email), editButton.getContext().getString(R.string.contact_person_email)); final EditTextRow vesselNameRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.vessel_name), editButton.getContext().getString(R.string.vessel_name)); final EditTextRow vesselPhoneNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.vessel_phone_number), editButton.getContext().getString(R.string.vessel_phone_number)); final EditTextRow vesselIrcsNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.ircs_number), editButton.getContext().getString(R.string.ircs_number)); final EditTextRow vesselMmsiNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.mmsi_number), editButton.getContext().getString(R.string.mmsi_number)); final EditTextRow vesselImoNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.imo_number), editButton.getContext().getString(R.string.imo_number)); final EditTextRow vesselRegistrationNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.registration_number), editButton.getContext().getString(R.string.registration_number)); final ErrorRow errorRow = new ErrorRow(editButton.getContext(), editButton.getContext().getString(R.string.error_minimum_identification_factors_not_met), false); final SimpleDateFormat sdfMilliSeconds = new SimpleDateFormat( editButton.getContext().getString(R.string.datetime_format_yyyy_mm_dd_t_hh_mm_ss_sss), Locale.getDefault()); final SimpleDateFormat sdf = new SimpleDateFormat( editButton.getContext().getString(R.string.datetime_format_yyyy_mm_dd_t_hh_mm_ss), Locale.getDefault()); View.OnClickListener deleteButtonRowOnClickListener = new OnClickListener() { @Override public void onClick(View v) { String confirmationText; switch (toolEntry.getToolStatus()) { case STATUS_RECEIVED: case STATUS_SENT_UNCONFIRMED: confirmationText = v.getContext() .getString(R.string.confirm_registered_tool_deletion_text); break; case STATUS_UNSENT: case STATUS_UNREPORTED: confirmationText = v.getContext().getString(R.string.confirm_tool_deletion_text); break; case STATUS_REMOVED_UNCONFIRMED: confirmationText = v.getContext() .getString(R.string.confirm_registered_tool_with_local_changes_deletion_text); break; default: confirmationText = v.getContext() .getString(R.string.confirm_tool_deletion_text_general); break; } final Dialog deleteToolDialog = dialogInterface.getConfirmationDialog(v.getContext(), v.getContext().getString(R.string.delete_tool), confirmationText, v.getContext().getString(R.string.delete)); Button confirmToolDeletionButton = (Button) deleteToolDialog .findViewById(R.id.dialog_bottom_confirm_bottom); confirmToolDeletionButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View parentView = (View) ((editButton.getParent()).getParent()); ((LinearLayout) parentView).removeView(((View) (editButton.getParent()))); Toast.makeText(v.getContext(), v.getContext().getString(R.string.tool_deleted), Toast.LENGTH_LONG).show(); user.getToolLog().removeTool(toolEntry.getSetupDate(), toolEntry.getToolLogId()); user.writeToSharedPref(v.getContext()); deleteToolDialog.dismiss(); dialog.dismiss(); } }); deleteToolDialog.show(); } }; View.OnClickListener archiveToolOnClickListener = new OnClickListener() { @Override public void onClick(View v) { String confirmationText; switch (toolEntry.getToolStatus()) { case STATUS_RECEIVED: confirmationText = v.getContext().getString(R.string.confirm_registered_tool_archiving); break; case STATUS_UNSENT: if (!toolEntry.getId().isEmpty()) { confirmationText = v.getContext().getString(R.string.confirm_tool_archiving_text); } else { confirmationText = v.getContext().getString( R.string.confirm_registered_tool_with_local_changes_archiving_text); } break; default: confirmationText = v.getContext() .getString(R.string.confirm_tool_archiving_text_general); break; } final Dialog archiveDialog = dialogInterface.getConfirmationDialog(v.getContext(), v.getContext().getString(R.string.archive_tool), confirmationText, v.getContext().getString(R.string.archive)); Button confirmToolArchiveButton = (Button) archiveDialog .findViewById(R.id.dialog_bottom_confirm_bottom); confirmToolArchiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View parentView = (View) ((editButton.getParent()).getParent()).getParent(); ((LinearLayout) parentView) .removeView(((View) (editButton.getParent()).getParent())); Toast.makeText(v.getContext(), v.getContext().getString(R.string.tool_archived), Toast.LENGTH_LONG).show(); toolEntry.setToolStatus(ToolEntryStatus.STATUS_REMOVED); user.writeToSharedPref(v.getContext()); archiveDialog.dismiss(); dialog.dismiss(); } }); archiveDialog.show(); } }; ActionRow archiveRow = new ActionRow(editButton.getContext(), editButton.getContext().getString(R.string.archive_tool), R.drawable.ic_archive_black_24dp, archiveToolOnClickListener); ActionRow deleteRow = new ActionRow(editButton.getContext(), editButton.getContext().getString(R.string.delete_tool), R.drawable.ic_delete_black_24dp, deleteButtonRowOnClickListener); commentRow.setInputType(InputType.TYPE_CLASS_TEXT); commentRow.setHelpText(editButton.getContext().getString(R.string.comment_help_description)); vesselNameRow.setInputType(InputType.TYPE_CLASS_TEXT); contactPersonPhoneRow .setHelpText(editButton.getContext().getString(R.string.vessel_name_help_description)); vesselPhoneNumberRow.setInputType(InputType.TYPE_CLASS_PHONE); vesselIrcsNumberRow.setInputType(InputType.TYPE_CLASS_TEXT); vesselIrcsNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter( editButton.getContext().getResources().getInteger(R.integer.input_length_ircs)), new InputFilter.AllCaps() }); vesselIrcsNumberRow.setHelpText(editButton.getContext().getString(R.string.ircs_help_description)); vesselMmsiNumberRow.setInputType(InputType.TYPE_CLASS_NUMBER); vesselMmsiNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter( editButton.getContext().getResources().getInteger(R.integer.input_length_mmsi)) }); vesselMmsiNumberRow.setHelpText(editButton.getContext().getString(R.string.mmsi_help_description)); vesselImoNumberRow.setInputType(InputType.TYPE_CLASS_NUMBER); vesselImoNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter( editButton.getContext().getResources().getInteger(R.integer.input_length_imo)) }); vesselImoNumberRow.setHelpText(editButton.getContext().getString(R.string.imo_help_description)); vesselRegistrationNumberRow.setInputType(InputType.TYPE_CLASS_TEXT); vesselRegistrationNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter(editButton.getContext().getResources() .getInteger(R.integer.input_length_registration_number)), new InputFilter.AllCaps() }); vesselRegistrationNumberRow.setHelpText( editButton.getContext().getString(R.string.registration_number_help_description)); contactPersonNameRow.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); contactPersonPhoneRow.setInputType(InputType.TYPE_CLASS_PHONE); contactPersonEmailRow.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); contactPersonNameRow.setHelpText( editButton.getContext().getString(R.string.contact_person_name_help_description)); contactPersonPhoneRow.setHelpText( editButton.getContext().getString(R.string.contact_person_phone_help_description)); contactPersonEmailRow.setHelpText( editButton.getContext().getString(R.string.contact_person_email_help_description)); coordinatesRow.setCoordinates(activity, toolEntry.getCoordinates()); setupDateRow.setEnabled(false); /* Should these fields be editable after tools are reported? */ // vesselRegistrationNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselImoNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselMmsiNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselNameRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselIrcsNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); ArrayAdapter<String> currentAdapter = toolRow.getAdapter(); toolRow.setSelectedSpinnerItem(currentAdapter.getPosition(toolEntry.getToolType().toString())); toolRemovedRow.setChecked(!toolEntry.getRemovedTime().isEmpty()); commentRow.setText(toolEntry.getComment()); contactPersonNameRow.setText(toolEntry.getContactPersonName()); contactPersonPhoneRow .setText(!toolEntry.getContactPersonPhone().equals("") ? toolEntry.getContactPersonPhone() : toolEntry.getVesselPhone()); contactPersonEmailRow .setText(!toolEntry.getContactPersonEmail().equals("") ? toolEntry.getContactPersonEmail() : toolEntry.getVesselEmail()); vesselNameRow.setText(toolEntry.getVesselName()); vesselPhoneNumberRow.setText(toolEntry.getVesselPhone()); vesselIrcsNumberRow.setText(toolEntry.getIRCS()); vesselMmsiNumberRow.setText(toolEntry.getMMSI()); vesselImoNumberRow.setText(toolEntry.getIMO()); vesselRegistrationNumberRow.setText(toolEntry.getRegNum()); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); Date setupDate = null; String toolSetupDateTime; try { setupDate = sdf.parse(toolEntry.getSetupDateTime()); } catch (ParseException e) { e.printStackTrace(); } sdfMilliSeconds.setTimeZone(TimeZone.getDefault()); toolSetupDateTime = sdfMilliSeconds.format(setupDate); setupDateRow.setDate(toolSetupDateTime.substring(0, 10)); setupTimeRow.setTime(toolSetupDateTime.substring(toolEntry.getSetupDateTime().indexOf('T') + 1, toolEntry.getSetupDateTime().indexOf('T') + 6)); fieldContainer.addView(coordinatesRow.getView()); fieldContainer.addView(setupDateRow.getView()); fieldContainer.addView(setupTimeRow.getView()); fieldContainer.addView(toolRow.getView()); fieldContainer.addView(toolRemovedRow.getView()); fieldContainer.addView(commentRow.getView()); fieldContainer.addView(contactPersonNameRow.getView()); fieldContainer.addView(contactPersonPhoneRow.getView()); fieldContainer.addView(contactPersonEmailRow.getView()); fieldContainer.addView(vesselNameRow.getView()); fieldContainer.addView(vesselPhoneNumberRow.getView()); fieldContainer.addView(vesselIrcsNumberRow.getView()); fieldContainer.addView(vesselMmsiNumberRow.getView()); fieldContainer.addView(vesselImoNumberRow.getView()); fieldContainer.addView(vesselRegistrationNumberRow.getView()); fieldContainer.addView(errorRow.getView()); if (toolEntry.getToolStatus() != ToolEntryStatus.STATUS_UNREPORTED) { fieldContainer.addView(archiveRow.getView()); } fieldContainer.addView(deleteRow.getView()); updateButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View updateButton) { List<Point> coordinates = coordinatesRow.getCoordinates(); ToolType toolType = ToolType.createFromValue(toolRow.getCurrentSpinnerItem()); boolean toolRemoved = toolRemovedRow.isChecked(); String vesselName = vesselNameRow.getFieldText(); String vesselPhoneNumber = vesselPhoneNumberRow.getFieldText(); String toolSetupDate = setupDateRow.getDate(); String toolSetupTime = setupTimeRow.getTime(); String toolSetupDateTime; String commentString = commentRow.getFieldText(); String vesselIrcsNumber = vesselIrcsNumberRow.getFieldText(); String vesselMmsiNumber = vesselMmsiNumberRow.getFieldText(); String vesselImoNumber = vesselImoNumberRow.getFieldText(); String registrationNumber = vesselRegistrationNumberRow.getFieldText(); String contactPersonName = contactPersonNameRow.getFieldText(); String contactPersonPhone = contactPersonPhoneRow.getFieldText(); String contactPersonEmail = contactPersonEmailRow.getFieldText(); FiskInfoUtility utility = new FiskInfoUtility(); boolean validated; boolean edited = false; boolean ircsValidated; boolean mmsiValidated; boolean imoValidated; boolean regNumValidated; boolean minimumIdentificationFactorsMet; validated = coordinates != null; if (!validated) { return; } validated = utility.validateName(contactPersonNameRow.getFieldText().trim()); contactPersonNameRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_name)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, contactPersonNameRow.getView().getBottom()); contactPersonNameRow.requestFocus(); } }); return; } validated = utility.validatePhoneNumber(contactPersonPhoneRow.getFieldText().trim()); contactPersonPhoneRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_phone_number)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, contactPersonPhoneRow.getView().getBottom()); contactPersonPhoneRow.requestFocus(); } }); return; } validated = utility.isEmailValid(contactPersonEmailRow.getFieldText().trim()); contactPersonEmailRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_email)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, contactPersonEmailRow.getView().getBottom()); contactPersonEmailRow.requestFocus(); } }); return; } validated = vesselNameRow.getFieldText().trim() != null && !vesselNameRow.getFieldText().isEmpty(); vesselNameRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_vessel_name)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselNameRow.getView().getBottom()); vesselNameRow.requestFocus(); } }); return; } validated = vesselPhoneNumberRow.getFieldText().trim() != null && !vesselPhoneNumberRow.getFieldText().isEmpty(); vesselPhoneNumberRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_phone_number)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselPhoneNumberRow.getView().getBottom()); vesselPhoneNumberRow.requestFocus(); } }); return; } validated = (ircsValidated = utility.validateIRCS(vesselIrcsNumber)) || vesselIrcsNumber.isEmpty(); vesselIrcsNumberRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_ircs)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselIrcsNumberRow.getView().getBottom()); vesselIrcsNumberRow.requestFocus(); } }); return; } validated = (mmsiValidated = utility.validateMMSI(vesselMmsiNumber)) || vesselMmsiNumber.isEmpty(); vesselMmsiNumberRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_mmsi)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselMmsiNumberRow.getView().getBottom()); vesselMmsiNumberRow.requestFocus(); } }); return; } validated = (imoValidated = utility.validateIMO(vesselImoNumber)) || vesselImoNumber.isEmpty(); vesselImoNumberRow.setError( validated ? null : updateButton.getContext().getString(R.string.error_invalid_imo)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselImoNumberRow.getView().getBottom()); vesselImoNumberRow.requestFocus(); } }); return; } validated = (regNumValidated = utility.validateRegistrationNumber(registrationNumber)) || registrationNumber.isEmpty(); vesselRegistrationNumberRow.setError(validated ? null : editButton.getContext().getString(R.string.error_invalid_registration_number)); if (!validated) { ((ScrollView) fieldContainer.getParent().getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent().getParent()).scrollTo(0, vesselRegistrationNumberRow.getView().getBottom()); vesselRegistrationNumberRow.requestFocus(); } }); return; } sdf.setTimeZone(TimeZone.getDefault()); Date setupDate = null; String setupDateString = toolSetupDate + "T" + toolSetupTime + ":00Z"; try { setupDate = sdf.parse(setupDateString); } catch (ParseException e) { e.printStackTrace(); } sdfMilliSeconds.setTimeZone(TimeZone.getTimeZone("UTC")); setupDateString = sdfMilliSeconds.format(setupDate); toolSetupDateTime = setupDateString.substring(0, setupDateString.indexOf('.')).concat("Z"); minimumIdentificationFactorsMet = !vesselName.isEmpty() && (ircsValidated || mmsiValidated || imoValidated || regNumValidated); if ((coordinates != null && coordinates.size() != toolEntry.getCoordinates().size()) || toolType != toolEntry.getToolType() || (toolRemoved) == (toolEntry.getRemovedTime().isEmpty()) || (vesselName != null && !vesselName.equals(toolEntry.getVesselName())) || (vesselPhoneNumber != null && !vesselPhoneNumber.equals(toolEntry.getVesselPhone())) || (toolSetupDateTime != null && !toolSetupDateTime.equals(toolEntry.getSetupDateTime())) || (vesselIrcsNumber != null && !vesselIrcsNumber.equals(toolEntry.getIRCS())) || (vesselMmsiNumber != null && !vesselMmsiNumber.equals(toolEntry.getMMSI())) || (vesselImoNumber != null && !vesselImoNumber.equals(toolEntry.getIMO())) || (registrationNumber != null && !registrationNumber.equals(toolEntry.getRegNum())) || (contactPersonName != null && !contactPersonName.equals(toolEntry.getContactPersonName())) || (contactPersonPhone != null && !contactPersonPhone.equals(toolEntry.getContactPersonPhone())) || (contactPersonEmail != null && !contactPersonEmail.equals(toolEntry.getContactPersonEmail())) || (commentString != null && !commentString.equals(toolEntry.getComment()))) { edited = true; } else { List<Point> points = toolEntry.getCoordinates(); for (int i = 0; i < coordinates.size(); i++) { if (coordinates.get(i).getLatitude() != points.get(i).getLatitude() || coordinates.get(i).getLongitude() != points.get(i).getLongitude()) { edited = true; break; } } } if (edited) { if (!minimumIdentificationFactorsMet) { errorRow.setVisibility(!minimumIdentificationFactorsMet); return; } Date lastChangedDate = new Date(); Date previousSetupDate = null; SimpleDateFormat sdfSetupCompare = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); String lastChangedDateString = sdfMilliSeconds.format(lastChangedDate).concat("Z"); sdfSetupCompare.setTimeZone(TimeZone.getTimeZone("UTC")); try { previousSetupDate = sdf.parse(toolEntry.getSetupDateTime() .substring(0, toolEntry.getSetupDateTime().length() - 1).concat(".000")); } catch (ParseException e) { e.printStackTrace(); } if (!sdfSetupCompare.format(previousSetupDate) .equals(sdfSetupCompare.format(setupDate))) { // TODO: setup date is changed, tool needs to be moved in log so the app does not crash when trying to delete tool. // user.getToolLog().removeTool(toolEntry.getSetupDate(), toolEntry.getToolLogId()); // user.getToolLog().addTool(toolEntry, toolEntry.getSetupDateTime().substring(0, 10)); // user.writeToSharedPref(editButton.getContext()); } ToolEntryStatus toolStatus = (toolRemoved ? ToolEntryStatus.STATUS_REMOVED_UNCONFIRMED : (toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED ? ToolEntryStatus.STATUS_UNREPORTED : ToolEntryStatus.STATUS_UNSENT)); toolEntry.setToolStatus(toolStatus); toolEntry.setCoordinates(coordinates); toolEntry.setToolType(toolType); toolEntry.setVesselName(vesselName); toolEntry.setVesselPhone(vesselPhoneNumber); toolEntry.setSetupDateTime(toolSetupDateTime); toolEntry.setRemovedTime(toolRemoved ? lastChangedDateString : null); toolEntry.setComment(commentString); toolEntry.setIRCS(vesselIrcsNumber); toolEntry.setMMSI(vesselMmsiNumber); toolEntry.setIMO(vesselImoNumber); toolEntry.setRegNum(registrationNumber); toolEntry.setLastChangedDateTime(lastChangedDateString); toolEntry.setLastChangedBySource(lastChangedDateString); toolEntry.setContactPersonName(contactPersonName); toolEntry.setContactPersonPhone(contactPersonPhone); toolEntry.setContactPersonEmail(contactPersonEmail); try { ImageView notificationView = (ImageView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_reported_image_view); if (notificationView != null) { notificationView.setVisibility(View.VISIBLE); notificationView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), R.string.notification_tool_unreported_changes, Toast.LENGTH_LONG).show(); } }); } TextView dateTimeTextView = (TextView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_latest_date_text_view); TextView toolTypeTextView = (TextView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_tool_type_text_view); TextView positionTextView = (TextView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_tool_position_text_view); StringBuilder sb = new StringBuilder(); sb.append(FiskInfoUtility .decimalToDMS((toolEntry.getCoordinates().get(0).getLatitude()))); sb.append(", "); sb.append(FiskInfoUtility .decimalToDMS((toolEntry.getCoordinates().get(0).getLongitude()))); String coordinateString = sb.toString(); coordinateString = toolEntry.getCoordinates().size() < 2 ? coordinateString : coordinateString + "\n.."; sdfMilliSeconds.setTimeZone(TimeZone.getTimeZone("GMT+1")); setupDateString = sdfMilliSeconds.format(setupDate); dateTimeTextView.setText(setupDateString.substring(0, 16).replace("T", " ")); toolTypeTextView.setText(toolEntry.getToolType().toString()); positionTextView.setText(coordinateString); Date toolDate; Date currentDate = new Date(); try { toolDate = sdf.parse(toolEntry.getSetupDateTime() .substring(0, toolEntry.getSetupDateTime().length() - 1) .concat(".000")); long diff = currentDate.getTime() - toolDate.getTime(); double days = diff / updateButton.getContext().getResources() .getInteger(R.integer.milliseconds_in_a_day); if (days > 14) { dateTimeTextView.setTextColor(ContextCompat .getColor(updateButton.getContext(), (R.color.error_red))); } else { dateTimeTextView.setTextColor(toolTypeTextView.getCurrentTextColor()); } } catch (ParseException e) { e.printStackTrace(); return; } } catch (ClassCastException e) { e.printStackTrace(); } user.writeToSharedPref(updateButton.getContext()); } else { Toast.makeText(editButton.getContext(), R.string.no_changes_made, Toast.LENGTH_LONG) .show(); } dialog.dismiss(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }; }
From source file:usbong.android.retrocc.UsbongDecisionTreeEngineActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mTts.isSpeaking()) { mTts.stop();/*from w w w . j a v a2s. com*/ } StringBuffer sb = new StringBuffer(); switch (item.getItemId()) { /* case(R.id.set_language): initSetLanguage(); //refresh the menu options supportInvalidateOptionsMenu(); //added by Mike, 20160507 invalidateOptionsMenu(); return true; case(R.id.speak): processSpeak(sb); return true; case(R.id.settings): //20160417 //Reference: http://stackoverflow.com/questions/16954196/alertdialog-with-checkbox-in-android; //last accessed: 20160408; answer by: kamal; edited by: Empty2K12 final CharSequence[] items = {UsbongConstants.AUTO_NARRATE_STRING, UsbongConstants.AUTO_PLAY_STRING, UsbongConstants.AUTO_LOOP_STRING}; // arraylist to keep the selected items selectedSettingsItems=new ArrayList<Integer>(); //check saved settings if (UsbongUtils.IS_IN_AUTO_NARRATE_MODE) { selectedSettingsItems.add(UsbongConstants.AUTO_NARRATE); } if (UsbongUtils.IS_IN_AUTO_PLAY_MODE) { selectedSettingsItems.add(UsbongConstants.AUTO_PLAY); selectedSettingsItems.add(UsbongConstants.AUTO_NARRATE); //if AUTO_PLAY is checked, AUTO_NARRATE should also be checked } if (UsbongUtils.IS_IN_AUTO_LOOP_MODE) { selectedSettingsItems.add(UsbongConstants.AUTO_LOOP); } selectedSettingsItemsInBoolean = new boolean[items.length]; for(int k=0; k<items.length; k++) { selectedSettingsItemsInBoolean[k] = false; } for(int i=0; i<selectedSettingsItems.size(); i++) { selectedSettingsItemsInBoolean[selectedSettingsItems.get(i)] = true; } inAppSettingsDialog = new AlertDialog.Builder(this) .setTitle("Settings") .setMultiChoiceItems(items, selectedSettingsItemsInBoolean, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) { Log.d(">>>","onClick"); if (isChecked) { // If the user checked the item, add it to the selected items selectedSettingsItems.add(indexSelected); if ((indexSelected==UsbongConstants.AUTO_PLAY) && !selectedSettingsItems.contains(UsbongConstants.AUTO_NARRATE)) { final ListView list = inAppSettingsDialog.getListView(); list.setItemChecked(UsbongConstants.AUTO_NARRATE, true); } } else if (selectedSettingsItems.contains(indexSelected)) { if ((indexSelected==UsbongConstants.AUTO_NARRATE) && selectedSettingsItems.contains(UsbongConstants.AUTO_PLAY)) { final ListView list = inAppSettingsDialog.getListView(); list.setItemChecked(indexSelected, false); } else { // Else, if the item is already in the array, remove it selectedSettingsItems.remove(Integer.valueOf(indexSelected)); } } //updated selectedSettingsItemsInBoolean for(int k=0; k<items.length; k++) { selectedSettingsItemsInBoolean[k] = false; } for(int i=0; i<selectedSettingsItems.size(); i++) { selectedSettingsItemsInBoolean[selectedSettingsItems.get(i)] = true; } } }).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { InputStreamReader reader = UsbongUtils.getFileFromSDCardAsReader(UsbongUtils.BASE_FILE_PATH + "usbong.config"); BufferedReader br = new BufferedReader(reader); String currLineString; //write first to a temporary file PrintWriter out = UsbongUtils.getFileFromSDCardAsWriter(UsbongUtils.BASE_FILE_PATH + "usbong.config" +"TEMP"); while((currLineString=br.readLine())!=null) { Log.d(">>>", "currLineString: "+currLineString); if ((currLineString.contains("IS_IN_AUTO_NARRATE_MODE=")) || (currLineString.contains("IS_IN_AUTO_PLAY_MODE=")) || (currLineString.contains("IS_IN_AUTO_LOOP_MODE="))) { continue; } else { out.println(currLineString); } } for (int i=0; i<items.length; i++) { Log.d(">>>>", i+""); if (selectedSettingsItemsInBoolean[i]==true) { if (i==UsbongConstants.AUTO_NARRATE) { out.println("IS_IN_AUTO_NARRATE_MODE=ON"); UsbongUtils.IS_IN_AUTO_NARRATE_MODE=true; } else if (i==UsbongConstants.AUTO_PLAY) { out.println("IS_IN_AUTO_PLAY_MODE=ON"); UsbongUtils.IS_IN_AUTO_PLAY_MODE=true; } else if (i==UsbongConstants.AUTO_LOOP) { out.println("IS_IN_AUTO_LOOP_MODE=ON"); UsbongUtils.IS_IN_AUTO_LOOP_MODE=true; } } else { if (i==UsbongConstants.AUTO_NARRATE) { out.println("IS_IN_AUTO_NARRATE_MODE=OFF"); UsbongUtils.IS_IN_AUTO_NARRATE_MODE=false; } else if (i==UsbongConstants.AUTO_PLAY) { out.println("IS_IN_AUTO_PLAY_MODE=OFF"); UsbongUtils.IS_IN_AUTO_PLAY_MODE=false; } else if (i==UsbongConstants.AUTO_LOOP) { out.println("IS_IN_AUTO_LOOP_MODE=OFF"); UsbongUtils.IS_IN_AUTO_LOOP_MODE=false; } } } out.close(); //remember to close //copy temp file to actual usbong.config file InputStreamReader reader2 = UsbongUtils.getFileFromSDCardAsReader(UsbongUtils.BASE_FILE_PATH + "usbong.config"+"TEMP"); BufferedReader br2 = new BufferedReader(reader2); String currLineString2; //write to actual usbong.config file PrintWriter out2 = UsbongUtils.getFileFromSDCardAsWriter(UsbongUtils.BASE_FILE_PATH + "usbong.config"); while((currLineString2=br2.readLine())!=null) { out2.println(currLineString2); } out2.close(); UsbongUtils.deleteRecursive(new File(UsbongUtils.BASE_FILE_PATH + "usbong.config"+"TEMP")); } catch(Exception e) { e.printStackTrace(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Your code when user clicked on Cancel } }).create(); inAppSettingsDialog.show(); return true; */ case (R.id.about): new AlertDialog.Builder(UsbongDecisionTreeEngineActivity.this).setTitle("About") .setMessage(UsbongUtils.readTextFileInAssetsFolder(UsbongDecisionTreeEngineActivity.this, "credits.txt")) //don't add a '/', otherwise the file would not be found .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); return true; case (R.id.account): final EditText firstName = new EditText(this); firstName.setHint("First Name"); final EditText surName = new EditText(this); surName.setHint("Surname"); final EditText contactNumber = new EditText(this); contactNumber.setHint("Contact Number"); contactNumber.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); //added by Mike, 20170223 final RadioGroup preference = new RadioGroup(this); preference.setOrientation(RadioGroup.HORIZONTAL); RadioButton meetup = new AppCompatRadioButton(this); meetup.setText("Meet-up"); preference.addView(meetup); RadioButton shipping = new AppCompatRadioButton(this); shipping.setText("Shipping"); preference.addView(shipping); final EditText shippingAddress = new EditText(this); shippingAddress.setHint("Shipping Address"); shippingAddress.setMinLines(5); //added by Mike, 20170223 final RadioGroup modeOfPayment = new RadioGroup(this); modeOfPayment.setOrientation(RadioGroup.VERTICAL); RadioButton cashUponMeetup = new AppCompatRadioButton(this); cashUponMeetup.setText("Cash upon meet-up"); modeOfPayment.addView(cashUponMeetup); RadioButton bankDeposit = new AppCompatRadioButton(this); bankDeposit.setText("Bank Deposit"); modeOfPayment.addView(bankDeposit); RadioButton peraPadala = new AppCompatRadioButton(this); peraPadala.setText("Pera Padala"); modeOfPayment.addView(peraPadala); //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example //; last accessed: 20150609 //answer by Elenasys //added by Mike, 20150207 SharedPreferences prefs = getSharedPreferences(UsbongConstants.MY_ACCOUNT_DETAILS, MODE_PRIVATE); if (prefs != null) { firstName.setText(prefs.getString("firstName", ""));//"" is the default value. surName.setText(prefs.getString("surname", "")); //"" is the default value. contactNumber.setText(prefs.getString("contactNumber", "")); //"" is the default value. //added by Mike, 20170223 ((RadioButton) preference.getChildAt(prefs.getInt("preference", UsbongConstants.defaultPreference))) .setChecked(true); shippingAddress.setText(prefs.getString("shippingAddress", "")); //"" is the default value. //added by Mike, 20170223 ((RadioButton) modeOfPayment .getChildAt(prefs.getInt("modeOfPayment", UsbongConstants.defaultModeOfPayment))) .setChecked(true); } LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(firstName); ll.addView(surName); ll.addView(contactNumber); ll.addView(preference); ll.addView(shippingAddress); ll.addView(modeOfPayment); new AlertDialog.Builder(this).setTitle("My Account").setView(ll) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //ACTION } }).setPositiveButton("Save & Exit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //ACTION //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example //; last accessed: 20150609 //answer by Elenasys //added by Mike, 20170207 SharedPreferences.Editor editor = getSharedPreferences( UsbongConstants.MY_ACCOUNT_DETAILS, MODE_PRIVATE).edit(); editor.putString("firstName", firstName.getText().toString()); editor.putString("surname", surName.getText().toString()); editor.putString("contactNumber", contactNumber.getText().toString()); for (int i = 0; i < preference.getChildCount(); i++) { if (((RadioButton) preference.getChildAt(i)).isChecked()) { currPreference = i; } } editor.putInt("preference", currPreference); //added by Mike, 20170223 editor.putString("shippingAddress", shippingAddress.getText().toString()); for (int i = 0; i < modeOfPayment.getChildCount(); i++) { if (((RadioButton) modeOfPayment.getChildAt(i)).isChecked()) { currModeOfPayment = i; } } editor.putInt("modeOfPayment", currModeOfPayment); //added by Mike, 20170223 editor.commit(); } }).show(); return true; case android.R.id.home: //added by Mike, 22 Sept. 2015 /*//commented out by Mike, 201702014; UsbongDecisionTreeEngineActivity is already the main menu processReturnToMainMenuActivity(); */ return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** * Click handler for the list items. Will create the appropriate edit * box for the clicked setting./*w w w . j a v a 2 s . c o m*/ */ @Override public void onListItemClick(ListView oParent, View v, int iPos, long id) { final ListView oParentListView = oParent; final SettingsListItem oItem = m_filteredSettings.get(iPos); if (oItem instanceof ChoiceSettingsListItem) { final ChoiceSettingsListItem oChoiceItem = (ChoiceSettingsListItem) oItem; // Show dialog new AlertDialog.Builder(SettingsActivity.this) .setTitle(getString(R.string.Label_Edit) + " " + oItem.m_sLabel) .setSingleChoiceItems(oChoiceItem.m_asText, oChoiceItem.m_iSelectedItem, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { oChoiceItem.select(whichButton); if (oItem.m_iPropId == PropertyID.CONNECTION_AUTO_REGISTRATION_HINT) { m_iRegistrationMethod = (Integer) oChoiceItem.m_oValue; if (m_iRegistrationMethod == Settings.REGISTRATION_METHOD.CERTIFICATE) { handleLocalCertificateSelection(); } } // refresh in ui refreshList(); oParentListView.invalidate(); // Close dialog dialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Close dialog dialog.dismiss(); } }).show(); } else { // inflate the xml layout final View oView = m_oInflater.inflate(R.layout.settings_edit, null); TextView tv = (TextView) oView.findViewById(R.id.TextViewEditSettings); if (tv != null) tv.setText(getItemLabel(oItem)); // set value tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); if (tv != null) tv.setText(oItem.m_oValue.toString()); // special input validator for integers if (oItem.m_oValue instanceof Integer) tv.setInputType(InputType.TYPE_CLASS_NUMBER); if (oItem.m_bPassword) tv.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // show dialog, valid value when user clicks ok button new AlertDialog.Builder(this).setTitle(getString(R.string.Label_Edit) + " " + getItemLabel(oItem)) .setView(oView).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { TextView tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); String sText = tv.getText().toString(); if (oItem.m_oValue instanceof Integer) oItem.m_oValue = Integer.parseInt(sText); else if (oItem.m_oValue instanceof Boolean) oItem.m_oValue = Boolean.parseBoolean(sText); else oItem.m_oValue = sText; InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); //validate the input value if (!validateField(oItem)) { // validation failed, reset to original value oItem.m_oValue = oItem.m_oOrigValue; showValidationErrorDialog(oItem.m_sLabel); } else { // refresh in ui refreshList(); oParentListView.invalidate(); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { TextView tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); dialog.dismiss(); } }).show(); } }
From source file:com.roiland.crm.sm.ui.view.ScOppoInfoFragment.java
/** * //from w w w .j a v a2 s. c o m * <pre> * ? * </pre> * * @param isDetail ? */ public void displayCarInfo(boolean isDetail) { if (carInfo == null) { carInfo = new ArrayList<BasicInfoListAdapter.Info>(); } if (project == null) { project = new Project(); } project.setPurchaseCarIntention(getUpdatedPurchaseCar()); if (!isDetail) { // carInfo.clear(); if (isSubmitNewCar() || hsaActivityOrder()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.brand_1), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getBrand() : null), true, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.brand_1), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getBrand() : null), true)); } if (addFlag) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.model), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getModel() : null), false, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.outsideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getOutsideColor() : null), false, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInsideColor() : null), false, false)); } else { if (isSubmitNewCar() || hsaActivityOrder()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.model), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getModel() : null), true, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.outsideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getOutsideColor() : null), true, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInsideColor() : null), true)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.model), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getModel() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.outsideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getOutsideColor() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInsideColor() : null), false)); } } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColorCheck), BaseInfoRowViewItem.BOOLEAN2_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? String.valueOf(project.getPurchaseCarIntention().isInsideColorCheck()) : "false"), false)); if (project != null && project.getPurchaseCarIntention() != null) { if (!StringUtils.isEmpty(project.getPurchaseCarIntention().getModel())) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.carConfiguration), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getCarConfiguration() : null), false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.carConfiguration), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getCarConfiguration() : null), false, false)); } } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.salesQuote), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getSalesQuote() : null), false, InputType.TYPE_CLASS_NUMBER)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.preorderCount), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getPreorderCount() : "1"), false, InputType.TYPE_CLASS_NUMBER)); if (project != null && project.getPurchaseCarIntention() != null) { if (project.getPurchaseCarIntention().getFlowStatus() != null && getString(R.string.flowStatus_1) .equals(project.getPurchaseCarIntention().getFlowStatus())) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.finish_preorderDate), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true, false)); } else if (project.getPurchaseCarIntention().isGiveupTag() != null && project.getPurchaseCarIntention().isGiveupTag()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.lose_date), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.preorderDate), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true)); } } if (project != null && project.getPurchaseCarIntention() != null) { if (project.getPurchaseCarIntention().isGiveupTag()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.flowStatus), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getFlowStatus() : getString(R.string.flowStatus_2)), false, false)); } else if (getString(R.string.flowStatus_1) .equals(project.getPurchaseCarIntention().getFlowStatus()) && !isFirstSubmitNewCar) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.flowStatus), BaseInfoRowViewItem.SELECTION_TYPE, null, project.getPurchaseCarIntention().getFlowStatus(), false, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.flowStatus), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getFlowStatus() : getString(R.string.flowStatus_2)), false)); } } } else { carInfo.clear(); if (isSubmitNewCar() || hsaActivityOrder()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.brand_1), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getBrand() : null), true, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.brand_1), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getBrand() : null), true)); } if (addFlag) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.model), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getModel() : null), false, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.outsideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getOutsideColor() : null), false, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInsideColor() : null), false, false)); } else { if (isSubmitNewCar() || hsaActivityOrder()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.model), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getModel() : null), true, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.outsideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getOutsideColor() : null), true, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInsideColor() : null), true)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.model), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getModel() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.outsideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getOutsideColor() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColor), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInsideColor() : null), false)); } } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.insideColorCheck), BaseInfoRowViewItem.BOOLEAN2_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? String.valueOf(project.getPurchaseCarIntention().isInsideColorCheck()) : "false"), false)); if (project != null && project.getPurchaseCarIntention() != null) { if (!StringUtils.isEmpty(project.getPurchaseCarIntention().getModel())) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.carConfiguration), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getCarConfiguration() : null), false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.carConfiguration), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getCarConfiguration() : null), false, false)); } } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.salesQuote), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getSalesQuote() : null), false, InputType.TYPE_CLASS_NUMBER)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.dealPriceInterval), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getDealPriceInterval() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.payment), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getPayment() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.preorderCount), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getPreorderCount() : "1"), false, InputType.TYPE_CLASS_NUMBER)); if (project != null && project.getPurchaseCarIntention() != null) { if (project.getPurchaseCarIntention().getFlowStatus() != null && getString(R.string.flowStatus_1) .equals(project.getPurchaseCarIntention().getFlowStatus())) { if (isSubmitNewCar) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.finish_preorderDate), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true, true)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.finish_preorderDate), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true, false)); } } else if (project.getPurchaseCarIntention().isGiveupTag() != null && project.getPurchaseCarIntention().isGiveupTag()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.lose_date), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.preorderDate), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention().getPreorderDate() != 0 ? String.valueOf(project.getPurchaseCarIntention().getPreorderDate()) : null)), true)); } } if (project != null && project.getPurchaseCarIntention() != null) { if (project.getPurchaseCarIntention().isGiveupTag()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.flowStatus), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getFlowStatus() : getString(R.string.flowStatus_2)), false, false)); } else if (getString(R.string.flowStatus_1) .equals(project.getPurchaseCarIntention().getFlowStatus()) && !isFirstSubmitNewCar) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.flowStatus), BaseInfoRowViewItem.SELECTION_TYPE, null, project.getPurchaseCarIntention().getFlowStatus(), false, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.flowStatus), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getFlowStatus() : getString(R.string.flowStatus_2)), false)); } } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.dealPossibility), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getDealPossibility() : "0.05"), false, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.purchMotivation), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getPurchMotivation() : null), false)); if (isSubmitNewCar()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.chassisNo), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getChassisNo() : null), true)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.engineNo), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getEngineNo() : null), true)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.chassisNo), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getChassisNo() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.engineNo), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getEngineNo() : null), false)); } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.licensePlate), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getLicensePlate() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.licenseProp), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getLicenseProp() : null), false)); carInfo.add( new BasicInfoListAdapter.Info(getString(R.string.pickupDate), BaseInfoRowViewItem.DATE_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? ("0".equals(project.getPurchaseCarIntention().getPickupDate()) || project.getPurchaseCarIntention().getPickupDate() == null || project.getPurchaseCarIntention().getPickupDate() == "null" ? null : String.valueOf((StringUtils.getDateTrimNullLong( project.getPurchaseCarIntention().getPickupDate())))) : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.preorderTag), BaseInfoRowViewItem.BOOLEAN2_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getPreorderTag() : null), false)); //? if (addFlag || (project != null && project.getPurchaseCarIntention() != null && getString(R.string.flowStatus_1) .equals(project.getPurchaseCarIntention().getFlowStatus()))) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.giveupTag), BaseInfoRowViewItem.BOOLEAN2_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? String.valueOf(project.getPurchaseCarIntention().isGiveupTag()) : "false"), false, false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.giveupReason), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getGiveupReason() : null), false, false)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.giveupTag), BaseInfoRowViewItem.BOOLEAN2_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? String.valueOf(project.getPurchaseCarIntention().isGiveupTag()) : "false"), false)); if (project != null && project.getPurchaseCarIntention() != null && project.getPurchaseCarIntention().isGiveupTag()) { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.giveupReason), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getGiveupReason() : null), true)); } else { carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.giveupReason), BaseInfoRowViewItem.SELECTION_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getGiveupReason() : null), false, false)); } } carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.invoiceTitle), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getInvoiceTitle() : null), false)); carInfo.add(new BasicInfoListAdapter.Info(getString(R.string.comment), BaseInfoRowViewItem.SIMPLETEXT_TYPE, null, ((project != null && project.getPurchaseCarIntention() != null) ? project.getPurchaseCarIntention().getProjectComment() : null), false)); carInfoCaches = new ArrayList<BasicInfoListAdapter.Info>(); carInfoCaches.addAll(carInfo); } carInfoAdapter.setContentList(carInfo); carInfoAdapter.notifyDataSetChanged(); refreshCarList(); }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * For user removal://from www .j a v a 2s.c o m * Shows a prompt for a user serial number. The associated user will be removed. */ private void showRemoveUserPrompt() { if (getActivity() == null || getActivity().isFinishing()) { return; } View view = LayoutInflater.from(getActivity()).inflate(R.layout.simple_edittext, null); final EditText input = (EditText) view.findViewById(R.id.input); input.setHint(R.string.enter_user_id); input.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); new AlertDialog.Builder(getActivity()).setTitle(R.string.remove_user).setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { boolean success = false; long serialNumber = -1; try { serialNumber = Long.parseLong(input.getText().toString()); UserHandle userHandle = mUserManager.getUserForSerialNumber(serialNumber); if (userHandle != null) { success = mDevicePolicyManager.removeUser(mAdminComponentName, userHandle); } } catch (NumberFormatException e) { // Error message is printed in the next line. } showToast(success ? R.string.user_removed : R.string.failed_to_remove_user); } }).show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setCompareEditTextAttr(GlobalParameters mGlblParms, String c_tgt, EditText et_value1, EditText et_value2) {//from w w w.j av a2 s. c o m if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_BLUETOOTH)) { et_value1.setInputType(InputType.TYPE_CLASS_TEXT); et_value2.setInputType(InputType.TYPE_CLASS_TEXT); } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_WIFI)) { et_value1.setInputType(InputType.TYPE_CLASS_TEXT); et_value2.setInputType(InputType.TYPE_CLASS_TEXT); } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_BATTERY)) { try { Integer.parseInt(et_value1.getText().toString()); } catch (NumberFormatException e) { et_value1.setText(""); } try { Integer.parseInt(et_value2.getText().toString()); } catch (NumberFormatException e) { et_value2.setText(""); } et_value1.setInputType(InputType.TYPE_CLASS_NUMBER); et_value2.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_LIGHT)) { try { Integer.parseInt(et_value1.getText().toString()); } catch (NumberFormatException e) { et_value1.setText(""); } try { Integer.parseInt(et_value2.getText().toString()); } catch (NumberFormatException e) { et_value2.setText(""); } et_value1.setInputType(InputType.TYPE_CLASS_NUMBER); et_value2.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (c_tgt.equals(PROFILE_ACTION_TYPE_COMPARE_TARGET_TIME)) { try { Integer.parseInt(et_value1.getText().toString()); } catch (NumberFormatException e) { et_value1.setText(""); } try { Integer.parseInt(et_value2.getText().toString()); } catch (NumberFormatException e) { et_value2.setText(""); } et_value1.setInputType(InputType.TYPE_CLASS_NUMBER); et_value2.setInputType(InputType.TYPE_CLASS_NUMBER); } }