List of usage examples for android.content.res Resources getInteger
public int getInteger(@IntegerRes int id) throws NotFoundException
From source file:com.viewpagerindicator.EgouCirclePageIndicator.java
public EgouCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/* www . j a v a 2 s . co m*/ // Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); final float defaultIndicatorPadding = res.getDimension(R.dimen.default_indicator_padding); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); mCirclePadding = a.getDimension(R.styleable.CirclePageIndicator_circlePadding, defaultIndicatorPadding); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); }
From source file:com.vadimbasco.carousel.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs) { super(context, attrs); if (isInEditMode()) return;//ww w . j a v a2 s .c o m //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); mCentered = defaultCentered; mOrientation = defaultOrientation; mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(defaultPageColor); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(defaultStrokeColor); mPaintStroke.setStrokeWidth(defaultStrokeWidth); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(defaultFillColor); mRadius = defaultRadius; mSnap = defaultSnap; final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.chen.mail.ui.NestedFolderTeaserView.java
public NestedFolderTeaserView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final Resources resources = context.getResources(); if (sCollapsedFolderThreshold < 0) { sCollapsedFolderThreshold = resources.getInteger(R.integer.nested_folders_collapse_threshold); }/* ww w. ja v a 2s. c om*/ mFolderItemUpdateDelayMs = resources.getInteger(R.integer.folder_item_refresh_delay_ms); mTabletDevice = Utils.useTabletUI(resources); mListCollapsible = resources.getBoolean(R.bool.list_collapsible); }
From source file:com.zxl.easyapp.ui.viewpagerindicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w ww. j a va 2 s.c om //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = Color.TRANSPARENT; final int defaultFillColor = res.getColor(R.color.red_ff4848); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.gray_ddd); final float defaultStrokeWidth = res.getDimension(R.dimen.dp1); final float defaultRadius = res.getDimension(R.dimen.dp3); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:ru.surfstudio.infinitepageindicator.InfiniteCirclePageIndicator.java
public InfiniteCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from ww w . ja v a2 s .c o m*/ //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); // mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.valtech.androidtoolkit.view.indicator.RectPageIndicator.java
@SuppressWarnings("unused") public RectPageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(Color.TRANSPARENT); mPaintStroke/*from w ww . ja v a2 s . c om*/ .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(getResources().getColor(R.color.header_color)); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.android.mail.ui.NestedFolderTeaserView.java
public NestedFolderTeaserView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final Resources resources = context.getResources(); if (sCollapsedFolderThreshold < 0) { sCollapsedFolderThreshold = resources.getInteger(R.integer.nested_folders_collapse_threshold); }/*from ww w . ja v a 2s. c o m*/ mFolderItemUpdateDelayMs = resources.getInteger(R.integer.folder_item_refresh_delay_ms); mInflater = LayoutInflater.from(context); }
From source file:com.ramsofttech.adpushlibrary.fragment.GridFragment.java
/** * onActivityCreated/* www . j ava 2 s .com*/ * When the activity is created, divide the usable space into columns * and put a grid of images in that area. */ @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Activity a = getActivity(); Resources res = a.getResources(); View rootView = getView(); GridView gridview = (GridView) rootView.findViewById(R.id.grid); DisplayMetrics metrics = new DisplayMetrics(); a.getWindowManager().getDefaultDisplay().getMetrics(metrics); // From the resource files, determine how many rows and columns are to be displayed. int numRows = res.getInteger(R.integer.grid_num_rows); int numCols = res.getInteger(R.integer.grid_num_cols); AppDataHolder dataHolder = ((AppDataHolder) getActivity().getApplicationContext()); if (dataHolder.getNumCols() != 0) numCols = dataHolder.getNumCols(); if (dataHolder.getNumRows() != 0) numRows = dataHolder.getNumRows(); // Figure out how much space is available for the N rows and M columns to be displayed. // We start with the root view for the fragment and adjust for the title, padding, etc. int titleHeight = res.getDimensionPixelSize(R.dimen.topic_title_height); int titlePadding = res.getDimensionPixelSize(R.dimen.topic_title_padding); int buttonAreaHeight = res.getDimensionPixelSize(R.dimen.button_area_height); int titleBarHeight = res.getDimensionPixelSize(R.dimen.title_bar_height); int gridHspacing = res.getDimensionPixelSize(R.dimen.image_grid_hspacing); int gridVSpacing = res.getDimensionPixelSize(R.dimen.image_grid_vspacing); int otherGridH = res.getDimensionPixelSize(R.dimen.other_grid_h); int otherGridW = res.getDimensionPixelSize(R.dimen.other_grid_w); int heightUsed = 2 * titleBarHeight + (numRows + 2) * gridVSpacing + (titleHeight + 2 * titlePadding) + otherGridH + buttonAreaHeight; int widthUsed = 40; // just a guess for now. int availableHeight = metrics.heightPixels - heightUsed; int availableWidth = metrics.widthPixels - widthUsed; int cellWidth = availableWidth / numCols; if (availableWidth > 1000) { cellWidth -= 20; } float cellHeight = numRows * (availableHeight / numRows) / 6; if (dataHolder.getCellHeight() != 0) { cellHeight = numRows * (availableHeight / numRows) / dataHolder.getCellHeight(); } // Put this back in to check the calculations for cell height and width. Log.d("Debug", "--- metrics h: " + metrics.heightPixels + " w: " + metrics.widthPixels); Log.d("Debug", " available h: " + availableHeight + " w: " + availableWidth); Log.d("Debug", " already used h: " + heightUsed + " w: " + widthUsed); Log.d("Debug", " cell h: " + cellHeight + " w: " + cellWidth); Log.d("Debug", "--- num rows: " + numRows + " cols: " + numCols); Log.d("Debug", "--- firstImage: " + mFirstImage + " image count: " + mImageCount); if (gridview == null) Log.d("DEBUG", "Unable to locate the gridview."); else { Log.i("Adapter", "--inside call appadapter"); // AppDataHolder dataHolder = ((AppDataHolder) getActivity().getApplication()); gridview.setNumColumns(numCols); // Connect the gridview with an adapter that fills up the space. // gridview.setAdapter (new GridImageAdapter (a, mTopicList, mFirstImage, mImageCount, cellWidth, cellHeight)); gridview.setAdapter(new AppAdapter(a, dataHolder.getApplicationList(), mFirstImage, mImageCount, cellWidth, cellHeight)); // Arrange it so a long click on an item in the grid shows the topic associated with the image. gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub //showTopic(mFirstImage + position); Toast.makeText(getActivity(), "" + (mFirstImage + position), Toast.LENGTH_LONG).show(); clickAsyncTask clickAsynctask = new clickAsyncTask(getActivity()); clickAsynctask.execute("" + (mFirstImage + position)); AppDataHolder dataHolder = ((AppDataHolder) getActivity().getApplication()); List<ApplicationData> applicationList = dataHolder.getApplicationList(); ApplicationData application = applicationList.get(mFirstImage + position); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + application.getPackageName()))); } }); } }
From source file:j2w.team.common.widget.infiniteviewpager.InfiniteCirclePageIndicator.java
public InfiniteCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w. j av a 2s . c om*/ // Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); // mTouchSlop = // ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.dev.nutclass.view.pager.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from ww w .j ava 2 s .co m*/ // Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.circle_page_indicator_page_color); final int defaultFillColor = res.getColor(R.color.circle_page_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.circle_page_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.circle_indicator_snap); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); interval = mRadius * 4; }