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

The following examples show how to use android.content.res.Resources#getStringArray() . 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: X8DroneInfoStateController.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void initViews(View rootView) {
    this.list = new ArrayList();
    this.parentView = LayoutInflater.from(rootView.getContext()).inflate(R.layout.x8_main_all_setting_drone_info_state, (ViewGroup) rootView, true);
    RecyclerView recyclerView = (RecyclerView) this.parentView.findViewById(R.id.ryv_drone_state);
    recyclerView.setLayoutManager(new LinearLayoutManager(rootView.getContext()));
    Resources res = rootView.getContext().getResources();
    String[] states = res.getStringArray(R.array.x8_drone_info_state_array);
    for (int i = 0; i < states.length; i++) {
        X8DroneInfoState state = new X8DroneInfoState();
        state.setName(states[i]);
        state.setState(State.NA);
        state.setMode(getMode(i));
        state.setInfo(res.getString(R.string.x8_na));
        state.setErrorEvent(getEvent(state.getMode()));
        this.list.add(state);
    }
    this.adapter = new X8DroneInfoStateAdapter(this.list);
    this.adapter.setOnEventClickListener(this);
    recyclerView.setAdapter(this.adapter);
    initActions();
}
 
Example 2
Source File: ResourceUtils.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public static String getDeviceOverrideValue(final Resources res, final int overrideResId,
        final String defaultValue) {
    final int orientation = res.getConfiguration().orientation;
    final String key = overrideResId + "-" + orientation;
    if (sDeviceOverrideValueMap.containsKey(key)) {
        return sDeviceOverrideValueMap.get(key);
    }

    final String[] overrideArray = res.getStringArray(overrideResId);
    final String overrideValue = findConstantForKeyValuePairs(sBuildKeyValues, overrideArray);
    // The overrideValue might be an empty string.
    if (overrideValue != null) {
        Log.i(TAG, "Find override value:"
                + " resource="+ res.getResourceEntryName(overrideResId)
                + " build=" + sBuildKeyValuesDebugString
                + " override=" + overrideValue);
        sDeviceOverrideValueMap.put(key, overrideValue);
        return overrideValue;
    }

    sDeviceOverrideValueMap.put(key, defaultValue);
    return defaultValue;
}
 
Example 3
Source File: HorizontalRTToolbar.java    From memoir with Apache License 2.0 6 votes vote down vote up
private SpinnerItems<FontSizeSpinnerItem> getTextSizeItems() {
    SpinnerItems<FontSizeSpinnerItem> spinnerItems = new SpinnerItems<>();
    Resources res = getResources();

    // empty size
    spinnerItems.add(new FontSizeSpinnerItem(-1, "", true));

    // regular sizes
    String[] fontSizeEntries = res.getStringArray(R.array.rte_toolbar_fontsizes_entries);
    int[] fontSizeValues = res.getIntArray(R.array.rte_toolbar_fontsizes_values);
    for (int i = 0; i < fontSizeEntries.length; i++) {
        spinnerItems.add(new FontSizeSpinnerItem(fontSizeValues[i], fontSizeEntries[i], false));
    }

    return spinnerItems;
}
 
Example 4
Source File: HorizontalRTToolbar.java    From Android-RTEditor with Apache License 2.0 6 votes vote down vote up
private SpinnerItems<FontSizeSpinnerItem> getTextSizeItems() {
    SpinnerItems<FontSizeSpinnerItem> spinnerItems = new SpinnerItems<FontSizeSpinnerItem>();
    Resources res = getResources();

    // empty size
    spinnerItems.add(new FontSizeSpinnerItem(-1, "", true));

    // regular sizes
    String[] fontSizeEntries = res.getStringArray(R.array.rte_toolbar_fontsizes_entries);
    int[] fontSizeValues = res.getIntArray(R.array.rte_toolbar_fontsizes_values);
    for (int i = 0; i < fontSizeEntries.length; i++) {
        spinnerItems.add(new FontSizeSpinnerItem(fontSizeValues[i], fontSizeEntries[i], false));
    }

    return spinnerItems;
}
 
Example 5
Source File: InspectUsingNative.java    From rootinspector with GNU General Public License v2.0 6 votes vote down vote up
private ArrayList<RootMethodModel> doChecking() {
	ArrayList<RootMethodModel> values;
	pm = getPackageManager();
	manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
	Resources res = getResources();
	detectionDescriptions = res.getStringArray(R.array.native_detection_types_array);
	detectionTitles = res.getStringArray(R.array.native_detection_titles);
	detectionFailures= res.getStringArray(R.array.native_detection_failures_array);
	passString = res.getString(R.string.pass_string);
	failString = res.getString(R.string.failure_string);
	
	values = new ArrayList<RootMethodModel>();
	
	for (int i = 0; i < detectionTitles.length; i++) {
		values.add(checkRootUsingMethodNative(i));
	}
	
	
	return values;
}
 
Example 6
Source File: DownloadModule.java    From Aria with Apache License 2.0 5 votes vote down vote up
/**
 * 最高优先级任务测试列表
 */
