Java Code Examples for android.support.annotation.PluralsRes

The following are top voted examples for showing how to use android.support.annotation.PluralsRes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: apps-android-wikipedia   File: ContinueReadingCardView.java   View source code 6 votes vote down vote up
private void header(@NonNull ContinueReadingCard card) {
    int age = (int) card.daysOld();
    @PluralsRes int subtitlePlural;
    String subtitle;
    if (age == 0) {
        subtitle = getResources().getString(R.string.view_continue_reading_card_subtitle_today);
    } else {
        subtitlePlural = R.plurals.view_continue_reading_card_subtitle;
        subtitle = getResources().getQuantityString(subtitlePlural, age, age);
    }
    headerView().setTitle(R.string.view_continue_reading_card_title)
            .setImage(R.drawable.ic_arrow_forward_black_24dp)
            .setImageCircleColor(R.color.base30)
            .setCard(card)
            .setCallback(getCallback());
    largeHeaderView().setTitle(card.title())
            .setImage(card.image())
            .setSubtitle(subtitle)
            .onClickListener(new CardClickListener())
            .setVisibility(VISIBLE);
}
 
Example 2
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@NonNull
@Override
public CharSequence getQuantityText(@PluralsRes int id, int quantity) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getQuantityText(realId, quantity);
    }
    return super.getQuantityText(id, quantity);
}
 
Example 3
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@NonNull
@Override
public String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getQuantityString(realId, quantity, formatArgs);
    }
    return super.getQuantityString(id, quantity, formatArgs);
}
 
Example 4
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@NonNull
@Override
public String getQuantityString(@PluralsRes int id, int quantity) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getQuantityString(realId, quantity);
    }
    return super.getQuantityString(id, quantity);
}
 
Example 5
Project: fitnotifications   File: SettingsActivity.java   View source code 5 votes vote down vote up
private void updateSummaryWithPlurals(String summaryKey,
                                      int value,
                                      @PluralsRes int pluralsId,
                                      @StringRes int stringId,
                                      boolean enabled) {
    if (enabled) {
        findPreference(summaryKey).setSummary(getResources()
                .getQuantityString(pluralsId, value, value));
    } else {
        findPreference(summaryKey).setSummary(getString(stringId));
    }

    findPreference(summaryKey).setEnabled(enabled);
}
 
Example 6
Project: android-common   File: BaseFragmentImpl.java   View source code 5 votes vote down vote up
@Override
public void showToast(@PluralsRes final int id, final int quantity, final String... formatArgs) {
  if (isAvailable()) {
    Toast.makeText(
            getContext(),
            getQuantityString(id, quantity, (Object[]) formatArgs),
            Toast.LENGTH_LONG)
        .show();
  }
}
 
Example 7
Project: lex   File: LexString.java   View source code 4 votes vote down vote up
@NonNull
public ParsedLexString withPlural(@NonNull LexKey key, int quantity, @PluralsRes int resourceId) {
    return with(key, Lex.resources.getQuantityString(resourceId, quantity));
}
 
Example 8
Project: disclosure-android-app   File: StringProvider.java   View source code 4 votes vote down vote up
public String getPlural(@PluralsRes int resId, int quantity, Object... formatArgs) {
  return context.getResources().getQuantityString(resId, quantity, formatArgs);
}
 
Example 9
Project: tribbble   File: TribbbleApp.java   View source code 4 votes vote down vote up
public static String plural(@PluralsRes int resId, int quantity) {
  return sContext.getResources().getQuantityString(resId, quantity, quantity);
}
 
Example 10
Project: TimeSinceTextView   File: TimeSinceTextViewAndroidTest.java   View source code 4 votes vote down vote up
private String getQuantityString(@PluralsRes int resId, int n) {
    return getContext().getResources().getQuantityString(resId, n, n);
}
 
Example 11
Project: android_external_MicroGUiTools   File: Condition.java   View source code 4 votes vote down vote up
public Builder titlePlurals(@PluralsRes int val) {
    titlePluralsRes = val;
    return this;
}
 
Example 12
Project: android_external_MicroGUiTools   File: Condition.java   View source code 4 votes vote down vote up
public Builder summaryPlurals(@PluralsRes int val) {
    summaryPluralsRes = val;
    return this;
}
 
Example 13
Project: android_external_MicroGUiTools   File: Condition.java   View source code 4 votes vote down vote up
public Builder firstActionPlurals(@PluralsRes int val, View.OnClickListener listener) {
    firstActionPluralsRes = val;
    firstActionListener = listener;
    return this;
}
 
Example 14
Project: android_external_MicroGUiTools   File: Condition.java   View source code 4 votes vote down vote up
public Builder secondActionPlurals(@PluralsRes int val, View.OnClickListener listener) {
    secondActionPluralsRes = val;
    secondActionListener = listener;
    return this;
}
 
