List of usage examples for java.lang CharSequence equals
public boolean equals(Object obj)
From source file:io.doist.datetimepicker.time.TimePickerClockDelegate.java
private void tryAnnounceForAccessibility(CharSequence text, boolean isHour) { if (mLastAnnouncedIsHour != isHour || !text.equals(mLastAnnouncedText)) { // TODO: Find a better solution, potentially live regions? mDelegator.announceForAccessibility(text); mLastAnnouncedText = text;//from w w w . ja v a 2 s. c o m mLastAnnouncedIsHour = isHour; } }
From source file:com.tr4android.support.extension.picker.time.AppCompatTimePickerDelegate.java
private void tryAnnounceForAccessibility(CharSequence text, boolean isHour) { if (mLastAnnouncedIsHour != isHour || !text.equals(mLastAnnouncedText)) { // TODO: Find a better solution, potentially live regions? ViewCompatUtils.announceForAccessibility(mDelegator, text); mLastAnnouncedText = text;/*www . jav a 2s . c om*/ mLastAnnouncedIsHour = isHour; } }
From source file:com.app.blockydemo.ui.adapter.BrickAdapter.java
@Override public void onClick(final View view) { if (!viewSwitchLock.tryLock()) { return;//www . j av a 2 s. c o m } animatedBricks.clear(); final int itemPosition = calculateItemPositionAndTouchPointY(view); final List<CharSequence> items = new ArrayList<CharSequence>(); if (brickList.get(itemPosition) instanceof ScriptBrick) { int scriptIndex = getScriptIndexFromProject(itemPosition); ProjectManager.getInstance().setCurrentScript(sprite.getScript(scriptIndex)); } if (!(brickList.get(itemPosition) instanceof DeadEndBrick) && !(brickList.get(itemPosition) instanceof ScriptBrick)) { items.add(context.getText(R.string.brick_context_dialog_move_brick)); } if (brickList.get(itemPosition) instanceof NestingBrick) { items.add(context.getText(R.string.brick_context_dialog_animate_bricks)); } if (!(brickList.get(itemPosition) instanceof ScriptBrick)) { items.add(context.getText(R.string.brick_context_dialog_copy_brick)); items.add(context.getText(R.string.brick_context_dialog_delete_brick)); } else { items.add(context.getText(R.string.brick_context_dialog_edit_script_name)); items.add(context.getText(R.string.brick_context_dialog_delete_script)); } if (brickList.get(itemPosition) instanceof FormulaBrick) { items.add(context.getText(R.string.brick_context_dialog_formula_edit_brick)); } AlertDialog.Builder builder = new AlertDialog.Builder(context); boolean drawingCacheEnabled = view.isDrawingCacheEnabled(); view.setDrawingCacheEnabled(true); view.setDrawingCacheBackgroundColor(Color.TRANSPARENT); view.buildDrawingCache(true); if (view.getDrawingCache() != null) { Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(drawingCacheEnabled); ImageView imageView = dragAndDropListView.getGlowingBorder(bitmap); builder.setCustomTitle(imageView); } builder.setItems(items.toArray(new CharSequence[items.size()]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { CharSequence clickedItemText = items.get(item); if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_move_brick))) { view.performLongClick(); } else if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_copy_brick))) { copyBrickListAndProject(itemPosition); } else if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_delete_brick)) || clickedItemText.equals(context.getText(R.string.brick_context_dialog_delete_script))) { showConfirmDeleteDialog(itemPosition); } else if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_animate_bricks))) { int itemPosition = calculateItemPositionAndTouchPointY(view); Brick brick = brickList.get(itemPosition); if (brick instanceof NestingBrick) { List<NestingBrick> list = ((NestingBrick) brick).getAllNestingBrickParts(true); for (Brick tempBrick : list) { animatedBricks.add(tempBrick); } } notifyDataSetChanged(); } else if (clickedItemText .equals(context.getText(R.string.brick_context_dialog_formula_edit_brick))) { if (brickList.get(itemPosition) instanceof FormulaBrick) { FormulaEditorFragment.showFragment(view, brickList.get(itemPosition), ((FormulaBrick) brickList.get(itemPosition)).getFormula()); } } else if (clickedItemText .equals(context.getText(R.string.brick_context_dialog_edit_script_name))) { ScriptNameDialog dialog2 = new ScriptNameDialog( ProjectManager.getInstance().getCurrentScript()); dialog2.show(((FragmentActivity) view.getContext()).getSupportFragmentManager(), ScriptNameDialog.DIALOG_FRAGMENT_TAG); initBrickList(); notifyDataSetChanged(); notifyDataSetInvalidated(); } } }); AlertDialog alertDialog = builder.create(); if ((selectMode == ListView.CHOICE_MODE_NONE)) { alertDialog.show(); } }
From source file:org.totschnig.myexpenses.util.Utils.java
/** * @param ctx/*from w w w . ja v a2 s . com*/ * for retrieving resources * @param other * if not null, all features except the one provided will be returned * @param type if not null, only features of this type will be listed * @return construct a list of all contrib features to be included into a * TextView */ public static CharSequence getContribFeatureLabelsAsFormattedList(Context ctx, ContribFeature other, LicenceHandler.LicenceStatus type) { CharSequence result = "", linefeed = Html.fromHtml("<br>"); Iterator<ContribFeature> iterator = EnumSet.allOf(ContribFeature.class).iterator(); while (iterator.hasNext()) { ContribFeature f = iterator.next(); if (!f.equals(other) && (!f.equals(ContribFeature.AD_FREE) || IS_FLAVOURED)) { if (type != null && ((f.isExtended() && !type.equals(LicenceHandler.LicenceStatus.EXTENDED)) || (!f.isExtended() && type.equals(LicenceHandler.LicenceStatus.EXTENDED)))) { continue; } String resName = "contrib_feature_" + f.toString() + "_label"; int resId = ctx.getResources().getIdentifier(resName, "string", ctx.getPackageName()); if (resId == 0) { AcraHelper.report(new Resources.NotFoundException(resName)); continue; } if (!result.equals("")) { result = TextUtils.concat(result, linefeed); } result = TextUtils.concat(result, "\u25b6 ", ctx.getText(resId)); } } return result; }
From source file:com.appeaser.sublimepickerlibrary.timepicker.SublimeTimePicker.java
private void tryAnnounceForAccessibility(CharSequence text, boolean isHour) { if (mLastAnnouncedIsHour != isHour || !text.equals(mLastAnnouncedText)) { // TODO: Find a better solution, potentially live regions? AccessibilityUtils.makeAnnouncement(this, text); mLastAnnouncedText = text;/*from w ww. j a va2 s. co m*/ mLastAnnouncedIsHour = isHour; } }
From source file:github.popeen.dsub.activity.SubsonicActivity.java
@Override public void setTitle(CharSequence title) { if (title != null && getSupportActionBar() != null && !title.equals(getSupportActionBar().getTitle())) { getSupportActionBar().setTitle(title); recreateSpinner();//from w ww.j av a 2 s. com } }
From source file:android.support.v7.preference.Preference.java
/** * Sets the title for this Preference with a CharSequence. * This title will be placed into the ID * {@link android.R.id#title} within the View bound by * {@link #onBindViewHolder(PreferenceViewHolder)}. * * @param title The title for this Preference. *//* w w w . java2s. co m*/ public void setTitle(CharSequence title) { if (title == null && mTitle != null || title != null && !title.equals(mTitle)) { mTitle = title; notifyChanged(); } }
From source file:android.support.v7.preference.Preference.java
/** * Sets the summary for this Preference with a CharSequence. * * @param summary The summary for the preference. *//*from w w w . j ava2 s . c o m*/ public void setSummary(CharSequence summary) { if (summary == null && mSummary != null || summary != null && !summary.equals(mSummary)) { mSummary = summary; notifyChanged(); } }
From source file:com.oasisfeng.nevo.decorators.whatsapp.WhatsAppDecorator.java
@Override public void apply(final StatusBarNotificationEvo evolving) throws RemoteException { final INotification n = evolving.notification(); final IBundle extras = n.extras(); final CharSequence who, group, message; @SuppressWarnings("unchecked") final List<CharSequence> lines = extras.getCharSequenceArray(EXTRA_TEXT_LINES); final boolean has_lines = lines != null && !lines.isEmpty(); final CharSequence title = extras.getCharSequence(EXTRA_TITLE); final CharSequence last = has_lines ? lines.get(lines.size() - 1) : extras.getCharSequence(EXTRA_TEXT); final CharSequence[] last_parts = extract(title, last); who = last_parts[0];//from ww w . j a v a 2 s . c o m group = last_parts[1]; message = last_parts[2]; if (group != null) evolving.setTag(".Group"); else if (who != null) evolving.setTag(".Direct"); else return; // Nothing to do for other messages. final CharSequence new_title = group != null ? group : who; evolving.setId(new_title.toString().hashCode()); if (n.getColor() == 0) n.setColor(DEFAULT_COLOR); // Fix the missing color in some notifications if (!has_lines) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.removeFlags(Notification.FLAG_GROUP_SUMMARY); else extras.remove("android.support.isGroupSummary"); extras.putCharSequence(EXTRA_TITLE, new_title); extras.putCharSequence(EXTRA_TITLE_BIG, new_title); extras.putCharSequence(EXTRA_TEXT, group != null ? who + ": " + message : message); final List<CharSequence> new_lines = new ArrayList<>(lines.size()); for (final CharSequence line : lines) { final CharSequence[] parts = extract(title, line); if (group != null) { // Group chat, keep messages within the same group. if (!group.equals(parts[1])) continue; final SpannableStringBuilder new_line = new SpannableStringBuilder(); new_line.append(parts[0]).setSpan(new StyleSpan(BOLD), 0, new_line.length(), SPAN_EXCLUSIVE_EXCLUSIVE); new_lines.add(new_line.append(": ").append(parts[2])); } else if (who.equals(parts[0]) && parts[1] == null) new_lines.add(parts[2]); // Direct chat, keep messages from the same person (excluding group chat) } extras.putCharSequenceArray(EXTRA_TEXT_LINES, new_lines); extras.remove(EXTRA_SUMMARY_TEXT); extras.putString(EXTRA_REBUILD_STYLE, STYLE_INBOX); if (new_lines.size() > 1) n.setNumber(new_lines.size()); }
From source file:dev.memento.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;//from w w w . ja v a 2s . c o m AlertDialog.Builder builder = new AlertDialog.Builder(this); switch (id) { case DIALOG_ERROR: builder.setMessage("error message").setCancelable(false).setPositiveButton("OK", null); dialog = builder.create(); break; case DIALOG_MEMENTO_YEARS: builder.setTitle(R.string.select_year); final TreeMap<Integer, Integer> yearCount = mMementos.getAllYears(); if (Log.LOG) Log.d(LOG_TAG, "Dialog: num of years = " + yearCount.size()); // This shouldn't happen, but just in case if (yearCount.size() == 0) { showToast("There are no years to choose from... something is wrong."); if (Log.LOG) Log.d(LOG_TAG, "Num of mementos: " + mMementos.size()); return null; } // Build a list that shows how many dates are available for each year final CharSequence[] yearText = new CharSequence[yearCount.size()]; // Parallel arrays used to determine which entry was selected. // Could also have used a regular expression. final int years[] = new int[yearCount.size()]; final int count[] = new int[yearCount.size()]; int selectedYear = -1; int displayYear = mDateDisplayed.getYear(); int i = 0; for (Map.Entry<Integer, Integer> entry : yearCount.entrySet()) { Integer year = entry.getKey(); // Select the year of the Memento currently displayed if (displayYear == year) selectedYear = i; years[i] = year; count[i] = entry.getValue(); yearText[i] = Integer.toString(year) + " (" + entry.getValue() + ")"; i++; } builder.setSingleChoiceItems(yearText, selectedYear, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); mSelectedYear = years[item]; int numItems = count[item]; if (numItems > MAX_NUM_MEMENTOS_PER_MONTH) showDialog(DIALOG_MEMENTO_MONTHS); else showDialog(DIALOG_MEMENTO_DATES); } }); dialog = builder.create(); // Cause the dialog to be freed whenever it is dismissed. // This is necessary because the items are dynamic. dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { removeDialog(DIALOG_MEMENTO_YEARS); } }); break; case DIALOG_MEMENTO_MONTHS: builder.setTitle(R.string.select_month); final LinkedHashMap<CharSequence, Integer> monthCount = mMementos.getMonthsForYear(mSelectedYear); // This shouldn't happen, but just in case if (monthCount.size() == 0) { showToast("There are no months to choose from... something is wrong."); if (Log.LOG) Log.d(LOG_TAG, "Num of mementos: " + mMementos.size()); return null; } // Build a list that shows how many dates are available for each month final CharSequence[] monthText = new CharSequence[monthCount.size()]; int selectedMonth = mDateDisplayed.getMonth() - 1; i = 0; for (Map.Entry<CharSequence, Integer> entry : monthCount.entrySet()) { CharSequence month = entry.getKey(); monthText[i] = month + " (" + entry.getValue() + ")"; i++; } builder.setSingleChoiceItems(monthText, selectedMonth, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); // Pull out month name so we can map it back to a number. // This is ugly, but it's necessary because the LinkedHashMap doesn't // give back the order of its keys. Pattern r = Pattern.compile("^(.+) "); Matcher m = r.matcher(monthText[item]); if (m.find()) { String month = m.group(1); mSelectedMonth = Utilities.monthStringToInt(month); showDialog(DIALOG_MEMENTO_DATES); } else { if (Log.LOG) Log.e(LOG_TAG, "Could not find month in [" + monthText[item] + "]"); } } }); dialog = builder.create(); // Cause the dialog to be freed whenever it is dismissed. // This is necessary because the items are dynamic. dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { removeDialog(DIALOG_MEMENTO_MONTHS); } }); break; case DIALOG_MEMENTO_DATES: builder.setTitle(R.string.select_day); // Which radio button is selected? int selected = -1; final CharSequence[] dates; if (Log.LOG) Log.d(LOG_TAG, "mSelectedMonth = " + mSelectedMonth); if (Log.LOG) Log.d(LOG_TAG, "mSelectedYear = " + mSelectedYear); final Memento[] mementoList; // See if there is a month/year filter if (mSelectedMonth != -1 || mSelectedYear != -1) { if (mSelectedMonth != -1) mementoList = mMementos.getByMonthAndYear(mSelectedMonth, mSelectedYear); else mementoList = mMementos.getByYear(mSelectedYear); if (Log.LOG) Log.d(LOG_TAG, "Number of dates = " + mementoList.length); // Get dates for selected mementos dates = new CharSequence[mementoList.length]; i = 0; for (Memento m : mementoList) { dates[i] = m.getDateAndTimeFormatted(); i++; } // See if any of these items match. This could take a little while if // there are a large number of items unfortunately. Memento m = mMementos.getCurrent(); if (m != null) { CharSequence searchDate = m.getDateAndTimeFormatted(); for (i = 0; i < dates.length; i++) { if (searchDate.equals(dates[i])) { selected = i; break; } } } } else { // No filter, so get all available mementos dates = mMementos.getAllDates(); if (Log.LOG) Log.d(LOG_TAG, "Number of dates = " + dates.length); selected = mMementos.getCurrentIndex(); mementoList = mMementos.toArray(new Memento[0]); } if (Log.LOG) Log.d(LOG_TAG, "Selected index = " + selected); // Reset for future selections mSelectedYear = -1; mSelectedMonth = -1; builder.setSingleChoiceItems(dates, selected, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); // Display this Memento Memento m = mementoList[item]; mCurrentMemento = m; final SimpleDateTime dateSelected = m.getDateTime(); mDateDisplayed = dateSelected; setChosenDate(mDateDisplayed); if (Log.LOG) Log.d(LOG_TAG, "User selected Memento with date " + dateSelected.dateFormatted()); showToast("Time traveling to " + mDateDisplayed.dateFormatted()); refreshDisplayedDate(); // Load memento into the browser String redirectUrl = m.getUrl(); surfToUrl(redirectUrl); setEnableForNextPrevButtons(); mNowButton.setEnabled(true); // Potentially lengthly operation new Thread() { public void run() { int index = mMementos.getIndex(dateSelected); if (index == -1) { // This should never happen if (Log.LOG) Log.e(LOG_TAG, "!! Couldn't find " + dateSelected + " in the memento list!"); } else mMementos.setCurrentIndex(index); } }.start(); } }); dialog = builder.create(); // Cause the dialog to be freed whenever it is dismissed. // This is necessary because the items are dynamic. I couldn't find // a better way to solve this problem. dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { removeDialog(DIALOG_MEMENTO_DATES); } }); break; } return dialog; }