List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:im.vector.fragments.VectorRoomSettingsFragment.java
/** * The room history readability has been updated. *///from www . j ava 2 s . co m private void onRoomHistoryReadabilityPreferenceChanged() { // sanity check if ((null == mRoom) || (null == mRoomHistoryReadabilityRulesListPreference)) { Log.w(LOG_TAG, "## onRoomHistoryReadabilityPreferenceChanged(): not processed due to invalid parameters"); return; } // get new and previous values String previousValue = mRoom.getLiveState().history_visibility; String newValue = mRoomHistoryReadabilityRulesListPreference.getValue(); if (!TextUtils.equals(newValue, previousValue)) { String historyVisibility; if (newValue.equals(getResources().getString(R.string.room_settings_read_history_entry_value_anyone))) { historyVisibility = RoomState.HISTORY_VISIBILITY_WORLD_READABLE; } else if (newValue.equals(getResources() .getString(R.string.room_settings_read_history_entry_value_members_only_option_time_shared))) { historyVisibility = RoomState.HISTORY_VISIBILITY_SHARED; } else if (newValue.equals(getResources() .getString(R.string.room_settings_read_history_entry_value_members_only_invited))) { historyVisibility = RoomState.HISTORY_VISIBILITY_INVITED; } else if (newValue.equals(getResources() .getString(R.string.room_settings_read_history_entry_value_members_only_joined))) { historyVisibility = RoomState.HISTORY_VISIBILITY_JOINED; } else { // unknown value Log.w(LOG_TAG, "## onRoomHistoryReadabilityPreferenceChanged(): unknown value:" + newValue); historyVisibility = null; } if (null != historyVisibility) { displayLoadingView(); mRoom.updateHistoryVisibility(historyVisibility, mUpdateCallback); } } }
From source file:com.android.calendar.AllInOneActivity.java
private void setTitleInActionBar(EventInfo event) { if (event.eventType != EventType.UPDATE_TITLE) { return;// w ww .ja v a 2 s .c om } final long start = event.startTime.toMillis(false /* use isDst */); final long end; if (event.endTime != null) { end = event.endTime.toMillis(false /* use isDst */); } else { end = start; } final String msg = Utils.formatDateRange(this, start, end, (int) event.extraLong); CharSequence oldDate = mDateRange.getText(); mDateRange.setText(msg); updateSecondaryTitleFields(event.selectedTime != null ? event.selectedTime.toMillis(true) : start); if (!TextUtils.equals(oldDate, msg)) { mDateRange.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); if (mShowWeekNum && mWeekTextView != null) { mWeekTextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); } } }
From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java
private void onTextChanged(CharSequence newText) { CharSequence text = mQueryTextView.getText(); mUserQuery = text;/*from w w w . j av a 2 s . com*/ boolean hasText = !TextUtils.isEmpty(text); updateSubmitButton(hasText); updateVoiceButton(!hasText); updateCloseButton(); updateSubmitArea(); if (mOnQueryChangeListener != null && !TextUtils.equals(newText, mOldQueryText)) { mOnQueryChangeListener.onQueryTextChange(newText.toString()); } mOldQueryText = newText.toString(); }
From source file:com.android.calendar.AllInOneActivity.java
private void updateSecondaryTitleFields(long visibleMillisSinceEpoch) { mShowWeekNum = Utils.getShowWeekNumber(this); mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater); if (visibleMillisSinceEpoch != -1) { int weekNum = Utils.getWeekNumberFromTime(visibleMillisSinceEpoch, this); mWeekNum = weekNum;//from www . j a v a 2s. co m } if (mShowWeekNum && (mCurrentView == ViewType.WEEK) && mIsTabletConfig && mWeekTextView != null) { String weekString = getResources().getQuantityString(R.plurals.weekN, mWeekNum, mWeekNum); mWeekTextView.setText(weekString); mWeekTextView.setVisibility(View.VISIBLE); } else if (visibleMillisSinceEpoch != -1 && mWeekTextView != null && mCurrentView == ViewType.DAY && mIsTabletConfig) { Time time = new Time(mTimeZone); time.set(visibleMillisSinceEpoch); int julianDay = Time.getJulianDay(visibleMillisSinceEpoch, time.gmtoff); time.setToNow(); int todayJulianDay = Time.getJulianDay(time.toMillis(false), time.gmtoff); String dayString = Utils.getDayOfWeekString(julianDay, todayJulianDay, visibleMillisSinceEpoch, this); mWeekTextView.setText(dayString); mWeekTextView.setVisibility(View.VISIBLE); } else if (mWeekTextView != null && (!mIsTabletConfig || mCurrentView != ViewType.DAY)) { mWeekTextView.setVisibility(View.GONE); } if (mHomeTime != null && (mCurrentView == ViewType.DAY || mCurrentView == ViewType.WEEK || mCurrentView == ViewType.AGENDA) && !TextUtils.equals(mTimeZone, Time.getCurrentTimezone())) { Time time = new Time(mTimeZone); time.setToNow(); long millis = time.toMillis(true); boolean isDST = time.isDst != 0; int flags = DateUtils.FORMAT_SHOW_TIME; if (DateFormat.is24HourFormat(this)) { flags |= DateUtils.FORMAT_24HOUR; } // Formats the time as String timeString = (new StringBuilder(Utils.formatDateRange(this, millis, millis, flags))).append(" ") .append(TimeZone.getTimeZone(mTimeZone).getDisplayName(isDST, TimeZone.SHORT, Locale.getDefault())) .toString(); mHomeTime.setText(timeString); mHomeTime.setVisibility(View.VISIBLE); // Update when the minute changes mHomeTime.removeCallbacks(mHomeTimeUpdater); mHomeTime.postDelayed(mHomeTimeUpdater, DateUtils.MINUTE_IN_MILLIS - (millis % DateUtils.MINUTE_IN_MILLIS)); } else if (mHomeTime != null) { mHomeTime.setVisibility(View.GONE); } }
From source file:com.android.mtkex.chips.BaseRecipientAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { /// M: add view holder to improve performance. DropDownListViewHolder viewHolder;/*from w ww . j a v a 2 s .com*/ /// M: get view holder from convert view. @{ if (convertView == null) { convertView = mInflater.inflate(getItemLayout(), parent, false); viewHolder = new DropDownListViewHolder(); if (convertView != null) { viewHolder.name = (TextView) convertView.findViewById(getDisplayNameId()); viewHolder.dest = (TextView) convertView.findViewById(getDestinationId()); viewHolder.destType = (TextView) convertView.findViewById(getDestinationTypeId()); viewHolder.img = (ImageView) convertView.findViewById(getPhotoId()); convertView.setTag(viewHolder); } } else { viewHolder = (DropDownListViewHolder) convertView.getTag(); } /// @} final RecipientEntry entry = getEntries().get(position); String displayName = entry.getDisplayName(); String destination = entry.getDestination(); if (TextUtils.isEmpty(displayName) || TextUtils.equals(displayName, destination)) { displayName = destination; // We only show the destination for secondary entries, so clear it // only for the first level. if (entry.isFirstLevel()) { destination = null; } } /// M: get properties from view holder. @{ final View itemView = convertView; final TextView displayNameView = viewHolder.name; final TextView destinationView = viewHolder.dest; final TextView destinationTypeView = viewHolder.destType; final ImageView imageView = viewHolder.img; /// @} displayNameView.setText(displayName); if (!TextUtils.isEmpty(destination)) { destinationView.setText(destination); } else { destinationView.setText(null); } if (destinationTypeView != null) { CharSequence destinationType = null; if (mShowPhoneAndEmail) { /// M: Current query is phone query, but there may exist email results as well. /// Hence, we need to get destinationType of email results by Queries.EMAIL. @{ if (entry.getDestinationKind() == RecipientEntry.ENTRY_KIND_EMAIL) { destinationType = Queries.EMAIL.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } else { destinationType = Queries.PHONE.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } /// @} } else { destinationType = mQuery.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } destinationTypeView.setText(destinationType); } if (entry.isFirstLevel()) { displayNameView.setVisibility(View.VISIBLE); if (imageView != null) { imageView.setVisibility(View.VISIBLE); final byte[] photoBytes = entry.getPhotoBytes(); if (photoBytes != null) { /// M: get bitmap from recipient entry Bitmap photo = entry.getBitmap(); /// M: cache bitmap if unavailable. @{ if (photo == null) { photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length); entry.setBitmap(photo); } /// @} imageView.setImageBitmap(photo); } else { imageView.setImageResource(getDefaultPhotoResource()); } } } else { displayNameView.setVisibility(View.GONE); if (imageView != null) { imageView.setVisibility(View.INVISIBLE); } } return itemView; }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // if the user toggles the contacts book permission if (TextUtils.equals(key, ContactsManager.CONTACTS_BOOK_ACCESS_KEY)) { // reset the current snapshot ContactsManager.getInstance().clearSnapshot(); }/*from www . ja va 2s.c o m*/ }
From source file:im.neon.activity.VectorRoomActivity.java
@Override public void onScroll(int firstVisibleItem, int visibleItemCount, int totalItemCount) { Event eventAtBottom = mVectorMessageListFragment.getEvent(firstVisibleItem + visibleItemCount - 1); if ((null != eventAtBottom) && ((null == mLatestDisplayedEvent) || !TextUtils.equals(eventAtBottom.eventId, mLatestDisplayedEvent.eventId))) { Log.d(LOG_TAG, "## onScroll firstVisibleItem " + firstVisibleItem + " visibleItemCount " + visibleItemCount + " totalItemCount " + totalItemCount); mLatestDisplayedEvent = eventAtBottom; // don't send receive if the app is in background if (!VectorApp.isAppInBackground()) { sendReadReceipt();//from ww w .ja v a 2 s. co m } else { Log.d(LOG_TAG, "## onScroll : the app is in background"); } } }
From source file:com.silentcircle.contacts.calllognew.CallLogAdapter.java
/** Checks whether the contact info from the call log matches the one from the contacts db. */ private boolean callLogInfoMatches(ContactInfo callLogInfo, ContactInfo info) { // The call log only contains a subset of the fields in the contacts db. // Only check those. return TextUtils.equals(callLogInfo.name, info.name) && callLogInfo.type == info.type && TextUtils.equals(callLogInfo.label, info.label); }
From source file:com.silentcircle.contacts.calllognew.CallLogAdapter.java
/** Stores the updated contact info in the call log if it is different from the current one. */ private void updateCallLogContactInfoCache(String number, String countryIso, ContactInfo updatedInfo, ContactInfo callLogInfo) {/* www.j ava 2s . c o m*/ final ContentValues values = new ContentValues(); boolean needsUpdate = false; if (callLogInfo != null) { if (!TextUtils.equals(updatedInfo.name, callLogInfo.name)) { values.put(ScCalls.CACHED_NAME, updatedInfo.name); needsUpdate = true; } if (updatedInfo.type != callLogInfo.type) { values.put(ScCalls.CACHED_NUMBER_TYPE, updatedInfo.type); needsUpdate = true; } if (!TextUtils.equals(updatedInfo.label, callLogInfo.label)) { values.put(ScCalls.CACHED_NUMBER_LABEL, updatedInfo.label); needsUpdate = true; } if (!UriUtils.areEqual(updatedInfo.lookupUri, callLogInfo.lookupUri)) { values.put(ScCalls.CACHED_LOOKUP_URI, UriUtils.uriToString(updatedInfo.lookupUri)); needsUpdate = true; } // Only replace the normalized number if the new updated normalized number isn't empty. if (!TextUtils.isEmpty(updatedInfo.normalizedNumber) && !TextUtils.equals(updatedInfo.normalizedNumber, callLogInfo.normalizedNumber)) { values.put(ScCalls.CACHED_NORMALIZED_NUMBER, updatedInfo.normalizedNumber); needsUpdate = true; } if (!TextUtils.equals(updatedInfo.number, callLogInfo.number)) { values.put(ScCalls.CACHED_MATCHED_NUMBER, updatedInfo.number); needsUpdate = true; } if (updatedInfo.photoId != callLogInfo.photoId) { values.put(ScCalls.CACHED_PHOTO_ID, updatedInfo.photoId); needsUpdate = true; } if (!TextUtils.equals(updatedInfo.formattedNumber, callLogInfo.formattedNumber)) { values.put(ScCalls.CACHED_FORMATTED_NUMBER, updatedInfo.formattedNumber); needsUpdate = true; } } else { // No previous values, store all of them. values.put(ScCalls.CACHED_NAME, updatedInfo.name); values.put(ScCalls.CACHED_NUMBER_TYPE, updatedInfo.type); values.put(ScCalls.CACHED_NUMBER_LABEL, updatedInfo.label); values.put(ScCalls.CACHED_LOOKUP_URI, UriUtils.uriToString(updatedInfo.lookupUri)); values.put(ScCalls.CACHED_MATCHED_NUMBER, updatedInfo.number); values.put(ScCalls.CACHED_NORMALIZED_NUMBER, updatedInfo.normalizedNumber); values.put(ScCalls.CACHED_PHOTO_ID, updatedInfo.photoId); values.put(ScCalls.CACHED_FORMATTED_NUMBER, updatedInfo.formattedNumber); needsUpdate = true; } if (!needsUpdate) return; if (countryIso == null) { mContext.getContentResolver().update(ScCalls.CONTENT_URI, values, ScCalls.NUMBER + " = ? AND " + ScCalls.COUNTRY_ISO + " IS NULL", new String[] { number }); } else { mContext.getContentResolver().update(ScCalls.CONTENT_URI, values, ScCalls.NUMBER + " = ? AND " + ScCalls.COUNTRY_ISO + " = ?", new String[] { number, countryIso }); } }
From source file:dk.nota.lyt.libvlc.PlaybackService.java
@MainThread public void loadUri(Uri uri) { String path = uri.toString(); if (TextUtils.equals(uri.getScheme(), "content")) { path = "file://" + Utils.getPathFromURI(uri); }/*from ww w . java 2 s . co m*/ loadLocation(path); }