List of usage examples for android.text TextUtils isDigitsOnly
public static boolean isDigitsOnly(CharSequence str)
From source file:th.in.ffc.person.visit.VisitAncPregnancyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.visit_pragnancy_activity); setSupportProgressBarIndeterminateVisibility(false); mAction = getIntent().getAction();/* w ww .j av a2 s . c o m*/ if (TextUtils.isEmpty(mAction)) throw new IllegalStateException("VisitAncPregnancyActivity not support null Action Intent"); doInitializeView(savedInstanceState); if (savedInstanceState == null) { //do by request action if (mAction.equals(Action.INSERT)) getSupportLoaderManager().initLoader(LOAD_LAST_PREG, null, this); else if (mAction.equals(Action.EDIT)) { mPregNo = getIntent().getStringExtra(PregnancyColumns._PREGNO); if (TextUtils.isEmpty(mPregNo)) throw new InvalidParameterException("Edit Action must have \'pregno\'"); if (!TextUtils.isDigitsOnly(mPregNo)) throw new InvalidParameterException("pregno must be digits only"); PregNo.setEnabled(false); PregNo.setText(mPregNo); getSupportLoaderManager().initLoader(LOAD_PREG, null, this); getSupportLoaderManager().initLoader(LOAD_RISK, null, this); } } else { mAction = savedInstanceState.getString("action"); mMinPregNo = savedInstanceState.getInt("min"); Hint.setText(savedInstanceState.getCharSequence("hint")); mPregNo = savedInstanceState.getString("pregno"); PregNo.setEnabled(savedInstanceState.getBoolean("enable")); RiskLayout.setVisibility(savedInstanceState.getBoolean("showRisk") ? View.VISIBLE : View.GONE); } }
From source file:net.naonedbus.rest.controller.impl.HoraireController.java
private String parseTerminus(final String minute, final Map<String, String> notes) { if (TextUtils.isDigitsOnly(minute)) { return null; }//from w w w .j a v a 2 s . c o m final String code = minute.replaceAll("[0-9]", ""); return notes.get(code); }
From source file:com.readystatesoftware.chuck.internal.ui.TransactionListFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { CursorLoader loader = new CursorLoader(getContext()); loader.setUri(ChuckContentProvider.TRANSACTION_URI); if (!TextUtils.isEmpty(currentFilter)) { if (TextUtils.isDigitsOnly(currentFilter)) { loader.setSelection("responseCode LIKE ?"); loader.setSelectionArgs(new String[] { currentFilter + "%" }); } else {/*from w w w . j av a2 s . c om*/ loader.setSelection("path LIKE ?"); loader.setSelectionArgs(new String[] { "%" + currentFilter + "%" }); } } loader.setProjection(HttpTransaction.PARTIAL_PROJECTION); loader.setSortOrder("requestDate DESC"); return loader; }
From source file:org.wso2.emm.agent.api.RuntimeInfo.java
public Application getHighestCPU() { Application appData = null;//from w w w . j av a 2s. c o m for (String topCommandRow : topCommandRows) { if (topCommandRow != null && !topCommandRow.isEmpty() && !topCommandRow.contains(" root ")) { String[] columns = topCommandRow.replaceFirst("^\\s*", "").split(" "); String pidColumnValue = columns[0].trim(); if (!pidColumnValue.isEmpty() && TextUtils.isDigitsOnly(pidColumnValue)) { appData = new Application(); appData.setPackageName(columns[columns.length - 1]); appData.setPid(Integer.parseInt(columns[0])); for (String column : columns) { if (column != null) { String columnValue = column.trim(); if (columnValue.contains("%")) { String percentage = columnValue.replace("%", ""); if (!percentage.isEmpty() && TextUtils.isDigitsOnly(percentage)) { appData.setCpu(Integer.parseInt(percentage)); } break; } } } } } } return appData; }
From source file:org.andstatus.app.net.http.HttpConnectionMock.java
@Override public boolean getCredentialsPresent() { return !TextUtils.isEmpty(password) || (!TextUtils.isDigitsOnly(userToken) && !TextUtils.isEmpty(userSecret)); }
From source file:com.easemob.helpdeskdemo.ui.SettingFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case REQUEST_CODE_APPKEY: String oldAppkey = tvAppkey.getText().toString(); String newAppkey = data.getStringExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT); if (TextUtils.isEmpty(newAppkey.trim())) { Toast.makeText(getActivity(), "appkey?,!", Toast.LENGTH_SHORT).show(); return; }/* w w w.jav a 2s .co m*/ if (!newAppkey.matches("^[0-9a-zA-Z-_#]+$")) { Toast.makeText(getActivity(), "appkey??,!", Toast.LENGTH_SHORT).show(); return; } if (oldAppkey.equals(newAppkey)) { return; } tvAppkey.setText(newAppkey); showCustomMessage(newAppkey); break; case REQUEST_CODE_ACCOUNT: String oldAccount = tvAccount.getText().toString(); String newAccount = data.getStringExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT); if (oldAccount.equals(newAccount)) { return; } tvAccount.setText(newAccount); Preferences.getInstance().setCustomerAccount(newAccount); break; case REQUEST_CODE_NICK: String oldNick = tvNick.getText().toString(); String newNick = data.getStringExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT); if (oldNick.equals(newNick)) { return; } tvNick.setText(newNick); Preferences.getInstance().setNickName(newNick); break; case REQUEST_CODE_TENANT_ID: String oldTenantId = tvTenantId.getText().toString(); String newTenantId = data.getStringExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT); if (!TextUtils.isDigitsOnly(newTenantId)) { return; } if (oldTenantId.equals(newTenantId)) { return; } tvTenantId.setText(newTenantId); Preferences.getInstance().setTenantId(newTenantId); ChatClient.getInstance().setTenantId(newTenantId); break; case REQUEST_CODE_PROJECT_ID: String oldProjectId = tvProjectId.getText().toString(); String newProjectId = data.getStringExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT); if (!TextUtils.isDigitsOnly(newProjectId)) { return; } if (oldProjectId.equals(newProjectId)) { return; } tvProjectId.setText(newProjectId); Preferences.getInstance().setSettingProjectId(newProjectId); break; case REQUEST_CODE_QCODE: //??? if (null != data) { Bundle bundle = data.getExtras(); if (bundle == null) { return; } if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { String result = bundle.getString(CodeUtils.RESULT_STRING); //http://m.easemob.com/download/app/cs_demo?appkey=zdxd#sq&tenantid=25115#projectId=23&imservicenum=ceshia try { Map<String, String> paramMap = urlParamParse(result); String appkey = paramMap.get("appkey"); String imServiceNum = paramMap.get("imservicenum"); String tenantId = paramMap.get("tenantid"); String projectId = paramMap.get("projectid"); if (!TextUtils.isEmpty(appkey)) { tvAppkey.setText(appkey); showCustomMessage(appkey); } if (!TextUtils.isEmpty(projectId)) { tvProjectId.setText(projectId); Preferences.getInstance().setSettingProjectId(projectId); } if (!TextUtils.isEmpty(tenantId)) { tvTenantId.setText(tenantId); Preferences.getInstance().setTenantId(tenantId); ChatClient.getInstance().setTenantId(tenantId); } if (!TextUtils.isEmpty(imServiceNum)) { tvAccount.setText(imServiceNum); Preferences.getInstance().setCustomerAccount(imServiceNum); } if (!TextUtils.isEmpty(appkey) && !TextUtils.isEmpty(tenantId)) { Toast.makeText(getActivity(), getString(R.string.qrcode_success), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), getString(R.string.qrcode_invalid), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { Toast.makeText(getActivity(), getString(R.string.qrcode_fail), Toast.LENGTH_SHORT) .show(); } } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { Toast.makeText(getActivity(), getString(R.string.qrcode_fail), Toast.LENGTH_SHORT).show(); } } break; default: break; } } }
From source file:th.in.ffc.person.PersonDetailEditFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);//w w w . j av a2s .c o m provcode.setDialog(getFFCActivity().getSupportFragmentManager(), ProvinceListDialog.class, "prov"); distcode.setDialog(getFFCActivity().getSupportFragmentManager(), DistrictListDialog.class, "dist"); subdistcode.setDialog(getFFCActivity().getSupportFragmentManager(), SubDistrictListDialog.class, "subdist"); provcode.addTextChangedListener(watchprov); distcode.addTextChangedListener(watchdist); String action = getArguments().getString("action"); if (savedInstanceState == null) { if (action.equals(Action.EDIT)) getActivity().getSupportLoaderManager().initLoader(0, null, this); else if (action.equals(Action.INSERT)) { // set default hcode if it have String hcode = getArguments().getString("hcode"); if (!TextUtils.isEmpty(hcode) && TextUtils.isDigitsOnly(hcode)) { house.setSelectionById(Long.parseLong(hcode)); house.setEnabled(false); mHcode = hcode; getDefaultHouseDetail(hcode); } getActivity().getSupportLoaderManager().initLoader(1, null, this); } } citizenId.addTextChangedListener(idcardWatcher); }
From source file:hloli.love.animefun.widget.PagerSlidingTabStrip.java
public void notifyDataSetChanged() { tabsContainer.removeAllViews();/*from w w w . j av a 2 s . c om*/ tabCount = pager.getAdapter().getCount(); for (int i = 0; i < tabCount; i++) { String s = pager.getAdapter().getPageTitle(i).toString(); if (TextUtils.isDigitsOnly(s)) { addIconTab(i, Integer.parseInt(s)); } else { addTextTab(i, pager.getAdapter().getPageTitle(i).toString()); } } updateTabStyles(); getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { getViewTreeObserver().removeOnGlobalLayoutListener(this); } currentPosition = pager.getCurrentItem(); scrollToChild(currentPosition, 0); } }); }
From source file:org.mariotaku.utwitterapi.util.OAuthPasswordAuthenticator.java
public static String readOAuthPINFromHtml(final Reader in) throws XmlPullParserException, IOException { boolean start_div = false, start_code = false; final XmlPullParserFactory f = XmlPullParserFactory.newInstance(); final XmlPullParser parser = f.newPullParser(); parser.setFeature(Xml.FEATURE_RELAXED, true); parser.setInput(in);/*w w w .j av a 2 s. c o m*/ while (parser.next() != XmlPullParser.END_DOCUMENT) { final String tag = parser.getName(); final int type = parser.getEventType(); if (type == XmlPullParser.START_TAG) { if ("div".equalsIgnoreCase(tag)) { start_div = "oauth_pin".equals(parser.getAttributeValue(null, "id")); } else if ("code".equalsIgnoreCase(tag)) { if (start_div) { start_code = true; } } } else if (type == XmlPullParser.END_TAG) { if ("div".equalsIgnoreCase(tag)) { start_div = false; } else if ("code".equalsIgnoreCase(tag)) { start_code = false; } } else if (type == XmlPullParser.TEXT) { final String text = parser.getText(); if (start_code && !TextUtils.isEmpty(text) && TextUtils.isDigitsOnly(text)) return text; } } return null; }
From source file:comp3111h.anytaxi.driver.Register_FormFragment.java
private boolean isValidPhone() { EditText rPhone_Field;//from w ww . j a v a 2 s .c om String rPhone_Input; rPhone_Field = rField.get(PHONE); rPhone_Input = rPhone_Field.getText().toString(); rInput.set(PHONE, rPhone_Input); // Reset the error message rPhone_Field.setError(null); // Check for invalidity if (TextUtils.isEmpty(rPhone_Input)) { rPhone_Field.setError(getString(R.string.register_error_required_field)); return false; } if (!TextUtils.isDigitsOnly(rPhone_Input)) { rPhone_Field.setError(getString(R.string.register_error_only_number)); return false; } if (rPhone_Input.length() < 8) { rPhone_Field.setError(getString(R.string.register_error_unreal_phone)); return false; } if (rPhone_Input.charAt(0) != '5' && rPhone_Input.charAt(0) != '6' && rPhone_Input.charAt(0) != '9') { rPhone_Field.setError(getString(R.string.register_error_mobile_phone)); return false; } return true; }