List of usage examples for android.content.res Resources getQuantityText
@NonNull public CharSequence getQuantityText(@PluralsRes int id, int quantity) throws NotFoundException
From source file:com.tct.mail.browse.SendersView.java
private static synchronized void getSenderResources(Context context, final boolean resourceCachingRequired) { if (sConfigurationChangedReceiver == null && resourceCachingRequired) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//from ww w .ja v a2s .c o m public void onReceive(Context context, Intent intent) { sDraftSingularString = null; getSenderResources(context, true); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (sDraftSingularString == null) { Resources res = context.getResources(); sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedString = res.getString(R.string.senders_elided); sDraftSingularString = res.getQuantityText(R.plurals.draft, 1); sDraftPluralString = res.getQuantityText(R.plurals.draft, 2); sDraftCountFormatString = res.getString(R.string.draft_count_format); sMeSubjectString = res.getString(R.string.me_subject_pronoun); sMeObjectString = res.getString(R.string.me_object_pronoun); sToHeaderString = res.getString(R.string.to_heading); sMessageInfoUnreadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoUnreadTextAppearance); sMessageInfoReadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoReadTextAppearance); sDraftsStyleSpan = new TextAppearanceSpan(context, R.style.DraftTextAppearance); sUnreadStyleSpan = new TextAppearanceSpan(context, R.style.SendersAppearanceUnreadStyle); sSendingStyleSpan = new TextAppearanceSpan(context, R.style.SendingTextAppearance); sQueuedStyleSpan = new TextAppearanceSpan(context, R.style.RetryingTextAppearance); sFailedStyleSpan = new TextAppearanceSpan(context, R.style.FailedTextAppearance); sReadStyleSpan = new TextAppearanceSpan(context, R.style.SendersAppearanceReadStyle); sMessageCountSpacerString = res.getString(R.string.message_count_spacer); sSendingString = res.getString(R.string.sending); sQueuedString = res.getString(R.string.message_retrying); sFailedString = res.getString(R.string.message_failed); sBidiFormatter = BidiFormatter.getInstance(); } }
From source file:com.chen.mail.browse.SendersView.java
private static synchronized void getSenderResources(Context context, final boolean resourceCachingRequired) { if (sConfigurationChangedReceiver == null && resourceCachingRequired) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//from w w w . ja va 2s . c om public void onReceive(Context context, Intent intent) { sDraftSingularString = null; getSenderResources(context, true); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (sDraftSingularString == null) { Resources res = context.getResources(); sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedString = res.getString(R.string.senders_elided); sDraftSingularString = res.getQuantityText(R.plurals.draft, 1); sDraftPluralString = res.getQuantityText(R.plurals.draft, 2); sDraftCountFormatString = res.getString(R.string.draft_count_format); sMessageInfoUnreadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoUnreadTextAppearance); sMessageInfoReadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoReadTextAppearance); sDraftsStyleSpan = new TextAppearanceSpan(context, R.style.DraftTextAppearance); sUnreadStyleSpan = new TextAppearanceSpan(context, R.style.SendersUnreadTextAppearance); sSendingStyleSpan = new TextAppearanceSpan(context, R.style.SendingTextAppearance); sReadStyleSpan = new TextAppearanceSpan(context, R.style.SendersReadTextAppearance); sMessageCountSpacerString = res.getString(R.string.message_count_spacer); sSendingString = res.getString(R.string.sending); sBidiFormatter = BidiFormatter.getInstance(); } }
From source file:com.android.mail.browse.SendersView.java
private static synchronized void getSenderResources(Context context, final boolean resourceCachingRequired) { if (sConfigurationChangedReceiver == null && resourceCachingRequired) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//from w ww . ja v a 2 s. co m public void onReceive(Context context, Intent intent) { sDraftSingularString = null; getSenderResources(context, true); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (sDraftSingularString == null) { Resources res = context.getResources(); sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedString = res.getString(R.string.senders_elided); sDraftSingularString = res.getQuantityText(R.plurals.draft, 1); sDraftPluralString = res.getQuantityText(R.plurals.draft, 2); sDraftCountFormatString = res.getString(R.string.draft_count_format); sMeSubjectString = res.getString(R.string.me_subject_pronoun); sMeObjectString = res.getString(R.string.me_object_pronoun); sToHeaderString = res.getString(R.string.to_heading); sMessageInfoUnreadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoUnreadTextAppearance); sMessageInfoReadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoReadTextAppearance); sDraftsStyleSpan = new TextAppearanceSpan(context, R.style.DraftTextAppearance); sUnreadStyleSpan = new TextAppearanceSpan(context, R.style.SendersAppearanceUnreadStyle); sSendingStyleSpan = new TextAppearanceSpan(context, R.style.SendingTextAppearance); sRetryingStyleSpan = new TextAppearanceSpan(context, R.style.RetryingTextAppearance); sFailedStyleSpan = new TextAppearanceSpan(context, R.style.FailedTextAppearance); sReadStyleSpan = new TextAppearanceSpan(context, R.style.SendersAppearanceReadStyle); sMessageCountSpacerString = res.getString(R.string.message_count_spacer); sSendingString = res.getString(R.string.sending); sRetryingString = res.getString(R.string.message_retrying); sFailedString = res.getString(R.string.message_failed); sBidiFormatter = BidiFormatter.getInstance(); } }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
/** * This is now only used for the query screen *//*from ww w . j a v a 2 s . com*/ public static String makeAlbumsSongsLabel(Context context, int numalbums, int numsongs, boolean isUnknown) { // There are several formats for the albums/songs information: // "1 Song" - used if there is only 1 song // "N Songs" - used for the "unknown artist" item // "1 Album"/"N Songs" // "N Album"/"M Songs" // Depending on locale, these may need to be further subdivided StringBuilder songs_albums = new StringBuilder(); if (numsongs == 1) { songs_albums.append(context.getString(R.string.onesong)); } else { Resources r = context.getResources(); if (!isUnknown) { String f = r.getQuantityText(R.plurals.Nalbums, numalbums).toString(); sFormatBuilder.setLength(0); sFormatter.format(f, Integer.valueOf(numalbums)); songs_albums.append(sFormatBuilder); songs_albums.append(context.getString(R.string.albumsongseparator)); } String f = r.getQuantityText(R.plurals.Nsongs, numsongs).toString(); sFormatBuilder.setLength(0); sFormatter.format(f, Integer.valueOf(numsongs)); songs_albums.append(sFormatBuilder); } return songs_albums.toString(); }
From source file:dev.drsoran.moloko.fragments.dialogs.EstimatePickerDialogFragment.java
private void setUnits(int pos) { final Context context = getSherlockActivity(); final Resources res = context.getResources(); unitWheel.setViewAdapter(new ArrayWheelAdapter<String>(context, new String[] { res.getQuantityText(R.plurals.g_day, pos).toString(), res.getQuantityText(R.plurals.g_hour, pos).toString(), res.getQuantityText(R.plurals.g_minute, pos).toString() })); }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
public static String makeAlbumsLabel(Context context, int numalbums, int numsongs, boolean isUnknown) { // There are two formats for the albums/songs information: // "N Song(s)" - used for unknown artist/album // "N Album(s)" - used for known albums StringBuilder songs_albums = new StringBuilder(); Resources r = context.getResources(); if (isUnknown) { if (numsongs == 1) { songs_albums.append(context.getString(R.string.onesong)); } else {/*from w w w.j a v a 2s.co m*/ String f = r.getQuantityText(R.plurals.Nsongs, numsongs).toString(); sFormatBuilder.setLength(0); sFormatter.format(f, Integer.valueOf(numsongs)); songs_albums.append(sFormatBuilder); } } else { String f = r.getQuantityText(R.plurals.Nalbums, numalbums).toString(); sFormatBuilder.setLength(0); sFormatter.format(f, Integer.valueOf(numalbums)); songs_albums.append(sFormatBuilder); songs_albums.append(context.getString(R.string.albumsongseparator)); } return songs_albums.toString(); }
From source file:dev.drsoran.moloko.fragments.dialogs.RecurrencePickerDialogFragment.java
private void initFreqWheel(Map<Integer, List<Object>> elements) { final Activity activity = getSherlockActivity(); final Resources res = activity.getResources(); final int interval = getInterval(); freqWheel.setViewAdapter(new ArrayWheelAdapter<String>(activity, new String[] { res.getQuantityText(R.plurals.g_year, interval).toString(), res.getQuantityText(R.plurals.g_month, interval).toString(), res.getQuantityText(R.plurals.g_week, interval).toString(), res.getQuantityText(R.plurals.g_day, interval).toString() })); if (elements != null) { Integer freq = getPatternElement(elements, RecurrencePatternParser.OP_FREQ, Integer.class); if (freq != null) { switch (freq.intValue()) { case RecurrencePatternParser.VAL_YEARLY: freqWheel.setCurrentItem(0); break; case RecurrencePatternParser.VAL_MONTHLY: freqWheel.setCurrentItem(1); break; case RecurrencePatternParser.VAL_WEEKLY: freqWheel.setCurrentItem(2); break; case RecurrencePatternParser.VAL_DAILY: freqWheel.setCurrentItem(3); break; default: freq = Integer.valueOf(-1); break; }// w w w .j a v a 2 s . c o m } else { freq = Integer.valueOf(-1); } if (freq.intValue() == -1) freqWheel.setCurrentItem(0); } }