Example 15
Project: bridddle-for-dribbble   File: StringUtils.java   View source code 4 votes vote down vote up
public String formatWithText(@PluralsRes int pluralResource, @StringRes int zeroCountString, Integer count) {
    if (count == null || count == 0)
        return resources.getString(zeroCountString);
    String formattedNumber = NumberFormat.getIntegerInstance().format(count);
    return resources.getQuantityString(pluralResource, count, formattedNumber);
}
 
Example 16
Project: Android-App-Template   File: ResourcesUtil.java   View source code 4 votes vote down vote up
public static String getQuantityString(@PluralsRes int pluralsRes, int quantity) throws Resources.NotFoundException {
    return ContextUtil.getResources().getQuantityString(pluralsRes, quantity);
}
 
Example 17
Project: android-common   File: BaseFragmentImpl.java   View source code 4 votes vote down vote up
public String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs) {
  return getResources().getQuantityString(id, quantity, formatArgs);
}
 
Example 18
Project: resourceholder   File: PluralStringResource.java   View source code 4 votes vote down vote up
public PluralStringResource(@PluralsRes final int pluralResourceId) {
    mPluralResourceId = pluralResourceId;
}
 
Example 19
Project: FxcnBeta   File: TimeStringHelper.java   View source code 4 votes vote down vote up
private static String getResString(@PluralsRes int pluralsId, int value) {
    return sResources.getQuantityString(pluralsId, value, value);
}
 
Example 20
Project: BabyFace   File: FaceSettingsActivity.java   View source code 4 votes vote down vote up
private String prettyPrintDuration(int amount, @PluralsRes int pluralsRes) {
	return amount + " " + getResources().getQuantityString(pluralsRes, amount);
}
 
Example 21
Project: edx-app-android   File: ResourceUtil.java   View source code 4 votes vote down vote up
public static CharSequence getFormattedStringForQuantity(@NonNull Resources resources, @PluralsRes int resourceId, int quantity) {
    return getFormattedStringForQuantity(resources, resourceId, QuantityHolder, quantity);
}
 
Example 22
Project: edx-app-android   File: ResourceUtil.java   View source code 4 votes vote down vote up
public static CharSequence getFormattedStringForQuantity(@NonNull Resources resources, @PluralsRes int resourceId, @NonNull String key, int quantity) {
    String template = resources.getQuantityString(resourceId, quantity);
    return Phrase.from(template).put(key, quantity + "").format();
}
 
Example 23
Project: Qiitanium   File: ResUtils.java   View source code 4 votes vote down vote up
public static String getQuantityString(Context ctx, @PluralsRes int pluralResId, int quantity) {
  return ctx.getResources().getQuantityString(pluralResId, quantity, quantity);
}
 
Example 24
Project: apps-android-wikipedia   File: ReadingListFragment.java   View source code 4 votes vote down vote up
@NonNull private String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs) {
    return getResources().getQuantityString(id, quantity, formatArgs);
}
 
Example 25
Project: FormattEditText   File: DecimalEditText.java   View source code 3 votes vote down vote up
/**
 * Set whole format of edit text field for displaying decimal value.
 *
 * @param decimalRounding
 * 		Amount of fraction digits.
 * @param pluralResource
 * 		Resource ID of plural strings (don't use plurals with numbers!).
 */
public void setFormat(int decimalRounding, @PluralsRes int pluralResource) {
	this.decimalRounding = decimalRounding;
	if (this.decimalRounding < 0)
		this.decimalRounding = 0;
	this.pluralLabel = pluralResource;
	updateText();
}
 
Example 26
Project: AndProx   File: Utils.java   View source code 2 votes vote down vote up
/**
 * Given a plural resource (R.plurals), localize the string according to the language preferences
 * on the device.
 *
 * @param pluralResource R.plurals to localize.
 * @param quantity       Quantity to use for pluaralisation rules
 * @param formatArgs     Formatting arguments to pass
 * @return Localized string
 */
public static String localizePlural(@PluralsRes int pluralResource, int quantity, Object... formatArgs) {
    Resources res = AndProxApplication.getInstance().getResources();
    return res.getQuantityString(pluralResource, quantity, formatArgs);
}
 
Example 27
Project: Minerva   File: Minerva.java   View source code 2 votes vote down vote up
/**
 * Get a formatted quantity string resource using the application context.
 * @param resId      String resource ID.
 * @param count      Quantity.
 * @param formatArgs Format arguments.
 * @return Formatted quantity string.
 */
public String getQString(@PluralsRes int resId, int count, Object... formatArgs) {
    return getResources().getQuantityString(resId, count, formatArgs);
}
 
Example 28
Project: FormattEditText   File: DecimalEditText.java   View source code 2 votes vote down vote up
/**
 * Gets resource ID of plural for formatting view of input field.
 *
 * @return ID of current plural in resources.
 */
@PluralsRes
public int getPluralResource() {
	return pluralLabel;
}
 
