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.klinker.android.twitter.ui.compose.NotificationCompose.java

@Override
public void setUpReplyText() {
    // mark the messages as read here
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);//  w ww.j  a va 2 s. c o  m
    mNotificationManager.cancel(9);

    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    Context context = getApplicationContext();
    int currentAccount = sharedPrefs.getInt("current_account", 1);

    // we can just mark everything as read because it isnt taxing at all and won't do anything in the mentions if there isn't one
    // and the shared prefs are easy.
    // this is only called from the notification and there will only ever be one thing that is unread when this button is available

    MentionsDataSource.getInstance(context).markAllRead(currentAccount);

    // set up the reply box
    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();
    reply.setText(sharedPrefs.getString("from_notification", ""));
    reply.setSelection(reply.getText().toString().length());
    notiId = sharedPrefs.getLong("from_notification_long", 0);
    replyText = sharedPrefs.getString("from_notification_text", "");

    sharedPrefs.edit().putLong("from_notification_id", 0).commit();
    sharedPrefs.edit().putString("from_notification_text", "").commit();
    sharedPrefs.edit().putString("from_notification", "").commit();
    sharedPrefs.edit().putBoolean("from_notification_bool", false).commit();

    String t = reply.getText().toString();
    if (!android.text.TextUtils.isEmpty(t) && !t.endsWith(" ")) {
        reply.append(" ");
        reply.setSelection(reply.getText().length());
    }

    // try from android wear device
    CharSequence voiceReply = getVoiceReply(getIntent());
    if (voiceReply != null) {
        if (!voiceReply.equals("")) {
            // set the text
            reply.append(voiceReply);

            // send the message
            doneClick();

            finish();
        }
    }
}

From source file:com.klinker.android.twitter.activities.compose.NotificationComposeSecondAcc.java

@Override
public void setUpReplyText() {
    // mark the messages as read here
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);//from   w w w  .j a va 2 s. co m
    mNotificationManager.cancel(9);

    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    Context context = getApplicationContext();
    int currentAccount = sharedPrefs.getInt("current_account", 1);

    if (currentAccount == 1) {
        currentAccount = 2;
    } else {
        currentAccount = 1;
    }

    useAccOne = false;
    useAccTwo = true;

    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);

    if (settings.roundContactImages) {
        pic.loadImage(settings.secondProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.secondProfilePicUrl, false, null);
    }

    currentName.setText("@" + settings.secondScreenName);

    MentionsDataSource.getInstance(context).markAllRead(currentAccount);
    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();

    // set up the reply box
    reply.setText(sharedPrefs.getString("from_notification_second", ""));
    reply.setSelection(reply.getText().toString().length());
    notiId = sharedPrefs.getLong("from_notification_long_second", 0);
    replyText = sharedPrefs.getString("from_notification_text_second", "");

    sharedPrefs.edit().putLong("from_notification_id_second", 0).commit();
    sharedPrefs.edit().putString("from_notification_text_second", "").commit();
    sharedPrefs.edit().putString("from_notification_second", "").commit();
    sharedPrefs.edit().putBoolean("from_notification_bool_second", false).commit();

    // try from android wear device
    CharSequence voiceReply = getVoiceReply(getIntent());
    if (voiceReply != null) {
        if (!voiceReply.equals("")) {
            // set the text
            reply.append(voiceReply);

            // send the message
            doneClick();

            finish();
        }
    }
}

From source file:com.klinker.android.twitter.ui.compose.NotificationComposeSecondAcc.java

@Override
public void setUpReplyText() {
    // mark the messages as read here
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);/*ww w .ja  v a 2s. c  o m*/
    mNotificationManager.cancel(9);

    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    Context context = getApplicationContext();
    int currentAccount = sharedPrefs.getInt("current_account", 1);

    if (currentAccount == 1) {
        currentAccount = 2;
    } else {
        currentAccount = 1;
    }

    useAccOne = false;
    useAccTwo = true;

    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);

    if (settings.roundContactImages) {
        pic.loadImage(settings.secondProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.secondProfilePicUrl, false, null);
    }

    currentName.setText("@" + settings.secondScreenName);

    MentionsDataSource.getInstance(context).markAllRead(currentAccount);
    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();

    // set up the reply box
    reply.setText(sharedPrefs.getString("from_notification_second", ""));
    reply.setSelection(reply.getText().toString().length());
    notiId = sharedPrefs.getLong("from_notification_long_second", 0);
    replyText = sharedPrefs.getString("from_notification_text_second", "");

    sharedPrefs.edit().putLong("from_notification_id_second", 0).commit();
    sharedPrefs.edit().putString("from_notification_text_second", "").commit();
    sharedPrefs.edit().putString("from_notification_second", "").commit();
    sharedPrefs.edit().putBoolean("from_notification_bool_second", false).commit();

    // try from android wear device
    CharSequence voiceReply = getVoiceReply(getIntent());
    if (voiceReply != null) {
        if (!voiceReply.equals("")) {
            // set the text
            reply.append(voiceReply);

            // send the message
            doneClick();

            finish();
        }
    }
}

