Java Code Examples for android.content.res.Resources#getTextArray()

The following examples show how to use android.content.res.Resources#getTextArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationProvider.java    From beacons-android with Apache License 2.0 6 votes vote down vote up
private void fillInboxStyleNotification(NotificationCompat.InboxStyle inboxStyle) {
    Resources resources = mContext.getResources();
    CharSequence[] txPowers = resources.getTextArray(R.array.com_uriio_txPowerNames);

    for (Beacon beacon : Beacons.getActive()) {
        if (beacon.getAdvertiseState() != Beacon.ADVERTISE_RUNNING) continue;

        SpannableStringBuilder builder = new SpannableStringBuilder();
        builder.append(beacon.getNotificationSubject());
        builder.append(" ")
                .append(Html.fromHtml(String.format(NOTIF_FORMAT_TX_POWER[beacon.getTxPowerLevel()],
                        txPowers[beacon.getTxPowerLevel()])))
                .append(" ")
                .append(Html.fromHtml(String.format(NOTIF_FORMAT_ADV_MODES[beacon.getAdvertiseMode()],
                        1000 / Advertiser.getPduIntervals()[beacon.getAdvertiseMode()])));

        inboxStyle.addLine(builder);
    }
}
 
Example 2
Source File: HelpActivity.java    From Noyze with Apache License 2.0 6 votes vote down vote up
public HelpFragmentAdapter(Context mContext) {
	this.mContext = mContext;
	final Map<CharSequence, Integer> mMappedItems = new LinkedHashMap<CharSequence, Integer>();
	
	final Resources res = mContext.getResources();
	final CharSequence[] mDescriptions = res.getTextArray(0);//R.array.help_descriptions);
	final TypedArray mImages = res.obtainTypedArray(0);//R.array.help_images);

          // Add items to our HashMap.
          if (mDescriptions.length == mImages.length()) {
              for (int i = 0; i < mDescriptions.length; ++i) {
                  mMappedItems.put(mDescriptions[i], mImages.getResourceId(i, 0));
              }
          }
	
	mImages.recycle();
	mItems = (new ArrayList<Entry<CharSequence, Integer>>(mMappedItems.entrySet()));
}
 
Example 3
Source File: CustomListPreference.java    From MCPDict with MIT License 6 votes vote down vote up
public CustomListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    this.context = context;
    Resources res = context.getResources();

    int entriesResId = attrs.getAttributeResourceValue(ANDROID_NS, "entries", 0);
    if (entriesResId != 0) {
        mEntries = res.getTextArray(entriesResId);
    }

    int defaultValueResId = attrs.getAttributeResourceValue(ANDROID_NS, "defaultValue", 0);
    if (defaultValueResId != 0) {
        mValue = res.getInteger(defaultValueResId);
    }

    setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference pref, Object value) {
            pref.setSummary(getEntry());
            return true;
        }
    });
}
 
Example 4
Source File: HelpActivity.java    From Noyze with Apache License 2.0 6 votes vote down vote up
public HelpFragmentAdapter(Context mContext) {
	this.mContext = mContext;
	final Map<CharSequence, Integer> mMappedItems = new LinkedHashMap<CharSequence, Integer>();
	
	final Resources res = mContext.getResources();
	final CharSequence[] mDescriptions = res.getTextArray(0);//R.array.help_descriptions);
	final TypedArray mImages = res.obtainTypedArray(0);//R.array.help_images);

          // Add items to our HashMap.
          if (mDescriptions.length == mImages.length()) {
              for (int i = 0; i < mDescriptions.length; ++i) {
                  mMappedItems.put(mDescriptions[i], mImages.getResourceId(i, 0));
              }
          }
	
	mImages.recycle();
	mItems = (new ArrayList<Entry<CharSequence, Integer>>(mMappedItems.entrySet()));
}