public List<DownloadEntity> getHighestTestList() {
  List<DownloadEntity> list = new LinkedList<>();
  Resources res = getContext().getResources();
  String[] urls = res.getStringArray(R.array.highest_urls);
  String[] names = res.getStringArray(R.array.highest_names);
  for (int i = 0, len = urls.length; i < len; i++) {
    list.add(createDownloadEntity(urls[i], names[i]));
  }
  return list;
}
 
Example 7
Source File: ThemeSettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
static void updateKeyboardThemeSummary(final Preference pref) {
    final Context context = pref.getContext();
    final Resources res = context.getResources();
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        if (keyboardTheme.mThemeId == keyboardThemeIds[index]) {
            pref.setSummary(keyboardThemeNames[index]);
            return;
        }
    }
}
 
Example 8
Source File: MainActivityTest.java    From fontster with Apache License 2.0 5 votes vote down vote up
private static Set<String> getFontNamesStartingWith(String startingString) {
  final Resources resources = InstrumentationRegistry.getTargetContext().getResources();
  final String[] fontList = resources.getStringArray(R.array.font_list);
  final Set<String> output = new HashSet<>();
  for (String fontName : fontList) {
    if (fontName.startsWith(startingString)) output.add(fontName);
    else if (!output.isEmpty()) break;
  }
  return output;
}
 
Example 9
Source File: ADFilterTool.java    From styT with Apache License 2.0 5 votes vote down vote up
public static boolean hasAd(Context context, String url) {
    Resources res = context.getResources();
    String[] adUrls = res.getStringArray(R.array.adBlockUrl);
    for (String adUrl : adUrls) {
        if (url.contains(adUrl)) {
            return true;
        }
    }
    return false;
}
 
Example 10
Source File: Building.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
public static ArrayList<Building> createList(Context ctx) {
    Resources res = ctx.getResources();
    String[] names = res.getStringArray(R.array.names);
    String[] heights = res.getStringArray(R.array.heights);
    TypedArray icons = res.obtainTypedArray(R.array.photos);
    ArrayList<Building> items = new ArrayList<Building>(names.length);
    for (int i = 0; i < names.length; ++i) {
        items.add(new Building(names[i], heights[i], icons.getDrawable(i)));
    }
    icons.recycle();
    return items;
}
 
Example 11
Source File: ResourceHelper.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
public static String[] getStringArray(int resourceId) {
    Context context = CoreMaterialApplication.getContext();
    if (context == null) {
        return null;
    }

    Resources resources = context.getResources();
    if (resources == null) {
        return null;
    }

    return resources.getStringArray(resourceId);
}
 
Example 12
Source File: GetRestrictionsReceiver.java    From enterprise-samples with Apache License 2.0 5 votes vote down vote up
public static void populateMultiEntry(Resources res, RestrictionEntry reMultiSelect) {
    String[] multiEntries = res.getStringArray(R.array.multi_entry_entries);
    String[] multiValues = res.getStringArray(R.array.multi_entry_values);
    if (reMultiSelect.getAllSelectedStrings() == null) {
        reMultiSelect.setAllSelectedStrings(new String[0]);
    }
    reMultiSelect.setTitle(res.getString(R.string.multi_entry_title));
    reMultiSelect.setChoiceEntries(multiEntries);
    reMultiSelect.setChoiceValues(multiValues);
    reMultiSelect.setType(RestrictionEntry.TYPE_MULTI_SELECT);
}
 
Example 13
Source File: ThemeSettingsFragment.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
static void updateKeyboardThemeSummary(final Preference pref) {
    final Context context = pref.getContext();
    final Resources res = context.getResources();
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        if (keyboardTheme.mThemeId == keyboardThemeIds[index]) {
            pref.setSummary(keyboardThemeNames[index]);
            return;
        }
    }
}
 
Example 14
Source File: ColorizeFaceActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
private Map<String, ProductTypeTwo> filterProduct(Map<String, ProductTypeTwo> unsortMap, int categoryResult) {
    List<Map.Entry<String, ProductTypeTwo>> temp = new LinkedList<Map.Entry<String, ProductTypeTwo>>(unsortMap.entrySet());
    //compare temp
    List<Map.Entry<String, ProductTypeTwo>> temp2 = new LinkedList<Map.Entry<String, ProductTypeTwo>>(unsortMap.entrySet());

    int tempSize = temp2.size();
    List<String> removeList = new ArrayList<>();
    Resources res = getResources();
    final String[] categoryArray = res.getStringArray(R.array.category_type_array);

    if (categoryResult >= 0) {
        for (int i = 0; i < tempSize; i++) {
            if (!categoryArray[categoryResult].equals(temp2.get(i).getValue().getCategory())) {
                Log.d(TAG + " remove : " + temp2.get(i).getKey(), categoryArray[categoryResult] + " : " + temp2.get(i).getValue().getCategory());
                removeList.add(temp2.get(i).getKey());
            }
        }
    }
    Log.d("Filtered ", "Map");
    // Maintaining insertion order with the help of LinkedList
    Map<String, ProductTypeTwo> filteredMap = new LinkedHashMap<>();
    for (Map.Entry<String, ProductTypeTwo> entry : temp) {
        if (!removeList.contains(entry.getKey())) {
            filteredMap.put(entry.getKey(), entry.getValue());
            Log.d(entry.getKey(), entry.getValue().getProductName() + " : " + entry.getValue().getCategory());
        }
    }

    return filteredMap;
}
 
