List of usage examples for android.content.res Resources getInteger
public int getInteger(@IntegerRes int id) throws NotFoundException
From source file:br.com.brolam.cloudvision.ui.helpers.ImagesHelper.java
public ImagesHelper(Activity activity, CloudVisionProvider cloudVisionProvider) { this.activity = activity; Resources resources = activity.getResources(); this.noteVisionBackgroundWidth = resources.getInteger(R.integer.note_vision_background_width); this.noteVisionBackgroundHeight = resources.getInteger(R.integer.note_vision_background_height); this.cloudVisionProvider = cloudVisionProvider; this.firebaseStorage = FirebaseStorage.getInstance(); if (notesVisionUploadsReference == null) { notesVisionUploadsReference = new HashMap<>(); } else {//from ww w .jav a2 s. c o m restoreStorageReference(); } }
From source file:pl.itiner.nutiteq.NutiteqMap.java
private PoznanAPIMap getMap() { Resources res = getResources(); final String baseUrl = res.getString(R.string.base_url); final int tileSize = res.getInteger(R.integer.tile_size); final double[] resolutions = createResolutionsArray(res.getStringArray(R.array.resolutions)); final int minZoom = res.getInteger(R.integer.min_zoom); final int maxZoom = minZoom + resolutions.length - 1; final String layerName = res.getString(R.string.base_layer_name); final String gravesLayer = res.getString(R.string.graves_layer_name); final String imageType = res.getString(R.string.png_type); final String getString = res.getString(R.string.map_get_string); final String copyrightTxt = res.getString(R.string.map_copyright_txt); final int minEpsgX = res.getInteger(R.integer.epsg_min_x); final int minEpsgY = res.getInteger(R.integer.epsg_min_y); PoznanAPIMap mainMap = new PoznanAPIMap(baseUrl, tileSize, minZoom, maxZoom, layerName, imageType, "", getString, copyrightTxt, resolutions, minEpsgX, minEpsgY); mainMap.setMissingTileImage(Image.createImage(createMissingTileBitmap(mainMap.getTileSize(), getString(R.string.map_no_connection), getResources()))); mainMap.addTileOverlay(new MapTileOverlay() { @Override/*w w w. j a v a 2 s . c om*/ public String getOverlayTileUrl(MapTile tile) { String url = tile.getIDString(); url = url.replaceFirst(Tools.urlEncode(layerName), Tools.urlEncode(gravesLayer)); return url; } }); return mainMap; }
From source file:com.android.messaging.ui.conversationlist.ConversationListSwipeHelper.java
public ConversationListSwipeHelper(final RecyclerView recyclerView) { mRecyclerView = recyclerView;/*w w w.j a v a 2 s . c o m*/ final Context context = mRecyclerView.getContext(); final Resources res = context.getResources(); mDefaultRestoreAnimationDuration = res.getInteger(R.integer.swipe_duration_ms); mDefaultDismissAnimationDuration = res.getInteger(R.integer.swipe_duration_ms); mMaxTranslationAnimationDuration = res.getInteger(R.integer.swipe_duration_ms); final ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mTouchSlop = viewConfiguration.getScaledPagingTouchSlop(); mMaximumFlingVelocity = Math.min(viewConfiguration.getScaledMaximumFlingVelocity(), res.getInteger(R.integer.swipe_max_fling_velocity_px_per_s)); mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); }
From source file:com.murrayc.galaxyzoo.app.ListFragment.java
private void update() { final Activity activity = getActivity(); if (activity == null) { return;//from w w w.j a v a2 s. c om } mAdapter = new ListCursorAdapter(activity, /* No cursor yet */ new ListCursorAdapter.OnItemClickedListener() { @Override public void onItemClicked(final int position, final View sharedElementView) { onGridItemClicked(position, sharedElementView); } }); //TODO: Can we specify the layout manager in the layout XML? int gridSpan = 3; //A suitable default for the error case. final Resources resources = getResources(); if (resources != null) { //This is different depending on the screen width: final int resourcesGridSpan = resources.getInteger(R.integer.list_grid_span); //A sanity check: if (resourcesGridSpan > 0) { gridSpan = resourcesGridSpan; } } final RecyclerView gridView = getGridView(); if (gridView == null) { Log.error("update(): gridView is null."); return; } gridView.setLayoutManager(new GridLayoutManager(activity, gridSpan)); //This is apparently already the default: //gridView.setItemAnimator(new DefaultItemAnimator()); //For performance, because all our items are the same size: gridView.setHasFixedSize(true); gridView.setAdapter(mAdapter); /* * Initializes the CursorLoader. The URL_LOADER value is eventually passed * to onCreateLoader(). */ getLoaderManager().initLoader(URL_LOADER, null, this); }
From source file:com.facebook.samples.musicdashboard.MusicGalleryFragment.java
int getColumnWidth() { if (null == gridView) return 0; Resources r = getActivity().getResources(); int horizontalSpacing = r.getDimensionPixelSize(R.dimen.gridview_horizontal_spacing); int numColumns = r.getInteger(R.integer.gridview_num_columns); int spacing = horizontalSpacing * (numColumns - 1); int padding = gridView.getListPaddingLeft() + gridView.getListPaddingRight(); return (gridView.getWidth() - padding - spacing) / numColumns; }
From source file:com.ovrhere.android.careerstack.ui.fragments.MainFragment.java
/** Not intended to be called in {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} * @return <code>true</code> if successfully initialized seekbar, * <code>false</code> if something went wrong. * @param view The view to initialize with. *//*www.j a v a 2 s . c om*/ private boolean initSeekBar(View view) { sb_distanceSeek = (SeekBar) view.findViewById(R.id.careerstack_distanceSeekbar_seekBar); tv_distance = (TextView) view.findViewById(R.id.careerstack_distanceSeekbar_text_value); if (sb_distanceSeek != null && tv_distance != null) { Resources r = getResources(); distanceSeekBarWrapper = new SeekBarWrapper(sb_distanceSeek, r.getInteger(R.integer.careerstack_seekBar_min), r.getInteger(R.integer.careerstack_seekBar_max), r.getInteger(R.integer.careerstack_seekBar_step)); distanceSeekBarWrapper.setOnValueChangedListener(this); distanceSeekBarWrapper.setProgress(currentDistanceValue); return true; } else { return false; //end early } }
From source file:co.paulburke.android.textviewpager.TextViewPagerIndicator.java
public TextViewPagerIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from ww w. jav a 2 s. com*/ final Resources res = getResources(); // Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.scroll_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.scroll_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.scroll_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.scroll_indicator_selected_color); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewPagerIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.TextViewPagerIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.TextViewPagerIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.TextViewPagerIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.TextViewPagerIndicator_fadeLength, defaultFadeLength)); Drawable background = a.getDrawable(R.styleable.TextViewPagerIndicator_android_background); if (background != null) setBackgroundDrawable(background); a.recycle(); }
From source file:com.aksalj.viewpagerslideshow.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w ww. j av a 2 s .com*/ final Resources res = getResources(); //Load defaults from resources final int defaultLineStyle = res.getInteger(R.integer.default_line_style); final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color); final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color); final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width); final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width); final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width); final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0); mBoxStyle = a.getInt(R.styleable.LinePageIndicator_lineStyle, defaultLineStyle) == 1; mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, mBoxStyle ? false : defaultCentered); mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth); mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, mBoxStyle ? 0.0f : defaultGapWidth); setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintUnselected .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor)); mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor)); Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.lovebridge.library.view.viewpagerindicator.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/* w w w .j a v a2 s . co m*/ final Resources res = getResources(); // Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.shafiq.mytwittle.widget.viewpagerindicator.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/* w ww . j av a 2 s.co m*/ final Resources res = getResources(); // Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }