List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:cat.terrones.devops.radiofx.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 *///w w w.j a v a 2s.com public static boolean isMediaItemPlaying(Context context, MediaBrowserCompat.MediaItem mediaItem) { // Media item is considered to be playing or paused based on the controller's current // media id MediaControllerCompat controller = ((FragmentActivity) context).getSupportMediaController(); 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.koushikdutta.async.http.BasicNameValuePair.java
public boolean equals(final Object object) { if (object == null) return false; if (this == object) return true; if (object instanceof NameValuePair) { BasicNameValuePair that = (BasicNameValuePair) object; return this.name.equals(that.name) && TextUtils.equals(this.value, that.value); } else {/* www .j a va2 s .com*/ return false; } }
From source file:com.google.android.apps.forscience.whistlepunk.metadata.TriggerListFragment.java
@Override public void onResume() { super.onResume(); getDataController().getSensorLayouts(mExperimentId, new LoggingConsumer<List<GoosciSensorLayout.SensorLayout>>(TAG, "get layout") { @Override/*from ww w . j ava 2 s .com*/ public void success(List<GoosciSensorLayout.SensorLayout> value) { for (GoosciSensorLayout.SensorLayout layout : value) { if (TextUtils.equals(layout.sensorId, mSensorId)) { mSensorLayout = layout; } } } }); getDataController().getSensorTriggersForSensor(mSensorId, new LoggingConsumer<List<SensorTrigger>>(TAG, "get triggers for sensor") { @Override public void success(List<SensorTrigger> triggers) { Comparator<SensorTrigger> cp; if (mTriggerOrder != null) { // If this is not the first load, use the saved order to define a new // order, but insert new triggers at the top. cp = new Comparator<SensorTrigger>() { @Override public int compare(SensorTrigger lhs, SensorTrigger rhs) { int lhsIndex = mTriggerOrder.indexOf(lhs.getTriggerId()); int rhsIndex = mTriggerOrder.indexOf(rhs.getTriggerId()); if (lhsIndex == rhsIndex && lhsIndex == -1) { // If they are both not found, they are both new. return Long.compare(rhs.getLastUsed(), lhs.getLastUsed()); } return Integer.compare(lhsIndex, rhsIndex); } }; } else { // Only do this sort on the first load. cp = new Comparator<SensorTrigger>() { @Override public int compare(SensorTrigger lhs, SensorTrigger rhs) { boolean lhsIsActive = isTriggerActive(lhs); boolean rhsIsActive = isTriggerActive(rhs); if (lhsIsActive && !rhsIsActive) { return -1; } if (!lhsIsActive && rhsIsActive) { return 1; } return Long.compare(rhs.getLastUsed(), lhs.getLastUsed()); } }; } // Sort sensor triggers Collections.sort(triggers, cp); mTriggerAdapter.setSensorTriggers(triggers); } }); WhistlePunkApplication.getUsageTracker(getActivity()).trackScreenView(TrackerConstants.SCREEN_TRIGGER_LIST); }
From source file:com.junnanhao.next.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 ww w. j av a2 s. c om public static boolean isMediaItemPlaying(Context 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((FragmentActivity) 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.nicolls.ablum.fragment.ImageFragment.java
private void setAdapter(Cursor imagecursor) { // Toast.makeText(getActivity(),pathList.size()+"###",Toast.LENGTH_SHORT).show(); if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); for (String path : pathList) { if (TextUtils.equals(path, galleryModel.url)) { galleryModel.status = true; mSelectedItems.add(galleryModel.url.toString()); break; }/* www . j a v a 2s .co m*/ } mGalleryModelList.add(galleryModel); } mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false); mImageGridView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } mImageGridView.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), "image/*"); startActivity(intent); return true; } }); mImageGridView.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()), false); if (size != 0) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.file_size_exeeded) + " " + MediaChooserConstants.SELECTED_IMAGE_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.onImageSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:com.scooter1556.sms.android.playback.CastPlayback.java
@Override public void play(MediaSessionCompat.QueueItem item) { Log.d(TAG, "play(" + item.getDescription().getMediaId() + ")"); boolean mediaHasChanged = !TextUtils.equals(item.getDescription().getMediaId(), currentMediaId); if (mediaHasChanged) { currentMediaId = item.getDescription().getMediaId(); currentPosition = 0;/*from w w w. jav a 2 s . c om*/ } if (playbackState == PlaybackStateCompat.STATE_PAUSED && !mediaHasChanged && remoteMediaClient.hasMediaSession()) { remoteMediaClient.play(); } else { loadMedia(item, true); playbackState = PlaybackStateCompat.STATE_BUFFERING; } if (callback != null) { callback.onPlaybackStatusChanged(playbackState); } }
From source file:com.aylanetworks.aura.GcmIntentService.java
private void sendNotification(String msg, String sound) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); // Find the launcher class for our application PackageManager pm = getPackageManager(); String packageName = getPackageName(); Intent query = new Intent(Intent.ACTION_MAIN); Class launcherClass = null;// www .ja v a 2 s .c om query.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> foundIntents = pm.queryIntentActivities(query, 0); for (ResolveInfo info : foundIntents) { if (TextUtils.equals(info.activityInfo.packageName, packageName)) { launcherClass = info.activityInfo.getClass(); } } if (launcherClass == null) { Log.e(TAG, "Could not find application launcher class"); return; } Intent appIntent = new Intent(this, launcherClass); // main activity of Ayla Control/aMCA PendingIntent contentIntent = PendingIntent.getActivity(this, 0, appIntent, 0); //Determine the sound to be played Uri soundUri = null; if (sound == null) { // NOP //PushNotification.playSound("bdth.mp3"); } else if (sound.equals("none")) { // NOP } else if (sound.equals("default")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } else if (sound.equals("alarm")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); // TYPE_NOTIFICATION or TYPE_ALARM } else { boolean playedSound; playedSound = PushNotification.playSound(sound); if (playedSound == false) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } } // @formatter:off NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) //.setSound(soundUri) .setSmallIcon(R.drawable.ic_push_icon).setContentTitle(getResources().getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setLights(0xFFff0000, 500, 500) // flashing red light .setContentText(msg).setAutoCancel(true) //.setPriority(Notification.FLAG_HIGH_PRIORITY) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.FLAG_SHOW_LIGHTS); // @formatter:on if (soundUri != null) { mBuilder.setSound(soundUri); } mBuilder.setPriority(PRIORITY_MAX); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:mobi.espier.lgc.data.UploadHelper.java
public void doUploadData(int limit) { List<WxLiveNotification> notis = LgcDataUtil.queryNotification(mContext, limit); LogUtils.d(TAG,/*from w w w.j a va2 s .c o m*/ ".................doUploadData query notification size = " + (notis != null ? notis.size() : 0)); if (notis == null || notis.size() < 1) { return; } String data = packageData(notis); LogUtils.d(TAG, "................. doUploadData data = " + data); if (TextUtils.isEmpty(data)) { return; } LogUtils.d(TAG, "................. doUploadData url = " + mUploadUrl); String response = doHttpPostAndGetResponse(mUploadUrl, data.getBytes()); LogUtils.d(TAG, "................. doUploadData response = " + response); LogUtils.d(TAG, "................. doUploadData mIDList = " + mIDList); if (TextUtils.equals("OK", response) && mIDList.size() > 0) { int count = LgcDataUtil.markSyncDone(mContext, mIDList); LogUtils.d(TAG, "................. doUploadData mark sync done = " + count); } }
From source file:com.alibaba.weex.WXPageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wxpage); setCurrentWxPageActivity(this); WXSDKEngine.setActivityNavBarSetter(new NavigatorAdapter()); getWindow().setFormat(PixelFormat.TRANSLUCENT); mUri = getIntent().getData();/*from w w w .j a v a 2 s .c om*/ Bundle bundle = getIntent().getExtras(); if (mUri == null && bundle == null) { mUri = Uri.parse(Constants.BUNDLE_URL + Constants.WEEX_SAMPLES_KEY); } if (bundle != null) { String bundleUrl = bundle.getString("bundleUrl"); Log.i(TAG, "bundleUrl==" + bundleUrl); if (bundleUrl != null) { mConfigMap.put("bundleUrl", bundleUrl + Constants.WEEX_SAMPLES_KEY); mUri = Uri.parse(bundleUrl + Constants.WEEX_SAMPLES_KEY); } } else { mConfigMap.put("bundleUrl", mUri.toString() + Constants.WEEX_SAMPLES_KEY); // mUri = Uri.parse(mUri.toString() + Constants.WEEX_SAMPLES_KEY) } if (mUri == null) { Toast.makeText(this, "the uri is empty!", Toast.LENGTH_SHORT).show(); finish(); return; } Log.e("TestScript_Guide mUri==", mUri.toString()); initUIAndData(); if (WXPAGE.equals(mUri.getScheme())) { mUri = mUri.buildUpon().scheme("http").build(); loadWXfromService(mUri.toString()); startHotRefresh(); mWXHandler.removeCallbacks(mCollectIDMap); mWXHandler.postDelayed(mCollectIDMap, 2000); } else if (TextUtils.equals("http", mUri.getScheme()) || TextUtils.equals("https", mUri.getScheme())) { // if url has key "_wx_tpl" then get weex bundle js String weexTpl = mUri.getQueryParameter(Constants.WEEX_TPL_KEY); String url = TextUtils.isEmpty(weexTpl) ? mUri.toString() : weexTpl; loadWXfromService(url); startHotRefresh(); } else { loadWXfromLocal(false); } mInstance.onActivityCreate(); registerBroadcastReceiver(); mWxAnalyzerDelegate = new WXAnalyzerDelegate(this); mWxAnalyzerDelegate.onCreate(); }
From source file:com.example.android.AudioArchive.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. j a v a 2 s.c o m FragmentTransaction transaction = getFragmentManager().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, FRAGMENT_TAG); // 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(); } }