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.justwayward.reader.ui.easyadapter.BookDiscussionAdapter.java

@Override
public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
    return new BaseViewHolder<DiscussionList.PostsBean>(parent, R.layout.item_community_book_discussion_list) {
        @Override//from w  ww .  j  av  a 2  s . co  m
        public void setData(DiscussionList.PostsBean item) {
            if (!SettingManager.getInstance().isNoneCover()) {
                holder.setCircleImageUrl(R.id.ivBookCover, Constant.IMG_BASE_URL + item.author.avatar,
                        R.drawable.avatar_default);
            } else {
                holder.setImageResource(R.id.ivBookCover, R.drawable.avatar_default);
            }

            holder.setText(R.id.tvBookTitle, item.author.nickname)
                    .setText(R.id.tvBookType,
                            String.format(mContext.getString(R.string.book_detail_user_lv), item.author.lv))
                    .setText(R.id.tvTitle, item.title).setText(R.id.tvHelpfulYes, item.commentCount + "")
                    .setText(R.id.tvLikeCount, item.likeCount + "");

            try {
                TextView textView = holder.getView(R.id.tvHelpfulYes);
                if (item.type.equals("vote")) {
                    Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_notif_vote);
                    drawable.setBounds(0, 0, ScreenUtils.dpToPxInt(15), ScreenUtils.dpToPxInt(15));
                    textView.setCompoundDrawables(drawable, null, null, null);
                } else {
                    Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_notif_post);
                    drawable.setBounds(0, 0, ScreenUtils.dpToPxInt(15), ScreenUtils.dpToPxInt(15));
                    textView.setCompoundDrawables(drawable, null, null, null);
                }

                if (TextUtils.equals(item.state, "hot")) {
                    holder.setVisible(R.id.tvHot, true);
                    holder.setVisible(R.id.tvTime, false);
                    holder.setVisible(R.id.tvDistillate, false);
                } else if (TextUtils.equals(item.state, "distillate")) {
                    holder.setVisible(R.id.tvDistillate, true);
                    holder.setVisible(R.id.tvHot, false);
                    holder.setVisible(R.id.tvTime, false);
                } else {
                    holder.setVisible(R.id.tvTime, true);
                    holder.setVisible(R.id.tvHot, false);
                    holder.setVisible(R.id.tvDistillate, false);
                    holder.setText(R.id.tvTime, FormatUtils.getDescriptionTimeFromDateString(item.created));
                }
            } catch (Exception e) {
                LogUtils.e(e.toString());
            }
        }
    };
}

From source file:im.vector.util.ThemeUtils.java

/**
 * Update the application theme//from  www  .j ava2 s  .c  o  m
 *
 * @param aTheme the new theme
 */
public static void setApplicationTheme(Context context, String aTheme) {
    if (null != aTheme) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString(APPLICATION_THEME_KEY, aTheme);
        editor.commit();
    }

    if (TextUtils.equals(aTheme, THEME_DARK_VALUE)) {
        VectorApp.getInstance().setTheme(R.style.AppTheme_Dark);
    } else if (TextUtils.equals(aTheme, THEME_BLACK_VALUE)) {
        VectorApp.getInstance().setTheme(R.style.AppTheme_Black);
    } else {
        VectorApp.getInstance().setTheme(R.style.AppTheme);
    }

    mColorByAttr.clear();
}

From source file:com.androidinspain.deskclock.timer.TimerItem.java

/**
 * Updates this view to display the latest state of the {@code timer}.
 *///from   w  ww.j  a v a 2 s.  co  m
void update(Timer timer) {
    // Update the time.
    mTimerTextController.setTimeString(timer.getRemainingTime());

    // Update the label if it changed.
    final String label = timer.getLabel();
    if (!TextUtils.equals(label, mLabelView.getText())) {
        mLabelView.setText(label);
    }

    // Update visibility of things that may blink.
    final boolean blinkOff = SystemClock.elapsedRealtime() % 1000 < 500;
    if (mCircleView != null) {
        final boolean hideCircle = (timer.isExpired() || timer.isMissed()) && blinkOff;
        mCircleView.setVisibility(hideCircle ? INVISIBLE : VISIBLE);

        if (!hideCircle) {
            // Update the progress of the circle.
            mCircleView.update(timer);
        }
    }
    if (!timer.isPaused() || !blinkOff || mTimerText.isPressed()) {
        mTimerText.setAlpha(1f);
    } else {
        mTimerText.setAlpha(0f);
    }

    // Update some potentially expensive areas of the user interface only on state changes.
    if (timer.getState() != mLastState) {
        mLastState = timer.getState();
        final Context context = getContext();
        switch (mLastState) {
        case RESET:
        case PAUSED: {
            mResetAddButton.setText(R.string.timer_reset);
            mResetAddButton.setContentDescription(null);
            mTimerText.setClickable(true);
            mTimerText.setActivated(false);
            mTimerText.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
            ViewCompat.setAccessibilityDelegate(mTimerText,
                    new ClickAccessibilityDelegate(context.getString(R.string.timer_start), true));
            break;
        }
        case RUNNING: {
            final String addTimeDesc = context.getString(R.string.timer_plus_one);
            mResetAddButton.setText(R.string.timer_add_minute);
            mResetAddButton.setContentDescription(addTimeDesc);
            mTimerText.setClickable(true);
            mTimerText.setActivated(false);
            mTimerText.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
            ViewCompat.setAccessibilityDelegate(mTimerText,
                    new ClickAccessibilityDelegate(context.getString(R.string.timer_pause)));
            break;
        }
        case EXPIRED:
        case MISSED: {
            final String addTimeDesc = context.getString(R.string.timer_plus_one);
            mResetAddButton.setText(R.string.timer_add_minute);
            mResetAddButton.setContentDescription(addTimeDesc);
            mTimerText.setClickable(false);
            mTimerText.setActivated(true);
            mTimerText.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
            break;
        }
        }
    }
}