From source file:com.github.rubensousa.bottomsheetbuilder.adapter.BottomSheetAdapterBuilder.java

private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor, int itemTextColor,
        int itemBackground, int tintColor) {
    List<BottomSheetItem> items = new ArrayList<>();

    boolean addedSubMenu = false;

    for (int i = 0; i < mMenu.size(); i++) {
        MenuItem item = mMenu.getItem(i);

        if (item.isVisible()) {
            if (item.hasSubMenu()) {
                SubMenu subMenu = item.getSubMenu();

                if (i != 0 && addedSubMenu) {
                    if (mMode == BottomSheetBuilder.MODE_GRID) {
                        throw new IllegalArgumentException(
                                "MODE_GRID can't have submenus." + " Use MODE_LIST instead");
                    }//from www . j a  v  a2  s.  c om
                    items.add(new BottomSheetDivider(dividerBackground));
                }

                CharSequence title = item.getTitle();
                if (title != null && !title.equals("")) {
                    items.add(new BottomSheetHeader(title.toString(), titleTextColor));
                }

                for (int j = 0; j < subMenu.size(); j++) {
                    MenuItem subItem = subMenu.getItem(j);
                    if (subItem.isVisible()) {
                        items.add(new BottomSheetMenuItem(subItem, itemTextColor, itemBackground, tintColor));
                        addedSubMenu = true;
                    }
                }
            } else {
                items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor));
            }
        }
    }

    return items;
}

From source file:at.jclehner.rxdroid.preferences.DrugNamePreference2.java

@Override
public void setTitle(CharSequence title) {
    if (title == null || title.equals(""))
        super.setTitle(getContext().getString(R.string._title_drug_name));
    else/*from  ww  w.  ja va2s. c om*/
        super.setTitle(title);
}

