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:com.example.chu.googleplaylibrary.playback.LocalPlayback.java

@Override
public void play(QueueItem item) {
    mPlayOnFocusGain = true;//w ww.j av  a 2s  .  co 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

        String source = mMusicProvider;

        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());
            }
        }
    }
}

From source file:com.rascarlo.aurdroid.ui.SearchResultFragment.java

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Context context = container.getContext();
    FragmentSearchResultBinding fragmentSearchResultBinding = FragmentSearchResultBinding.inflate(inflater,
            container, false);//from www .  ja va  2  s.  com
    ProgressBar progressBar = fragmentSearchResultBinding.fragmentSearchResultProgressBar;
    progressBar.setVisibility(View.VISIBLE);
    SearchViewModelFactory searchViewModelFactory = new SearchViewModelFactory(bundleSearchBy, bundleQuery);
    SearchViewModel searchViewModel = ViewModelProviders.of(this, searchViewModelFactory)
            .get(SearchViewModel.class);
    resultAdapter = new SearchResultAdapter(searchResult -> {
        if (searchResultFragmentCallback != null) {
            if (searchResult != null && searchResult.getName() != null
                    && !TextUtils.isEmpty(searchResult.getName())) {
                searchResultFragmentCallback
                        .onSearchResultFragmentCallbackOnResultClicked(searchResult.getName());
            }
        }
    });
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL,
            false);
    RecyclerView recyclerView = fragmentSearchResultBinding.fragmentSearchResultRecyclerView;
    recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(linearLayoutManager);
    searchViewModel.getSearchLiveData().observe(this, aurSearch -> {
        if (aurSearch != null) {
            this.searchResultList = aurSearch.getResults();
            submitSearchResultList(false);
        }
        progressBar.setVisibility(View.GONE);
    });
    searchViewModel.getMessageMutableLiveData().observe(this, s -> {
        if (s != null && !TextUtils.isEmpty(s)) {
            Toast.makeText(context,
                    TextUtils.equals(AurdroidConstants.RETROFIT_FAILURE, s)
                            ? getString(R.string.retrofit_something_went_wrong)
                            : s,
                    Toast.LENGTH_LONG).show();
        }
        progressBar.setVisibility(View.GONE);
    });
    recyclerView.setAdapter(resultAdapter);
    return fragmentSearchResultBinding.getRoot();
}

From source file:com.appdevper.mediaplayer.app.LocalPlayback.java

