List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.androidzeitgeist.dashwatch.muzei.SourceManager.java
public void handlePublishState(String token, SourceState state) { synchronized (this) { if (!TextUtils.equals(token, mSelectedSourceToken)) { Log.w(TAG, "Dropping update from non-selected source (token mismatch)."); return; }/* w w w . j av a 2 s .co m*/ if (state == null) { mSourceStates.remove(mSelectedSource); } else { mSourceStates.put(mSelectedSource, state); } try { StringBuilder sb = new StringBuilder(); Set<String> sourceStates = new HashSet<String>(); for (ComponentName source : mSourceStates.keySet()) { SourceState sourceState = mSourceStates.get(source); if (sourceState == null) { continue; } sb.setLength(0); sb.append(source.flattenToShortString()).append("|").append(sourceState.toJson().toString()); sourceStates.add(sb.toString()); } mSharedPrefs.edit().putStringSet(PREF_SOURCE_STATES, sourceStates).apply(); } catch (JSONException e) { Log.e(TAG, "Error storing source status data.", e); } } // EventBus.getDefault().post(new SelectedSourceStateChangedEvent()); }
From source file:com.android.dialer.util.TelecomUtil.java
public static boolean isDefaultDialer(Context context) { final boolean result = TextUtils.equals(context.getPackageName(), TelecomManagerCompat.getDefaultDialerPackage(getTelecomManager(context))); if (result) { sWarningLogged = false;//from ww w. java 2 s . c o m } else { if (!sWarningLogged) { // Log only once to prevent spam. Log.w(TAG, "Dialer is not currently set to be default dialer"); sWarningLogged = true; } } return result; }
From source file:com.murati.oszk.audiobook.playback.CastPlayback.java
private void loadMedia(String mediaId, boolean autoPlay) throws JSONException { String musicId = MediaIDHelper.extractMusicIDFromMediaID(mediaId); MediaMetadataCompat track = mMusicProvider.getTrack(musicId); if (track == null) { throw new IllegalArgumentException("Invalid mediaId " + mediaId); }/*from w ww. j av a2 s . c o m*/ if (!TextUtils.equals(mediaId, mCurrentMediaId)) { mCurrentMediaId = mediaId; mCurrentPosition = 0; } JSONObject customData = new JSONObject(); customData.put(ITEM_ID, mediaId); MediaInfo media = toCastMediaMetadata(track, customData); mRemoteMediaClient.load(media, autoPlay, mCurrentPosition, customData); }
From source file:com.classiqo.nativeandroid_32bitz.utils.QueueHelper.java
public static boolean isQueueItemPlaying(Context context, MediaSessionCompat.QueueItem queueItem) { MediaControllerCompat controller = ((FragmentActivity) context).getSupportMediaController(); if (controller != null && controller.getPlaybackState() != null) { long currentPlayingQueueId = controller.getPlaybackState().getActiveQueueItemId(); String currentPlayingMediaId = controller.getMetadata().getDescription().getMediaId(); String itemMusicId = MediaIDHelper.extractMusicIDFromMediaID(queueItem.getDescription().getMediaId()); if (queueItem.getQueueId() == currentPlayingQueueId && currentPlayingMediaId != null && TextUtils.equals(currentPlayingMediaId, itemMusicId)) { return true; }/*from ww w .ja va2 s . c o m*/ } return false; }
From source file:com.appdevper.mediaplayer.ui.PlaybackControlsFragment.java
private void onMetadataChanged(final MediaMetadataCompat metadata) { LogHelper.d(TAG, "onMetadataChanged ", metadata); if (getActivity() == null) { return;/*from w w w. jav a2 s . c om*/ } if (metadata == null) { return; } mTitle.setText(metadata.getDescription().getTitle()); mSubtitle.setText(metadata.getDescription().getSubtitle()); String artUrl = null; if (metadata.getDescription().getIconUri() != null) { artUrl = metadata.getDescription().getIconUri().toString(); } else { Utils.downloadBitmap(getResources(), metadata.getDescription().getMediaId(), mAlbumArt); return; } if (!TextUtils.equals(artUrl, mArtUrl)) { mArtUrl = artUrl; Bitmap art = metadata.getDescription().getIconBitmap(); AlbumArtCache cache = AlbumArtCache.getInstance(); if (art == null) { art = cache.getIconImage(mArtUrl); } if (art != null) { mAlbumArt.setImageBitmap(art); } else { cache.fetch(artUrl, new AlbumArtCache.FetchListener() { @Override public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) { if (icon != null) { if (isAdded()) { mAlbumArt.setImageBitmap(icon); } } } @Override public void onError(String artUrl, Exception e) { Utils.downloadBitmap(getResources(), metadata.getDescription().getMediaId(), mAlbumArt); } }); } } }
From source file:cn.code.notes.gtask.data.Task.java
public void setContentByLocalJSON(JSONObject js) { if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE) || !js.has(GTaskStringUtils.META_HEAD_DATA)) { Log.w(TAG, "setContentByLocalJSON: nothing is avaiable"); }//from www. jav a 2s . co m try { JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA); if (note.getInt(NoteColumns.TYPE) != Notes.TYPE_NOTE) { Log.e(TAG, "invalid type"); return; } for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); if (TextUtils.equals(data.getString(DataColumns.MIME_TYPE), DataConstants.NOTE)) { setName(data.getString(DataColumns.CONTENT)); break; } } } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } }
From source file:com.google.cloud.android.language.MainActivity.java
private void handleShareIntent() { final Intent intent = getIntent(); if (TextUtils.equals(intent.getAction(), Intent.ACTION_SEND) && TextUtils.equals(intent.getType(), "text/plain")) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { mInput.setText(text);//from ww w. ja v a 2 s . c o m } } }
From source file:com.classiqo.nativeandroid_32bitz.playback.CastPlayback.java
private void loadMedia(String mediaId, boolean autoPlay) throws JSONException { String musicId = MediaIDHelper.extractMusicIDFromMediaID(mediaId); MediaMetadataCompat track = mMusicProvider.getMusic(musicId); if (track == null) { throw new IllegalArgumentException("Invalid mediaId" + mediaId); }/*w ww.ja v a 2 s . co m*/ if (!TextUtils.equals(mediaId, mCurrentMediaId)) { mCurrentMediaId = mediaId; mCurrentPosition = 0; } JSONObject customData = new JSONObject(); customData.put(ITEM_ID, mediaId); MediaInfo media = toCastMediaMetadata(track, customData); mRemoteMediaClient.load(media, autoPlay, mCurrentPosition, customData); }
From source file:com.jefftharris.passwdsafe.sync.lib.AbstractSyncedFilesActivity.java
@Override public void changeDir(String pathDisplay, String pathId) { PasswdSafeUtil.dbginfo(TAG, "changeDir: %s", pathDisplay); Fragment files = SyncedFilesFragment.newInstance(pathDisplay, pathId); FragmentManager fragmgr = getSupportFragmentManager(); FragmentTransaction txn = fragmgr.beginTransaction(); txn.replace(R.id.content, files);//from w w w . j av a 2s .c o m if (!TextUtils.equals(pathId, itsRootId)) { txn.addToBackStack(null); } txn.commit(); }
From source file:com.taobao.weex.ui.component.list.template.CellDataManager.java
/** * @param data data object//w ww . j a v a2 s . c o m * @param index insert index * update data, reset new render state, * return true if only data changed, false if viewType changed * */ public boolean updateData(Object data, int index) { boolean onlyDataChange = TextUtils.equals(templateList.getTemplateKey(index), templateList.getTemplateKey(data)); listData.set(index, data); if (!onlyDataChange) { //structure changed, reset render state cleanRenderState(renderStates.remove(index)); } else { CellRenderState renderState = renderStates.get(index); if (renderState != null) { renderState.hasDataUpdate = true; } } return onlyDataChange; }