Example usage for android.text TextUtils equals

List of usage examples for android.text TextUtils equals

Introduction

In this page you can find the example usage for android.text TextUtils equals.

Prototype

public static boolean equals(CharSequence a, CharSequence b) 

Source Link

Document

Returns true if a and b are equal, including if they are both null.

Usage

From source file:alexander.martinz.libs.materialpreferences.MaterialEditTextPreference.java

protected AlertDialog createAlertDialog() {
    final Context context = getContext();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(getTitle());/* www.  j a  v  a 2 s .c  o m*/

    // create the wrapper layout to apply margins to the edit text
    final LinearLayout wrapper = new LinearLayout(context);
    wrapper.setOrientation(LinearLayout.VERTICAL);
    final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    final int margin = (int) convertDpToPixels(10);
    layoutParams.setMargins(margin, 0, margin, 0);

    // create the EditText and add it to the wrapper layout
    final EditText editText = new EditText(context);
    editText.setText(mValue);
    wrapper.addView(editText, layoutParams);

    // set our wrapper as view
    builder.setView(wrapper);

    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String value = editText.getText().toString();
            if (TextUtils.equals(value, mValue)) {
                // the value did not change, so lets end here
                return;
            }

            mValue = value;
            final MaterialEditTextPreference preference = MaterialEditTextPreference.this;

            if (mListener != null) {
                if (mListener.onPreferenceChanged(preference, mValue)) {
                    setText(mValue);
                }
            } else {
                setText(mValue);
            }
        }
    });

    return builder.create();
}

From source file:com.android.tv.settings.device.storage.FormatActivity.java

private VolumeInfo findVolume(String diskId) {
    final List<VolumeInfo> vols = mStorageManager.getVolumes();
    for (final VolumeInfo vol : vols) {
        if (TextUtils.equals(diskId, vol.getDiskId()) && (vol.getType() == VolumeInfo.TYPE_PRIVATE)) {
            return vol;
        }/*from w ww  .ja  v  a 2 s . c  om*/
    }
    return null;
}

From source file:com.android.mail.browse.MessageAttachmentBar.java

/**
 * Render or update an attachment's view. This happens immediately upon instantiation, and
 * repeatedly as status updates stream in, so only properties with new or changed values will
 * cause sub-views to update.//from   www . j  a va  2s . co  m
 */
public void render(Attachment attachment, Account account, ConversationMessage message, boolean loaderResult,
        BidiFormatter bidiFormatter) {
    // get account uri for potential eml viewer usage
    mAccount = account;

    final Attachment prevAttachment = mAttachment;
    mAttachment = attachment;
    if (mAccount != null) {
        mActionHandler.setAccount(mAccount.getEmailAddress());
    }
    mActionHandler.setMessage(message);
    mActionHandler.setAttachment(mAttachment);
    mHideExtraOptionOne = message.getConversation() == null;

    // reset mSaveClicked if we are not currently downloading
    // So if the download fails or the download completes, we stop
    // showing progress, etc
    mSaveClicked = !attachment.isDownloading() ? false : mSaveClicked;

    LogUtils.d(LOG_TAG,
            "got attachment list row: name=%s state/dest=%d/%d dled=%d" + " contentUri=%s MIME=%s flags=%d",
            attachment.getName(), attachment.state, attachment.destination, attachment.downloadedSize,
            attachment.contentUri, attachment.getContentType(), attachment.flags);

    final String attachmentName = attachment.getName();
    if ((attachment.flags & Attachment.FLAG_DUMMY_ATTACHMENT) != 0) {
        mTitle.setText(R.string.load_attachment);
    } else if (prevAttachment == null || !TextUtils.equals(attachmentName, prevAttachment.getName())) {
        mTitle.setText(attachmentName);
    }

    if (prevAttachment == null || attachment.size != prevAttachment.size) {
        mAttachmentSizeText = bidiFormatter
                .unicodeWrap(AttachmentUtils.convertToHumanReadableSize(getContext(), attachment.size));
        mDisplayType = bidiFormatter.unicodeWrap(AttachmentUtils.getDisplayType(getContext(), attachment));
        updateSubtitleText();
    }

    updateActions();
    mActionHandler.updateStatus(loaderResult);
}

From source file:com.classiqo.nativeandroid_32bitz.playback.LocalPlayback.java

