java isdigitsonly_Java TextUtils.isDigitsOnly方法代碼示例

本文整理匯總了Java中android.text.TextUtils.isDigitsOnly方法的典型用法代碼示例。如果您正苦於以下問題:Java TextUtils.isDigitsOnly方法的具體用法?Java TextUtils.isDigitsOnly怎麽用?Java TextUtils.isDigitsOnly使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.TextUtils的用法示例。

在下文中一共展示了TextUtils.isDigitsOnly方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: update

​點讚 3

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();

}

開發者ID:barnhill,項目名稱:SimpleBible,代碼行數:23,

示例2: onCreateLoader

​點讚 3

import android.text.TextUtils; //導入方法依賴的package包/類

@Override

public Loader 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;

}

開發者ID:jgilfelt,項目名稱:chuck,代碼行數:18,

示例3: doParse

​點讚 3

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;

}

開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:19,

示例4: convert

​點讚 3

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);

}

}

開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:30,

示例5: validateNumberOfTables

​點讚 3

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;

}

開發者ID:Wisebite,項目名稱:wisebite_android,代碼行數:20,

示例6: getGistId

​點讚 2

import android.text.TextUtils; //導入方法依賴的package包/類

@Nullable private static String getGistId(@NonNull Uri uri) {

List 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;

}

開發者ID:duyp,項目名稱:mvvm-template,代碼行數:10,

示例7: addTagsFilter

​點讚 2

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);

}

}

開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:36,

示例8: isDiscussionJump

​點讚 2

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;

}

開發者ID:ProjectFishpond,項目名稱:TPondof,代碼行數:20,

示例9: isCommentJump

​點讚 2

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;

}

開發者ID:ProjectFishpond,項目名稱:TPondof,代碼行數:19,

示例10: extractIdIFE

​點讚 2

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;

}

開發者ID:BrandonVargas,項目名稱:AndroidOCRFforID,代碼行數:14,

示例11: getIntText

​點讚 2

import android.text.TextUtils; //導入方法依賴的package包/類

/**

* 獲取輸入的數字類型文本

* @return int類型文本

*/

public int getIntText() {

if (TextUtils.isDigitsOnly(mText))

return Integer.valueOf(mText);

else

return -1;

}

開發者ID:fendoudebb,項目名稱:DragBadgeView,代碼行數:11,

示例12: validatePhone

​點讚 2

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;

}

開發者ID:Wisebite,項目名稱:wisebite_android,代碼行數:16,

示例13: onBindViewHolder

​點讚 2

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);

}

開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:28,

示例14: getAdbPort

​點讚 2

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;

}

開發者ID:brevent,項目名稱:Brevent,代碼行數:13,

示例15: verify

​點讚 2

import android.text.TextUtils; //導入方法依賴的package包/類

@Override public Observable> verify(String text, AppCompatEditText item) {

if (TextUtils.isDigitsOnly(text)) {

return Observable.just(RxVerifyCompacResult.createSuccess(item));

}

return Observable.just(RxVerifyCompacResult.createImproper(item, digitOnlyMessage));

}

開發者ID:datalink747,項目名稱:Rx_java2_soussidev,代碼行數:7,

示例16: handleUriBefore

​點讚 2

import android.text.TextUtils; //導入方法依賴的package包/類

@SuppressLint("DefaultLocale")

private void handleUriBefore(XParam param) throws Throwable {

// Check URI

if (param.args.length > 1 && param.args[0] instanceof Uri) {

String uri = ((Uri) param.args[0]).toString().toLowerCase();

String[] projection = (param.args[1] instanceof String[] ? (String[]) param.args[1] : null);

if (uri.startsWith("content://com.android.contacts/contacts/name_phone_or_email")) {

// Do nothing

} else if (uri.startsWith("content://com.android.contacts/")

&& !uri.equals("content://com.android.contacts/")) {

String[] components = uri.replace("content://com.android.", "").split("/");

String methodName = components[0] + "/" + components[1].split("\\?")[0];

if (methodName.equals("contacts/contacts") || methodName.equals("contacts/data")

|| methodName.equals("contacts/phone_lookup") || methodName.equals("contacts/raw_contacts"))

if (isRestrictedExtra(param, PrivacyManager.cContacts, methodName, uri)) {

// Get ID from URL if any

int urlid = -1;

if ((methodName.equals("contacts/contacts") || methodName.equals("contacts/phone_lookup"))

&& components.length > 2 && TextUtils.isDigitsOnly(components[2]))

urlid = Integer.parseInt(components[2]);

// Modify projection

boolean added = false;

if (projection != null && urlid < 0) {

List listProjection = new ArrayList();

listProjection.addAll(Arrays.asList(projection));

String cid = getIdForUri(uri);

if (cid != null && !listProjection.contains(cid)) {

added = true;

listProjection.add(cid);

}

param.args[1] = listProjection.toArray(new String[0]);

}

if (added)

param.setObjectExtra("column_added", added);

}

}

}

}

開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:42,

示例17: isValidType

​點讚 2

import android.text.TextUtils; //導入方法依賴的package包/類

private boolean isValidType(String numberType) {

return !TextUtils.isEmpty(numberType) && TextUtils.isDigitsOnly(numberType);

}

開發者ID:nitiwari-dev,項目名稱:android-contact-extractor,代碼行數:4,

示例18: getHeWeatherType

​點讚 2

import android.text.TextUtils; //導入方法依賴的package包/類

