List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.google.android.gms.nearby.messages.samples.nearbybackgroundbeacons.MainActivityFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (TextUtils.equals(key, Constants.KEY_CACHED_MESSAGES)) { List<String> messages = new ArrayList<>(Utils.getCachedMessages(getActivity())); mNearbyMessagesList.clear();/*from w ww .j a v a2 s . com*/ for (String message : messages) { mNearbyMessagesList.add(message); } mNearbyMessagesArrayAdapter.notifyDataSetChanged(); } }
From source file:com.android.contacts.model.AccountTypeManager.java
static Account getDefaultGoogleAccount(AccountManager accountManager, SharedPreferences prefs, String defaultAccountKey) { // Get all the google accounts on the device final Account[] accounts = accountManager.getAccountsByType(GoogleAccountType.ACCOUNT_TYPE); if (accounts == null || accounts.length == 0) { return null; }/* w w w .j a v a2 s . c om*/ // Get the default account from preferences final String defaultAccount = prefs.getString(defaultAccountKey, null); final AccountWithDataSet accountWithDataSet = defaultAccount == null ? null : AccountWithDataSet.unstringify(defaultAccount); // Look for an account matching the one from preferences if (accountWithDataSet != null) { for (int i = 0; i < accounts.length; i++) { if (TextUtils.equals(accountWithDataSet.name, accounts[i].name) && TextUtils.equals(accountWithDataSet.type, accounts[i].type)) { return accounts[i]; } } } // Just return the first one return accounts[0]; }
From source file:com.android.tv.settings.about.AboutFragment.java
@Override public boolean onPreferenceLongClick(Preference preference) { if (TextUtils.equals(preference.getKey(), KEY_RESTART)) { if (getCallbackFragment() instanceof LeanbackSettingsFragment) { LeanbackSettingsFragment callback = (LeanbackSettingsFragment) getCallbackFragment(); callback.startImmersiveFragment(RebootConfirmFragment.newInstance(true /* safeMode */)); return true; }// w w w. j ava2 s . c om } return false; }
From source file:com.example.android.uamp.playback.CastPlayback.java
private void setMetadataFromRemote() { // Sync: We get the customData from the remote media information and update the local // metadata if it happens to be different from the one we are currently using. // This can happen when the app was either restarted/disconnected + connected, or if the // app joins an existing session while the Chromecast was playing a queue. try {/*from w ww.j a v a 2 s.c o m*/ MediaInfo mediaInfo = mRemoteMediaClient.getMediaInfo(); if (mediaInfo == null) { return; } JSONObject customData = mediaInfo.getCustomData(); if (customData != null && customData.has(ITEM_ID)) { String remoteMediaId = customData.getString(ITEM_ID); if (!TextUtils.equals(mCurrentMediaId, remoteMediaId)) { mCurrentMediaId = remoteMediaId; if (mCallback != null) { mCallback.setCurrentMediaId(remoteMediaId); } updateLastKnownStreamPosition(); } } } catch (JSONException e) { LogHelper.e(TAG, e, "Exception processing update metadata"); } }
From source file:com.android.tv.settings.device.storage.FormatActivity.java
@Override public void onRequestFormatAsPrivate(String diskId) { final FormattingProgressFragment fragment = FormattingProgressFragment.newInstance(); getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit(); mFormatAsPrivateDiskId = diskId;/*from w w w. j a va 2 s. c om*/ final List<VolumeInfo> volumes = mStorageManager.getVolumes(); for (final VolumeInfo volume : volumes) { if ((volume.getType() == VolumeInfo.TYPE_PRIVATE || volume.getType() == VolumeInfo.TYPE_PUBLIC) && TextUtils.equals(volume.getDiskId(), diskId)) { mFormatDiskDesc = mStorageManager.getBestVolumeDescription(volume); } } if (TextUtils.isEmpty(mFormatDiskDesc)) { final DiskInfo info = mStorageManager.findDiskById(diskId); if (info != null) { mFormatDiskDesc = info.getDescription(); } } SettingsStorageService.formatAsPrivate(this, diskId); }
From source file:com.murrayc.galaxyzoo.app.ClassifyFragment.java
public void update() { final Activity activity = getActivity(); if (activity == null) return;/*from ww w .j a v a2 s. c o m*/ if (TextUtils.equals(getItemId(), ItemsContentProvider.URI_PART_ITEM_ID_NEXT)) { /* * Initializes the CursorLoader. The LOADER_ID_NEXT_ID 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. * * However, we don't start another "next" request when one is already in progress, * because then we would waste the first one and slow both down. * This can happen during resume. */ if (!mGetNextInProgress) { mGetNextInProgress = true; //Don't stay inverted after a previous classification. final FragmentManager fragmentManager = getChildFragmentManager(); final SubjectFragment fragmentSubject = (SubjectFragment) fragmentManager .findFragmentById(R.id.child_fragment_subject); if (fragmentSubject != null) { fragmentSubject.setInverted(false); } //Get the actual ID and other details: getLoaderManager().restartLoader(LOADER_ID_NEXT_ID, null, this); } } else { //Add, or update, the child fragments already, because we know the Item IDs: addOrUpdateChildFragments(); } }
From source file:com.google.android.apps.forscience.whistlepunk.EditNoteDialog.java
private boolean labelBelongsToRun() { return !TextUtils.equals(mLabel.getRunId(), RecordFragment.NOT_RECORDING_RUN_ID); }
From source file:com.murati.oszk.audiobook.ui.MusicPlayerActivity.java
private void navigateToBrowser(String mediaId) { //TODO: maybe place navigate block here LogHelper.d(TAG, "navigateToBrowser, mediaId=" + mediaId); MediaBrowserFragment fragment = getBrowseFragment(); updateBookButtons(mediaId);/* ww w. j a va 2s.c o m*/ if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) { // Create Transaction 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); // Create Backstack // Not an empty, root or the same where we are currently, for refresh retries if (fragment != null && mediaId != null && mediaId != getMediaId()) { transaction.addToBackStack(null); } //Create new fragment and navigate fragment = new MediaBrowserFragment(); fragment.setMediaId(mediaId); transaction.replace(R.id.container, fragment, FRAGMENT_TAG); //Do it transaction.commit(); } }
From source file:android.support.v7.preference.PreferenceGroup.java
/** * Finds a {@link Preference} based on its key. If two {@link Preference} * share the same key (not recommended), the first to appear will be * returned (to retrieve the other preference with the same key, call this * method on the first preference). If this preference has the key, it will * not be returned.// www .ja v a 2 s. c o m * <p> * This will recursively search for the preference into children that are * also {@link PreferenceGroup PreferenceGroups}. * * @param key The key of the preference to retrieve. * @return The {@link Preference} with the key, or null. */ public Preference findPreference(CharSequence key) { if (TextUtils.equals(getKey(), key)) { return this; } final int preferenceCount = getPreferenceCount(); for (int i = 0; i < preferenceCount; i++) { final Preference preference = getPreference(i); final String curKey = preference.getKey(); if (curKey != null && curKey.equals(key)) { return preference; } if (preference instanceof PreferenceGroup) { final Preference returnedPreference = ((PreferenceGroup) preference).findPreference(key); if (returnedPreference != null) { return returnedPreference; } } } return null; }
From source file:com.kanedias.vanilla.lyrics.LyricsShowActivity.java
/** * This plugin also has P2P functionality with others. * <br/>//from w ww . j av a 2 s . c o m * Tag plugin - Uses provided field retrieval interface for LYRICS tag: * <p/> * <pre> * Lyrics Plugin Tag Editor Plugin * | | * | P2P intent with lyrics request | * |---------------------------------------->| * | | * | P2P intent with lyrics response | * |<----------------------------------------| (can be empty if no embedded lyrics found) * | | * * At this point lyrics plugin starts activity with either * extras from lyrics response (if found) or with original intent * </pre> * * @param ctx context to resolve activities from * @param pkgName package name of the plugin to be queried */ private static boolean pluginInstalled(Context ctx, String pkgName) { List<ResolveInfo> resolved = ctx.getPackageManager().queryIntentActivities(new Intent(ACTION_LAUNCH_PLUGIN), 0); for (ResolveInfo pkg : resolved) { if (TextUtils.equals(pkg.activityInfo.packageName, pkgName)) { return true; } } return false; }