List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.taobao.weex.ui.component.WXComponent.java
public void setVisibility(String visibility) { View view;//from w ww .j a v a2 s. c om if ((view = getRealView()) != null) { if (TextUtils.equals(visibility, Constants.Value.VISIBLE)) { view.setVisibility(View.VISIBLE); } else if (TextUtils.equals(visibility, Constants.Value.HIDDEN)) { view.setVisibility(View.GONE); } } }
From source file:com.android.messaging.ui.conversation.ConversationFragment.java
@Override public void closeConversation(final String conversationId) { if (TextUtils.equals(conversationId, mConversationId)) { mHost.onFinishCurrentConversation(); // TODO: Explicitly transition to ConversationList (or just go back)? }//from w w w . j av a2s . co m }
From source file:im.vector.fragments.VectorRoomSettingsFragment.java
/** *//*from w ww. ja v a 2s . c om*/ private void onRoomNotificationsPreferenceChanged() { // sanity check if ((null == mRoom) || (null == mBingRulesManager)) { return; } String value = mRoomNotificationsPreference.getValue(); BingRulesManager.RoomNotificationState updatedState; if (TextUtils.equals(value, getString(R.string.room_settings_all_messages_noisy))) { updatedState = BingRulesManager.RoomNotificationState.ALL_MESSAGES_NOISY; } else if (TextUtils.equals(value, getString(R.string.room_settings_all_messages))) { updatedState = BingRulesManager.RoomNotificationState.ALL_MESSAGES; } else if (TextUtils.equals(value, getString(R.string.room_settings_mention_only))) { updatedState = BingRulesManager.RoomNotificationState.MENTIONS_ONLY; } else { updatedState = BingRulesManager.RoomNotificationState.MUTE; } // update only, if values are different if (mBingRulesManager.getRoomNotificationState(mRoom.getRoomId()) != updatedState) { displayLoadingView(); mBingRulesManager.updateRoomNotificationState(mRoom.getRoomId(), updatedState, new BingRulesManager.onBingRuleUpdateListener() { @Override public void onBingRuleUpdateSuccess() { Log.d(LOG_TAG, "##onRoomNotificationsPreferenceChanged(): update succeed"); hideLoadingView(UPDATE_UI); } @Override public void onBingRuleUpdateFailure(String errorMessage) { Log.w(LOG_TAG, "##onRoomNotificationsPreferenceChanged(): BingRuleUpdateFailure"); hideLoadingView(DO_NOT_UPDATE_UI); } }); } }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
/** * Check if the given MIME-type appears in the list of excluded MIME-types * that the most-recent caller requested. *//*www . j ava 2s . com*/ private boolean isMimeExcluded(String mimeType) { if (mExcludeMimes == null) return false; for (String excludedMime : mExcludeMimes) { if (TextUtils.equals(excludedMime, mimeType)) { return true; } } return false; }
From source file:com.android.utils.AccessibilityNodeInfoUtils.java
/** * Returns a fresh copy of node by traversing the given window for a similar node. * For example, the node that you want might be in a popup window that has closed and re-opened, * causing the accessibility IDs of its views to be different. * Note: you must recycle the node that is returned from this method. *///from ww w .ja v a 2 s . c o m public static AccessibilityNodeInfoCompat refreshNodeFuzzy(final AccessibilityNodeInfoCompat node, AccessibilityWindowInfo window) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return null; } if (window == null || node == null) { return null; } AccessibilityNodeInfo root = window.getRoot(); if (root == null) { return null; } NodeFilter similarFilter = new NodeFilter() { @Override public boolean accept(AccessibilityNodeInfoCompat other) { return other != null && TextUtils.equals(node.getText(), other.getText()); } }; AccessibilityNodeInfoCompat rootCompat = new AccessibilityNodeInfoCompat(root); try { return getMatchingDescendant(rootCompat, similarFilter); } finally { rootCompat.recycle(); } }
From source file:im.vector.activity.VectorRoomActivity.java
/** * Send the editText text./*from w w w . j ava2 s .c o m*/ */ private void sendTextMessage() { String body = mEditText.getText().toString().trim(); // markdownToHtml does not manage properly urls with underscores // so we replace the urls by a tmp value before parsing it. List<String> urls = VectorUtils.listURLs(body); List<String> tmpUrlsValue = new ArrayList<>(); String modifiedBody = body; if (urls.size() > 0) { // sort by length -> largest before Collections.sort(urls, new Comparator<String>() { @Override public int compare(String str1, String str2) { return str2.length() - str1.length(); } }); for (String url : urls) { String tmpValue = "url" + Math.abs(url.hashCode()); modifiedBody = modifiedBody.replace(url, tmpValue); tmpUrlsValue.add(tmpValue); } } String html = mAndDown.markdownToHtml(checkHashes(modifiedBody)); if (null != html) { for (int index = 0; index < tmpUrlsValue.size(); index++) { html = html.replace(tmpUrlsValue.get(index), urls.get(index)); } html = html.trim(); if (html.startsWith("<p>")) { html = html.substring("<p>".length()); } if (html.endsWith("</p>\n")) { html = html.substring(0, html.length() - "</p>\n".length()); } else if (html.endsWith("</p>")) { html = html.substring(0, html.length() - "</p>".length()); } if (TextUtils.equals(html, body)) { html = null; } else { // remove the markdowns body = Html.fromHtml(html).toString(); } } // hide the header room enableActionBarHeader(HIDE_ACTION_BAR_HEADER); sendMessage(body, html, Message.FORMAT_MATRIX_HTML); mEditText.setText(""); }
From source file:im.vector.fragments.VectorRoomSettingsFragment.java
/** * Action when updating the room name. *//*from ww w. j a v a2s. c o m*/ private void onRoomNamePreferenceChanged() { // sanity check if ((null == mRoom) || (null == mSession) || (null == mRoomNameEditTxt)) { return; } // get new and previous values String previousName = mRoom.getLiveState().name; String newName = mRoomNameEditTxt.getText(); // update only, if values are different if (!TextUtils.equals(previousName, newName)) { displayLoadingView(); Log.d(LOG_TAG, "##onRoomNamePreferenceChanged to " + newName); mRoom.updateName(newName, mUpdateCallback); } }
From source file:im.vector.fragments.VectorRoomSettingsFragment.java
/** * Action when updating the room topic. *///from w ww .jav a2 s . c o m private void onRoomTopicPreferenceChanged() { // sanity check if (null == mRoom) { return; } // get new and previous values String previousTopic = mRoom.getTopic(); String newTopic = mRoomTopicEditTxt.getText(); // update only, if values are different if (!TextUtils.equals(previousTopic, newTopic)) { displayLoadingView(); Log.d(LOG_TAG, "## update topic to " + newTopic); mRoom.updateTopic(newTopic, mUpdateCallback); } }
From source file:com.android.mail.compose.ComposeActivity.java
private ReplyFromAccount getReplyFromAccountFromDraft(final Message msg) { final Address[] draftFroms = Address.parse(msg.getFrom()); final String sender = draftFroms.length > 0 ? draftFroms[0].getAddress() : ""; ReplyFromAccount replyFromAccount = null; // Do not try to check against the "default" account because the default might be an alias. for (ReplyFromAccount fromAccount : mFromSpinner.getReplyFromAccounts()) { if (TextUtils.equals(fromAccount.address, sender)) { replyFromAccount = fromAccount; break; }/* ww w . java 2 s. co m*/ } return replyFromAccount; }
From source file:com.android.messaging.datamodel.BugleDatabaseOperations.java
/** * When moving/removing an existing message update conversation metadata if necessary * @param dbWrapper db wrapper//w w w. jav a 2 s. co m * @param conversationId conversation to modify * @param messageId message that is leaving the conversation * @param shouldAutoSwitchSelfId should we try to auto-switch the conversation's self-id as a * result of this call when we see a new latest message? * @param keepArchived should we keep the conversation archived despite refresh */ @DoesNotRunOnMainThread public static void maybeRefreshConversationMetadataInTransaction(final DatabaseWrapper dbWrapper, final String conversationId, final String messageId, final boolean shouldAutoSwitchSelfId, final boolean keepArchived) { Assert.isNotMainThread(); boolean refresh = true; if (!TextUtils.isEmpty(messageId)) { refresh = false; // Look for an existing conversation in the db with this conversation id Cursor cursor = null; try { cursor = dbWrapper.query(DatabaseHelper.CONVERSATIONS_TABLE, new String[] { ConversationColumns.LATEST_MESSAGE_ID }, ConversationColumns._ID + "=?", new String[] { conversationId }, null, null, null); Assert.inRange(cursor.getCount(), 0, 1); if (cursor.moveToFirst()) { refresh = TextUtils.equals(cursor.getString(0), messageId); } } finally { if (cursor != null) { cursor.close(); } } } if (refresh) { // TODO: I think it is okay to delete the conversation if it is empty... refreshConversationMetadataInTransaction(dbWrapper, conversationId, shouldAutoSwitchSelfId, keepArchived); } }