List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.torrenttunes.android.ui.MusicPlayerActivity.java
private void navigateToBrowser(String mediaId) { LogHelper.d(TAG, "navigateToBrowser, mediaId=" + mediaId); MediaBrowserFragment fragment = getBrowseFragment(); if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) { fragment = new MediaBrowserFragment(); fragment.setMediaId(mediaId);//from w ww. ja va2 s . co m FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // transaction.setCustomAnimations( // R.animator.slide_in_from_right, R.animator.slide_out_to_left, // R.animator.slide_in_from_left, R.animator.slide_out_to_right); transaction.replace(R.id.container, fragment); // If this is not the top level media (root), we add it to the fragment back stack, // so that actionbar toggle and Back will work appropriately: if (mediaId != null) { transaction.addToBackStack(null); } transaction.commit(); } }
From source file:im.neon.util.VectorUtils.java
/** * Provide a display name for a calling room * * @param context the application context. * @param session the room session.// w w w .j av a 2 s. c o m * @param room the room. * @return the calling room display name. */ public static String getCallingRoomDisplayName(Context context, MXSession session, Room room) { if ((null == context) || (null == session) || (null == room)) { return null; } Collection<RoomMember> roomMembers = room.getJoinedMembers(); if (2 == roomMembers.size()) { ArrayList<RoomMember> roomMembersList = new ArrayList<>(roomMembers); if (TextUtils.equals(roomMembersList.get(0).getUserId(), session.getMyUserId())) { return room.getLiveState().getMemberName(roomMembersList.get(1).getUserId()); } else { return room.getLiveState().getMemberName(roomMembersList.get(0).getUserId()); } } else { return getRoomDisplayName(context, session, room); } }
From source file:com.torrenttunes.android.LocalPlayback.java
@Override public void play(QueueItem item) { mPlayOnFocusGain = true;/*from w w w . ja v a2 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(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) { LogHelper.e(TAG, ex, "Exception playing song"); if (mCallback != null) { mCallback.onError(ex.getMessage()); } } } }
From source file:com.example.lzhang.stockchartt.media.playback.LocalPlayback.java
@Override public void play(MediaSessionCompat.QueueItem item) { mPlayOnFocusGain = true;//from w w w . j a v a 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())); //noinspection ResourceType String source = item.getDescription().getMediaUri().toString();//track.getString(MusicProviderSource.CUSTOM_METADATA_TRACK_SOURCE); if (source != null) { source = source.replaceAll(" ", "%20"); // Escape spaces for URLs } 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.google.android.apps.muzei.SourceManager.java
public void handlePublishState(String token, SourceState state) { synchronized (this) { if (!TextUtils.equals(token, mSelectedSourceToken)) { LOGW(TAG, "Dropping update from non-selected source (token mismatch)."); return; }/*from w w w . j av a2 s . com*/ 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) { LOGE(TAG, "Error storing source status data.", e); } } EventBus.getDefault().post(new SelectedSourceStateChangedEvent()); }
From source file:com.location.philippweiher.test.SendMockLocationService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { // Get the type of test to run mTestRequest = startIntent.getAction(); latitude = startIntent.getDoubleExtra(MapsActivity.LAT_FOR_POINT, 0); longitude = startIntent.getDoubleExtra(MapsActivity.LON_FOR_POINT, 0); /*/*from w w w . j a v a 2 s . c om*/ * If the incoming Intent was a request to run a one-time or continuous test */ if (TextUtils.equals(mTestRequest, MapsActivity.ACTION_START)) { // Get the pause interval and injection interval mPauseInterval = startIntent.getIntExtra(MapsActivity.EXTRA_PAUSE_VALUE, 2); mInjectionInterval = startIntent.getIntExtra(MapsActivity.EXTRA_SEND_INTERVAL, 1); // Create a location client mLocationClient = new LocationClient(this, this, this); // Start connecting to Location Services mLocationClient.connect(); } else if (TextUtils.equals(mTestRequest, MapsActivity.ACTION_STOP_TEST)) { // Send a message back to the main activity that the test is stopping sendBroadcastMessage(); // Stop this Service stopSelf(); } /* * Tell the system to keep the Service alive, but to discard the Intent that * started the Service */ return Service.START_STICKY; }
From source file:com.example.android.uamp.LocalPlayback.java
@Override public void play(MediaSessionCompat.QueueItem item) { mPlayOnFocusGain = true;/* w w w.jav 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 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()); } } } }
From source file:com.classiqo.nativeandroid_32bitz.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. ja v a 2 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 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.taobao.weex.ui.action.GraphicActionAddElement.java
@Override public void executeAction() { super.executeAction(); try {//from ww w .ja va 2s.c o m if (!TextUtils.equals(mComponentType, "video") && !TextUtils.equals(mComponentType, "videoplus")) child.mIsAddElementToTree = true; parent.addChild(child, mIndex); parent.createChildViewAt(mIndex); if (layoutPosition != null && layoutSize != null) { child.setDemission(layoutSize, layoutPosition); } child.applyLayoutAndEvent(child); child.bindData(child); } catch (Exception e) { WXLogUtils.e("add component failed.", e); } }
From source file:com.nicolls.ablum.fragment.VideoFragment.java
private void setAdapter() { int count = mCursor.getCount(); // Toast.makeText(getActivity(),pathList.size()+"###",Toast.LENGTH_SHORT).show(); if (count > 0) { mDataColumnIndex = mCursor.getColumnIndex(MEDIA_DATA); //move position to first element mCursor.moveToFirst();//from ww w .j a v a 2s. c om mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < count; i++) { mCursor.moveToPosition(i); String url = mCursor.getString(mDataColumnIndex); MediaModel galleryModel = new MediaModel(url, false); for (String path : pathList) { if (TextUtils.equals(path, galleryModel.url)) { galleryModel.status = true; mSelectedItems.add(galleryModel.url.toString()); break; } } mGalleryModelList.add(galleryModel); } mVideoAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, true); mVideoAdapter.videoFragment = this; mVideoGridView.setAdapter(mVideoAdapter); mVideoGridView.setOnScrollListener(this); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } mVideoGridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "video/*"); startActivity(intent); return false; } }); mVideoGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), true); if (size != 0) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.file_size_exeeded) + " " + MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB + " " + getActivity().getResources().getString(R.string.mb), Toast.LENGTH_SHORT).show(); return; } if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) { if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.file), Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.files), Toast.LENGTH_SHORT).show(); return; } } } // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); MediaChooserConstants.SELECTED_MEDIA_COUNT++; } else { mSelectedItems.remove(galleryModel.url.toString().trim()); MediaChooserConstants.SELECTED_MEDIA_COUNT--; } if (mCallback != null) { mCallback.onVideoSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }