Example usage for java.lang CharSequence equals

List of usage examples for java.lang CharSequence equals

Introduction

In this page you can find the example usage for java.lang CharSequence equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.google.dotorg.crisisresponse.translationcards.RecordingActivity.java

private void moveToLabelStep() {
    setContentView(R.layout.recording_label);
    recycleBitmap();//from   ww w .  ja  v  a 2  s  .  c  o  m
    currentBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.recording_label_image);
    currentBitmapView = (ImageView) findViewById(R.id.recording_label_image);
    currentBitmapView.setImageBitmap(currentBitmap);
    final EditText labelField = (EditText) findViewById(R.id.recording_label_field);
    if (label != null) {
        labelField.setText(label);
        labelField.setTextColor(Color.BLACK);
        labelField.setSelection(label.length());
        setLabelNextButtonEnabled(true);
    }
    if (inEditMode) {
        ImageView deleteButton = (ImageView) findViewById(R.id.recording_label_delete_image);
        deleteButton.setVisibility(View.VISIBLE);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DbManager dbm = new DbManager(RecordingActivity.this);
                dbm.deleteTranslation(translationId);
                if (!isAsset) {
                    File oldFile = new File(filename);
                    oldFile.delete();
                    if (!savedIsAsset && (savedFilename != null) && !savedFilename.equals(filename)) {
                        oldFile = new File(savedFilename);
                        oldFile.delete();
                    }
                }
                setResult(RESULT_OK);
                finish();
            }
        });
        findViewById(R.id.recording_label_step_marker).setVisibility(View.GONE);
    }
    labelField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus
                    && labelField.getText().toString().equals(getString(R.string.recording_label_hint_text))) {
                labelField.setText("");
                labelField.setTextColor(Color.BLACK);
            } else if (!hasFocus && labelField.getText().toString().equals("")) {
                labelField.setText(getString(R.string.recording_label_hint_text));
                labelField.setTextColor(getResources().getColor(R.color.borderColor));
            }
            if (hasFocus) {
                InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                inputMethodManager.toggleSoftInputFromWindow(labelField.getApplicationWindowToken(),
                        InputMethodManager.SHOW_FORCED, 0);
            }
        }
    });
    labelField.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Do nothing here.
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() != 0 && !s.equals(getString(R.string.recording_label_hint_text))) {
                setLabelNextButtonEnabled(true);
            } else {
                setLabelNextButtonEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
            // Do nothing here.
        }
    });
    View nextButton = (View) findViewById(R.id.recording_label_next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            label = labelField.getText().toString();
            if (label.length() == 0 || label.equals(getString(R.string.recording_label_hint_text))) {
                return;
            }
            moveToAudioStep();
        }
    });
    stepHistory.push(Step.LABEL);
}

From source file:android.support.design.widget.CustomCollapsingTextHelper.java

public void setSubtitle(CharSequence text) {
    if (text == null || !text.equals(mSub)) {
        mSub = text;//from  w ww. j a  va 2 s  .c o m
        clearTexture();
        recalculate();
    }
}

From source file:android.support.design.widget.CustomCollapsingTextHelper.java

/**
 * Set the title to display//from ww  w . j a  v  a 2 s .  c o  m
 *
 * @param text
 */
public void setText(CharSequence text) {
    if (text == null || !text.equals(mText)) {
        mText = text;
        mTextToDraw = null;
        clearTexture();
        recalculate();
    }
}

From source file:com.muzakki.ahmad.widget.CollapsingTextHelper.java

void setSubtitle(CharSequence text) {
    if (text == null || !text.equals(mSub)) {
        mSub = text;
        clearTexture();
        recalculate();
    }
}

From source file:org.mercycorps.translationcards.activity.RecordingActivity.java

private void moveToLabelStep() {
    setContentView(R.layout.recording_label);
    TextView labelTitle = (TextView) findViewById(R.id.recording_label_title);
    labelTitle.setText(getString(R.string.recording_label_create_title, dictionaryLabel));
    recycleBitmap();/*  w  ww . ja va2s .co m*/
    currentBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.recording_label_image);
    currentBitmapView = (ImageView) findViewById(R.id.recording_label_image);
    currentBitmapView.setImageBitmap(currentBitmap);
    final EditText labelField = (EditText) findViewById(R.id.recording_label_field);
    final EditText translatedTextField = (EditText) findViewById(R.id.recording_translated_text_field);
    fillPrepopulatedField(label, labelField, getString(R.string.recording_label_hint_text));
    fillPrepopulatedField(translatedText, translatedTextField,
            String.format(getString(R.string.translated_text_hint), dictionaryLabel));
    if (inEditMode) {
        ImageView deleteButton = (ImageView) findViewById(R.id.recording_label_delete_image);
        deleteButton.setVisibility(View.VISIBLE);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DbManager dbm = new DbManager(RecordingActivity.this);
                dbm.deleteTranslation(translationId);
                if (!isAsset) {
                    File oldFile = new File(filename);
                    oldFile.delete();
                    if (!savedIsAsset && (savedFilename != null) && !savedFilename.equals(filename)) {
                        oldFile = new File(savedFilename);
                        oldFile.delete();
                    }
                }
                setResult(RESULT_OK, intent);
                finish();
            }
        });
        findViewById(R.id.recording_label_step_marker).setVisibility(View.GONE);
    }
    labelField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            setFieldBasedOnFocus(hasFocus, labelField, R.string.recording_label_hint_text);
        }
    });

    translatedTextField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            setFieldBasedOnFocus(hasFocus, translatedTextField, R.string.recording_text_hint_text);
        }
    });

    labelField.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Do nothing here.
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() != 0 && !s.equals(getString(R.string.recording_label_hint_text))) {
                setLabelNextButtonEnabled(true);
            } else {
                setLabelNextButtonEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
            // Do nothing here.
        }
    });
    View nextButton = (View) findViewById(R.id.recording_label_next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            label = labelField.getText().toString();
            if (label.length() == 0 || label.equals(getString(R.string.recording_label_hint_text))) {
                return;
            }

            translatedText = translatedTextField.getText().toString();
            if (translatedText.trim().isEmpty()
                    || translatedText.equals(getString(R.string.recording_text_hint_text))) {
                translatedText = "";
            }
            moveToAudioStep();
        }
    });
    stepHistory.push(Step.LABEL);
}

From source file:com.android.music.AlbumBrowserActivity.java

private void setTitle() {
    CharSequence fancyName = "";
    if (mAlbumCursor != null && mAlbumCursor.getCount() > 0) {
        mAlbumCursor.moveToFirst();//from   w  w  w.  j av a2  s . c  o m
        fancyName = mAlbumCursor.getString(mAlbumCursor.getColumnIndex(MediaStore.Audio.Albums.ARTIST));
        if (fancyName == null || fancyName.equals(MediaStore.UNKNOWN_STRING))
            fancyName = getText(R.string.unknown_artist_name);
    }

    if (mArtistId != null && fancyName != null)
        setTitle(fancyName);
    else
        setTitle(R.string.albums_title);
}

From source file:org.puder.trs80.EmulatorActivity.java

private void updateMenuIcons() {
    if (muteMenuItem != null && unmuteMenuItem != null) {
        if (soundMuted) {
            muteMenuItem.setVisible(true);
            unmuteMenuItem.setVisible(false);
        } else {/*from w w w  .  j ava  2  s.  c  om*/
            muteMenuItem.setVisible(false);
            unmuteMenuItem.setVisible(true);
        }
    }

    if (pasteMenuItem != null) {
        boolean hasClip = false;
        if (clipboardManager.hasPrimaryClip()) {
            ClipData clip = clipboardManager.getPrimaryClip();
            ClipData.Item item = clip.getItemAt(0);
            CharSequence text = item.getText();
            hasClip = (text != null) && !text.equals("");
        }
        pasteMenuItem.setEnabled(hasClip);
    }
}

From source file:com.github.nevo.decorators.reply.wechat.WeChatDecorator.java

@Override
public void apply(final StatusBarNotificationEvo evolving) throws RemoteException {
    final INotification n = evolving.notification();
    final IBundle extras = n.extras();

    // WeChat use dynamic counter as notification ID, which unfortunately will be reset upon evolving (removal, to be exact) by us,
    // causing all messages combined into one notification. So we split them by re-coding the notification ID by title.
    final CharSequence title = extras.getCharSequence(NotificationCompat.EXTRA_TITLE);
    if (title == null || title.length() == 0)
        return;//w w w  .j av  a 2 s  .com
    evolving.setId(calcSplitId(title)); // Split into separate slots

    // Chat history in big content view
    final Collection<StatusBarNotificationEvo> history = getArchivedNotifications(evolving.getKey(), 20);
    if (history.isEmpty())
        return;
    final List<CharSequence> lines = new ArrayList<>(KMaxNumLines);
    CharSequence text = null;
    int count = 0;
    final String redundant_prefix = title.toString() + ": ";
    for (final StatusBarNotificationEvo each : history) {
        final IBundle its_extras = each.notification().extras();
        final CharSequence its_title = its_extras.getCharSequence(NotificationCompat.EXTRA_TITLE);
        if (!title.equals(its_title))
            continue; // Skip other conversations sharing the same key.
        final CharSequence its_text = its_extras.getCharSequence(NotificationCompat.EXTRA_TEXT);
        if (its_text == null)
            continue;
        final int result = trimAndExtractLeadingCounter(its_text);
        if (result >= 0) {
            count = result & 0xFFFF;
            CharSequence trimmed_text = its_text.subSequence(result >> 16, its_text.length());
            if (trimmed_text.toString().startsWith(redundant_prefix)) // Remove redundant prefix
                trimmed_text = trimmed_text.subSequence(redundant_prefix.length(), trimmed_text.length());
            lines.add(text = trimmed_text);
        } else
            lines.add(text = its_text);
    }
    if (lines.isEmpty())
        return;
    Collections.reverse(lines); // Latest first, since earliest lines will be trimmed by InboxStyle.

    extras.putCharSequence(NotificationCompat.EXTRA_TEXT, text);
    extras.putCharSequence(NotificationCompat.EXTRA_TITLE_BIG, title);
    extras.putCharSequenceArray(NotificationCompat.EXTRA_TEXT_LINES, lines);
    extras.putString(EXTRA_REBUILD_STYLE, STYLE_INBOX);

    n.setColor(0xFF33B332);
    if (count != 0)
        n.setNumber(count);
}

From source file:com.jecelyin.editor.v2.core.text.TextUtils.java

/**
 * Returns true if a and b are equal, including if they are both null.
 * <p><i>Note: In platform versions 1.1 and earlier, this method only worked well if
 * both the arguments were instances of String.</i></p>
 * @param a first CharSequence to check/*w  ww  .  jav a 2s .com*/
 * @param b second CharSequence to check
 * @return true if a and b are equal
 */
public static boolean equals(CharSequence a, CharSequence b) {
    if (a == b)
        return true;
    int length;
    if (a != null && b != null && (length = a.length()) == b.length()) {
        if (a instanceof String && b instanceof String) {
            return a.equals(b);
        } else {
            for (int i = 0; i < length; i++) {
                if (a.charAt(i) != b.charAt(i))
                    return false;
            }
            return true;
        }
    }
    return false;
}

From source file:github.daneren2005.dsub.activity.SubsonicActivity.java

@Override
public void setTitle(CharSequence title) {
    if (title != null && !title.equals(getSupportActionBar().getTitle())) {
        getSupportActionBar().setTitle(title);
        recreateSpinner();/*from  w w w.ja  v a 2  s. c  om*/
    }
}