@Override
public void play(QueueItem item) {
    mPlayOnFocusGain = true;//from  w w  w  .  jav  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 == PlaybackState.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) {
        configMediaPlayerState();
    } else {
        mState = PlaybackState.STATE_STOPPED;
        relaxResources(false); // release everything except MediaPlayer
        MediaMetadataCompat track = mMusicProvider.getMusic(item.getDescription().getMediaId());

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

        try {
            createMediaPlayerIfNeeded();

            mState = PlaybackState.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:de.elanev.studip.android.app.frontend.courses.CoursesFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (getActivity() == null) {
        return;//from   w  ww  .  j  av a  2  s  . c  o  m
    }

    cursor.moveToFirst();
    if (!cursor.isAfterLast()) {
        ArrayList<SectionedCursorAdapter.Section> sections = new ArrayList<SectionedCursorAdapter.Section>();
        String prevSemesterId = "";
        String currSemesterId = "";

        int semesterIdIdx = cursor.getColumnIndex(SEMESTER_ID);
        int semesterTitleIdx = cursor.getColumnIndex(SEMESTER_TITLE);

        while (!cursor.isAfterLast()) {
            currSemesterId = cursor.getString(semesterIdIdx);
            if (!TextUtils.equals(prevSemesterId, currSemesterId)) {
                sections.add(new SectionedCursorAdapter.Section(cursor.getPosition(),
                        cursor.getString(semesterTitleIdx)));
            }

            prevSemesterId = currSemesterId;
            cursor.moveToNext();
        }

        mAdapter.setSections(sections);
    }
    mAdapter.swapCursor(cursor);
    mSwipeRefreshLayoutListView.setRefreshing(false);
}

From source file:im.vector.receiver.VectorUniversalLinkReceiver.java

@Override
public void onReceive(final Context aContext, final Intent aIntent) {
    String action, uriString;/*from w ww.  j  av  a  2  s.  c  o m*/
    Uri intentUri;

    Log.d(LOG_TAG, "## onReceive() IN");

    // get session
    mSession = Matrix.getInstance(aContext).getDefaultSession();

    // user is not yet logged in
    if (null == mSession) {
        Log.e(LOG_TAG, "## onReceive() Warning - Unable to proceed URL link: Session is null");

        // No user is logged => no session. Just forward request to the login activity
        Intent intent = new Intent(aContext, LoginActivity.class);
        intent.putExtra(EXTRA_UNIVERSAL_LINK_URI, aIntent.getData());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        aContext.startActivity(intent);
        return;
    }

    // sanity check
    if (null != aIntent) {

        action = aIntent.getAction();
        uriString = aIntent.getDataString();
        boolean isSessionActive = mSession.isAlive();
        boolean isLoginStepDone = mSession.getDataHandler().isInitialSyncComplete();

        Log.d(LOG_TAG, "## onReceive() uri getDataString=" + uriString + "isSessionActive=" + isSessionActive
                + " isLoginStepDone=" + isLoginStepDone);

        if (TextUtils.equals(action, BROADCAST_ACTION_UNIVERSAL_LINK)) {
            Log.d(LOG_TAG, "## onReceive() action = BROADCAST_ACTION_UNIVERSAL_LINK");
            intentUri = aIntent.getData();

        } else if (TextUtils.equals(action, BROADCAST_ACTION_UNIVERSAL_LINK_RESUME)) {
            Log.d(LOG_TAG, "## onReceive() action = BROADCAST_ACTION_UNIVERSAL_LINK_RESUME");

            // A first BROADCAST_ACTION_UNIVERSAL_LINK has been received with a room alias that could not be translated to a room ID.
            // Translation has been asked to server, and the response is processed here.
            // ......................
            intentUri = aIntent.getParcelableExtra(EXTRA_UNIVERSAL_LINK_URI);
            // aIntent.getParcelableExtra(EXTRA_UNIVERSAL_LINK_SENDER_ID);
        } else {
            // unknown action (very unlikely)
            Log.e(LOG_TAG,
                    "## onReceive() Unknown action received (" + action + ") - unable to proceed URL link");
            return;
        }

        if (null != intentUri) {
            Log.d(LOG_TAG, "## onCreate() intentUri - host=" + intentUri.getHost() + " path="
                    + intentUri.getPath() + " queryParams=" + intentUri.getQuery());
            //intentUri.getEncodedSchemeSpecificPart() = //vector.im/beta/  intentUri.getSchemeSpecificPart() = //vector.im/beta/

            HashMap<String, String> params = parseUniversalLink(intentUri);

            if (null != params) {

                if (!isSessionActive) {
                    Log.w(LOG_TAG, "## onReceive() Warning: Session is not alive");
                }

                if (!isLoginStepDone) {
                    Log.w(LOG_TAG, "## onReceive() Warning: Session is not complete - start Login Activity");

                    // Start the login activity and wait for BROADCAST_ACTION_UNIVERSAL_LINK_RESUME.
                    // Once the login process flow is complete, BROADCAST_ACTION_UNIVERSAL_LINK_RESUME is
                    // sent back to resume the URL link processing.
                    Intent intent = new Intent(aContext, LoginActivity.class);
                    intent.putExtra(EXTRA_UNIVERSAL_LINK_URI, aIntent.getData());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    aContext.startActivity(intent);
                } else {
                    mParameters = params;

                    if (mParameters.containsKey(ULINK_ROOM_ID_OR_ALIAS_KEY)) {
                        manageRoomOnActivity(aContext);
                    } else if (mParameters.containsKey(ULINK_MATRIX_USER_ID_KEY)) {
                        manageMemberDetailsActivity(aContext);
                    } else if (mParameters.containsKey(ULINK_GROUP_ID_KEY)) {
                        manageGroupDetailsActivity(aContext);
                    } else {
                        Log.e(LOG_TAG, "## onReceive() : nothing to do");
                    }
                }
            } else {
                Log.e(LOG_TAG, "## onReceive() Path not supported: " + intentUri.getPath());
            }
        }
    }
}

From source file:com.bayapps.android.robophish.ui.PlaybackControlsFragment.java

private void onMetadataChanged(MediaMetadataCompat metadata) {
    LogHelper.d(TAG, "onMetadataChanged ", metadata);
    if (getActivity() == null) {
        LogHelper.w(TAG, "onMetadataChanged called when getActivity null,"
                + "this should not happen if the callback was properly unregistered. Ignoring.");
        return;/*from  w  w w.  j  ava2  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();
    }
    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) {
                        LogHelper.d(TAG, "album art icon of w=", icon.getWidth(), " h=", icon.getHeight());
                        if (isAdded()) {
                            mAlbumArt.setImageBitmap(icon);
                        }
                    }
                }
            });
        }
    }
}

From source file:dk.glutter.android.knr.ui.PlaybackControlsFragment.java

private void onMetadataChanged(MediaMetadataCompat metadata) {
    LogHelper.d(TAG, "onMetadataChanged ", metadata);
    if (getActivity() == null) {
        LogHelper.w(TAG, "onMetadataChanged called when getActivity null,"
                + "this should not happen if the callback was properly unregistered. Ignoring.");
        return;/* w  w  w .j av  a2 s  .  c  o  m*/
    }
    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();
    }
    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 onError(String artUrl, Exception e) {
                    Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.bg);
                    mAlbumArt.setImageBitmap(image);
                }

                @Override
                public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) {
                    if (icon != null) {
                        LogHelper.d(TAG, "album art icon of w=", icon.getWidth(), " h=", icon.getHeight());
                        if (isAdded()) {
                            mAlbumArt.setImageBitmap(icon);
                        }
                    }
                }
            });
        }
    }
}

