當前位置: 首頁>>代碼示例>>Java>>正文


Java Patterns類代碼示例

本文整理匯總了Java中android.util.Patterns的典型用法代碼示例。如果您正苦於以下問題:Java Patterns類的具體用法?Java Patterns怎麽用?Java Patterns使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: onClick

import android.util.Patterns; //導入依賴的package包/類
@Override
public void onClick(View widget) {
    try {
        Intent intent = new Intent();
        Uri uri;
        if (Patterns.WEB_URL.matcher(clickUrl).find()) {
            uri = Uri.parse(CustomTextView.makeWebUrl(clickUrl));
        } else {
            uri = Uri.parse(clickUrl);
        }
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(uri);
        if (Utils.isIntentAvailable(mContext, intent))
            mContext.startActivity(intent);
        else
            Toast.makeText(mContext, mContext.getString(R.string.kf5_no_file_found_hint), Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:21,代碼來源:CustomClickSpan.java

示例2: toNumberStringArray

import android.util.Patterns; //導入依賴的package包/類
public @NonNull String[] toNumberStringArray(boolean scrub) {
  String[] recipientsArray     = new String[recipients.size()];
  Iterator<Recipient> iterator = recipients.iterator();
  int i                        = 0;

  while (iterator.hasNext()) {
    String number = iterator.next().getNumber();

    if (scrub && number != null &&
        !Patterns.EMAIL_ADDRESS.matcher(number).matches() &&
        !GroupUtil.isEncodedGroup(number))
    {
      number = number.replaceAll("[^0-9+]", "");
    }

    recipientsArray[i++] = number;
  }

  return recipientsArray;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:21,代碼來源:Recipients.java

示例3: validLoginFields

import android.util.Patterns; //導入依賴的package包/類
/**
 * Check if the email and password are valid before login in
 * @return a boolean indicating if the login/password are in valid state
 */
private boolean validLoginFields() {

    String email = mEmailAutoComplete.getText().toString();
    String password = mPasswordEditText.getText().toString();
    Boolean validFields = true;

    if (TextUtils.isEmpty(email) ||
            !Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        validFields = false;
        mEmailAutoComplete.setError(getString(R.string.invalid_email_error));
    }

    if (TextUtils.isEmpty(password)) {
        validFields = false;
        mPasswordEditText.setError(getString(R.string.empty_password_error));
    }

    return validFields;
}
 
開發者ID:codingdojoangola,項目名稱:cda-app,代碼行數:24,代碼來源:LoginActivity.java

示例4: getUserEmail

import android.util.Patterns; //導入依賴的package包/類
private ArrayList<String> getUserEmail(){

		ArrayList<String> email = new ArrayList<String>();

		Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
		Account[] accounts = AccountManager.get(VerifyOTP.this).getAccounts();
		for (Account account : accounts) {
			if (emailPattern.matcher(account.name).matches()) {
				String possibleEmail = account.name;
				if(possibleEmail != null)
					if(possibleEmail.length() !=0 ){
						email.add(possibleEmail);
					}
			}
		}		
		return email;

	}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:19,代碼來源:VerifyOTP.java

示例5: validateInput

import android.util.Patterns; //導入依賴的package包/類
private boolean validateInput(String email, String userName, String password) {
    if (email.isEmpty()) {
        mEmail.setError(getString(R.string.text_email_cannot_be_empty));
        return false;
    }
    if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        mEmail.setError(getString(R.string.text_email_format_error));
        return false;
    }
    if (userName.isEmpty()) {
        mUserName.setError(getString(R.string.text_username_cannot_be_empty));
        return false;
    }
    if (password.isEmpty()) {
        mUserName.setError(getString(R.string.text_password_cannot_be_empty));
        return false;
    }
    if (password.length() < 6) {
        mPassword.setError(getString(R.string.nodebb_error_change_password_error_length));
        return false;
    }
    return true;
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:24,代碼來源:RegisterActivity.java

示例6: checkValues

import android.util.Patterns; //導入依賴的package包/類
private boolean checkValues() {
    if(mAddress.getText() == null || !Patterns.WEB_URL.matcher(mAddress.getText()).matches()) {
        Toast.makeText(getActivity(), getResources().getString(R.string.fragment_widget_configure_err_address), Toast.LENGTH_SHORT).show();
        return false;
    }

    if(mInterval.getValue() == null) {
        Toast.makeText(getActivity(), getResources().getString(R.string.fragment_widget_configure_err_interval), Toast.LENGTH_SHORT).show();
        return false;
    }

    if(mMaxPings.getValue() == null) {
        Toast.makeText(getActivity(), getResources().getString(R.string.fragment_widget_configure_err_max_pings), Toast.LENGTH_SHORT).show();
        return false;
    }
    return true;
}
 
開發者ID:abicelis,項目名稱:PingWidget,代碼行數:18,代碼來源:PingWidgetConfigureFragment.java

示例7: onClick

import android.util.Patterns; //導入依賴的package包/類
@Override
public void onClick(View v) {
    int id = v.getId();
    switch(id) {
        case R.id.dialog_edit_link_attachment_cancel:
            //Hide keyboard
            ((InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mLink.getWindowToken(), 0);

            dismiss();
            break;

        case R.id.dialog_edit_link_attachment_ok:
            String link = mLink.getText().toString().trim();
            if(!link.isEmpty() && Patterns.WEB_URL.matcher(link).matches()) {
                mListener.onFinishEditLinkAttachmentDialog(mLink.getText().toString());

                //Hide keyboard
                ((InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mLink.getWindowToken(), 0);

                dismiss();
            } else {
                Toast.makeText(getActivity(), getResources().getString(R.string.dialog_edit_link_error_empty_text), Toast.LENGTH_SHORT).show();
            }
            break;
    }
}
 
開發者ID:abicelis,項目名稱:Remindy,代碼行數:27,代碼來源:EditLinkAttachmentDialogFragment.java

示例8: actionsToResults

import android.util.Patterns; //導入依賴的package包/類
@Override
protected ObservableTransformer<Action, Result> actionsToResults() {
    return upstream -> upstream.ofType(EmailRegisterActions.EmailRegister.class)
            .flatMap(action -> {
                if (!Patterns.EMAIL_ADDRESS.matcher(action.getEmail()).matches()) {
                    return Observable.just(Result.<Boolean, EmailRegisterActions.EmailRegister>error(action, new FormValidationException("Must enter a valid email address!")));
                }
                if (!Pattern.compile("[0-9a-zA-Z]{6,}").matcher(action.getPassword()).matches()) {
                    return Observable.just(Result.<Boolean, EmailRegisterActions.EmailRegister>error(action, new FormValidationException("Password must be at least 6 characters long!")));
                }
                if (!TextUtils.equals(action.getPassword(), action.getPasswordConfirm())) {
                    return Observable.just(Result.<Boolean, EmailRegisterActions.EmailRegister>error(action, new FormValidationException("Passwords don't match!")));
                }

                return useCase.performAction(action)
                        .onErrorReturn(throwable -> Result.error(action, throwable))
                        .startWith(Result.<Boolean, EmailRegisterActions.EmailRegister>loading(action));
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io());
}
 
開發者ID:sztomek,項目名稱:cleanarchitecture-unidirectional,代碼行數:22,代碼來源:EmailRegisterPresenter.java

示例9: validate

import android.util.Patterns; //導入依賴的package包/類
private void validate() {
  mUserName = mInputName.getText().toString().trim();
  mEmali = mInputEmali.getText().toString().trim();
  mPwd = mInputPwd.getText().toString().trim();

  if (TextUtils.isEmpty(mUserName) || mUserName.length() < 3) {
    mNameLayout.setError("至少3個字符");
  } else {
    mNameLayout.setError(null);
  }

  if (TextUtils.isEmpty(mEmali) || !Patterns.EMAIL_ADDRESS.matcher(mEmali).matches()) {
    mEmailLayout.setError("請輸入合法的電子郵箱");
  } else {
    mEmailLayout.setError(null);
  }

  if (TextUtils.isEmpty(mPwd) || mPwd.length() < 6 || mPwd.length() > 10) {
    mPwdLayout.setError("密碼長度在6到10位之間");
  } else {
    mPwdLayout.setError(null);
  }
}
 
開發者ID:liuguoquan727,項目名稱:android-study,代碼行數:24,代碼來源:TextInputActivity.java

示例10: validate

import android.util.Patterns; //導入依賴的package包/類
private boolean validate() {
    KLog.d("Login....");
    boolean valid = true;
    String email = _emailText.getText().toString();
    String password = _passwordText.getText().toString();

    //這是一個正則表達式
    if (email.isEmpty() || !Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        _emailText.setError("enter a valid email address");
        valid = false;
    } else {
        _emailText.setError(null);
    }

    if (password.isEmpty() || password.length() < 6) {
        _passwordText.setError("the password length must be greater than six");
        valid = false;
    } else {
        _passwordText.setError(null);
    }

    return valid;
}
 
開發者ID:haihaio,項目名稱:AmenEye,代碼行數:24,代碼來源:LoginActivity.java

示例11: checkURL

import android.util.Patterns; //導入依賴的package包/類
public static boolean checkURL(CharSequence input) {
    if (TextUtils.isEmpty(input)) {
        return false;
    }
    Pattern URL_PATTERN = Patterns.WEB_URL;
    boolean isURL = URL_PATTERN.matcher(input).matches();
    if (!isURL) {
        String urlString = input + "";
        if (URLUtil.isNetworkUrl(urlString)) {
            try {
                new URL(urlString);
                isURL = true;
            } catch (Exception e) {
            }
        }
    }
    return isURL;
}
 
開發者ID:zzzmobile,項目名稱:VideoDownloader-Android,代碼行數:19,代碼來源:iUtils.java

示例12: showNotificationMessage

import android.util.Patterns; //導入依賴的package包/類
public void showNotificationMessage(final String title, final String message, final String timeStamp, Intent intent, String imageUrl) {
    if (TextUtils.isEmpty(message))
        return;
    final int icon = R.drawable.logo;
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    final PendingIntent resultPendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
    if (!TextUtils.isEmpty(imageUrl)) {
        if (imageUrl != null && imageUrl.length() > 4 && Patterns.WEB_URL.matcher(imageUrl).matches()) {
            Bitmap bitmap = getBitmapFromURL(imageUrl);
            if (bitmap != null) {
                showBigNotification(bitmap, mBuilder, icon, title, message, timeStamp, resultPendingIntent);
            } else {
                showSmallNotification(mBuilder, icon, title, message, timeStamp, resultPendingIntent);
            }
        }
    } else {
        showSmallNotification(mBuilder, icon, title, message, timeStamp, resultPendingIntent);
    }
}
 
開發者ID:anandwana001,項目名稱:Tech-Jalsa,代碼行數:21,代碼來源:NotificationUtils.java

示例13: setIntentFicUrl

import android.util.Patterns; //導入依賴的package包/類
private void setIntentFicUrl() {
    ficUrl = "";
    Intent intent = getIntent();
    if (intent != null) {
        String intentType = intent.getType();
        String intentAction = intent.getAction();
        Log.d("ficsaveM/intentReceived", intentAction + " " + intent.toString());
        if (Intent.ACTION_SEND.equals(intentAction) && intentType != null && "text/plain".equals(intentType)) {
            Matcher m = Patterns.WEB_URL.matcher(intent.getStringExtra(Intent.EXTRA_TEXT));
            while (m.find()) {
                String url = m.group();
                ficUrl = url;
                Log.d("ficsaveM/setIntFicUrl", "URL extracted: " + url);

                mGTracker.send(new HitBuilders.EventBuilder()
                        .setCategory(MAIN_PAGE_CATEGORY)
                        .setAction("Fic Url Set")
                        .setLabel(URL_LABEL + ficUrl)
                        .setValue(1)
                        .build());
                Bundle bundle = new Bundle();
                bundle.putString("Url", ficUrl);
                mFTracker.logEvent("FicUrlSet", bundle);
            }

        }
    }
}
 
開發者ID:xRahul,項目名稱:FicsaveMiddleware,代碼行數:29,代碼來源:MainActivity.java

示例14: sendVerificationClicked

import android.util.Patterns; //導入依賴的package包/類
@Override
public void sendVerificationClicked() {

    showLog("CLICKED");

    String email = view.getEmail();

    if(email.isEmpty()){
        view.setEmailError();
        return;
    }

    if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        view.clearCurrentEmailText();
        view.setEmailError();
        return;
    }

    // show a progress dialog
    view.showProgress();

    Worker.sendEmailVerification(this, email);
    view.clearCurrentEmailText();
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:25,代碼來源:Presenter.java

示例15: loginClicked

import android.util.Patterns; //導入依賴的package包/類
@Override
public void loginClicked() {
    String email = view.getEmail();
    String password = view.getPassword();

    if (TextUtils.isEmpty(email)) {
        view.setEmailError(R.string.empty_email);
        return;
    }

    if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        view.setEmailError(R.string.incorrect_email);
        return;
    }

    if (TextUtils.isEmpty(password)) {
        view.setPasswordError(R.string.empty_password);
        return;
    }

    view.showProgressDialog();
    usersRepository.login(email, password, this);
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:24,代碼來源:Presenter.java


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