Example 15
Source File: ProductRecommentationActivity.java    From FaceT with Mozilla Public License 2.0 4 votes vote down vote up
private void sortProduct() {

        Resources res = getResources();
        final String[] categoryArray = res.getStringArray(R.array.category_type_array);
        List<ProductTypeTwo> values = new ArrayList<>(mProducts.values());
        List<String> keys = new ArrayList<>(mProducts.keySet());

        for (int i = 0; i < keys.size(); i++) {
            Log.d("otherMatchColorList.containsKey " , otherMatchColorList.size() +  " , " + i);
            if (otherMatchColorList.containsKey(keys.get(i)) && values.get(i) != null && values.get(i).getCategory().equals(categoryArray[2])) {
                Log.d(TAG + "2 sortProduct: ", keys.get(i) + " " + values.get(0).getProductName());
                mBlushProducts.put(keys.get(i), values.get(i));
            } else if (values.get(i) != null && values.get(i).getCategory().equals(categoryArray[3])) {
                Log.d(TAG + "3 sortProduct: ", keys.get(i) + " " + values.get(0).getProductName());
                mEyshadowProducts.put(keys.get(i), values.get(i));
            } else if (otherMatchColorList.containsKey(keys.get(i)) && values.get(i) != null && values.get(i).getCategory().equals(categoryArray[4])) {
                Log.d(TAG + "4 sortProduct: ", keys.get(i) + " " + values.get(0).getProductName());
                mLipstickProducts.put(keys.get(i), values.get(i));
            }
        }
        LinearLayoutManager layoutManager1 = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        LinearLayoutManager layoutManager2 = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        LinearLayoutManager layoutManager3 = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        LinearLayoutManager layoutManager4 = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);

        recommend_product_list_1.setLayoutManager(layoutManager1);
        mProductAdapter1 = new ProductAdapter(mFoundationProducts, getApplicationContext());
        recommend_product_list_1.setAdapter(mProductAdapter1);
        mProductAdapter1.notifyDataSetChanged();

        recommend_product_list_2.setLayoutManager(layoutManager2);
        mProductAdapter2 = new ProductAdapter(mBlushProducts, getApplicationContext());
        recommend_product_list_2.setAdapter(mProductAdapter2);
        mProductAdapter2.notifyDataSetChanged();

        recommend_product_list_3.setLayoutManager(layoutManager3);
        mProductAdapter3 = new ProductAdapter(mEyshadowProducts, getApplicationContext());
        recommend_product_list_3.setAdapter(mProductAdapter3);
        mProductAdapter3.notifyDataSetChanged();

        recommend_product_list_4.setLayoutManager(layoutManager4);
        mProductAdapter4 = new ProductAdapter(mLipstickProducts, getApplicationContext());
        recommend_product_list_4.setAdapter(mProductAdapter4);
        mProductAdapter4.notifyDataSetChanged();
    }
 
Example 16
Source File: MiniWidgetProvider.java    From android with Apache License 2.0 4 votes vote down vote up
@Override
protected String[] getHijriNames(AppWidgetManager awm, Context context, int appWidgetId) {
    Resources r = context.getResources();
    return r.getStringArray(R.array.hijri_months_short);
}
 
Example 17
Source File: ResourceArrayParser.java    From Equate with GNU General Public License v3.0 4 votes vote down vote up
public static ArrayList<String> getUnitTypeNameArrayList(Resources resources) {
	String[] stringArray = resources.getStringArray(R.array.unit_type_array_combined);
	return getUnitArray(stringArray, UNIT_TYPE_KEY_NAME);
}
 
Example 18
Source File: MainActivity.java    From SSLSocks with MIT License 4 votes vote down vote up
@Override
public CharSequence getPageTitle(int position) {
	Resources res = getResources();
	String[] tabs = res.getStringArray(R.array.tabs_array);
	return tabs[position];
}
 
Example 19
Source File: TVSlideAdapter.java    From moviedb-android with Apache License 2.0 4 votes vote down vote up
public TVSlideAdapter(FragmentManager fm, Resources res) {
    super(fm);
    this.manager = fm;
    navMenuTitles = res.getStringArray(R.array.tvTabs);
    this.res = res;
}
 
Example 20
Source File: SettingsFragment.java    From fresco with MIT License 4 votes vote down vote up
private static void updateListPreference(
    Resources resources, ListPreference preference, int arrayValuesId) {
  final int valueIndex = preference.findIndexOfValue(preference.getValue());
  final String summary = resources.getStringArray(arrayValuesId)[valueIndex];
  preference.setSummary(summary);
}