Resources r = getResources(); int[] bases = r.getIntArray(R.array.UserBases);
public int[] getPalette() { int resourceId = getResource(R.attr.palette); if (resourceId < 0) throw new RuntimeException("resource not found"); return context.getResources().getIntArray(resourceId); }
private static @Nullable Unbinder parseBindArray(Object target, Field field, View source) { BindArray bindArray = field.getAnnotation(BindArray.class); if (bindArray == null) { return null; } validateMember(field); int id = bindArray.value(); Resources resources = source.getContext().getResources(); Object value; Class<?> fieldType = field.getType(); if (fieldType == TypedArray.class) { value = resources.obtainTypedArray(id); } else if (fieldType.isArray()) { Class<?> componentType = fieldType.getComponentType(); if (componentType == String.class) { value = resources.getStringArray(id); } else if (componentType == int.class) { value = resources.getIntArray(id); } else if (componentType == CharSequence.class) { value = resources.getTextArray(id); } else { throw new IllegalStateException(); // TODO } } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
/** * 向父容器中填充View */ private void fillViewToParent(Context context) { indicatorStrings = context.getResources().getStringArray(indicatorStringsResourceId); indicatorColorIds = context.getResources().getIntArray(indicatorColorsResourceId); if (indicatorStrings.length != indicatorColorIds.length) { throw new IllegalArgumentException("qualities和aqiColors的数组长度不一致!"); } for (int i = 0; i < indicatorStrings.length; i++) { addTextView(context, indicatorStrings[i], indicatorColorIds[i]); if (i != (indicatorStrings.length - 1)) { addBlankView(context); } } }
a.getResourceId(R.styleable.DribbbleFeed_shotLoadingPlaceholderColors, 0); if (loadingColorArrayId != 0) { int[] placeholderColors = host.getResources().getIntArray(loadingColorArrayId); shotLoadingPlaceholders = new ColorDrawable[placeholderColors.length]; for (int i = 0; i < placeholderColors.length; i++) {
public final int[] getIntArray(@ArrayRes int id) { return getResources().getIntArray(id); }
@Nullable private final int[] resolveIntArrayRes(@ArrayRes int resId) { if (resId != 0) { int[] cached = mResourceCache.get(resId); if (cached != null) { return cached; } int[] result = mResources.getIntArray(resId); mResourceCache.put(resId, result); return result; } return null; }
colorSchemeColors = context.getResources().getIntArray(colorsId); showArrow = t.getBoolean(R.styleable.MaterialRefreshLayout_progress_show_arrow, true); textType = t.getInt(R.styleable.MaterialRefreshLayout_progress_text_visibility, 1);
@Test(expected = Resources.NotFoundException.class) public void getIntegerArray_shouldThrowExceptionIfNotFound() { resources.getIntArray(-1); }
@Test public void getIntArray() throws Exception { assertThat(resources.getIntArray(R.array.empty_int_array)).isEqualTo(new int[]{}); assertThat(resources.getIntArray(R.array.zero_to_four_int_array)).isEqualTo(new int[]{0, 1, 2, 3, 4}); assertThat(resources.getIntArray(R.array.with_references_int_array)).isEqualTo(new int[]{0, 2000, 1}); assertThat(resources.getIntArray(R.array.referenced_colors_int_array)).isEqualTo(new int[]{0x1, 0xFFFFFFFF, 0xFF000000, 0xFFF5F5F5, 0x802C76AD}); }
ImageAnimator(CollapsingToolbarLayout collapsingToolbar, ImageView targetImage, ImageView outgoingImage) { this.collapsingToolbar = collapsingToolbar; mTargetImage = targetImage; mOutgoingImage = outgoingImage; BindingUtils.loadImg(mTargetImage, mImages[0]); Resources mResources = App.getAppContext().getResources(); int[] mColorDay = mResources.getIntArray(R.array.day_color_tab); int[] mColorNight = mResources.getIntArray(R.array.night_color_tab); mColors = SpUtil.isNight() ? mColorNight : mColorDay; collapsingToolbar.setContentScrimColor(mColors[0]); collapsingToolbar.setStatusBarScrimColor(mColors[0]); }
: getResources().getIntArray(indicatorColorsId); : getResources().getIntArray(dividerColorsId);
colors = res.getIntArray(colorsId);
@Test public void asIntArray() { IntArrayTarget target = new IntArrayTarget(); int[] expected = context.getResources().getIntArray(R.array.int_one_two_three); Unbinder unbinder = new BindArrayTest$IntArrayTarget_ViewBinding(target, context); assertThat(target.actual).isEqualTo(expected); unbinder.unbind(); assertThat(target.actual).isEqualTo(expected); }
private void setInterpolator(int position) { switch (position) { case 1: mCurrentInterpolator = new LinearInterpolator(); mSeekBarFactor.setEnabled(false); break; case 2: mCurrentInterpolator = new AccelerateDecelerateInterpolator(); mSeekBarFactor.setEnabled(false); break; case 3: mCurrentInterpolator = new DecelerateInterpolator(mFactor); mSeekBarFactor.setEnabled(true); break; case 4: mCurrentInterpolator = new FastOutSlowInInterpolator(); mSeekBarFactor.setEnabled(true); break; case 0: default: mCurrentInterpolator = new AccelerateInterpolator(mFactor); mSeekBarFactor.setEnabled(true); break; } mProgressBar.setSmoothProgressDrawableInterpolator(mCurrentInterpolator); mProgressBar.setSmoothProgressDrawableColors(getResources().getIntArray(R.array.gplus_colors)); updateValues(); }
mPocketBar.setSmoothProgressDrawableBackgroundDrawable( SmoothProgressBarUtils.generateDrawableWithColors( getResources().getIntArray(R.array.pocket_background_colors), ((SmoothProgressDrawable) mPocketBar.getIndeterminateDrawable()).getStrokeWidth()));
materialRefreshLayout.setWaveShow(true); materialRefreshLayout.setShowProgressBg(true); materialRefreshLayout.setProgressColors(getResources().getIntArray(R.array.material_colors)); materialRefreshLayout.setShowArrow(true); break;
@SuppressWarnings("deprecation") private void initLoading() { final Loading loading = (Loading) findViewById(R.id.loading_progress); loading.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Loading l = (Loading) v; if (l.isRunning()) l.stop(); else l.start(); } }); TextView tv = (TextView) findViewById(R.id.txt_loading); LoadingDrawable drawable = new LoadingCircleDrawable(); Resources resources = getResources(); drawable.setBackgroundColor(resources.getColor(R.color.g_default_base_background)); drawable.setForegroundColor(resources.getIntArray(R.array.g_default_loading_fg)); drawable.setBackgroundLineSize(2); drawable.setForegroundLineSize(4); tv.setBackgroundDrawable(drawable); drawable.start(); } }
rainbow200 = getResources().getIntArray(R.array.rainbow_200); rainbow500 = getResources().getIntArray(R.array.rainbow_500);
private void updateValues() { CircularProgressDrawable circularProgressDrawable; CircularProgressDrawable.Builder b = new CircularProgressDrawable.Builder(this) .colors(getResources().getIntArray(R.array.gplus_colors)) .sweepSpeed(mSpeed) .rotationSpeed(mSpeed) .strokeWidth(dpToPx(mStrokeWidth)) .style(CircularProgressDrawable.STYLE_ROUNDED); if (mCurrentInterpolator != null) { b.sweepInterpolator(mCurrentInterpolator); } mCircularProgressBar.setIndeterminateDrawable(circularProgressDrawable = b.build()); // /!\ Terrible hack, do not do this at home! circularProgressDrawable.setBounds(0, 0, mCircularProgressBar.getWidth(), mCircularProgressBar.getHeight()); mCircularProgressBar.setVisibility(View.INVISIBLE); mCircularProgressBar.setVisibility(View.VISIBLE); }