List of usage examples for android.content.res Resources getDimension
public float getDimension(@DimenRes int id) throws NotFoundException
From source file:de.qspool.clementineremote.backend.ClementinePlayerConnection.java
public void run() { // Start the thread mNotificationManager = (NotificationManager) App.mApp.getSystemService(Context.NOTIFICATION_SERVICE); Looper.prepare();/* www. ja v a 2 s . com*/ mHandler = new ClementineConnectionHandler(this); mPebble = new Pebble(); // Get a Wakelock Object PowerManager pm = (PowerManager) App.mApp.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clementine"); Resources res = App.mApp.getResources(); mNotificationHeight = (int) res.getDimension(android.R.dimen.notification_large_icon_height); mNotificationWidth = (int) res.getDimension(android.R.dimen.notification_large_icon_width); mAudioManager = (AudioManager) App.mApp.getSystemService(Context.AUDIO_SERVICE); mClementineMediaButtonEventReceiver = new ComponentName(App.mApp.getPackageName(), ClementineMediaButtonEventReceiver.class.getName()); mMediaButtonBroadcastReceiver = new ClementineMediaButtonEventReceiver(); fireOnConnectionReady(); Looper.loop(); }
From source file:com.jakewharton.android.viewpagerindicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); 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); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke//from www. ja va 2s . co m .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); 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); a.recycle(); }
From source file:com.sonymobile.androidapp.gridcomputing.fragments.ReportChartFragment.java
private void setLegends() { if (mChart.getData().getDataSets().size() > 1) { final Resources resources = ApplicationData.getAppContext().getResources(); final float density = getResources().getDisplayMetrics().density; final float legendWidth = resources.getDimension(R.dimen.chart_legend_width) / density; final float legendHeight = resources.getDimension(R.dimen.chart_legend_height) / density; final float legendMargin = resources.getDimension(R.dimen.chart_legend_margin) / density; final float legendCorner = resources.getDimension(R.dimen.chart_legend_corner) / density; for (ILineDataSet lineDataSet : mChart.getData().getDataSets()) { final CheckBox checkBox = new CheckBox(mLegendLayout.getContext()); checkBox.setChecked(true);/*from w ww .j a v a 2 s .c o m*/ checkBox.setText(lineDataSet.getLabel()); checkBox.setTag(lineDataSet); checkBox.setOnCheckedChangeListener(mLegendCheckedChangeListener); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setColor(lineDataSet.getColor()); drawable.setSize((int) legendWidth, (int) legendHeight); drawable.setCornerRadius(legendCorner); checkBox.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null); checkBox.setCompoundDrawablePadding((int) legendMargin); final GridLayout.Spec titleTxtSpecColumn = GridLayout.spec(GridLayout.UNDEFINED); final GridLayout.Spec titleRowSpec = GridLayout.spec(GridLayout.UNDEFINED); final GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(titleRowSpec, titleTxtSpecColumn); layoutParams.setMargins((int) legendWidth, 0, (int) legendWidth, 0); mLegendLayout.addView(checkBox, layoutParams); } } }
From source file:com.sonymobile.androidapp.gridcomputing.fragments.ReportChartFragment.java
private void setupChart() { final Resources resources = ApplicationData.getAppContext().getResources(); final float density = getResources().getDisplayMetrics().density; final float smallTextSize = resources.getDimension(R.dimen.text_smallest) / density; final int yAxisTextColor = ContextCompat.getColor(ApplicationData.getAppContext(), R.color.colorPrimary); final int xAxisTextColor = Color.BLACK; mChart.setDrawGridBackground(true);/*w ww . j a va2 s . c o m*/ mChart.getDescription().setEnabled(false); mChart.setDrawBorders(false); mChart.setExtraOffsets(0, smallTextSize, 0, 0); mChart.getAxisRight().setEnabled(false); mChart.getAxisLeft().setDrawAxisLine(false); mChart.getAxisLeft().setDrawGridLines(false); mChart.getAxisLeft().setGranularity(1f); mChart.getAxisLeft().setAxisMinimum(0f); mChart.getAxisLeft().setTextColor(yAxisTextColor); mChart.getAxisLeft().setTextSize(smallTextSize); mChart.getXAxis().setDrawAxisLine(false); mChart.getXAxis().setDrawGridLines(false); mChart.getXAxis().setGranularity(1f); mChart.getXAxis().setTextColor(xAxisTextColor); mChart.getXAxis().setTextSize(smallTextSize); mChart.getAxisLeft().setValueFormatter(new AxisHoursValueFormatter()); if (mDataType == DataType.WEEK) { mChart.getXAxis().setValueFormatter(new AxisWeekValueFormatter()); } else if (mDataType == DataType.MONTH) { mChart.getXAxis().setValueFormatter(new AxisWeekValueFormatter()); } else if (mDataType == DataType.ALL_TIME) { mChart.getXAxis().setValueFormatter(new AxisYearValueFormatter()); } // enable touch gestures mChart.setTouchEnabled(true); // enable scaling and dragging mChart.setDragEnabled(true); mChart.setScaleEnabled(true); mChart.getLegend().setEnabled(false); // if disabled, scaling can be done on x- and y-axis separately mChart.setPinchZoom(true); }
From source file:com.zxl.easyapp.ui.viewpagerindicator.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w ww. j a va 2s . c om final Resources res = getResources(); //Load defaults from resources final int defaultSelectedColor = Color.WHITE; final int defaultUnselectedColor = res.getColor(R.color.gray_bbb); final float defaultLineWidth = res.getDimension(R.dimen.dp12); final float defaultGapWidth = res.getDimension(R.dimen.dp4); final float defaultStrokeWidth = res.getDimension(R.dimen.dp1); final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered); mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth); mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, 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.androidmapsextensions.DefaultClusterOptionsProvider.java
public DefaultClusterOptionsProvider(Resources resources) { colors = new int[] { resources.getColor(R.color.ame_default_cluster_circle_color_small), resources.getColor(R.color.ame_default_cluster_circle_color_medium), resources.getColor(R.color.ame_default_cluster_circle_color_large), resources.getColor(R.color.ame_default_cluster_circle_color_extra_large), }; circlePaint = createCirclePaint(resources); circleShadowPaint = createCircleShadowPaint(resources); textPaint = createTextPaint(resources); textPadding = resources.getDimension(R.dimen.ame_default_cluster_text_padding); }
From source file:joshuatee.wx.NEXRADAttributesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); preferences = PreferenceManager.getDefaultSharedPreferences(this); theme_blue_current = preferences.getString("THEME_BLUE", ""); if (theme_blue_current.contains("white")) { highlight_color = Color.BLUE; background_color = Color.BLACK; highlight_color_str = "blue"; background_color_str = "black"; }/*w w w. ja v a 2 s . c o m*/ setTheme(Utility.Theme(theme_blue_current)); setContentView(R.layout.activity_nexradattributes); Resources res = getResources(); comma = Pattern.compile(","); padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) res.getDimension(R.dimen.padding), getResources().getDisplayMetrics()); padding_vertical = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) res.getDimension(R.dimen.padding_vertical), getResources().getDisplayMetrics()); text_size = res.getDimension(R.dimen.listitem_text); alert_cod_radar_current = preferences.getString("ALERT_COD_RADAR", ""); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, state_array)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:samson.AndroidNotifications.java
/** * Returns a bitmap for the large icon, or null if none could be decoded from the resources. *///w w w. j av a 2s . c o m protected Bitmap getLargeIcon(Builder builder) { Resources resources = applicationContext.getResources(); int resource = builder._icon; // pull the decoded resource from the resources Bitmap icon = BitmapFactory.decodeResource(resources, resource); if (icon == null) { return null; } // if possible, rescale the icon to the appropriate size if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width); int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height); icon = Bitmap.createScaledBitmap(icon, width, height, false); } return icon; }
From source file:com.ruesga.rview.wizard.WizardActivity.java
@SuppressWarnings("unchecked") @Override/*from w w w.ja va 2s . c o m*/ protected final void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); mFragmentManager = getSupportFragmentManager(); // Load the wizard pages setupPages(); mArePagesConfigured = true; if (mPages.isEmpty()) { Log.w(getTag(), "Wizard has no pages!!"); finish(); return; } if (savedInstanceState != null) { restoreInstance(savedInstanceState); } if (mCurrentPage < 0 || mCurrentPage >= mPages.size()) { performNavigateToPage(mCurrentPage); return; } // Configure the view setupStatusBar(); final Resources res = getResources(); mMinHeaderHeight = (int) res.getDimension(R.dimen.wizard_min_actionbar_size); mMaxHeaderHeight = (int) res.getDimension(R.dimen.wizard_max_actionbar_size); // Bind the views boolean isTablet = res.getBoolean(R.bool.config_isTablet); mIsExtendedHeaderLayoutSupported = !isTablet && res.getConfiguration().orientation == ORIENTATION_PORTRAIT; mBinding = DataBindingUtil.setContentView(this, R.layout.activity_wizard); mBinding.setHandlers(new WorkFlowHandlers(this)); if (mIsExtendedHeaderLayoutSupported) { mBinding.pageHeader.getLayoutParams().height = mIsExtendedHeaderLayoutSupported && mPages.get(mCurrentPage).hasExtendedHeader() ? mMaxHeaderHeight : mMinHeaderHeight; } // Prepared the back and forward loaders mLoaders = new Pair[mPages.size()]; RxLoaderManager loaderManager = RxLoaderManagerCompat.get(this); int i = 0; for (WizardPageFragment page : mPages) { Callable<Boolean> back = page.doBackAction(); Callable<Boolean> forward = page.doForwardAction(); RxLoader<Boolean> backLoader = null; if (back != null) { backLoader = loaderManager.create("lb" + i, actionObserver(back), mBackObserver); } RxLoader<Boolean> forwardLoader = null; if (forward != null) { forwardLoader = loaderManager.create("lf" + i, actionObserver(forward), mForwardObserver); } mLoaders[i] = new Pair<>(backLoader, forwardLoader); i++; } // Navigate and draw page information if (mCurrentChooserFragmentTag != null) { WizardChooserFragment chooser = (WizardChooserFragment) mFragmentManager .findFragmentByTag(mCurrentChooserFragmentTag); performOpenChooserPage(chooser); bindChooserWorkflow(chooser); } else { performNavigateToPage(mCurrentPage); } mIsActivityConfigured = true; }
From source file:com.threehalf.tucao.view.pageindicator.TabPageIndicator.java
public TabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); final Resources res = getResources(); // final int textColor = // res.getres(R.color.default_tab_indicator_text_color); final int tabSelectedColor = res.getColor(R.color.default_tab_indicator_selected_color); final int tabUnSelectedColor = res.getColor(R.color.default_tab_indicator_unselected_color); final float textSize = res.getDimension(R.dimen.default_tab_indicator_textsize); final float paddingLeft = res.getDimension(R.dimen.default_tab_indicator_paddingleft); final float paddingRight = res.getDimension(R.dimen.default_tab_indicator_paddingright); final float paddingTop = res.getDimension(R.dimen.default_tab_indicator_paddingtop); final float paddingBottom = res.getDimension(R.dimen.default_tab_indicator_paddingbottom); final float tabSelectedHeight = res.getDimension(R.dimen.default_tab_indicator_selected_height); final float tabUnSelectedHeight = res.getDimension(R.dimen.default_tab_indicator_unselected_height); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabPageIndicator); mTextColor = a.getResourceId(R.styleable.TabPageIndicator_textColor, R.drawable.selector_tabtextcolor); mTabSelectedColor = a.getColor(R.styleable.TabPageIndicator_selectedColor, tabSelectedColor); mTabUnSelectedColor = a.getColor(R.styleable.TabPageIndicator_unselectedColor, tabUnSelectedColor); mTextSize = a.getDimension(R.styleable.TabPageIndicator_textSize, textSize); mPaddingLeft = a.getDimension(R.styleable.TabPageIndicator_paddingLeft, paddingLeft); mPaddingRight = a.getDimension(R.styleable.TabPageIndicator_paddingRight, paddingRight); mPaddingTop = a.getDimension(R.styleable.TabPageIndicator_paddingTop, paddingTop); mPaddingBottom = a.getDimension(R.styleable.TabPageIndicator_paddingBottom, paddingBottom); mTabSelectedHeight = a.getDimension(R.styleable.TabPageIndicator_selectedHeight, tabSelectedHeight); mTabUnSelectedHeight = a.getDimension(R.styleable.TabPageIndicator_unSelectedHeight, tabUnSelectedHeight); setHorizontalScrollBarEnabled(false); mTabAndIndicator = new LinearLayout(context); mTabAndIndicator.setOrientation(LinearLayout.VERTICAL); mTabLayout = new LinearLayout(context); mTabAndIndicator.addView(mTabLayout, new LinearLayout.LayoutParams(WRAP_CONTENT, 0, 1)); mSlideLineIndicator = new SlideLineIndicator(context); mTabAndIndicator.addView(mSlideLineIndicator, new LinearLayout.LayoutParams(MATCH_PARENT, (int) mTabSelectedHeight, 0)); addView(mTabAndIndicator, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT)); a.recycle();/* w ww . ja va2 s . c o m*/ }