From source file:com.jrummyapps.busybox.utils.Utils.java

/**
 * Get a list of supported binaries for the given ABI.
 *
 * @param abi//from   w w  w . java2 s.com
 *     the {@link ABI} to filter
 * @return a list of binaries from the assets in this APK file.
 */
public static ArrayList<BinaryInfo> getBinariesFromAssets(ABI abi) {
    ArrayList<BinaryInfo> binaries = getBinariesFromAssets();
    String flavor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? "pie" : "nopie";
    for (Iterator<BinaryInfo> iterator = binaries.iterator(); iterator.hasNext();) {
        BinaryInfo binaryInfo = iterator.next();
        if (!TextUtils.equals(binaryInfo.abi, abi.base) || !TextUtils.equals(binaryInfo.flavor, flavor)) {
            iterator.remove();
        }
    }
    return binaries;
}

From source file:com.citrus.sdk.fragments.CreditCard.java

private void initSubmitButton() {
    submitButton.setOnClickListener(new OnClickListener() {

        @Override// w ww . java 2s  .  c om
        public void onClick(View v) {

            initValues();

            if (isValidCard()) {

                if (TextUtils.equals(paymentType, Constants.GUEST_FLOW)) {
                    createUser();
                } else {
                    savePayOption();
                }
                getSignature();
            }
        }
    });
}

From source file:com.vagabond.dealhunting.ui.SearchActivity.java

private void searchFor(String query) {
    Bundle args = new Bundle(1);
    if (query == null) {
        query = "";
    }/*from www .j  a va2 s  .  com*/
    args.putString(ARG_QUERY, query);

    if (TextUtils.equals(query, mQuery)) {
        getSupportLoaderManager().initLoader(SearchPromotionQuery.TOKEN, args, this);
    } else {
        getSupportLoaderManager().restartLoader(SearchPromotionQuery.TOKEN, args, this);
    }
    mQuery = query;
}

From source file:com.android.messaging.datamodel.MediaScratchFileProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    if (projection != null && projection.length > 0
            && TextUtils.equals(projection[0], OpenableColumns.DISPLAY_NAME) && isMediaScratchSpaceUri(uri)) {
        // Retrieve the display name associated with a temp file. This is used by the Contacts
        // ImportVCardActivity to retrieve the name of the contact(s) being imported.
        String displayName;//from   w  w w  .  j  a v  a  2 s .c o  m
        synchronized (sUriToDisplayNameMap) {
            displayName = sUriToDisplayNameMap.get(uri);
        }
        if (!TextUtils.isEmpty(displayName)) {
            MatrixCursor cursor = new MatrixCursor(new String[] { OpenableColumns.DISPLAY_NAME });
            RowBuilder row = cursor.newRow();
            row.add(displayName);
            return cursor;
        }
    }
    return null;
}

From source file:com.oldsneerjaw.sleeptimer.CountdownNotifierTest.java

public void testPostNotification() {
    Date countdownEnds = new Date(0);

    notifier.postNotification(countdownEnds);

    Mockito.verify(mockCountdownTimeFormatFactory).getTimeFormat();
    Mockito.verify(mockNotificationManager).notify(Mockito.eq(NOTIFICATION_ID),
            Mockito.argThat(new BaseMatcher<Notification>() {
                @Override//w  w  w  .j av a2 s . c  om
                public boolean matches(Object o) {
                    if (!(o instanceof Notification)) {
                        return false;
                    }

                    Notification candidate = (Notification) o;

                    return TextUtils.equals(NOTIFICATION_TITLE, candidate.tickerText)
                            && (candidate.icon == R.drawable.ic_launcher)
                            && (candidate.priority == NotificationCompat.PRIORITY_DEFAULT)
                            && (candidate.contentIntent != null)
                            && ((candidate.flags & Notification.FLAG_ONGOING_EVENT) != 0)
                            && ((candidate.flags & Notification.FLAG_AUTO_CANCEL) == 0);
                }

                @Override
                public void describeTo(Description description) {
                    // Describe the notification that was expected in the event of test failure
                    description.appendText(
                            "a notification with the correct title, icon, default priority, a pending intent, set to ongoing and NOT auto cancel");
                }
            }));
}

From source file:com.ntsync.android.sync.activities.KeyPasswordActivity.java

@Override
protected void onResume() {
    super.onResume();
    // Check if Account is available
    AccountManager acm = AccountManager.get(this);
    boolean found = false;
    for (Account accounts : acm.getAccounts()) {
        if (Constants.ACCOUNT_TYPE.equals(accounts.type) && TextUtils.equals(accounts.name, mUsername)) {
            found = true;//  w ww  .  j a  va2  s .com
        }
    }
    if (!found) {
        clearNotification(mUsername);
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
}