@Override
public void play(QueueItem item) {
    mPlayOnFocusGain = true;//from   ww w  .  j a  v  a  2 s. c  o  m

    tryToGetAudioFocus();
    registerAudioNoisyReceiver();
    String mediaId = item.getDescription().getMediaId();
    boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);

    if (mediaHasChanged) {
        mCurrentPosition = 0;
        mCurrentMediaId = mediaId;
    }

    if (mState == PlaybackStateCompat.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) {
        configMediaPlayerState();
    } else {
        mState = PlaybackStateCompat.STATE_STOPPED;
        relaxResources(false);
        MediaMetadataCompat track = mMusicProvider
                .getMusic(MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId()));

        //noinspection ResourceType
        String source = track.getString(MusicProviderSource.CUSTOM_METADATA_TRACK_SOURCE);

        if (source != null) {
            source = source.replaceAll(" ", "%20");
        }

        try {
            createMediaPlayerIfNeeded();

            mState = PlaybackStateCompat.STATE_BUFFERING;

            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mMediaPlayer.setDataSource(source);

            mMediaPlayer.prepareAsync();
            mWifiLock.acquire();

            if (mCallback != null) {
                mCallback.onPlaybackStatusChanged(mState);
            }
        } catch (IOException ex) {
            LogHelper.e(TAG, ex, "Exception playing song");

            if (mCallback != null) {
                mCallback.onError(ex.getMessage());
            }
        }
    }
}

From source file:com.classiqo.nativeandroid_32bitz.utils.QueueHelper.java

public static boolean equals(List<MediaSessionCompat.QueueItem> list1,
        List<MediaSessionCompat.QueueItem> list2) {
    if (list1 == list2) {
        return true;
    }/*from w w  w .j a va 2  s.  co m*/

    if (list1 == null || list2 == null) {
        return false;
    }

    if (list1.size() != list2.size()) {
        return false;
    }

    for (int i = 0; i < list1.size(); i++) {
        if (list1.get(i).getQueueId() != list2.get(i).getQueueId()) {
            return false;
        }

        if (!TextUtils.equals(list1.get(i).getDescription().getMediaId(),
                list2.get(i).getDescription().getMediaId())) {
            return false;
        }
    }

    return true;
}

From source file:com.murrayc.galaxyzoo.app.SubjectViewerFragment.java

public void update() {
    final Activity activity = getActivity();
    if (activity == null)
        return;/*from w  w  w  .  ja v  a2  s . c o  m*/

    if (TextUtils.equals(getItemId(), ItemsContentProvider.URI_PART_ITEM_ID_NEXT)) {
        /*
         * Initializes the CursorLoader. The URL_LOADER value is eventually passed
         * to onCreateLoader().
         * We use restartLoader(), instead of initLoader(),
         * so we can refresh this fragment to show a different subject,
         * even when using the same query ("next") to do that.
         */
        getLoaderManager().restartLoader(URL_LOADER, null, this);
    } else {
        //Add, or update, the child fragments already, because we know the Item IDs:
        addOrUpdateChildFragments();
    }
}

From source file:com.github.piasy.template.features.splash.GithubSearchFragment.java

@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    inflater.inflate(R.menu.menu_search_github_user, menu);
    final MenuItem search = menu.findItem(R.id.mActionSearch);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    RxSearchView.queryTextChanges(searchView)
            .compose(this.<CharSequence>bindUntilEvent(FragmentEvent.DESTROY_VIEW))
            .debounce(SEARCH_DELAY_MILLIS, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<CharSequence>() {
                @Override//  www.j a  va2 s  .  c  o m
                public void call(final CharSequence query) {
                    if (!TextUtils.equals(mCurrentQuery, query)) {
                        mCurrentQuery = query.toString();
                        if (TextUtils.isEmpty(mCurrentQuery)) {
                            showSearchUserResult(Collections.<GithubUser>emptyList());
                        } else {
                            presenter.searchUser(mCurrentQuery);
                            showProgress();
                            mIsLoading = true;
                        }
                    }
                }
            });
}

From source file:de.elanev.studip.android.app.widget.UserListFragment.java

