本文整理汇总了Java中android.text.TextUtils.isDigitsOnly方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtils.isDigitsOnly方法的具体用法?Java TextUtils.isDigitsOnly怎么用?Java TextUtils.isDigitsOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.TextUtils
的用法示例。
在下文中一共展示了TextUtils.isDigitsOnly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public void update(Observable observable, Object o) {
Activity activity = getActivity();
if (activity instanceof AppCompatActivity) {
ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(CurrentSelected.getVersion().getDisplayText());
}
}
if (o instanceof IVerseProvider) {
//noinspection unchecked
mAdapter.updateVerses(((IVerseProvider) o).getVerses());
final IVerse verse = CurrentSelected.getVerse();
if (verse != null && !TextUtils.isEmpty(verse.getVerseNumber()) && TextUtils.isDigitsOnly(verse.getVerseNumber())) {
new Handler().post(() -> scrollToVerse(verse));
}
}
setBookChapterText();
}
示例2: onCreateLoader
import android.text.TextUtils; //导入方法依赖的package包/类
@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 {
loader.setSelection("path LIKE ?");
loader.setSelectionArgs(new String[]{ "%" + currentFilter + "%" });
}
}
loader.setProjection(HttpTransaction.PARTIAL_PROJECTION);
loader.setSortOrder("requestDate DESC");
return loader;
}
示例3: doParse
import android.text.TextUtils; //导入方法依赖的package包/类
public static Object doParse(XulAttr prop) {
xulParsedAttr_Img_FadeIn val = new xulParsedAttr_Img_FadeIn();
String stringValue = prop.getStringValue();
if ("true".equals(stringValue) || "enabled".equals(stringValue)) {
val.enabled = true;
val.duration = 300;
} else if (TextUtils.isEmpty(stringValue) || "disabled".equals(stringValue) || "false".equals(stringValue)) {
val.enabled = false;
val.duration = 0;
} else if (TextUtils.isDigitsOnly(stringValue)) {
val.enabled = true;
val.duration = XulUtils.tryParseInt(stringValue, 300);
} else {
val.enabled = false;
val.duration = 300;
}
return val;
}
示例4: convert
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* Implement this method and use the helper to adapt the view to the given item.
*
* @param helper A fully initialized helper.
* @param item The item that needs to be displayed.
*/
@Override
protected void convert(BaseViewHolder helper, AqiDetailBean item) {
helper.setText(R.id.tv_aqi_name, item.getName());
helper.setText(R.id.tv_aqi_desc, item.getDesc());
if (TextUtils.isEmpty(item.getValue())) {
item.setValue("-1");
}
helper.setText(R.id.tv_aqi_value, item.getValue() + "");
int value = TextUtils.isDigitsOnly(item.getValue()) ? Integer.parseInt(item.getValue()) : 0;
if (value <= 50) {
helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFF6BCD07);
} else if (value <= 100) {
helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFFFBD029);
} else if (value <= 150) {
helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFFFE8800);
} else if (value <= 200) {
helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFFFE0000);
} else if (value <= 300) {
helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFF970454);
} else {
helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFF62001E);
}
}
示例5: validateNumberOfTables
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* Validate number of tables
* @return true if it's validated correctly, false otherwise
*/
private boolean validateNumberOfTables() {
String numberOfTables = inputNumberOfTables.getText().toString().trim();
if (TextUtils.isEmpty(numberOfTables) || !TextUtils.isDigitsOnly(numberOfTables)) {
inputLayoutNumberOfTables.setError(getString(R.string.err_msg_number_of_tables));
requestFocus(inputNumberOfTables);
return false;
} else if (Integer.valueOf(numberOfTables) > 1000) {
inputLayoutNumberOfTables.setError(getString(R.string.err_msg_number_of_tables_too_much_tables));
requestFocus(inputNumberOfTables);
return false;
} else {
inputLayoutNumberOfTables.setErrorEnabled(false);
}
return true;
}
示例6: getGistId
import android.text.TextUtils; //导入方法依赖的package包/类
@Nullable private static String getGistId(@NonNull Uri uri) {
List<String> segments = uri.getPathSegments();
if (segments.size() != 1 && segments.size() != 2) return null;
String gistId = segments.get(segments.size() - 1);
if (InputHelper.isEmpty(gistId)) return null;
if (TextUtils.isDigitsOnly(gistId)) return gistId;
else if (gistId.matches("[a-fA-F0-9]+")) return gistId;
else return null;
}
示例7: addTagsFilter
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* Adds the {@code tagsFilter} query parameter to the given {@code builder}. This query
* parameter is used by the {@link com.google.samples.apps.iosched.explore.ExploreSessionsActivity}
* when the user makes a selection containing multiple filters.
*/
private void addTagsFilter(SelectionBuilder builder, String tagsFilter, String numCategories) {
// Note: for context, remember that session queries are done on a join of sessions
// and the sessions_tags relationship table, and are GROUP'ed BY the session ID.
String[] requiredTags = tagsFilter.split(",");
if (requiredTags.length == 0) {
// filtering by 0 tags -- no-op
return;
} else if (requiredTags.length == 1) {
// filtering by only one tag, so a simple WHERE clause suffices
builder.where(Tags.TAG_ID + "=?", requiredTags[0]);
} else {
// Filtering by multiple tags, so we must add a WHERE clause with an IN operator,
// and add a HAVING statement to exclude groups that fall short of the number
// of required tags. For example, if requiredTags is { "X", "Y", "Z" }, and a certain
// session only has tags "X" and "Y", it will be excluded by the HAVING statement.
int categories = 1;
if (numCategories != null && TextUtils.isDigitsOnly(numCategories)) {
try {
categories = Integer.parseInt(numCategories);
LOGD(TAG, "Categories being used " + categories);
} catch (Exception ex) {
LOGE(TAG, "exception parsing categories ", ex);
}
}
String questionMarkTuple = makeQuestionMarkTuple(requiredTags.length);
builder.where(Tags.TAG_ID + " IN " + questionMarkTuple, requiredTags);
builder.having(
"COUNT(" + Qualified.SESSIONS_SESSION_ID + ") >= " + categories);
}
}
示例8: isDiscussionJump
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* 是否是帖子跳转
* @param context
* @param url
* @return
* https://pondof.fish/d/13
*/
public static boolean isDiscussionJump(Context context, String url,int mDiscussionId){
if(null!= url && url.length() > ApiManager.URL.length() + 2) {
String urlPath = url.substring(ApiManager.URL.length() + 2);
String[] paths = urlPath.split("/");
// 点击链接的帖子id和本帖子id不同
if(TextUtils.isDigitsOnly(paths[0]) && TextUtils.isDigitsOnly(paths[1]) && mDiscussionId != Integer.parseInt(paths[0])){
UIUtil.openDiscussionViewActivity(context,Integer.parseInt(paths[0]));
return true;
}
}
return false;
}
示例9: isCommentJump
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* 是否是评论跳转
* @param context
* @param url
* @return
* https://pondof.fish/d/10/2
*/
public static int isCommentJump(Context context, String url, int mDiscussionId) {
if(null!= url && url.length() > ApiManager.URL.length() + 2){
String commentPath = url.substring(ApiManager.URL.length() + 2);
String[] paths = commentPath.split("/");
// 点击链接的帖子id和本帖子id相同
if (TextUtils.isDigitsOnly(paths[0]) && TextUtils.isDigitsOnly(paths[1]) && mDiscussionId == Integer.parseInt(paths[0])) {
return Integer.parseInt(paths[1]);
}
}
return -1;
}
示例10: extractIdIFE
import android.text.TextUtils; //导入方法依赖的package包/类
private String extractIdIFE(String s) {
String[] lines = s.split("\r\n|\r|\n");
String result = s.replaceAll("\\s+", "").replaceAll("[-+.^:,]", "");
if (result.length() > 13) result = result.substring(0, 13);
if (!TextUtils.isDigitsOnly(result)) {
result = result.replace('b', '6').replace('L', '6').replace('l', '1').replace('i', '1').replace('I', '1')
.replace('y', '4').replace('o', '0').replace('O', '0').replace('s', '5').replace('S', '5')
.replace('z', '2').replace('Z', '2').replace('g', '9').replace('Y', '4').replace('e', '2')
.replace('?', '7').replace('E', '6');
}
return result;
}
示例11: getIntText
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* 获取输入的数字类型文本
* @return int类型文本
*/
public int getIntText() {
if (TextUtils.isDigitsOnly(mText))
return Integer.valueOf(mText);
else
return -1;
}
示例12: validatePhone
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* Validate restaurant phone
* @return true if it's validated correctly, false otherwise
*/
private boolean validatePhone() {
String phone = inputPhone.getText().toString().trim();
if (TextUtils.isEmpty(phone) || !TextUtils.isDigitsOnly(phone)) {
inputLayoutPhone.setError(getString(R.string.err_msg_phone));
requestFocus(inputPhone);
return false;
} else {
inputLayoutPhone.setErrorEnabled(false);
}
return true;
}
示例13: onBindViewHolder
import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(GradeListViewHolder holder, int position) {
Grade grade = gradeList.get(position);
String xfjd = "学分&绩点:" + grade.getXf() + "&" + grade.getJd();
String gradeTime = grade.getXn() + "学年第" + grade.getXq() + "学期";
String lessonName = grade.getKcmc();
String gradeScore = grade.getCj();
if (!TextUtils.isEmpty(grade.getBkcj())) {
gradeTime += "(补考)";
gradeScore = grade.getBkcj();
} else if (!TextUtils.isEmpty(grade.getCxbj()) && grade.getCxbj().equals("1")) {
gradeTime += "(重修)";
}
if (TextUtils.isDigitsOnly(gradeScore)) {
if (Integer.parseInt(gradeScore) < 60) {
lessonName += "(未通过)";
}
gradeScore += "分";
} else if (gradeScore.equals("不及格")) {
lessonName += "(未通过)";
}
holder.tvGradeLesson.setText(lessonName);
holder.tvGradeTime.setText(gradeTime);
holder.tvGradeJidian.setText(xfjd);
holder.tvGradeScore.setText(gradeScore);
}
示例14: getAdbPort
import android.text.TextUtils; //导入方法依赖的package包/类
public static int getAdbPort() {
// XXX: SystemProperties.get is @hide method
String port = SystemProperties.get("service.adb.tcp.port", "");
UILog.i("service.adb.tcp.port: " + port);
if (!TextUtils.isEmpty(port) && TextUtils.isDigitsOnly(port)) {
int p = Integer.parseInt(port);
if (p > 0 && p <= 0xffff) {
return p;
}
}
return -1;
}
示例15: verify
import android.text.TextUtils; //导入方法依赖的package包/类
@Override public Observable<RxVerifyCompacResult<AppCompatEditText>> verify(String text, AppCompatEditText item) {
if (TextUtils.isDigitsOnly(text)) {
return Observable.just(RxVerifyCompacResult.createSuccess(item));
}
return Observable.just(RxVerifyCompacResult.createImproper(item, digitOnlyMessage));
}