From source file:com.torrenttunes.android.ui.PlaybackControlsFragment.java

private void onMetadataChanged(MediaMetadataCompat metadata) {

    LogHelper.d(TAG, "onMetadataChanged ", metadata);

    if (getActivity() == null) {
        LogHelper.w(TAG, "onMetadataChanged called when getActivity null,"
                + "this should not happen if the callback was properly unregistered. Ignoring.");
        return;/*w w w  .  java 2  s.  c  o m*/
    }
    if (metadata == null) {
        return;
    }

    mTitle.setText(metadata.getDescription().getTitle());
    mSubtitle.setText(metadata.getDescription().getSubtitle());
    String artUrl = metadata.getDescription().getIconUri().toString();
    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) {
                        LogHelper.d(TAG, "album art icon of w=", icon.getWidth(), " h=", icon.getHeight());
                        if (isAdded()) {
                            mAlbumArt.setImageBitmap(icon);
                        }
                    }
                }
            });
        }
    }
}

From source file:com.whitecloud.ron.musicplayer.LocalPlayback.java

@Override
public void play(QueueItem item) {
    mPlayOnFocusGain = true;//from  www  .j  a  v a  2 s  . c om
    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 = MusicProvider
                .getTrackSource(track.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID));

        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());
            }
        }
    }
}

From source file:com.johnny.gank.ui.activity.PictureActivity.java

private int getInitPicPos(List<GankNormalItem> list) {
    int size = list.size();
    for (int i = 0; i < size; i++) {
        if (TextUtils.equals(list.get(i)._id, mInitPicId)) {
            return i;
        }// w w  w.  j av  a2s. co  m
    }
    return 0;
}