List of usage examples for android.text TextUtils isDigitsOnly
public static boolean isDigitsOnly(CharSequence str)
From source file:org.ale.scanner.zotero.web.zotero.ZoteroAPIClient.java
public static Group[] parseGroups(String resp) { /* example:/*from ww w .j a v a 2s. c o m*/ <!-- tons of garbage --> <zapi:totalResults>1</zapi:totalResults> <zapi:apiVersion>1</zapi:apiVersion> <updated>2011-07-15T22:46:21Z</updated> <entry xmlns:zxfer="http://zotero.org/ns/transfer"> <title>group title</title> <author> <name>some_user</name> <uri>http://zotero.org/some_user</uri> </author> <id>http://zotero.org/groups/12345</id> <published>2011-07-15T22:46:01Z</published> <updated>2011-07-15T22:46:21Z</updated> <link rel="self" type="application/atom+xml" href="https://api.zotero.org/groups/12345"/> <link rel="alternate" type="text/html" href="http://zotero.org/groups/12345"/> <zapi:numItems>10</zapi:numItems> <content type="html"> <!-- more garbage --> </content> </entry> */ /* Returns null for parsing errors */ Document doc = ZoteroAPIClient.parseXML(resp); if (doc == null) return null; NodeList totalResults = doc.getElementsByTagName("zapi:totalResults"); if (totalResults.getLength() == 0) return null; String trStr = totalResults.item(0).getFirstChild().getNodeValue(); if (trStr == null || !TextUtils.isDigitsOnly(trStr)) return null; int numGroups = Integer.parseInt(trStr); Group[] groups = new Group[numGroups]; NodeList entries = doc.getElementsByTagName("entry"); if (entries.getLength() != numGroups) return null; for (int i = 0; i < numGroups; i++) { if (entries.item(i).getNodeType() != Node.ELEMENT_NODE) return null; NodeList titles = ((Element) entries.item(i)).getElementsByTagName("title"); NodeList ids = ((Element) entries.item(i)).getElementsByTagName("id"); if (titles.getLength() != 1 || ids.getLength() != 1) return null; String title = titles.item(0).getFirstChild().getNodeValue(); String idUri = ids.item(0).getFirstChild().getNodeValue(); if (title == null || idUri == null) return null; int lastSeg = idUri.lastIndexOf("/"); if (lastSeg < 0) return null; String idstr = idUri.substring(lastSeg + 1); if (!TextUtils.isDigitsOnly(idstr)) return null; int id = Integer.parseInt(idstr); groups[i] = new Group(id, title); } return groups; }
From source file:com.mastercard.masterpasswallet.fragments.addcard.VerifyCardFragment.java
private void setupAddCardButton(View fragmentView) { Button btnAddCard = (Button) fragmentView.findViewById(R.id.btn_add_card); btnAddCard.setOnClickListener(new View.OnClickListener() { @Override//ww w .j ava2 s. co m public void onClick(View view) { Log.d(TAG, "Card added button pressed"); String cardholderName = mEdtCardholderName.getText().toString(); String cardNumber = mEdtCardNumber.getText().toString(); String cvc = mEdtCvc.getText().toString(); String expiry = mEdtExpiry.getText().toString(); String expiryMonth = ""; String expiryYear = ""; // Focus the field with the first error EditText focusField = null; // Expiry if (TextUtils.isEmpty(expiry)) { mEdtExpiry.setError(getString(R.string.error_expiry_date_is_required)); focusField = mEdtExpiry; } else { String[] expiryParts = expiry.split("/"); if (expiryParts.length != 2) { mEdtExpiry.setError(getString(R.string.error_expiry_date_is_not_valid)); focusField = mEdtExpiry; } else { expiryMonth = expiryParts[0]; expiryYear = expiryParts[1]; // parse to an int for further validation int month = Integer.parseInt(expiryMonth); int year = Integer.parseInt(expiryYear); // make sure the month is a valid number if (month > 12 || month < 1) { mEdtExpiry.setError(getString(R.string.error_expiry_date_is_not_valid)); focusField = mEdtExpiry; } else { if (!DateUtils.isInFuture(1, month, year + 2000)) { mEdtExpiry.setError(getString(R.string.error_expiry_date_is_not_future)); focusField = mEdtExpiry; } } } } // CVC if (TextUtils.isEmpty(cvc)) { mEdtCvc.setError(getString(R.string.error_cvc_is_required)); focusField = mEdtCvc; } else if (!TextUtils.isDigitsOnly(cvc) || (cvc.length() != 3 && cvc.length() != 4)) { mEdtCvc.setError(getString(R.string.error_cvc_is_not_valid)); focusField = mEdtCvc; } // Card Number if (TextUtils.isEmpty(cardNumber)) { mEdtCardNumber.setError(getString(R.string.error_card_number_is_required)); focusField = mEdtCardNumber; } else { // Check we don't already have this card in the list ArrayList<Card> cards = DataManager.INSTANCE.getFreshCards(); for (Card card : cards) { if (card.getPAN().replace(" ", "").equals(cardNumber.replace(" ", ""))) { mEdtCardNumber.setError(getString(R.string.error_card_number_already_in_use)); focusField = mEdtCardNumber; break; } } } // Card holder name if (TextUtils.isEmpty(cardholderName)) { mEdtCardholderName.setError(getString(R.string.error_cardholder_name_is_required)); focusField = mEdtCardholderName; } // apache credit card validator CreditCardValidator ccv = new CreditCardValidator(); if (!ccv.isValid(cardNumber.replace("-", "").replace(" ", ""))) { mEdtCardNumber.setError(getString(R.string.error_card_number_not_valid)); focusField = mEdtCardNumber; } // If there is no focusField set then the form is valid if (focusField != null) { focusField.requestFocus(); } else { hideKeyboard(); if (mIsFirstCard) { // When adding first card we have to set shipping address ShippingAddress shippingAddress = new ShippingAddress(); shippingAddress.mName = cardholderName; shippingAddress.mNickname = getString(R.string.verifycard_prefill_nickname); shippingAddress.mLine1 = getString(R.string.verifycard_prefill_billing_address); shippingAddress.mCity = getString(R.string.verifycard_prefill_billing_city); shippingAddress.mZipCode = getString(R.string.verifycard_prefill_billing_zipcode); shippingAddress.mState = getString(R.string.verifycard_prefill_billing_state); // only set as default if it's the first card shippingAddress.bIsDefault = true; mListener.addFirstCard(cardholderName, cardNumber, cvc, expiryMonth, expiryYear, shippingAddress); } else { mListener.addCard(cardholderName, cardNumber, cvc, expiryMonth, expiryYear); } } } }); }
From source file:com.pindroid.activity.Main.java
private void processIntent(Intent intent) { String action = intent.getAction(); String path = intent.getData() != null ? intent.getData().getPath() : ""; String lastPath = (intent.getData() != null && intent.getData().getLastPathSegment() != null) ? intent.getData().getLastPathSegment() : ""; String intentUsername = (intent.getData() != null && intent.getData().getUserInfo() != null) ? intent.getData().getUserInfo() : ""; if (!intentUsername.equals("") && !app.getUsername().equals(intentUsername)) { setAccount(intentUsername);/*from ww w.j ava 2s. co m*/ } if (Intent.ACTION_VIEW.equals(action)) { if (lastPath.equals("bookmarks")) { if (intent.getData().getQueryParameter("unread") != null && intent.getData().getQueryParameter("unread").equals("1")) { onMyUnreadSelected(); } else { onMyBookmarksSelected(intent.getData().getQueryParameter("tagname")); } } else if (lastPath.equals("notes")) { onMyNotesSelected(); } } else if (Intent.ACTION_SEND.equals(action)) { Bookmark b = loadBookmarkFromShareIntent(); b = findExistingBookmark(b); onBookmarkAdd(b); } else if (Constants.ACTION_SEARCH_SUGGESTION_VIEW.equals(action)) { if (path.contains("bookmarks") && TextUtils.isDigitsOnly(lastPath) && intent.hasExtra(SearchManager.USER_QUERY)) { try { String defaultAction = SettingsHelper.getDefaultAction(this); BookmarkViewType viewType = null; try { viewType = BookmarkViewType.valueOf(defaultAction.toUpperCase(Locale.US)); } catch (Exception e) { viewType = BookmarkViewType.VIEW; } onBookmarkSelected(BookmarkManager.GetById(Integer.parseInt(lastPath), this), viewType); } catch (NumberFormatException e) { e.printStackTrace(); } catch (ContentNotFoundException e) { e.printStackTrace(); } } else if (path.contains("bookmarks") && intent.hasExtra(SearchManager.USER_QUERY)) { if (intent.getData() != null && intent.getData().getQueryParameter("tagname") != null) onTagSelected(intent.getData().getQueryParameter("tagname"), true); } else if (path.contains("notes") && TextUtils.isDigitsOnly(lastPath) && intent.hasExtra(SearchManager.USER_QUERY)) { try { onNoteView(NoteManager.GetById(Integer.parseInt(lastPath), this)); } catch (NumberFormatException e) { e.printStackTrace(); } catch (ContentNotFoundException e) { e.printStackTrace(); } } } }
From source file:th.in.ffc.person.visit.VisitAncPregnancyActivity.java
public void doUpdateView(Cursor c) { String action = getIntent().getAction(); if (!TextUtils.isEmpty(action) && action.equals(Action.INSERT)) { String preg_no = c.getString(c.getColumnIndex(VisitAncPregnancy._PREGNO)); int no = 1; if (TextUtils.isDigitsOnly(preg_no)) { no = Integer.parseInt(preg_no); no += 1;// w ww .j ava 2s. co m } PregNo.setText("" + no); } else { PregNo.setText(c.getString(c.getColumnIndex(VisitAncPregnancy._PREGNO))); String sLmp = c.getString(c.getColumnIndex(VisitAncPregnancy.LMP)); if (!TextUtils.isEmpty(sLmp)) { Date lmp_date = Date.newInstance(sLmp); lmp.updateDate(lmp_date); } String sEdc = c.getString(c.getColumnIndex(VisitAncPregnancy.EDC)); if (!TextUtils.isEmpty(sEdc)) { Date edc_date = Date.newInstance(sEdc); edc.updateDate(edc_date); } } FpBefore.setSelection(c.getString(c.getColumnIndex(VisitAncPregnancy.FP_BEFORE))); FirstAbNormal.setSelection(c.getString(c.getColumnIndex(VisitAncPregnancy.FIRST_ABNORMAL))); }
From source file:com.hardcopy.vcontroller.fragments.AddBrokerFragment.java
private boolean saveUserInput(boolean addAndConnect) { mUserInput = new Bundle(); String clientId = mEditClientId.getText().toString(); String serverUri = mEditServerUri.getText().toString(); String port = mEditPort.getText().toString(); boolean cleanSession = mCheckCleanSession.isChecked(); String username = mEditUserName.getText().toString(); String password = mEditPassword.getText().toString(); String sslkey = null;/*from ww w.j a v a 2 s . c om*/ boolean ssl = mCheckSsl.isChecked(); if (ssl) { sslkey = mEditSslKeyPath.getText().toString(); } int keepalive; int timeout; try { timeout = Integer.parseInt(mEditTimeOut.getText().toString()); } catch (NumberFormatException nfe) { timeout = Constants.defaultTimeOut; } try { keepalive = Integer.parseInt(mEditKeepAlive.getText().toString()); } catch (NumberFormatException nfe) { keepalive = Constants.defaultKeepAlive; } String topic = mEditTopic.getText().toString(); String message = mEditMessage.getText().toString(); int checkedId = mRadioQos.getCheckedRadioButtonId(); int qos = 0; //determine which qos value has been selected switch (checkedId) { case R.id.qos0: qos = 0; break; case R.id.qos1: qos = 1; break; case R.id.qos2: qos = 2; break; } boolean retained = mCheckRetained.isChecked(); // check input value if (clientId == null || clientId.length() < 1) { if (addAndConnect) { Utils.showToast(mContext.getString(R.string.errorClientId), Toast.LENGTH_SHORT); return false; } } if (serverUri == null || serverUri.length() < 1) { if (addAndConnect) { Utils.showToast(mContext.getString(R.string.errorServerUri), Toast.LENGTH_SHORT); return false; } } else { Utils.writeSuggestion(Utils.AUTO_COMPLETE_SERVER, serverUri); // remember server URI for auto-complete } if (port == null || port.length() < 1 || !TextUtils.isDigitsOnly(port)) { if (addAndConnect) { Utils.showToast(mContext.getString(R.string.errorServerUri), Toast.LENGTH_SHORT); return false; } port = Integer.toString(Constants.defaultPort); } if (username == null) username = new String(Constants.empty); if (password == null) password = new String(Constants.empty); if (sslkey == null) sslkey = new String(Constants.empty); if (message == null) message = new String(Constants.empty); if (topic == null) topic = new String(Constants.empty); // put the daya collected into the bundle mUserInput.putString(Constants.clientId, clientId); mUserInput.putString(Constants.server, serverUri); mUserInput.putString(Constants.port, port); mUserInput.putBoolean(Constants.cleanSession, cleanSession); mUserInput.putString(Constants.username, username); mUserInput.putString(Constants.password, password); mUserInput.putBoolean(Constants.ssl, ssl); mUserInput.putString(Constants.ssl_key, sslkey); mUserInput.putInt(Constants.timeout, timeout); mUserInput.putInt(Constants.keepalive, keepalive); mUserInput.putString(Constants.message, message); mUserInput.putString(Constants.topic, topic); mUserInput.putInt(Constants.qos, qos); mUserInput.putBoolean(Constants.retained, retained); return true; }
From source file:rs.pedjaapps.kerneltuner.utility.IOHelper.java
public static String cpuCurFreq(int core) { File path;/*from w w w. j a va 2 s .c o m*/ switch (core) { case 0: path = Constants.CPU0_CURR_FREQ; break; case 1: path = Constants.CPU1_CURR_FREQ; break; case 2: path = Constants.CPU2_CURR_FREQ; break; case 3: path = Constants.CPU3_CURR_FREQ; break; default: path = Constants.CPU0_CURR_FREQ; break; } try { String freq = RCommand.readFileContent(path).trim(); if (TextUtils.isDigitsOnly(freq)) { return freq; } } catch (Exception ignore) { } return "offline"; }
From source file:org.ale.scanner.zotero.web.zotero.ZoteroAPIClient.java
public static String parseItems(String resp) { /* example:/*from www . jav a 2 s. c o m*/ <!-- tons of garbage --> <zapi:totalResults>1</zapi:totalResults> <zapi:apiVersion>1</zapi:apiVersion> <updated>2010-12-17T00:18:51Z</updated> <entry> <title>My Book</title> <author> <name>Zotero User</name> <uri>http://zotero.org/zuser</uri> </author> <id>http://zotero.org/users/zuser/items/ABCD2345</id> <published>2010-12-17T00:18:51Z</published> <updated>2010-12-17T00:18:51Z</updated> <link rel="self" type="application/atom+xml" href="https://api.zotero.org/users/1/items/ABCD2345?content=json"/> <link rel="alternate" type="text/html" href="http://zotero.org/users/zuser/items/ABCD2345"/> <zapi:key>ABCD2345</zapi:key> <zapi:itemType>book</zapi:itemType> <zapi:creatorSummary>McAuthor</zapi:creatorSummary> <zapi:numChildren>1</zapi:numChildren> <zapi:numTags>2</zapi:numTags> <content type="application/json" etag="8e984e9b2a8fb560b0085b40f6c2c2b7"> { "itemType" : "book", "title" : "My Book", "creators" : [ { "creatorType" : "author", "firstName" : "Sam", "lastName" : "McAuthor" }, { "creatorType":"editor", "name" : "John T. Singlefield" } ], "tags" : [ { "tag" : "awesome" }, { "tag" : "rad", "type" : 1 } ] } </content> </entry> </feed> */ /* Returns null for parsing errors */ Document doc = ZoteroAPIClient.parseXML(resp); if (doc == null) return null; NodeList totalResults = doc.getElementsByTagName("zapi:totalResults"); if (totalResults.getLength() == 0) return null; String trStr = totalResults.item(0).getFirstChild().getNodeValue(); if (trStr == null || !TextUtils.isDigitsOnly(trStr)) return null; int numGroups = Integer.parseInt(trStr); Group[] groups = new Group[numGroups]; NodeList entries = doc.getElementsByTagName("entry"); if (entries.getLength() != numGroups) return null; for (int i = 0; i < numGroups; i++) { if (entries.item(i).getNodeType() != Node.ELEMENT_NODE) return null; NodeList titles = ((Element) entries.item(i)).getElementsByTagName("title"); NodeList ids = ((Element) entries.item(i)).getElementsByTagName("id"); if (titles.getLength() != 1 || ids.getLength() != 1) return null; String title = titles.item(0).getFirstChild().getNodeValue(); String idUri = ids.item(0).getFirstChild().getNodeValue(); if (title == null || idUri == null) return null; int lastSeg = idUri.lastIndexOf("/"); if (lastSeg < 0) return null; String idstr = idUri.substring(lastSeg + 1); if (!TextUtils.isDigitsOnly(idstr)) return null; int id = Integer.parseInt(idstr); groups[i] = new Group(id, title); } return ""; }
From source file:org.jnrain.mobile.accounts.kbs.KBSRegisterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.kbs_register); mHandler = new Handler() { @Override/*from w w w .j ava 2 s .c om*/ public void handleMessage(Message msg) { loadingDlg = DialogHelper.showProgressDialog(KBSRegisterActivity.this, R.string.check_updates_dlg_title, R.string.please_wait, false, false); } }; lastUIDCheckTime = 0; initValidationMapping(); // instance state if (savedInstanceState != null) { /* * editNewUID.onRestoreInstanceState(savedInstanceState * .getParcelable("newUID")); * editNewEmail.onRestoreInstanceState(savedInstanceState * .getParcelable("newEmail")); * editNewPassword.onRestoreInstanceState(savedInstanceState * .getParcelable("newPass")); * editRetypeNewPassword.onRestoreInstanceState * (savedInstanceState .getParcelable("repeatPass")); * editNewNickname.onRestoreInstanceState(savedInstanceState * .getParcelable("newNickname")); * editStudID.onRestoreInstanceState(savedInstanceState * .getParcelable("studID")); * editRealName.onRestoreInstanceState(savedInstanceState * .getParcelable("realname")); * editPhone.onRestoreInstanceState(savedInstanceState * .getParcelable("phone")); * editCaptcha.onRestoreInstanceState(savedInstanceState * .getParcelable("captcha")); */ // captcha image byte[] captchaPNG = savedInstanceState.getByteArray("captchaImage"); ByteArrayInputStream captchaStream = new ByteArrayInputStream(captchaPNG); try { Drawable captchaDrawable = BitmapDrawable.createFromStream(captchaStream, "src"); imageRegCaptcha.setImageDrawable(captchaDrawable); } finally { try { captchaStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } // event handlers // UID editNewUID.addTextChangedListener(new StrippedDownTextWatcher() { long lastCheckTime = 0; String lastUID; @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // FIXME: use monotonic clock... long curtime = System.currentTimeMillis(); if (curtime - lastCheckTime >= KBSUIConstants.REG_CHECK_UID_INTERVAL_MILLIS) { String uid = s.toString(); // don't check at the first char if (uid.length() > 1) { checkUIDAvailability(uid, curtime); } lastCheckTime = curtime; lastUID = uid; // schedule a new delayed check if (delayedUIDChecker != null) { delayedUIDChecker.cancel(); delayedUIDChecker.purge(); } delayedUIDChecker = new Timer(); delayedUIDChecker.schedule(new TimerTask() { @Override public void run() { final String uid = getUID(); if (uid != lastUID) { runOnUiThread(new Runnable() { @Override public void run() { checkUIDAvailability(uid, System.currentTimeMillis()); } }); lastUID = uid; } } }, KBSUIConstants.REG_CHECK_UID_INTERVAL_MILLIS); } } }); editNewUID.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { // lost focus, force check uid availability checkUIDAvailability(getUID(), System.currentTimeMillis()); } else { // inputting, temporarily clear that notice updateUIDAvailability(false, 0); } } }); // E-mail editNewEmail.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editNewEmail, false, true, R.string.reg_email_empty); return; } if (!EMAIL_CHECKER.matcher(s).matches()) { updateValidation(editNewEmail, false, true, R.string.reg_email_malformed); return; } updateValidation(editNewEmail, true, true, R.string.ok_short); } }); // Password editNewPassword.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editNewPassword, false, true, R.string.reg_psw_empty); return; } if (s.length() < 6) { updateValidation(editNewPassword, false, true, R.string.reg_psw_too_short); return; } if (s.length() > 39) { updateValidation(editNewPassword, false, true, R.string.reg_psw_too_long); return; } if (getUID().equalsIgnoreCase(s.toString())) { updateValidation(editNewPassword, false, true, 0); } updateValidation(editNewPassword, true, true, R.string.ok_short); updateRetypedPasswordCorrectness(); } }); // Retype password editRetypeNewPassword.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateRetypedPasswordCorrectness(); } }); // Nickname editNewNickname.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editNewNickname, false, true, R.string.reg_nick_empty); return; } updateValidation(editNewNickname, true, true, R.string.ok_short); } }); // Student ID editStudID.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editStudID, false, true, R.string.reg_stud_id_empty); return; } if (!IDENT_CHECKER.matcher(s).matches()) { updateValidation(editStudID, false, true, R.string.reg_stud_id_malformed); return; } updateValidation(editStudID, true, true, R.string.ok_short); } }); // Real name editRealName.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editRealName, false, true, R.string.reg_realname_empty); return; } updateValidation(editRealName, true, true, R.string.ok_short); } }); // Phone editPhone.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editPhone, false, true, R.string.reg_phone_empty); return; } if (!TextUtils.isDigitsOnly(s)) { updateValidation(editPhone, false, true, R.string.reg_phone_onlynumbers); return; } updateValidation(editPhone, true, true, R.string.ok_short); } }); // Captcha editCaptcha.addTextChangedListener(new StrippedDownTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { updateValidation(editCaptcha, false, true, R.string.reg_captcha_empty); return; } updateValidation(editCaptcha, true, true, R.string.ok_short); } }); // Use current phone checkUseCurrentPhone.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setUseCurrentPhone(isChecked); } }); // Is ethnic minority checkIsEthnicMinority.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setEthnicMinority(isChecked); } }); // Submit form! btnSubmitRegister.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // progress dialog mHandler.sendMessage(new Message()); // prevent repeated requests setSubmitButtonEnabled(false); // fire our biiiiiig request! // TODO: ??23333 final String uid = getUID(); final String psw = editNewPassword.getText().toString(); makeSpiceRequest( new KBSRegisterRequest(uid, psw, editNewNickname.getText().toString(), getRealName(), editStudID.getText().toString(), editNewEmail.getText().toString(), getPhone(), editCaptcha.getText().toString(), 2), new KBSRegisterRequestListener(KBSRegisterActivity.this, uid, psw)); } }); // interface init // UID availability updateUIDAvailability(false, 0); // HTML-formatted register disclaimer FormatHelper.setHtmlText(this, textRegisterDisclaimer, R.string.register_disclaimer); textRegisterDisclaimer.setMovementMethod(LinkMovementMethod.getInstance()); // is ethnic minority defaults to false checkIsEthnicMinority.setChecked(false); setEthnicMinority(false); // current phone number currentPhoneNumber = TelephonyHelper.getPhoneNumber(this); isCurrentPhoneNumberAvailable = currentPhoneNumber != null; if (isCurrentPhoneNumberAvailable) { // display the obtained number as hint FormatHelper.setHtmlText(this, checkUseCurrentPhone, R.string.field_use_current_phone, currentPhoneNumber); } else { // phone number unavailable, disable the choice checkUseCurrentPhone.setEnabled(false); checkUseCurrentPhone.setVisibility(View.GONE); } // default to use current phone number if available checkUseCurrentPhone.setChecked(isCurrentPhoneNumberAvailable); setUseCurrentPhone(isCurrentPhoneNumberAvailable); if (savedInstanceState == null) { // issue preflight request // load captcha in success callback this.makeSpiceRequest(new KBSRegisterRequest(), new KBSRegisterRequestListener(this)); } }
From source file:th.in.ffc.person.visit.VisitAncPregnancyActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor c) { setSupportProgressBarIndeterminateVisibility(false); switch (loader.getId()) { case LOAD_LAST_PREG: if (c.moveToFirst()) { doUpdateView(c);/* www . j a v a 2 s . co m*/ if (TextUtils.isEmpty(mPregNo)) { mPregNo = c.getString(c.getColumnIndex(PregnancyColumns._PREGNO)); if (TextUtils.isDigitsOnly(mPregNo)) { mMinPregNo = Integer.parseInt(mPregNo) + 1; Hint.setText("> " + mMinPregNo); } getSupportLoaderManager().initLoader(LOAD_RISK, null, this); } } else { mMinPregNo = 1; PregNo.setText("" + mMinPregNo); } break; case LOAD_RISK: RiskAdder run = new RiskAdder(c); mHandle.post(run); break; case LOAD_PREG: if (c.moveToFirst()) { doUpdateView(c); } break; } }
From source file:com.digi.android.wva.fragments.EndpointOptionsDialog.java
/** * @param subInterval EditText holding user input for interval * @return true if subscription was valid (and probably worked), false * if the interval is invalid//w ww. j ava 2s.c o m */ protected boolean handleMakingSubscription(EditText subInterval) { // Shouldn't need to worry about NumberFormatException - // the EditText is set to type numeric Editable intervalText = subInterval.getText(); String interval; if (intervalText == null) interval = ""; else interval = intervalText.toString(); if (TextUtils.isEmpty(interval) || !TextUtils.isDigitsOnly(interval)) { return false; } int iinterval; try { iinterval = Integer.valueOf(interval); } catch (NumberFormatException e) { return false; } if (isSubscribing() || subscriptionIntervalChanged(iinterval)) { subscribe(mConfig.getEndpoint(), iinterval); } return true; }