private static int getAnalyticsSamplePercentage(Context context) { if (sAnalyticsSamplePercentage == -1) { sAnalyticsSamplePercentage = context.getResources().getInteger(R.integer.ga_sampleFrequency); } return sAnalyticsSamplePercentage; }
private void initValues(Context context, boolean editMode) { mStrokeWidth = context.getResources().getDimension(R.dimen.cpb_default_stroke_width); mSweepSpeed = 1f; mRotationSpeed = 1f; if (editMode) { mColors = new int[]{Color.BLUE}; mMinSweepAngle = 20; mMaxSweepAngle = 300; } else { mColors = new int[]{context.getResources().getColor(R.color.cpb_default_color)}; mMinSweepAngle = context.getResources().getInteger(R.integer.cpb_default_min_sweep_angle); mMaxSweepAngle = context.getResources().getInteger(R.integer.cpb_default_max_sweep_angle); } mStyle = Style.ROUNDED; }
public TitleChanger(TextView title) { this.title = title; Resources res = title.getResources(); animDelay = DEFAULT_ANIMATION_DELAY; animDuration = res.getInteger(android.R.integer.config_shortAnimTime) / 2; translate = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_Y_TRANSLATION_DP, res.getDisplayMetrics() ); }
private void animOut(final View v){ Animation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
private static @Nullable Unbinder parseBindInt(Object target, Field field, View source) { BindInt bindInt = field.getAnnotation(BindInt.class); if (bindInt == null) { return null; } validateMember(field); int id = bindInt.value(); Resources resources = source.getContext().getResources(); Class<?> fieldType = field.getType(); Object value; if (fieldType == int.class) { value = resources.getInteger(id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
private void animIn(final View v){ Animation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { v.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); v.startAnimation(anim); }
private void initialiseInnerViews() { mFoldableIcon = mFoldableLayout.findViewById(R.id.foldableIcon); mFoldableTextView = mFoldableLayout.findViewById(R.id.foldableText); mFoldableTextView.setText(mFoldedLabel); // retrieve and cache the system's short animation time mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); LinearLayout foldableControl = mFoldableLayout .findViewById(R.id.foldableControl); foldableControl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mIsFolded = !mIsFolded; updateFoldedState(mIsFolded, true); } }); }
public NavigationManager(NavigationDrawerDrawable navigationIcon, Toolbar toolbar){ mToolbar = toolbar; mNavigationIcon = navigationIcon; mToolbar.setNavigationIcon(mNavigationVisible ? mNavigationIcon : null); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onNavigationClick(); } }); mAnimationDuration = toolbar.getResources().getInteger(android.R.integer.config_shortAnimTime); }
protected void init(Context context, AttributeSet attrs, int defStyle) { ViewConfiguration configuration = ViewConfiguration.get(context); mMinFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = configuration.getScaledMaximumFlingVelocity(); mDefaultAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); setScaleType(ScaleType.MATRIX); }
public int getFillPercentage() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_fillPercentage, context().getResources().getInteger(R.integer.fillPercentage)); } @Override public ClippingTransform getClippingTransform() {
@Override public int getFillDuration() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_fillDuration, context().getResources().getInteger(R.integer.fillDuration)); }
@Override public int getStrokeDrawingDuration() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_strokeDrawingDuration, context().getResources().getInteger(R.integer.strokeDrawingDuration)); }
public int resolveIntRes(@IntegerRes int resId) { if (resId != 0) { Integer cached = mResourceCache.get(resId); if (cached != null) { return cached; } int result = mResources.getInteger(resId); mResourceCache.put(resId, result); return result; } return 0; }
@Test public void getInt() throws Exception { assertThat(resources.getInteger(R.integer.meaning_of_life)).isEqualTo(42); assertThat(resources.getInteger(R.integer.test_integer1)).isEqualTo(2000); assertThat(resources.getInteger(R.integer.test_integer2)).isEqualTo(9); assertThat(resources.getInteger(R.integer.test_large_hex)).isEqualTo(-65536); assertThat(resources.getInteger(R.integer.test_value_with_zero)).isEqualTo(7210); assertThat(resources.getInteger(R.integer.meaning_of_life_as_item)).isEqualTo(42); }
private void initCountryText() { countryAnimDuration = getResources().getInteger(R.integer.labels_animation_duration); countryOffset1 = getResources().getDimensionPixelSize(R.dimen.left_offset); countryOffset2 = getResources().getDimensionPixelSize(R.dimen.card_width); country1TextView = (TextView) findViewById(R.id.tv_country_1); country2TextView = (TextView) findViewById(R.id.tv_country_2); country1TextView.setX(countryOffset1); country2TextView.setX(countryOffset2); country1TextView.setText(countries[0]); country2TextView.setAlpha(0f); country1TextView.setTypeface(Typeface.createFromAsset(getAssets(), "open-sans-extrabold.ttf")); country2TextView.setTypeface(Typeface.createFromAsset(getAssets(), "open-sans-extrabold.ttf")); }
public static StateListDrawable getCheckableIconStateList(Context ctx, Drawable icon, Drawable checkedIcon, boolean animate) { StateListDrawable iconStateListDrawable = new StateListDrawable(); iconStateListDrawable.addState(new int[]{android.R.attr.state_checked}, checkedIcon); iconStateListDrawable.addState(new int[]{-android.R.attr.state_checked}, icon); if (animate) { int duration = ctx.getResources().getInteger(android.R.integer.config_shortAnimTime); iconStateListDrawable.setEnterFadeDuration(duration); iconStateListDrawable.setExitFadeDuration(duration); } return iconStateListDrawable; } }
@Test public void asInt() { Target target = new Target(); int expected = context.getResources().getInteger(R.integer.twelve); Unbinder unbinder = new BindIntTest$Target_ViewBinding(target, context); assertThat(target.actual).isEqualTo(expected); unbinder.unbind(); assertThat(target.actual).isEqualTo(expected); } }
@Test public void getInt_withReference() throws Exception { assertThat(resources.getInteger(R.integer.reference_to_meaning_of_life)).isEqualTo(42); }
public DayView(Context context, CalendarDay day) { super(context); fadeTime = getResources().getInteger(android.R.integer.config_shortAnimTime); setSelectionColor(this.selectionColor); setGravity(Gravity.CENTER); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setTextAlignment(TEXT_ALIGNMENT_CENTER); } setDay(day); }
private void bindResources() { drawer = findViewById(R.id.drawer); toolbar = findViewById(R.id.toolbar); grid = findViewById(R.id.grid); fab = findViewById(R.id.fab); fab.setOnClickListener(view -> { fabClick(); }); filtersList = findViewById(R.id.filters); loading = findViewById(android.R.id.empty); noConnection = findViewById(R.id.no_connection); columns = getResources().getInteger(R.integer.num_columns); }