List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.google.android.apps.forscience.whistlepunk.metadata.EditTriggerFragment.java
private boolean updateLocalTriggerIfChanged(int triggerType, int triggerWhen, double triggerValue) { boolean isUpdated = false; if (mTriggerToEdit.getTriggerWhen() != triggerWhen) { mTriggerToEdit.setTriggerWhen(triggerWhen); isUpdated = true;/*from w w w . j ava 2 s . c om*/ } if (mTriggerToEdit.getValueToTrigger() != triggerValue) { mTriggerToEdit.setValueToTrigger(triggerValue); isUpdated = true; } if (mTriggerToEdit.getActionType() != triggerType) { mTriggerToEdit.setTriggerActionType(triggerType); isUpdated = true; } if (triggerType == TriggerInformation.TRIGGER_ACTION_NOTE) { String noteText = String.valueOf(mNoteValue.getText()); if (!TextUtils.equals(noteText, mTriggerToEdit.getNoteText())) { mTriggerToEdit.setNoteText(String.valueOf(mNoteValue.getText())); isUpdated = true; } } else if (triggerType == TriggerInformation.TRIGGER_ACTION_ALERT) { int[] alertTypes = getCurrentAlertTypes(); if (!SensorTrigger.hasSameAlertTypes(alertTypes, mTriggerToEdit.getAlertTypes())) { mTriggerToEdit.setAlertTypes(alertTypes); isUpdated = true; } } return isUpdated; }
From source file:com.meetingninja.csse.database.UserDatabaseAdapter.java
public static Schedule parseSchedule(JsonNode node) { // Initialize ObjectMapper Schedule sched = null;/*from w ww . j a v a 2 s .c o m*/ Event event = null; // task or meeting final JsonNode scheduleArray = node.get(Keys.User.SCHEDULE); JsonNode _id; if (scheduleArray.isArray()) { sched = new Schedule(); // start parsing a schedule for (final JsonNode meetingOrTaskNode : scheduleArray) { if ((_id = meetingOrTaskNode.get(Keys._ID)) != null) { // Get the type of event String type = JsonUtils.getJSONValue(meetingOrTaskNode, Keys.TYPE); if (TextUtils.equals(type, "meeting")) { event = new Meeting(); } else if (TextUtils.equals(type, "task")) { event = new Task(); } if (event != null) { event.setID(_id.asText()); event.setTitle(JsonUtils.getJSONValue(meetingOrTaskNode, Keys.Meeting.TITLE)); event.setDescription(JsonUtils.getJSONValue(meetingOrTaskNode, Keys.Meeting.DESC)); event.setStartTime(JsonUtils.getJSONValue(meetingOrTaskNode, Keys.Meeting.START)); event.setEndTime(JsonUtils.getJSONValue(meetingOrTaskNode, Keys.Meeting.END)); // Add event to the schedule if (event instanceof Meeting) sched.addMeeting((Meeting) event); else if (event instanceof Task) sched.addTask((Task) event); else Log.w(TAG + "> getSchedule", "Event cast failure"); } } } // end for } return sched; }
From source file:com.hiqes.andele.Andele.java
/** * After calling {@link #checkAndExecute}, Andele may have requested the required * permissions for the ProtectedAction. This is an asynchronous operation * and will ultimately provide a response via the owner (Activity, Fragment, * etc.) The app must properly call this method from the owner's * callback first to determine if this is a permission request that Andele * is handling. If the app is using Andele for all permissions handling * (and it should!) then simply call through to this method and do nothing * else./* w w w. j av a 2s . c o m*/ * <p> * Note that for Activities where permissions are being requested (this * includes AppCompatActivity derivatives), care must be taken when * Fragments are also in use or if you decided to mix and handle some * permissions work yourself. The best practice is to call through to * {@code onRequestPermissionsResult()} and if it returns {@code false} * call through to the superclass: * <pre> * {@code * @Override * public static void onRequestPermissionsResult(int reqCode, String[] permissions, int[] grantResults) { * if (!Andele.onRequestPermissionsResult(reqCode, permissions, grantResults)) { * super.onRequestPermissionsResult(reqCode, permissions, grantResults); * } * } * } * </pre> * @param reqCode The request code for the permissions request * @param permissions The array of permissions which were requested * @param grantResults The results of the permissions request * @return true if this method handled the results, otherwise false */ public static boolean onRequestPermissionsResult(int reqCode, String[] permissions, int[] grantResults) { boolean handled = false; Request req; // Lookup the code, remove the node if there, complain if it doesn't exist req = sReqMgr.removeRequest(reqCode); if (req == null) { Log.w(TAG, "onRequestPermissionsResult: request not found for code " + reqCode); } else { ProtectedAction[] reqActions = req.getActions(); int actionCount = req.getActionCount(); for (int i = 0; i < permissions.length; i++) { String curPerm = permissions[i]; for (int j = 0; j < actionCount; j++) { ProtectedAction curAction = reqActions[j]; if (!TextUtils.equals(curAction.mPermDetails.mPermission, curPerm)) { continue; } Message msg; // Found a match with the request, fire up // the right message to deal with it. if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { // Call back the action handler, let them know // the grant was done. curAction.mListener.onPermissionGranted(curAction.mPermDetails); // Now allow the action to take place. Use the // request's handler for this since the original // execute request could have come on a different // thread. msg = new Message(); msg.what = MSG_DO_ACTION; msg.obj = curAction; req.getHandler().sendMessage(msg); } else { // The permission request was denied. Now figure out // what to show the user, if anything. PermissionUse curUsage = curAction.mPermDetails.mUsage; if (curUsage == PermissionUse.CRITICAL) { // If the permission is CRITICAL we need to inform // the user this is a big problem. showDeniedCritical(req, j); continue; } else if (curUsage == PermissionUse.ESSENTIAL) { // If this is an ESSENTIAL permission then remind // the user of the problems with denial. showDeniedReminder(req, j); continue; } else if (req.getOwner().shouldShowRequestPermissionRationale(curPerm)) { // This permission covers a secondary type of feature // so as long as the user is open to feedback go // ahead and provide it. showDeniedFeedback(req, j); continue; } // If we get here there was either no UI to show for // this action or the app disabled UX helper. notifyDenied(curAction); } } } handled = true; } return handled; }
From source file:com.xandy.calendar.month.SimpleDayPickerFragment.java
/** * Sets the month displayed at the top of this view based on time. Override * to add custom events when the title is changed. * * @param time A day in the new focus month. * @param updateHighlight TODO(epastern): *///from w w w . j a v a2 s.c om protected void setMonthDisplayed(Time time, boolean updateHighlight) { CharSequence oldMonth = mMonthName.getText(); mMonthName.setText(Utils.formatMonthYear(mContext, time)); mMonthName.invalidate(); if (!TextUtils.equals(oldMonth, mMonthName.getText())) { mMonthName.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); } mCurrentMonthDisplayed = time.month; if (updateHighlight) { mAdapter.updateFocusMonth(mCurrentMonthDisplayed); } }
From source file:android.support.designox.widget.TextInputLayout.java
/** * Sets an error message that will be displayed below our {@link EditText}. If the * {@code error} is {@code null}, the error message will be cleared. * <p>//from w w w . j ava2 s . co m * If the error functionality has not been enabled via {@link #setErrorEnabled(boolean)}, then * it will be automatically enabled if {@code error} is not empty. * * @param error Error message to display, or null to clear * * @see #getError() */ public void setError(@Nullable final CharSequence error) { if (TextUtils.equals(mError, error)) { // If we already have the same error, ignore return; } mError = error; if (!mErrorEnabled) { if (TextUtils.isEmpty(error)) { // If error isn't enabled, and the error is empty, just return return; } // Else, we'll assume that they want to enable the error functionality setErrorEnabled(true); } // Only animate if we've been laid out already final boolean animate = ViewCompat.isLaidOut(this); mErrorShown = !TextUtils.isEmpty(error); if (mErrorShown) { mErrorView.setText(error); mErrorView.setVisibility(VISIBLE); if (animate) { if (ViewCompat.getAlpha(mErrorView) == 1f) { // If it's currently 100% show, we'll animate it from 0 ViewCompat.setAlpha(mErrorView, 0f); } ViewCompat.animate(mErrorView).alpha(1f).setDuration(ANIMATION_DURATION) .setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { view.setVisibility(VISIBLE); } }).start(); } } else { if (mErrorView.getVisibility() == VISIBLE) { if (animate) { ViewCompat.animate(mErrorView).alpha(0f).setDuration(ANIMATION_DURATION) .setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { mErrorView.setText(error); view.setVisibility(INVISIBLE); } }).start(); } else { mErrorView.setVisibility(INVISIBLE); } } } updateEditTextBackground(); updateLabelState(true); }
From source file:com.tr4android.support.extension.widget.CollapsingTextHelper.java
private void calculateUsingTextSize(final float textSize) { if (mText == null) return;/*from w w w. j a v a2 s.co m*/ final float availableWidth = lerp(mExpandedBounds.width(), mCollapsedBounds.width(), mExpandedFraction, mTextSizeInterpolator); final float newTextSize; boolean updateDrawText = false; if (isClose(textSize, mCollapsedTextSize)) { newTextSize = mCollapsedTextSize; mScale = 1f; if (mCurrentTypeface != mCollapsedTypeface) { mCurrentTypeface = mCollapsedTypeface; updateDrawText = true; } } else { newTextSize = mExpandedTextSize; if (mCurrentTypeface != mExpandedTypeface) { mCurrentTypeface = mExpandedTypeface; updateDrawText = true; } if (isClose(textSize, mExpandedTextSize)) { // If we're close to the expanded text size, snap to it and use a scale of 1 mScale = 1f; } else { // Else, we'll scale down from the expanded text size mScale = textSize / mExpandedTextSize; } } if (availableWidth > 0) { updateDrawText = (mCurrentTextSize != newTextSize) || mBoundsChanged || updateDrawText; mCurrentTextSize = newTextSize; mBoundsChanged = false; } if (mTextToDraw == null || updateDrawText) { mTextPaint.setTypeface(mCurrentTypeface); } // Now we update the text ellipsis... mTextPaint.setTextSize(textSize); final CharSequence title = TextUtils.ellipsize(mText, mTextPaint, availableWidth, TextUtils.TruncateAt.END); if (!TextUtils.equals(title, mTextToDraw)) { mTextToDraw = title; mIsRtl = calculateIsRtl(mTextToDraw); } mTextPaint.setTextSize(mCurrentTextSize); }
From source file:com.granita.tasks.ViewTaskFragment.java
@SuppressLint("NewApi") @Override//from w w w . ja v a 2 s .c om public void onContentLoaded(ContentSet contentSet) { if (contentSet.containsKey(Tasks.ACCOUNT_TYPE)) { mListColor = TaskFieldAdapters.LIST_COLOR.get(contentSet); ((Callback) getActivity()).updateColor(darkenColor2(mListColor)); if (VERSION.SDK_INT >= 11) { updateColor((float) mRootView.getScrollY() / ((ActionBarActivity) getActivity()).getSupportActionBar().getHeight()); } Activity activity = getActivity(); int newStatus = TaskFieldAdapters.STATUS.get(contentSet); if (VERSION.SDK_INT >= 11 && activity != null && (mOldStatus != -1 && mOldStatus != newStatus || mOldStatus == -1 && TaskFieldAdapters.IS_CLOSED.get(mContentSet))) { // new need to update the options menu, because the status of the task has changed activity.invalidateOptionsMenu(); } mOldStatus = newStatus; if (mModel == null || !TextUtils.equals(mModel.getAccountType(), contentSet.getAsString(Tasks.ACCOUNT_TYPE))) { Sources.loadModelAsync(mAppContext, contentSet.getAsString(Tasks.ACCOUNT_TYPE), this); } else { // the model didn't change, just update the view postUpdateView(); } } }
From source file:com.jefftharris.passwdsafe.PasswdSafeOpenFileFragment.java
/** * Handle when the open task is finished */// w w w.ja va 2 s . c om private void openTaskFinished(OpenResult result) { if (itsOpenTask == null) { return; } itsOpenTask = null; if (result == null) { cancelFragment(false); return; } if (result.itsFileData != null) { switch (itsSaveChange) { case ADD: { if (result.itsKeygenError != null) { String msg = getString(R.string.password_save_canceled_key_error, result.itsKeygenError.getLocalizedMessage()); PasswdSafeUtil.showErrorMsg(msg, getContext()); break; } cancelSavedPasswordUsers(); itsAddSavedPasswordUser = new AddSavedPasswordUser(result); itsSavedPasswordsMgr.startPasswordAccess(getFileUri(), itsAddSavedPasswordUser); setPhase(Phase.SAVING_PASSWORD); break; } case REMOVE: { itsSavedPasswordsMgr.removeSavedPassword(getFileUri()); finishFileOpen(result.itsFileData); break; } case NONE: { finishFileOpen(result.itsFileData); break; } } } else { Exception e = result.itsError; if (((e instanceof IOException) && TextUtils.equals(e.getMessage(), "Invalid password")) || (e instanceof InvalidPassphraseException)) { if (itsRetries++ < 5) { TextInputUtils.setTextInputError(getString(R.string.invalid_password), itsPasswordInput); if (itsErrorClearingWatcher == null) { itsErrorClearingWatcher = new ErrorClearingWatcher(); itsPasswordEdit.addTextChangedListener(itsErrorClearingWatcher); } } else { PasswdSafeUtil.showFatalMsg(getString(R.string.invalid_password), getActivity(), false); } } else { String msg = e.toString(); PasswdSafeUtil.showFatalMsg(e, msg, getActivity()); } setPhase(Phase.WAITING_PASSWORD); } }
From source file:demo.design.TextInputLayout.java
/** * Sets an error message that will be displayed below our {@link EditText}. If the * {@code error} is {@code null}, the error message will be cleared. * <p>//from w w w . j av a2 s. c o m * If the error functionality has not been enabled via {@link #setErrorEnabled(boolean)}, then * it will be automatically enabled if {@code error} is not empty. * * @param error Error message to display, or null to clear * * @see #getError() */ public void setError(@Nullable final CharSequence error) { mError = error; if (!mErrorEnabled) { if (TextUtils.isEmpty(error)) { // If error isn't enabled, and the error is empty, just return return; } // Else, we'll assume that they want to enable the error functionality setErrorEnabled(true); } // Only animate if we've been laid out already and we have a different error final boolean animate = ViewCompat.isLaidOut(this) && !TextUtils.equals(mErrorView.getText(), error); mErrorShown = !TextUtils.isEmpty(error); if (mErrorShown) { mErrorView.setText(error); mErrorView.setVisibility(VISIBLE); if (animate) { if (ViewCompat.getAlpha(mErrorView) == 1f) { // If it's currently 100% show, we'll animate it from 0 ViewCompat.setAlpha(mErrorView, 0f); } ViewCompat.animate(mErrorView).alpha(1f).setDuration(ANIMATION_DURATION) .setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { view.setVisibility(VISIBLE); } }).start(); } else { // Set alpha to 1f, just in case ViewCompat.setAlpha(mErrorView, 1f); } } else { if (mErrorView.getVisibility() == VISIBLE) { if (animate) { ViewCompat.animate(mErrorView).alpha(0f).setDuration(ANIMATION_DURATION) .setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { mErrorView.setText(error); view.setVisibility(INVISIBLE); } }).start(); } else { mErrorView.setText(error); mErrorView.setVisibility(INVISIBLE); } } } updateEditTextBackground(); updateLabelState(true); }
From source file:com.android.calendar.month.SimpleDayPickerFragment.java
/** * Sets the month displayed at the top of this view based on time. Override * to add custom events when the title is changed. * * @param time/* w w w . j av a2 s .com*/ * A day in the new focus month. * @param updateHighlight * TODO(epastern): */ protected void setMonthDisplayed(Time time, int jMonth, boolean updateHighlight) { CharSequence oldMonth = mMonthName.getText(); mMonthName.setText(Utils.formatMonthYear(mContext, time)); mMonthName.invalidate(); if (!TextUtils.equals(oldMonth, mMonthName.getText())) { mMonthName.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); } mCurrentMonthDisplayed = jMonth; if (updateHighlight) { mAdapter.updateFocusMonth(mCurrentMonthDisplayed); } }