List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.waz.zclient.pages.main.profile.preferences.dialogs.AddPhoneNumberPreferenceDialogFragment.java
private void showError(final String error) { if (TextUtils.equals(errorView.getText(), error)) { return;//from ww w .j av a2 s.co m } final boolean animate = ViewCompat.isLaidOut(containerView); final boolean errorShown = !TextUtils.isEmpty(error); ViewCompat.animate(errorView).cancel(); if (errorShown) { errorView.setText(error); errorView.setVisibility(View.VISIBLE); if (animate) { if (MathUtils.floatEqual(ViewCompat.getAlpha(errorView), 1f)) { ViewCompat.setAlpha(errorView, 0f); } ViewCompat.animate(errorView).alpha(1f).setDuration(ANIMATION_DURATION) .setInterpolator(LINEAR_OUT_SLOW_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { view.setVisibility(View.VISIBLE); } }).start(); } } else { if (errorView.getVisibility() == View.VISIBLE) { if (animate) { ViewCompat.animate(errorView).alpha(0f).setDuration(ANIMATION_DURATION) .setInterpolator(FAST_OUT_LINEAR_IN_INTERPOLATOR) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { errorView.setText(error); view.setVisibility(View.INVISIBLE); updateEditTextBackground(countryEditText); updateEditTextBackground(phoneEditText); } }).start(); } else { errorView.setVisibility(View.INVISIBLE); } } } updateEditTextBackground(countryEditText); updateEditTextBackground(phoneEditText); }
From source file:com.android.tv.settings.MainFragment.java
private void updateAccounts() { if (mAccountsGroup == null) { return;/*from w ww . ja v a 2 s . co m*/ } final Set<String> touchedAccounts = new ArraySet<>(mAccountsGroup.getPreferenceCount()); final AccountManager am = AccountManager.get(getContext()); final AuthenticatorDescription[] authTypes = am.getAuthenticatorTypes(); final ArrayList<String> allowableAccountTypes = new ArrayList<>(authTypes.length); final Context themedContext = getPreferenceManager().getContext(); for (AuthenticatorDescription authDesc : authTypes) { final Context targetContext; try { targetContext = getContext().createPackageContext(authDesc.packageName, 0); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Authenticator description with bad package name", e); continue; } catch (SecurityException e) { Log.e(TAG, "Security exception loading package resources", e); continue; } // Main title text comes from the authenticator description (e.g. "Google"). String authTitle = null; try { authTitle = targetContext.getString(authDesc.labelId); if (TextUtils.isEmpty(authTitle)) { authTitle = null; // Handled later when we add the row. } } catch (Resources.NotFoundException e) { Log.e(TAG, "Authenticator description with bad label id", e); } // There exist some authenticators which aren't intended to be user-facing. // If the authenticator doesn't have a title or an icon, don't present it to // the user as an option. if (authTitle != null || authDesc.iconId != 0) { allowableAccountTypes.add(authDesc.type); } Account[] accounts = am.getAccountsByType(authDesc.type); if (accounts == null || accounts.length == 0) { continue; // No point in continuing; there aren't any accounts to show. } // Icon URI to be displayed for each account is based on the type of authenticator. Drawable authImage = null; try { authImage = targetContext.getDrawable(authDesc.iconId); } catch (Resources.NotFoundException e) { Log.e(TAG, "Authenticator has bad resources", e); } // Display an entry for each installed account we have. for (final Account account : accounts) { final String key = "account_pref:" + account.type + ":" + account.name; Preference preference = findPreference(key); if (preference == null) { preference = new Preference(themedContext); } preference.setTitle(authTitle != null ? authTitle : account.name); preference.setIcon(authImage); preference.setSummary(authTitle != null ? account.name : null); preference.setFragment(AccountSyncFragment.class.getName()); AccountSyncFragment.prepareArgs(preference.getExtras(), account); touchedAccounts.add(key); preference.setKey(key); mAccountsGroup.addPreference(preference); } } for (int i = 0; i < mAccountsGroup.getPreferenceCount();) { final Preference preference = mAccountsGroup.getPreference(i); final String key = preference.getKey(); if (touchedAccounts.contains(key) || TextUtils.equals(KEY_ADD_ACCOUNT, key)) { i++; } else { mAccountsGroup.removePreference(preference); } } // Never allow restricted profile to add accounts. final Preference addAccountPref = findPreference(KEY_ADD_ACCOUNT); if (addAccountPref != null) { addAccountPref.setOrder(Integer.MAX_VALUE); if (isRestricted()) { addAccountPref.setVisible(false); } else { Intent i = new Intent().setComponent(new ComponentName("com.android.tv.settings", "com.android.tv.settings.accounts.AddAccountWithTypeActivity")); i.putExtra(AddAccountWithTypeActivity.EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY, allowableAccountTypes.toArray(new String[allowableAccountTypes.size()])); // If there are available account types, show the "add account" button. addAccountPref.setVisible(!allowableAccountTypes.isEmpty()); addAccountPref.setIntent(i); } } }
From source file:dk.glutter.android.dansker.uamp.ui.tv.TvBrowseFragment.java
private void setupEventListeners() { setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override/*w w w. j a va2 s.co m*/ public void onItemClicked(Presenter.ViewHolder viewHolder, Object clickedItem, RowPresenter.ViewHolder viewHolder2, Row row) { if (clickedItem instanceof MediaBrowserCompat.MediaItem) { MediaItem item = (MediaItem) clickedItem; if (item.isPlayable()) { LogHelper.w(TAG, "Ignoring click on PLAYABLE MediaItem in" + "TvBrowseFragment. mediaId=", item.getMediaId()); return; } Intent intent = new Intent(getActivity(), TvVerticalGridActivity.class); intent.putExtra(TvBrowseActivity.SAVED_MEDIA_ID, item.getMediaId()); intent.putExtra(TvBrowseActivity.BROWSE_TITLE, item.getDescription().getTitle()); startActivity(intent); } else if (clickedItem instanceof MediaSessionCompat.QueueItem) { MediaSessionCompat.QueueItem item = (MediaSessionCompat.QueueItem) clickedItem; MediaControllerCompat mediaController = getActivity().getSupportMediaController(); // if clicked media item is not already playing, call skipToQueueItem to play it if (mediaController != null && mediaController.getMetadata() != null) { String currentPlaying = mediaController.getMetadata().getDescription().getMediaId(); String itemMusicId = MediaIDHelper .extractMusicIDFromMediaID(item.getDescription().getMediaId()); if (!TextUtils.equals(currentPlaying, itemMusicId)) { mediaController.getTransportControls().skipToQueueItem(item.getQueueId()); } } else { mediaController.getTransportControls().skipToQueueItem(item.getQueueId()); } Intent intent = new Intent(getActivity(), TvPlaybackActivity.class); startActivity(intent); } } }); setOnSearchClickedListener(new View.OnClickListener() { @Override public void onClick(View view) { LogHelper.d(TAG, "In-app search"); // TODO: implement in-app search Intent intent = new Intent(getActivity(), TvBrowseActivity.class); startActivity(intent); } }); }
From source file:com.tct.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 ww w.ja v a 2 s.c om */ 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 // TS: zhaotianyong 2015-01-29 EMAIL BUGFIX-916938 DEL_S // mSaveClicked = !attachment.isDownloading() ? false : mSaveClicked; // TS: zhaotianyong 2015-01-29 EMAIL BUGFIX-916938 DEL_S 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(); } //Unicode the downloaded size. if (mAttachment.isDownloading()) { mAttachmentDownloadedSize = bidiFormatter.unicodeWrap( AttachmentUtils.convertToHumanReadableSize(getContext(), mAttachment.downloadedSize)); } updateActions(loaderResult, mAttachment.isDownloading()); mActionHandler.updateStatus(loaderResult); //TS: Gantao 2015-08-27 EMAIL FEATURE_ID MOD_S //Load the image thunmbnail and show it. if (AttachmentTile.isTiledAttachment(mAttachment)) { if (loaderResult && mAttachment.isPresentLocally()) { ThumbnailLoadTask.setupThumbnailPreview(mThumbnail, attachment, this); } else { mThumbnail.setImageResource(R.drawable.ic_array); setThumbnailDefault(true); setTitleVisibility(VISIBLE); } } //TS: Gantao 2015-08-27 EMAIL FEATURE_ID MOD_E }
From source file:com.scooter1556.sms.android.playback.CastPlayback.java
private void setMetadataFromRemote() { Log.d(TAG, "setMetadataFromRemote()"); // Get the custom data from the remote media information and update the local // metadata if it's different from the one we are currently using. // This can happen when the app was either reconnected, or if the // app joins an existing session while the cast device is playing a queue. try {/*from w w w . j a va2 s . c om*/ MediaInfo mediaInfo = remoteMediaClient.getMediaInfo(); if (mediaInfo == null) { return; } JSONObject customData = mediaInfo.getCustomData(); if (customData != null && customData.has(MEDIA_ID)) { String remoteMediaId = customData.getString(MEDIA_ID); if (!TextUtils.equals(currentMediaId, remoteMediaId)) { currentMediaId = remoteMediaId; if (callback != null) { callback.setCurrentMediaID(remoteMediaId); } updateLastKnownStreamPosition(); } } } catch (JSONException e) { Log.e(TAG, "Exception processing metadata from remote client", e); } }
From source file:android.support.v7.preference.PreferenceGroupAdapter.java
@Override public int getPreferenceAdapterPosition(String key) { final int size = mPreferenceList.size(); for (int i = 0; i < size; i++) { final Preference candidate = mPreferenceList.get(i); if (TextUtils.equals(key, candidate.getKey())) { return i; }/* w w w. j a va2 s .c om*/ } return RecyclerView.NO_POSITION; }
From source file:com.nbarraille.loom.TaskManager.java
/** * Registers a listener with Loom.//ww w.j av a 2 s . c o m * The listener will receive all the events sent by tasks with a {@link Task#name()} matching * their {@link LoomListener#taskName()} * * If the task with the given ID has already finished (and hasn't been cleared from the backlog * yet), the listener's {@link LoomListener#onSuccess} or {@link LoomListener#onFailure} * callback be called immediately, in the UI thread. * * It is recommended to use this version of registerListener when task completion events could * have been missed (Activity/Fragment re-creation after configuration change, for example) * * @param listener the listener to register, cannot be null * @param taskId the ID of the task to receive past Success/Failure events for. If that task ID * refers to a task that has a different {@link Task#name} */ public void registerListener(@NonNull final LoomListener listener, int taskId) { mEventBus.register(listener); TaskStatus status = getTaskStatus(taskId); if (status != null) { if (status.isFinished()) { final SuccessEvent success = status.getSuccessEvent(); final FailureEvent failure = status.getFailureEvent(); if (success != null) { if (!TextUtils.equals(success.getTaskName(), listener.taskName()) && mIsLoggingEnabled) { Log.e(Loom.LOG_TAG, "The task with id " + taskId + " is not of type " + listener.taskName()); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { //noinspection unchecked listener.onSuccess(success); } }); } else if (failure != null) { if (!TextUtils.equals(failure.getTaskName(), listener.taskName()) && mIsLoggingEnabled) { Log.e(Loom.LOG_TAG, "The task with id " + taskId + " is not of type " + listener.taskName()); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { //noinspection unchecked listener.onFailure(failure); } }); } } } }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
/** * Notifies container that edit text has changed. And if text is not empty it triggers * also the typing indicator.// w w w . j a va 2 s. co m */ @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (isEditingMessage()) { if (message == null) { return; } boolean enableControls = !TextUtils.equals(newCursorEditText.getText(), message.getBody()); hintView.setVisibility(View.GONE); editMessageCursorToolbar.enableEditControls(enableControls); return; } String text = charSequence.toString(); if (cursorCallback != null) { cursorCallback.onEditTextHasChanged(newCursorEditText.getSelectionStart(), text); } if (TextUtils.isEmpty(charSequence.toString())) { hintView.setVisibility(View.VISIBLE); } else { hintView.setVisibility(View.GONE); } showTopbar(newCursorEditText.getLineCount() > maxLines); }
From source file:com.google.samples.apps.iosched.explore.ExploreSessionsActivity.java
private void onTagMetadataLoaded() { if (mTagFilterHolder == null) { // Use the Intent Extras to set up the TagFilterHolder mTagFilterHolder = new TagFilterHolder(); String tag = getIntent().getStringExtra(EXTRA_FILTER_TAG); TagMetadata.Tag userTag = mTagMetadata.getTag(tag); String userTagCategory = userTag == null ? null : userTag.getCategory(); if (tag != null && userTagCategory != null) { mTagFilterHolder.add(tag, userTagCategory); }//from w w w . j a va 2s . c o m mTagFilterHolder.setShowLiveStreamedSessions( getIntent().getBooleanExtra(EXTRA_SHOW_LIVE_STREAM_SESSIONS, false)); // update the selected filters using the following logic: // a) For onsite attendees, we should default to showing all 'types' // (i.e. Sessions, code labs, sandbox, misc). if (SettingsUtils.isAttendeeAtVenue(this)) { List<TagMetadata.Tag> tags = mTagMetadata.getTagsInCategory(Config.Tags.CATEGORY_TYPE); // Here we only add all 'types' if the user has not explicitly selected // one of the category_type tags. if (tags != null && !TextUtils.equals(userTagCategory, Config.Tags.CATEGORY_TYPE)) { for (TagMetadata.Tag theTag : tags) { mTagFilterHolder.add(theTag.getId(), theTag.getCategory()); } } } else { // b) For remote users, default to only showing Sessions that are Live streamed. TagMetadata.Tag theTag = mTagMetadata.getTag(Config.Tags.SESSIONS); if (!TextUtils.equals(theTag.getCategory(), userTagCategory)) { mTagFilterHolder.add(theTag.getId(), theTag.getCategory()); } mTagFilterHolder.setShowLiveStreamedSessions(true); } } reloadFragment(); TagAdapter tagAdapter = new TagAdapter(); mDrawerCollectionView.setCollectionAdapter(tagAdapter); mDrawerCollectionView.updateInventory(tagAdapter.getInventory()); }
From source file:io.github.hidroh.materialistic.AppUtils.java
@SuppressLint("MissingPermission") public static Pair<String, String> getCredentials(Context context) { String username = Preferences.getUsername(context); if (TextUtils.isEmpty(username)) { return null; }/* w ww .j a va 2 s. c o m*/ AccountManager accountManager = AccountManager.get(context); Account[] accounts = accountManager.getAccountsByType(BuildConfig.APPLICATION_ID); for (Account account : accounts) { if (TextUtils.equals(username, account.name)) { return Pair.create(username, accountManager.getPassword(account)); } } return null; }