/**
 * Creating floating context menu//from  w w w  . ja v a2 s.com
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getActivity().getMenuInflater();
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    Cursor listItemCursor = (Cursor) mListView.getAdapter().getItem(info.position);

    final String[] projection = new String[] {
            ContactsContract.Qualified.ContactGroups.CONTACT_GROUPS_GROUP_NAME,
            ContactsContract.Qualified.ContactGroups.CONTACT_GROUPS_GROUP_ID,
            ContactsContract.Qualified.ContactGroups.CONTACT_GROUPS_ID };
    final String contactId = listItemCursor
            .getString(listItemCursor.getColumnIndex(UsersContract.Columns.USER_ID));

    CursorLoader loader = new CursorLoader(getActivity(),
            ContactsContract.CONTENT_URI_CONTACTS.buildUpon().appendPath(contactId).build(), projection, null,
            null, ContactsContract.Columns.ContactGroups.GROUP_NAME + " ASC");

    final Cursor c = loader.loadInBackground();

    if (c.getCount() <= 0) {
        inflater.inflate(R.menu.user_add_context_menu, menu);
    } else {
        inflater.inflate(R.menu.user_context_menu, menu);
        c.moveToFirst();
        while (!c.isAfterLast()) {
            String currGroupName = c
                    .getString(c.getColumnIndex(ContactsContract.Columns.ContactGroups.GROUP_NAME));
            if (TextUtils.equals(currGroupName, getString(R.string.studip_app_contacts_favorites))) {
                menu.removeItem(R.id.add_to_favorites);
                menu.findItem(R.id.remove_from_favorites).setVisible(true);
            }

            c.moveToNext();
        }

    }
    c.close();
}

From source file:com.example.android.supportv4.media.Playback.java

public void play(QueueItem item) {
    mPlayOnFocusGain = true;/* w w w .ja v  a 2  s  .  co m*/
    tryToGetAudioFocus();
    registerAudioNoisyReceiver();
    String mediaId = item.getDescription().getMediaId();
    boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);
    if (mediaHasChanged) {
        mCurrentPosition = 0;
        mCurrentMediaId = mediaId;
    }

    if (mState == PlaybackState.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) {
        configMediaPlayerState();
    } else {
        mState = PlaybackState.STATE_STOPPED;
        relaxResources(false); // release everything except MediaPlayer
        MediaMetadataCompat track = mMusicProvider
                .getMusic(MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId()));

        String source = track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE);

        try {
            createMediaPlayerIfNeeded();

            mState = PlaybackState.STATE_BUFFERING;

            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mMediaPlayer.setDataSource(source);

            // 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!
            mMediaPlayer.prepareAsync();

            // If we are streaming from the internet, we want to hold a
            // Wifi lock, which prevents the Wifi radio from going to
            // sleep while the song is playing.
            mWifiLock.acquire();

            if (mCallback != null) {
                mCallback.onPlaybackStatusChanged(mState);
            }

        } catch (IOException ex) {
            Log.e(TAG, "Exception playing song", ex);
            if (mCallback != null) {
                mCallback.onError(ex.getMessage());
            }
        }
    }
}

From source file:com.example.android.mediabrowserservice.Playback.java

public void play(MediaSessionCompat.QueueItem item) {
    mPlayOnFocusGain = true;//  w  ww.ja va 2s .  c  o m
    tryToGetAudioFocus();
    registerAudioNoisyReceiver();
    String mediaId = item.getDescription().getMediaId();
    boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);
    if (mediaHasChanged) {
        mCurrentPosition = 0;
        mCurrentMediaId = mediaId;
    }

    if (mState == PlaybackStateCompat.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) {
        configMediaPlayerState();
    } else {
        mState = PlaybackStateCompat.STATE_STOPPED;
        relaxResources(false); // release everything except MediaPlayer
        MediaMetadataCompat track = mMusicProvider
                .getMusic(MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId()));

        String source = track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE);

        try {
            createMediaPlayerIfNeeded();

            mState = PlaybackStateCompat.STATE_BUFFERING;

            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mMediaPlayer.setDataSource(source);

            // 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!
            mMediaPlayer.prepareAsync();

            // If we are streaming from the internet, we want to hold a
            // Wifi lock, which prevents the Wifi radio from going to
            // sleep while the song is playing.
            mWifiLock.acquire();

            if (mCallback != null) {
                mCallback.onPlaybackStatusChanged(mState);
            }

        } catch (IOException ex) {
            LogHelper.e(TAG, ex, "Exception playing song");
            if (mCallback != null) {
                mCallback.onError(ex.getMessage());
            }
        }
    }
}