Example 29
Project: FormattEditText   File: DecimalEditText.java   View source code 2 votes vote down vote up
/**
 * Sets plural for formatting of current value with label and updates view.
 *
 * @param pluralResource
 * 		Resource ID of plural strings (don't use plurals with numbers!).
 */
public void setPluralResource(@PluralsRes final int pluralResource) {
	pluralLabel = pluralResource;
	updateText();
}
 
Example 30
Project: phrase   File: Phrase.java   View source code 2 votes vote down vote up
/**
 * Entry point into this API.
 *
 * @throws IllegalArgumentException if pattern contains any syntax errors.
 */
public static Phrase fromPlural(View v, @PluralsRes int patternResourceId, int quantity) {
  return fromPlural(v.getResources(), patternResourceId, quantity);
}
 
Example 31
Project: phrase   File: Phrase.java   View source code 2 votes vote down vote up
/**
 * Entry point into this API.
 *
 * @throws IllegalArgumentException if pattern contains any syntax errors.
 */
public static Phrase fromPlural(Context c, @PluralsRes int patternResourceId, int quantity) {
  return fromPlural(c.getResources(), patternResourceId, quantity);
}
 
Example 32
Project: phrase   File: Phrase.java   View source code 2 votes vote down vote up
/**
 * Entry point into this API.
 *
 * @throws IllegalArgumentException if pattern contains any syntax errors.
 */
public static Phrase fromPlural(Resources r, @PluralsRes int patternResourceId, int quantity) {
  return from(r.getQuantityText(patternResourceId, quantity));
}
 
Example 33
Project: android-tao-core   File: AppResources.java   View source code 2 votes vote down vote up
/**
 * Returns the character sequence necessary for grammatically correct pluralization
 * of the given resource ID for the given quantity.
 * Note that the character sequence is selected based solely on grammatical necessity,
 * and that such rules differ between languages. Do not assume you know which string
 * will be returned for a given quantity. See
 * <a href="{@docRoot}guide/topics/resources/string-resource.html#Plurals">String Resources</a>
 * for more detail.
 *
 * @param id       The desired resource identifier, as generated by the aapt
 *                 tool. This integer encodes the package, type, and resource
 *                 entry. The value 0 is an invalid identifier.
 * @param quantity The number used to get the correct string for the current language's
 *                 plural rules.
 * @return CharSequence The string data associated with the resource, plus
 * possibly styled text information.
 * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
 */
public static CharSequence getQuantityText(@PluralsRes int id, int quantity) throws NotFoundException {
   return resources.getQuantityText(id, quantity);
}
 
Example 34
Project: android-tao-core   File: AppResources.java   View source code 2 votes vote down vote up
/**
 * Formats the string necessary for grammatically correct pluralization
 * of the given resource ID for the given quantity, using the given arguments.
 * Note that the string is selected based solely on grammatical necessity,
 * and that such rules differ between languages. Do not assume you know which string
 * will be returned for a given quantity. See
 * <a href="{@docRoot}guide/topics/resources/string-resource.html#Plurals">String Resources</a>
 * for more detail.
 * <p/>
 * <p>Substitution of format arguments works as if using
 * {@link java.util.Formatter} and {@link java.lang.String#format}.
 * The resulting string will be stripped of any styled text information.
 *
 * @param id         The desired resource identifier, as generated by the aapt
 *                   tool. This integer encodes the package, type, and resource
 *                   entry. The value 0 is an invalid identifier.
 * @param quantity   The number used to get the correct string for the current language's
 *                   plural rules.
 * @param formatArgs The format arguments that will be used for substitution.
 * @return String The string data associated with the resource,
 * stripped of styled text information.
 * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
 */
public static String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs) throws NotFoundException {
   return resources.getQuantityString(id, quantity, formatArgs);
}
 
Example 35
Project: android-tao-core   File: AppResources.java   View source code 2 votes vote down vote up
/**
 * Returns the string necessary for grammatically correct pluralization
 * of the given resource ID for the given quantity.
 * Note that the string is selected based solely on grammatical necessity,
 * and that such rules differ between languages. Do not assume you know which string
 * will be returned for a given quantity. See
 * <a href="{@docRoot}guide/topics/resources/string-resource.html#Plurals">String Resources</a>
 * for more detail.
 *
 * @param id       The desired resource identifier, as generated by the aapt
 *                 tool. This integer encodes the package, type, and resource
 *                 entry. The value 0 is an invalid identifier.
 * @param quantity The number used to get the correct string for the current language's
 *                 plural rules.
 * @return String The string data associated with the resource,
 * stripped of styled text information.
 * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
 */
public static String getQuantityString(@PluralsRes int id, int quantity) throws NotFoundException {
   return resources.getQuantityString(id, quantity);
}
 
Example 36
Project: android-common   File: BaseFragment.java   View source code votes vote down vote up
void showToast(@PluralsRes int id, int quantity, String... formatArgs);