List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.google.plus.samples.photohunt.ThemeViewActivity.java
/** Restarts the FetchJsonTaskLoader if the URL being fetched has changed. */ private static <T> FetchJsonTaskLoader<T> restartLoader(LoaderManager loaderMgr, int id, FetchJsonTaskLoader<T> loader, LoaderManager.LoaderCallbacks<T> callbacks, String url) { FetchJsonTaskLoader<T> result = loader; Bundle bundle = new Bundle(); bundle.putString("url", url); if (!TextUtils.equals(url, loader.getUrl())) { result = (FetchJsonTaskLoader<T>) loaderMgr.restartLoader(id, bundle, callbacks); }/* w w w . j av a 2 s . co m*/ return result; }
From source file:com.android.mail.providers.Attachment.java
public void setContentType(String contentType) { if (!TextUtils.equals(this.contentType, contentType)) { this.inferredContentType = null; this.contentType = contentType; }//from w w w. jav a2s . com }
From source file:com.skubit.android.billing.BillingServiceBinder.java
private boolean isValidType(String type) { return TextUtils.equals(type, "inapp") || TextUtils.equals(type, "subs"); }
From source file:com.android.mail.providers.Attachment.java
public boolean setName(String name) { if (!TextUtils.equals(this.name, name)) { this.inferredContentType = null; this.name = name; return true; }/* w w w . j a v a2 s. c o m*/ return false; }
From source file:com.alibaba.weex.commons.AbsWeexActivity.java
protected boolean isLocalPage() { boolean isLocalPage = true; if (mUri != null) { String scheme = mUri.getScheme(); isLocalPage = !mUri.isHierarchical() || (!TextUtils.equals(scheme, "http") && !TextUtils.equals(scheme, "https")); }//from ww w . j a v a 2 s .c o m return isLocalPage; }
From source file:com.mindmeapp.extensions.ExtensionData.java
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override/*from w w w . j ava 2 s .co m*/ public boolean equals(Object o) { if (o == null) { return false; } try { ExtensionData other = (ExtensionData) o; return other.mVisible == mVisible && other.mIcon == mIcon && objectEquals(other.mIconUri, mIconUri) && TextUtils.equals(other.mStatusToDisplay, mStatusToDisplay) && TextUtils.equals(other.mStatusToSpeak, mStatusToSpeak) && objectEquals(other.mLanguageToSpeak, mLanguageToSpeak) && objectEquals(other.mViewsToDisplay, mViewsToDisplay) && TextUtils.equals(other.mContentDescription, mContentDescription) && other.mBackground == mBackground && objectEquals(other.mBackgroundUri, mBackgroundUri); } catch (ClassCastException e) { return false; } }
From source file:im.vector.adapters.VectorMessagesAdapter.java
/** * The user taps on the action icon./*from www . ja v a2 s. c om*/ * @param event the selected event. * @param textMsg the event text * @param anchorView the popup anchor. */ @SuppressLint("NewApi") private void onMessageClick(final Event event, final String textMsg, final View anchorView) { final PopupMenu popup = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) ? new PopupMenu(mContext, anchorView, Gravity.END) : new PopupMenu(mContext, anchorView); popup.getMenuInflater().inflate(R.menu.vector_room_message_settings, popup.getMenu()); // force to display the icons try { Field[] fields = popup.getClass().getDeclaredFields(); for (Field field : fields) { if ("mPopup".equals(field.getName())) { field.setAccessible(true); Object menuPopupHelper = field.get(popup); Class<?> classPopupHelper = Class.forName(menuPopupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); break; } } } catch (Exception e) { Log.e(LOG_TAG, "onMessageClick : force to display the icons failed " + e.getLocalizedMessage()); } Menu menu = popup.getMenu(); // hide entries for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(false); } menu.findItem(R.id.ic_action_view_source).setVisible(true); menu.findItem(R.id.ic_action_vector_permalink).setVisible(true); if (!TextUtils.isEmpty(textMsg)) { menu.findItem(R.id.ic_action_vector_copy).setVisible(true); menu.findItem(R.id.ic_action_vector_quote).setVisible(true); } if (event.isUploadingMedias(mMediasCache)) { menu.findItem(R.id.ic_action_vector_cancel_upload).setVisible(true); } if (event.isDownloadingMedias(mMediasCache)) { menu.findItem(R.id.ic_action_vector_cancel_download).setVisible(true); } if (event.canBeResent()) { menu.findItem(R.id.ic_action_vector_resend_message).setVisible(true); if (event.isUndeliverable()) { menu.findItem(R.id.ic_action_vector_redact_message).setVisible(true); } } else if (event.mSentState == Event.SentState.SENT) { // test if the event can be redacted boolean canBeRedacted = !mIsPreviewMode; if (canBeRedacted) { // oneself message -> can redact it if (TextUtils.equals(event.sender, mSession.getMyUserId())) { canBeRedacted = true; } else { // need the mininum power level to redact an event Room room = mSession.getDataHandler().getRoom(event.roomId); if ((null != room) && (null != room.getLiveState().getPowerLevels())) { PowerLevels powerLevels = room.getLiveState().getPowerLevels(); canBeRedacted = powerLevels.getUserPowerLevel(mSession.getMyUserId()) >= powerLevels.redact; } } } menu.findItem(R.id.ic_action_vector_redact_message).setVisible(canBeRedacted); if (Event.EVENT_TYPE_MESSAGE.equals(event.type)) { Message message = JsonUtils.toMessage(event.getContentAsJsonObject()); // share / forward the message menu.findItem(R.id.ic_action_vector_share).setVisible(true); menu.findItem(R.id.ic_action_vector_forward).setVisible(true); // save the media in the downloads directory if (Message.MSGTYPE_IMAGE.equals(message.msgtype) || Message.MSGTYPE_VIDEO.equals(message.msgtype) || Message.MSGTYPE_FILE.equals(message.msgtype)) { menu.findItem(R.id.ic_action_vector_save).setVisible(true); } // offer to report a message content menu.findItem(R.id.ic_action_vector_report) .setVisible(!mIsPreviewMode && !TextUtils.equals(event.sender, mSession.getMyUserId())); } } // display the menu popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { // warn the listener if (null != mVectorMessagesAdapterEventsListener) { mVectorMessagesAdapterEventsListener.onEventAction(event, textMsg, item.getItemId()); } // disable the selection mHighlightedEventId = null; notifyDataSetChanged(); return true; } }); popup.show(); }
From source file:android.support.designox.widget.CollapsingTextHelper.java
private void calculateUsingTextSize(final float textSize) { if (mText == null) return;// w w w. j av a 2s .c o m final float availableWidth; final float newTextSize; boolean updateDrawText = false; if (isClose(textSize, mCollapsedTextSize)) { availableWidth = mCollapsedBounds.width(); newTextSize = mCollapsedTextSize; mScale = 1f; if (mCurrentTypeface != mCollapsedTypeface) { mCurrentTypeface = mCollapsedTypeface; updateDrawText = true; } } else { availableWidth = mExpandedBounds.width(); 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.setTextSize(mCurrentTextSize); mTextPaint.setTypeface(mCurrentTypeface); // Use linear text scaling if we're scaling the canvas mTextPaint.setLinearText(mScale != 1f); // If we don't currently have text to draw, or the text size has changed, ellipsize... final CharSequence title = TextUtils.ellipsize(mText, mTextPaint, availableWidth, TextUtils.TruncateAt.END); if (!TextUtils.equals(title, mTextToDraw)) { mTextToDraw = title; mIsRtl = calculateIsRtl(mTextToDraw); } } }
From source file:com.vk.sdk.payments.VKIInAppBillingService.java
private static String getPurchaseData(@NonNull final Object iInAppBillingService, final int apiVersion, @NonNull final String packageName, @NonNull final String purchaseToken) throws RemoteException { Bundle ownedItems = getPurchases(iInAppBillingService, apiVersion, packageName, "inapp", purchaseToken); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); if (purchaseDataList != null) { for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseDataLocal = purchaseDataList.get(i); try { JSONObject o = new JSONObject(purchaseDataLocal); String token = o.optString(PURCHASE_DETAIL_TOKEN, o.optString(PURCHASE_DETAIL_PURCHASE_TOKEN)); if (TextUtils.equals(purchaseToken, token)) { return getReceipt(iInAppBillingService, apiVersion, packageName, purchaseDataLocal) .toJson();/*from w w w . j a v a2s .c om*/ } } catch (JSONException e) { // nothing } } } return null; }
From source file:com.tct.email.LegacyConversions.java
/** * Add a single attachment part to the message * * This will skip adding attachments if they are already found in the attachments table. * The heuristic for this will fail (false-positive) if two identical attachments are * included in a single POP3 message./*from w w w.j a v a 2s .c om*/ * TODO: Fix that, by (elsewhere) simulating an mLocation value based on the attachments * position within the list of multipart/mixed elements. This would make every POP3 attachment * unique, and might also simplify the code (since we could just look at the positions, and * ignore the filename, etc.) * * TODO: Take a closer look at encoding and deal with it if necessary. * * @param context a context for file operations * @param localMessage the attachments will be built against this message * @param part a single attachment part from POP or IMAP * @param index add for pop re-download attachment * @param protocol add to judge if it's pop3,it can be used later * @param isInline add to judge if it's isInline attachment */ public static void addOneAttachment(final Context context, final EmailContent.Message localMessage, final Part part, int index, String protocol, boolean isInline) throws MessagingException, IOException { Attachment localAttachment = mimePartToAttachment(context, part, index, protocol, isInline); // TS: Gantao 2015-06-04 EMAIL BUGFIX_1009030 MOD_E localAttachment.mMessageKey = localMessage.mId; localAttachment.mAccountKey = localMessage.mAccountKey; if (DEBUG_ATTACHMENTS) { LogUtils.d(Logging.LOG_TAG, "Add attachment " + localAttachment); } // To prevent duplication - do we already have a matching attachment? // The fields we'll check for equality are: // mFileName, mMimeType, mContentId, mMessageKey, mLocation // NOTE: This will false-positive if you attach the exact same file, twice, to a POP3 // message. We can live with that - you'll get one of the copies. final Uri uri = ContentUris.withAppendedId(Attachment.MESSAGE_ID_URI, localMessage.mId); final Cursor cursor = context.getContentResolver().query(uri, Attachment.CONTENT_PROJECTION, null, null, null); boolean attachmentFoundInDb = false; try { while (cursor.moveToNext()) { final Attachment dbAttachment = new Attachment(); dbAttachment.restore(cursor); // We test each of the fields here (instead of in SQL) because they may be // null, or may be strings. if (!TextUtils.equals(dbAttachment.mFileName, localAttachment.mFileName) || !TextUtils.equals(dbAttachment.mMimeType, localAttachment.mMimeType) || !TextUtils.equals(dbAttachment.mContentId, localAttachment.mContentId) || !TextUtils.equals(dbAttachment.mLocation, localAttachment.mLocation)) { continue; } // We found a match, so use the existing attachment id, and stop looking/looping attachmentFoundInDb = true; localAttachment.mId = dbAttachment.mId; if (DEBUG_ATTACHMENTS) { LogUtils.d(Logging.LOG_TAG, "Skipped, found db attachment " + dbAttachment); } break; } } finally { cursor.close(); } //TS: Gantao 2015-07-16 EMAIL BUGFIX_1045624 MOD_S // Save the attachment (so far) in order to obtain an id if (!attachmentFoundInDb) { localAttachment.save(context); } // If an attachment body was actually provided, we need to write the file now saveAttachmentBody(context, part, localAttachment, localMessage.mAccountKey); //TS: Gantao 2015-07-16 EMAIL BUGFIX_1045624 MOD_E if (localMessage.mAttachments == null) { localMessage.mAttachments = new ArrayList<Attachment>(); } //TS: wenggangjin 2014-12-10 EMAIL BUGFIX_852100 MOD_S Body body = Body.restoreBodyWithMessageId(context, localAttachment.mMessageKey); ContentValues cv = new ContentValues(); if (body != null && body.mHtmlContent != null && localAttachment.mContentId != null && localAttachment.getContentUri() != null) { cv.clear(); String html = body.mHtmlContent; String contentIdRe = "\\s+(?i)src=\"cid(?-i):\\Q" + localAttachment.mContentId + "\\E\""; //TS: zhaotianyong 2015-03-23 EMAIL BUGFIX_899799 MOD_S //TS: zhaotianyong 2015-04-01 EMAIL BUGFIX_962560 MOD_S String srcContentUri = " src=\"" + localAttachment.getContentUri() + "\""; //TS: zhaotianyong 2015-04-01 EMAIL BUGFIX_962560 MOD_E //TS: zhaotianyong 2015-03-23 EMAIL BUGFIX_899799 MOD_E //TS: zhaotianyong 2015-04-15 EMAIL BUGFIX_976967 MOD_S try { html = html.replaceAll(contentIdRe, srcContentUri); } catch (PatternSyntaxException e) { LogUtils.w(Logging.LOG_TAG, "Unrecognized backslash escape sequence in pattern"); } //TS: zhaotianyong 2015-04-15 EMAIL BUGFIX_976967 MOD_E cv.put(BodyColumns.HTML_CONTENT, html); Body.updateBodyWithMessageId(context, localAttachment.mMessageKey, cv); Body.restoreBodyHtmlWithMessageId(context, localAttachment.mMessageKey); } //TS: wenggangjin 2014-12-10 EMAIL BUGFIX_852100 MOD_E localMessage.mAttachments.add(localAttachment); //TS: Gantao 2015-09-28 EMAIL FEATURE_526529 MOD_S //We do not think the inline images is an attachment from now. if (!isInline) { localMessage.mFlagAttachment = true; } //TS: Gantao 2015-09-28 EMAIL FEATURE_526529 MOD_E }