List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.example.android.uamp.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 . j a v a 2 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.gh4a.activities.DiffViewerActivity.java
private void addCommentsToMap(List<CommitComment> comments) { for (CommitComment comment : comments) { if (!TextUtils.equals(comment.getPath(), mPath)) { continue; }/*w w w. ja v a 2 s. c o m*/ int position = comment.getPosition(); List<CommitComment> commentsByPos = mCommitCommentsByPos.get(position); if (commentsByPos == null) { commentsByPos = new ArrayList<>(); mCommitCommentsByPos.put(position, commentsByPos); } commentsByPos.add(comment); } }
From source file:com.asd.littleprincesbeauty.data.Task.java
@Override 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 w w w .j ava 2s . com 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:androidx.media.SessionToken2.java
@Override public boolean equals(Object obj) { if (!(obj instanceof SessionToken2)) { return false; }/*from w w w . ja va 2s.c o m*/ SessionToken2 other = (SessionToken2) obj; return mUid == other.mUid && TextUtils.equals(mPackageName, other.mPackageName) && TextUtils.equals(mServiceName, other.mServiceName) && TextUtils.equals(mId, other.mId) && mType == other.mType; }
From source file:com.bayapps.android.robophish.playback.LocalPlayback.java
public boolean playNext(QueueItem item) { MediaPlayer nextPlayer;// ww w.j a va2s .c o m if (mMediaPlayer == mMediaPlayerA) { nextPlayer = mMediaPlayerB; } else nextPlayer = mMediaPlayerA; String mediaId = item.getDescription().getMediaId(); boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId); if (mediaHasChanged) { mNextMediaId = mediaId; } MediaMetadataCompat track = mMusicProvider .getMusic(MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId())); //noinspection ResourceType String source = track.getString(MusicProviderSource.CUSTOM_METADATA_TRACK_SOURCE); nextPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { nextPlayer.setDataSource(source); } catch (IOException ex) { LogHelper.e(TAG, ex, "Exception playing song"); if (mCallback != null) { mCallback.onError(ex.getMessage()); } } // Starts preparing the media player in the background. When // it's done, it will call our OnPreparedListener (that is, // the onPrepared() method on this class, since we set the // listener to 'this'). Until the media player is prepared, // we *cannot* call start() on it! nextPlayer.prepareAsync(); mMediaPlayersSwapping = true; return true; }
From source file:com.orangesoft.jook.CastPlayback.java
private void loadMedia(final String mediaId, final boolean autoPlay) throws TransientNetworkDisconnectionException, NoConnectionException, JSONException { musicProvider.fetchSong(new SongListener() { @Override/*from ww w .j a va 2 s. c om*/ public void onSongMetadata(MediaMetadata track) { if (null == track) throw new IllegalArgumentException("Invalid mediaId " + mediaId); if (!TextUtils.equals(mediaId, currentMediaId)) { currentMediaId = mediaId; currentPosition = 0; } JSONObject customData = new JSONObject(); try { customData.put(ITEM_ID, mediaId); MediaInfo mediaInfo = toCastMediaMetadata(track, customData); castManager.loadMedia(mediaInfo, autoPlay, currentPosition, customData); } catch (Exception e) { throw new IllegalArgumentException(e); } } }, mediaId); }
From source file:com.jefftharris.passwdsafe.PasswdSafePolicyListFragment.java
/** * Save the policies/*from www. j av a 2s . c om*/ */ private void savePolicies(String rmPolicy, PasswdPolicy addPolicy) { final List<PasswdPolicy> newPolicies = new ArrayList<>(); if (itsHdrPolicies != null) { Collection<HeaderPasswdPolicies.HdrPolicy> hdrPolicies = itsHdrPolicies.getPolicies(); for (HeaderPasswdPolicies.HdrPolicy hdrPolicy : hdrPolicies) { if (!TextUtils.equals(hdrPolicy.getPolicy().getName(), rmPolicy)) { newPolicies.add(hdrPolicy.getPolicy()); } } } final ObjectHolder<Pair<String, String>> policyRename = new ObjectHolder<>(); if (addPolicy != null) { newPolicies.add(addPolicy); if (rmPolicy != null) { String newName = addPolicy.getName(); if (!TextUtils.equals(newName, rmPolicy)) { policyRename.set(new Pair<>(rmPolicy, newName)); } } } PasswdSafeUtil.dbginfo(TAG, "savePolicies: %s, rename: %s", newPolicies, policyRename); itsListener.useFileData(new PasswdFileDataUser() { @Override public void useFileData(@NonNull PasswdFileData fileData) { fileData.setHdrPasswdPolicies(newPolicies.isEmpty() ? null : newPolicies, policyRename.get()); } }); itsListener.finishPolicyEdit(new Runnable() { @Override public void run() { refresh(); } }); }
From source file:com.murati.oszk.audiobook.utils.MediaIDHelper.java
/** * Determine if media item is playing (matches the currently playing media item). * * @param context for retrieving the {@link MediaControllerCompat} * @param mediaItem to compare to currently playing {@link MediaBrowserCompat.MediaItem} * @return boolean indicating whether media item matches currently playing media item *//*from w w w . j a v a 2s . c om*/ public static boolean isMediaItemPlaying(Activity context, MediaBrowserCompat.MediaItem mediaItem) { // Media item is considered to be playing or paused based on the controller's current // media id MediaControllerCompat controller = MediaControllerCompat.getMediaController(context); if (controller != null && controller.getMetadata() != null) { String currentPlayingMediaId = controller.getMetadata().getDescription().getMediaId(); String itemMusicId = MediaIDHelper.extractMusicIDFromMediaID(mediaItem.getDescription().getMediaId()); if (currentPlayingMediaId != null && TextUtils.equals(currentPlayingMediaId, itemMusicId)) { return true; } } return false; }
From source file:com.udmurtlyk.extrainputmethod.accessibility.AccessibilityUtils.java
/** * Obtains a description for an auto-correction key, taking into account the * currently typed word and auto-correction. * * @param keyCodeDescription spoken description of the key that will insert * an auto-correction//from w ww.ja v a 2 s. co m * @param shouldObscure whether the key should be obscured * @return a description including a description of the auto-correction, if * needed */ public String getAutoCorrectionDescription(final String keyCodeDescription, final boolean shouldObscure) { if (!TextUtils.isEmpty(mAutoCorrectionWord)) { if (!TextUtils.equals(mAutoCorrectionWord, mTypedWord)) { if (shouldObscure) { // This should never happen, but just in case... return mContext.getString( com.udmurtlyk.extrainputmethod.latin.R.string.spoken_auto_correct_obscured, keyCodeDescription); } return mContext.getString(com.udmurtlyk.extrainputmethod.latin.R.string.spoken_auto_correct, keyCodeDescription, mTypedWord, mAutoCorrectionWord); } } return keyCodeDescription; }
From source file:io.github.hidroh.materialistic.accounts.UserServicesClient.java
@Override public void submit(Context context, String title, String content, boolean isUrl, Callback callback) { Pair<String, String> credentials = AppUtils.getCredentials(context); if (credentials == null) { callback.onDone(false);/*from w ww .ja va 2 s. com*/ return; } /** * The flow: * POST /submit with acc, pw * if 302 to /login, considered failed * POST /r with fnid, fnop, title, url or text * if 302 to /newest, considered successful * if 302 to /x, considered error, maybe duplicate or invalid input * if 200 or anything else, considered error */ // fetch submit page with given credentials execute(postSubmitForm(credentials.first, credentials.second)).flatMap( response -> response.code() != HttpURLConnection.HTTP_MOVED_TEMP ? Observable.just(response) : Observable.error(new IOException())) .flatMap(response -> { try { return Observable.just( new String[] { response.header(HEADER_SET_COOKIE), response.body().string() }); } catch (IOException e) { return Observable.error(e); } finally { response.close(); } }).map(array -> { array[1] = getInputValue(array[1], SUBMIT_PARAM_FNID); return array; }) .flatMap(array -> !TextUtils.isEmpty(array[1]) ? Observable.just(array) : Observable.error(new IOException())) .flatMap(array -> execute(postSubmit(title, content, isUrl, array[0], array[1]))) .flatMap(response -> response.code() == HttpURLConnection.HTTP_MOVED_TEMP ? Observable.just(Uri.parse(response.header(HEADER_LOCATION))) : Observable.error(new IOException())) .flatMap(uri -> TextUtils.equals(uri.getPath(), DEFAULT_SUBMIT_REDIRECT) ? Observable.just(true) : Observable.error(buildException(uri))) .observeOn(AndroidSchedulers.mainThread()).subscribe(callback::onDone, callback::onError); }