List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.brookmanholmes.bma.ui.newmatchwizard.model.PlayerNamePage.java
@Override public boolean isCompleted() { return !TextUtils.isEmpty(getPlayerName()) && !TextUtils.isEmpty(getOpponentName()) && !TextUtils.equals(getPlayerName(), getOpponentName()); }
From source file:com.google.android.apps.muzei.SourceSubscriberService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null || intent.getAction() == null) { return;/*w w w . j a va 2 s . c o m*/ } String action = intent.getAction(); if (!ACTION_PUBLISH_STATE.equals(action)) { return; } // Handle API call from source String token = intent.getStringExtra(EXTRA_TOKEN); ComponentName selectedSource = SourceManager.getSelectedSource(this); if (selectedSource == null || !TextUtils.equals(token, selectedSource.flattenToShortString())) { Log.w(TAG, "Dropping update from non-selected source, token=" + token + " does not match token for " + selectedSource); return; } SourceState state = null; if (intent.hasExtra(EXTRA_STATE)) { Bundle bundle = intent.getBundleExtra(EXTRA_STATE); if (bundle != null) { state = SourceState.fromBundle(bundle); } } if (state == null) { // If there is no state, there is nothing to change return; } ContentValues values = new ContentValues(); values.put(MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME, selectedSource.flattenToShortString()); values.put(MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED, true); values.put(MuzeiContract.Sources.COLUMN_NAME_DESCRIPTION, state.getDescription()); values.put(MuzeiContract.Sources.COLUMN_NAME_WANTS_NETWORK_AVAILABLE, state.getWantsNetworkAvailable()); JSONArray commandsSerialized = new JSONArray(); int numSourceActions = state.getNumUserCommands(); boolean supportsNextArtwork = false; for (int i = 0; i < numSourceActions; i++) { UserCommand command = state.getUserCommandAt(i); if (command.getId() == MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK) { supportsNextArtwork = true; } else { commandsSerialized.put(command.serialize()); } } values.put(MuzeiContract.Sources.COLUMN_NAME_SUPPORTS_NEXT_ARTWORK_COMMAND, supportsNextArtwork); values.put(MuzeiContract.Sources.COLUMN_NAME_COMMANDS, commandsSerialized.toString()); ContentResolver contentResolver = getContentResolver(); Cursor existingSource = contentResolver.query(MuzeiContract.Sources.CONTENT_URI, new String[] { BaseColumns._ID }, MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME + "=?", new String[] { selectedSource.flattenToShortString() }, null, null); if (existingSource != null && existingSource.moveToFirst()) { Uri sourceUri = ContentUris.withAppendedId(MuzeiContract.Sources.CONTENT_URI, existingSource.getLong(0)); contentResolver.update(sourceUri, values, null, null); } else { contentResolver.insert(MuzeiContract.Sources.CONTENT_URI, values); } if (existingSource != null) { existingSource.close(); } Artwork artwork = state.getCurrentArtwork(); if (artwork != null) { artwork.setComponentName(selectedSource); contentResolver.insert(MuzeiContract.Artwork.CONTENT_URI, artwork.toContentValues()); // Download the artwork contained from the newly published SourceState startService(TaskQueueService.getDownloadCurrentArtworkIntent(this)); } }
From source file:com.kogitune.wearlocationwatchface.WatchFaceService.java
@Override public void onPreferenceChange(WearSharedPreference preference, String key, Bundle bundle) { Toast.makeText(this, key + ":" + bundle.get(key), Toast.LENGTH_LONG).show(); if (TextUtils.equals(key, getString(R.string.key_preference_time_text_accent))) { }// ww w.j ava2 s . c o m }
From source file:com.appsimobile.appsii.module.home.config.MockHomeItemConfiguration.java
@Override public long findCellWithPropertyValue(String propertyName, String value) { if (mProperties.containsKey(propertyName)) { if (TextUtils.equals(value, mProperties.get(propertyName))) return 1L; }/*from ww w .j ava2 s . c o m*/ return -1L; }
From source file:com.achep.acdisplay.notifications.OpenNotification.java
public void loadData(Context context) { mNotificationData.loadNotification(context, this, false); mMine = TextUtils.equals(getPackageName(), PackageUtils.getName(context)); }
From source file:com.zhihu.android.app.mirror.widget.adapter.ArtboardPagerAdapter.java
@Override public int getItemPosition(Object object) { if (mList.size() <= 0) { return POSITION_NONE; }/*ww w. j a v a 2 s .co m*/ View view = (View) object; int position = (int) view.getTag(R.id.artboard_position); String id = (String) view.getTag(R.id.artboard_id); int index = -1; for (int i = 0; i < mList.size(); i++) { Artboard artboard = mList.get(i); if (TextUtils.equals(artboard.getId(), id)) { index = i; break; } } if (index != position) { return POSITION_NONE; } else { Artboard artboard = mList.get(position); boolean needUpdate = artboard.isNeedUpdateInPager(); artboard.setNeedUpdateInPager(false); return needUpdate ? POSITION_NONE : POSITION_UNCHANGED; } }
From source file:com.shopify.sample.activity.base.SampleActivity.java
@Override protected void onResume() { super.onResume(); // If we are being launched by a url scheme, check the scheme and retrieve the checkout token if provided Intent intent = getIntent();//from w w w . j a v a 2 s.c o m Uri uri = intent.getData(); String scheme = getString(R.string.web_return_to_scheme); if (uri != null && TextUtils.equals(uri.getScheme(), scheme)) { // If the app was launched using the scheme, we know we just successfully completed an order onCheckoutComplete(); } }
From source file:com.example.android.spotifystreamer.ui.tv.TvVerticalGridFragment.java
protected void setMediaId(String mediaId) { LogHelper.d(TAG, "setMediaId: ", mediaId); if (TextUtils.equals(mMediaId, mediaId)) { return;/*from ww w . j a v a 2 s . c o m*/ } MediaBrowser mediaBrowser = mMediaFragmentListener.getMediaBrowser(); // First, unsubscribe from old mediaId: if (mMediaId != null) { mediaBrowser.unsubscribe(mMediaId); } if (mediaId == null) { mediaId = mediaBrowser.getRoot(); } mMediaId = mediaId; mediaBrowser.subscribe(mMediaId, mSubscriptionCallback); }
From source file:com.google.android.apps.muzei.NewWallpaperNotificationReceiver.java
public static void maybeShowNewArtworkNotification(Context context, Artwork artwork, BitmapRegionLoader bitmapRegionLoader) { if (artwork == null || artwork.getImageUri() == null || bitmapRegionLoader == null) { return;//from w w w. j av a 2 s . c o m } ArtDetailOpenedClosedEvent adoce = EventBus.getDefault().getStickyEvent(ArtDetailOpenedClosedEvent.class); if (adoce != null && adoce.isArtDetailOpened()) { return; } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); if (!sp.getBoolean(PREF_ENABLED, true)) { return; } String lastSeenImageUri = sp.getString(PREF_LAST_SEEN_NOTIFICATION_IMAGE_URI, null); if (TextUtils.equals(lastSeenImageUri, artwork.getImageUri().toString())) { return; } Rect rect = new Rect(); int width = bitmapRegionLoader.getWidth(); int height = bitmapRegionLoader.getHeight(); if (width > height) { rect.set((width - height) / 2, 0, (width + height) / 2, height); } else { rect.set(0, (height - width) / 2, width, (height + width) / 2); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = ImageUtil.calculateSampleSize(height, 256); Bitmap largeIcon = bitmapRegionLoader.decodeRegion(rect, options); NotificationCompat.Builder nb = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_muzei).setPriority(Notification.PRIORITY_MIN).setAutoCancel(true) .setContentTitle(artwork.getTitle()) .setContentText(context.getString(R.string.notification_new_wallpaper)).setLargeIcon(largeIcon) .setContentIntent(PendingIntent.getActivity(context, 0, Intent.makeMainActivity(new ComponentName(context, MuzeiActivity.class)), PendingIntent.FLAG_UPDATE_CURRENT)) .setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(context, NewWallpaperNotificationReceiver.class) .setAction(ACTION_MARK_NOTIFICATION_READ), PendingIntent.FLAG_UPDATE_CURRENT)); NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(nb).bigLargeIcon(null) .setBigContentTitle(artwork.getTitle()).setSummaryText(artwork.getByline()).bigPicture(largeIcon); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, style.build()); // Clear any last-seen notification sp.edit().remove(PREF_LAST_SEEN_NOTIFICATION_IMAGE_URI).apply(); }
From source file:com.google.blockly.model.FieldImage.java
/** * Sets a new image to be shown./*from w w w . j av a 2s .c o m*/ * <p/> * Changes will induce a {@link Field.Observer#onValueChanged}, even though FieldImages do not * store a value. This trigger updates to the matching Fieldview, but in might also generate a * no-op {@link com.google.blockly.android.control.BlocklyEvent.ChangeEvent}. * * @param src A web address or Blockly reference to the image. * @param width The display width of the image in dips. * @param height The display height of the image in dips. */ public void setImage(String src, int width, int height) { if (!TextUtils.equals(mSrc, src) || mWidth != width || mHeight != height) { mSrc = src; mWidth = width; mHeight = height; fireValueChanged("", ""); } }