private static BaseWeatherType getHeWeatherType(Context context, ShortWeatherInfo info) {

if (info != null && TextUtils.isDigitsOnly(info.getCode())) {

int code = Integer.parseInt(info.getCode());

if (code == 100) {//晴

return new SunnyType(context, info);

} else if (code >= 101 && code <= 103) {//多雲

SunnyType sunnyType = new SunnyType(context, info);

sunnyType.setCloud(true);

return sunnyType;

} else if (code == 104) {//陰

return new OvercastType(context, info);

} else if (code >= 200 && code <= 213) {//各種風

return new SunnyType(context, info);

} else if (code >= 300 && code <= 303) {//各種陣雨

if (code >= 300 && code <= 301) {

return new RainType(context, RainType.RAIN_LEVEL_2, RainType.WIND_LEVEL_2);

} else {

RainType rainType = new RainType(context, RainType.RAIN_LEVEL_2, RainType.WIND_LEVEL_2);

rainType.setFlashing(true);

return rainType;

}

} else if (code == 304) {//陣雨加冰雹

return new HailType(context);

} else if (code >= 305 && code <= 312) {//各種雨

if (code == 305 || code == 309) {//小雨

return new RainType(context, RainType.RAIN_LEVEL_1, RainType.WIND_LEVEL_1);

} else if (code == 306) {//中雨

return new RainType(context, RainType.RAIN_LEVEL_2, RainType.WIND_LEVEL_2);

} else//大到暴雨

return new RainType(context, RainType.RAIN_LEVEL_3, RainType.WIND_LEVEL_3);

} else if (code == 313) {//凍雨

return new HailType(context);

} else if (code >= 400 && code <= 407) {//各種雪

if (code == 400) {

return new SnowType(context, SnowType.SNOW_LEVEL_1);

} else if (code == 401) {

return new SnowType(context, SnowType.SNOW_LEVEL_2);

} else if (code >= 402 && code <= 403) {

return new SnowType(context, SnowType.SNOW_LEVEL_3);

} else if (code >= 404 && code <= 406) {

RainType rainSnowType = new RainType(context, RainType.RAIN_LEVEL_1, RainType.WIND_LEVEL_1);

rainSnowType.setSnowing(true);

return rainSnowType;

} else {

return new SnowType(context, SnowType.SNOW_LEVEL_2);

}

} else if (code >= 500 && code <= 501) {//霧

return new FogType(context);

} else if (code == 502) {//霾

return new HazeType(context);

} else if (code >= 503 && code <= 508) {//各種沙塵暴

return new SandstormType(context);

} else if (code == 900) {//熱

return new SunnyType(context, info);

} else if (code == 901) {//冷

return new SnowType(context, SnowType.SNOW_LEVEL_1);

} else {//未知

return new SunnyType(context, info);

}

} else

return null;

}

開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:63,

示例19: updateMembers

​點讚 1

import android.text.TextUtils; //導入方法依賴的package包/類

/**

* 更新好友分組中成員的分組說明。

*

* @param list_id 好友分組ID,建議使用返回值裏的idstr

* @param uid 需要更新分組成員說明的用戶的UID

* @param group_description 需要更新的分組成員說明,每個說明最多8個漢字,16個半角字符,需要URLencode

* @param listener 異步請求回調接口

*/

public void updateMembers(long list_id, long uid, String group_description, RequestListener listener) {

WeiboParameters params = buildMembersParams(list_id, uid);

if (!TextUtils.isDigitsOnly(group_description)) {

params.put("group_description", group_description);

}

requestAsync(SERVER_URL_PRIX + "/members/update.json", params, HTTPMETHOD_POST, listener);

}

開發者ID:liying2008,項目名稱:Simpler,代碼行數:16,

注:本文中的android.text.TextUtils.isDigitsOnly方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

优化这个方法:private View getPopupWindowContentView(LayoutElementParcelable file) { // 一个自定义的布局,作为显示的内容 int layoutId = R.layout.popup_open_file_layout; // 布局ID View contentView = LayoutInflater.from(this).inflate(layoutId, null); // 点击重命名 contentView.findViewById(R.id.open_file_menu_rename).setOnClickListener(v -> { if (mPopupWindow != null) { mPopupWindow.dismiss(); } XLog.tag(TAG).i("popup click:rename"); checkDir(file, 0); }); // 点击删除 contentView.findViewById(R.id.open_file_menu_delete).setOnClickListener(v -> { if (mPopupWindow != null) { mPopupWindow.dismiss(); } XLog.tag(TAG).i("popup click:delete"); checkDir(file, 1); }); // 设置收藏按钮文字 收藏||取消收藏 String collectPath = ""; if (mCollects != null) { collectPath = mCollects.get(file.desc); } if (TextUtils.isEmpty(collectPath)) { collectPath = ""; } // 点击 收藏||取消收藏 TextView open_file_menu_collect = contentView.findViewById(R.id.open_file_menu_collect); String finalCollectPath = collectPath; open_file_menu_collect.setOnClickListener(v -> { if (mPopupWindow != null) { mPopupWindow.dismiss(); } if (finalCollectPath.equals(file.desc)) { XLog.tag(TAG).i("popup click:unCollect"); } else { XLog.tag(TAG).i("popup click:collect"); saveFileBrowseRecord(file); } }); if (collectPath.equals(file.desc)) { open_file_menu_collect.setText(getString(R.string.file_browser_un_collect)); } else { open_file_menu_collect.setText(getString(R.string.file_browser_collect)); } if (mTransferType == U_FTP_TO_FAB_FTP || mTransferType == FTP_U) { open_file_menu_collect.setVisibility(View.VISIBLE); } else { open_file_menu_collect.setVisibility(View.GONE); } return contentView; }
最新发布
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值