From source file:com.example.weixin.ActivityMain.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    CharSequence name = item.getTitle();
    if (name.equals("Search")) {
        Intent i = new Intent(this, ActivitySearch.class);
        startActivity(i);/*from   w  ww.ja  v a 2  s  . c o m*/
    }
    if (name.equals("??")) {
        T.showShort(this, "??");
    }
    if (name.equals("?")) {
        T.showShort(this, "?");
    }
    if (name.equals("")) {
        T.showShort(this, "");
    }
    if (name.equals("????")) {
        T.showShort(this, "????");
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.waz.zclient.BasePreferenceActivity.java

@Override
protected void onTitleChanged(CharSequence title, int color) {
    super.onTitleChanged(title, color);
    if (title == null) {
        return;//w  w w  .j a v a2  s .  c  o m
    }
    if (title.equals(this.title)) {
        return;
    }
    this.title = title;
    if (this.titleSwitcher != null) {
        this.titleSwitcher.setText(this.title);
    }
}

From source file:org.xerela.net.sim.telnet.TelnetTest.java

/**
 * //from   www .ja  v  a2  s  . c  om
 * @throws Exception
 */
public void testTelnet() throws Exception {
    /*     Start:
     *   +------------+
     * ,-! Send Input !
     * ! +------------+
     * !     | 
     * ! +------------+
     * ! ! Read Input !------. no
     * ! +------------+       \
     * !yes   |                |
     * ! +------------+ no +------------+ yes +------+
     * `-! IsCorrect? !----! IsTooLong? !-----! FAIL !
     *   +------------+    +------------+     +------+
     * 
     */
    IpAddress local = IpAddress.getIpAddress(Util.getLocalHost(), null);

    TelnetClient client = new TelnetClient();
    client.connect(local.getRealAddress());

    RecordingLoader recordingLoader = RecordingLoader.getInstance();
    Configuration config = ConfigurationService.getInstance()
            .findConfigurationFile(ConfigurationService.DEFAULT_CONFIG);

    WorkingConfig wc = config.getDefaultOperationWorkingConfig();

    // create the operation manually first so that we can easily get the records
    RecordingOperation operation = (RecordingOperation) recordingLoader.createOperation(wc, local, local);
    Interaction[] interactions = operation.getInteractions();
    operation.tearDown();

    BufferedInputStream in = new BufferedInputStream(client.getInputStream());
    PrintStream out = new PrintStream(client.getOutputStream(), true);

    byte[] bbuf = new byte[2048];

    CharSequenceBuffer cbuf = new CharSequenceBuffer();
    for (int i = 0; i < interactions.length; i++) {
        Interaction currInteraction = interactions[i];

        String proto = currInteraction.getCliProtocol();
        if (!proto.equals("Telnet")) {
            /*
             * Because the recording might have other protocols we should stop when we encounter one.
             * The recording may not behave properly if we continue as we are.
             * If we got through at least 10 interactions then this test is probably still valid.
             */
            assertTrue(
                    "At least 10 telnet interction should have been handled.  Maybe this test should be run with another recording.",
                    i > 10);
            System.err.println(
                    "Continueing could disrupt the validity of this test.  This test will only support Telnet operations.");
            break;
        }

        // The timeout will be four times the expected time or 4 seconds, whichever is longer.
        Long interactionTime = currInteraction.getEndTime() - currInteraction.getStartTime();
        long time = Math.max((long) (interactionTime * wc.getRateMultiplier()) * 4, 4000);
        long start = System.currentTimeMillis();

        CharSequence input = currInteraction.getCliCommand();
        CharSequence response = currInteraction.getCliResponse();
        if (!input.equals("No input sent") && !input.equals("")) {
            out.println(input);
        }

        cbuf.reset();
        while (true) {
            int len = 0;
            if (in.available() <= 0) {
                try {
                    Thread.sleep(250);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (in.available() <= 0) {
                    if (System.currentTimeMillis() - start > time) {
                        // isTooLong
                        fail("Timeout reached waiting for response for interaction '"
                                + currInteraction.getCliCommand() + "'");
                    }
                    continue;
                }
            }
            len = in.read(bbuf);
            cbuf.write(bbuf, 0, len);

            // isCorrect?
            if (compare(cbuf, response)) {
                break;
            } else if (System.currentTimeMillis() - start > time) {
                // isTooLong
                fail("Timeout reached waiting for response for interaction '" + currInteraction.getCliCommand()
                        + "'");
            }
        }
    }
}

From source file:de.schildbach.wallet.ui.RestoreWalletFromSeedDialogFragment.java

private void setupPasswordView() {
    passwordView.post(new Runnable() {
        @Override/*  ww w  . j a v  a2  s  .  c  o m*/
        public void run() {
            KeyboardUtil.showSoftKeyboard(getActivity(), passwordView);
        }
    });
    passwordView.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            setupRestoreButtonState();
        }
    });
    passwordView.setFilters(new InputFilter[] { new InputFilter() {
        public CharSequence filter(CharSequence src, int start, int end, Spanned dst, int dstart, int dend) {
            if (src.equals("")) { // for backspace
                return src;
            }
            int numOfWords = numOfWordsInPasswordView();
            if (numOfWords >= NUMBER_OF_WORDS_IN_SEED && src.equals(" ")) {
                return "";
            }
            if (src.toString().matches("[a-z ]+")) {
                return src;
            }
            return "";
        }
    } });
}

From source file:com.android.talkback.tutorial.TutorialMainFragment.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (mOffButton == null || mParentLayout == null) {
        return;//from   ww w. ja  va 2  s  . c  om
    }

    // There are three types of areas that we're detecting: the button area, areas of the
    // activity that are a11y-focusable, and areas of the activity that are blank.
    // 1) The HoverTrackingButton keeps track of the button area.
    // 2) The HoverTrackingLinearLayout keeps track of blank activity areas.
    // 3) We use TYPE_VIEW_HOVER_ENTER to track a11y-focusable activity areas.
    // The user must begin and end the touch interaction within the Turn TalkBack Off button
    // without moving their finger into other areas of the activity in order to turn TB off.

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
        mOtherViewHovered = false;
        mOffButton.clearTracking();
        mParentLayout.clearTracking();
        break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
        if (mOffButton.didHoverEnter() && !mParentLayout.didHoverEnter() && !mOtherViewHovered) {
            if (TalkBackService.getInstance() != null) {
                TalkBackService.getInstance().disableTalkBack();
            }
        }
        break;
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
        CharSequence className = event.getClassName();
        // Hovering over the button gives an event with TUTORIAL_CLASS_NAME class.
        // But empty areas of the activity should be tracked by HoverTrackingLinearLayout.
        if (className == null || !className.equals(TUTORIAL_CLASS_NAME)) {
            mOtherViewHovered = true;
        }
        break;
    }
}