List of usage examples for android.graphics.drawable Drawable getIntrinsicHeight
public int getIntrinsicHeight()
From source file:com.cyou.cma.clockscreen.widget.LinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;//from w w w . j a va2 s .c om } final int count = mViewPager.getAdapter().getCount(); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mDrawableSelected.getIntrinsicWidth() + mGapWidth; final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth; final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += (getWidth() / 2.0f - indicatorWidth / 2.0f); } // Draw stroked circles for (int i = 0; i < count; i++) { Drawable drawable = null; if (i == mCurrentPage) { drawable = getResources().getDrawable(R.drawable.indicator_selected); } else { drawable = getResources().getDrawable(R.drawable.indicator_normal); } final int right = (int) horizontalOffset + drawable.getIntrinsicWidth(); drawable.setBounds((int) horizontalOffset, 0, right, drawable.getIntrinsicHeight()); horizontalOffset += drawable.getIntrinsicWidth() + mGapWidth; ; drawable.draw(canvas); } }
From source file:com.marshalchen.common.uimodule.modifysys.PagerTitleStrip.java
SpannableString changeSpanString(String temp, int position, int color) { try {//from w w w . ja v a 2 s . com temp = temp.replaceAll("-", " - "); SpannableString ss = new SpannableString(temp); Matrix matrix = new Matrix(); matrix.postRotate(180); Bitmap bitmaporg = BitmapFactory.decodeResource(getResources(), R.drawable.ico_arrow2x); if (color == 2) { bitmaporg = BitmapFactory.decodeResource(getResources(), R.drawable.ico_arrow_grey2x); } Bitmap resizedBitmap = Bitmap.createBitmap(bitmaporg, 0, 0, bitmaporg.getWidth(), bitmaporg.getHeight(), matrix, true); BitmapDrawable bmd = new BitmapDrawable(getResources(), resizedBitmap); BitmapDrawable bm = new BitmapDrawable(getResources(), bitmaporg); Drawable drawable = position == 0 ? bm : bmd; drawable.setBounds(0, 0, drawable.getIntrinsicWidth() * 12 / 10, drawable.getIntrinsicHeight() * 12 / 10); ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE); ss.setSpan(imageSpan, temp.indexOf("-"), temp.indexOf("-") + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE); return ss; } catch (Exception e) { e.printStackTrace(); Logs.e(e, ""); return null; } }
From source file:net.alexjf.tmm.fragments.ImmedTransactionEditorFragment.java
private boolean validateInputFields() { boolean error = false; Resources res = getResources(); Drawable errorDrawable = res.getDrawable(R.drawable.indicator_input_error); errorDrawable.setBounds(0, 0, errorDrawable.getIntrinsicWidth(), errorDrawable.getIntrinsicHeight()); String value = valueText.getText().toString(); if (TextUtils.isEmpty(value)) { valueText.setError(res.getString(R.string.error_trans_value_unspecified), errorDrawable); error = true;/*from w w w . ja va 2 s. c om*/ } else { try { new ExpressionBuilder(value).build(); } catch (Exception e) { valueText.setError(res.getString(R.string.error_trans_value_invalid), errorDrawable); error = true; } } if (selectedCategory == null) { categoryButton.setError(true); error = true; } if (transferCheck.isChecked()) { if (selectedTransferMoneyNode == null) { transferMoneyNodeButton.setError(true); error = true; } else { CurrencyUnit thisTransactionCurrency = currentMoneyNode.getCurrency(); CurrencyUnit otherTransactionCurrency = selectedTransferMoneyNode.getCurrency(); if (!thisTransactionCurrency.equals(otherTransactionCurrency)) { String conversionAmount = transferConversionAmountText.getText().toString(); if (TextUtils.isEmpty(conversionAmount)) { transferConversionAmountText.setError( res.getString(R.string.error_trans_other_currency_unspecified), errorDrawable); error = true; } else { try { new ExpressionBuilder(conversionAmount).build(); } catch (Exception e) { transferConversionAmountText.setError(res.getString(R.string.error_trans_value_invalid), errorDrawable); error = true; } } } } } return !error; }
From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java
private int getMinHeight() { int minHeight = 0; final Drawable bg = getBackground(); if (bg != null) { minHeight = bg.getIntrinsicHeight(); }/*from w ww .j a v a 2s . c o m*/ return minHeight; }
From source file:com.hirebuddy.util.CircleImageView.java
private Bitmap getBitmapFromDrawable(Drawable drawable) { if (drawable == null) { return null; }/* ww w .ja va 2s .c o m*/ if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } try { Bitmap bitmap; if (drawable instanceof ColorDrawable) { bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.appsimobile.appsii.module.weather.WeatherActivity.java
void showDrawable(Drawable drawable, boolean isImmediate) { mBackgroundImage.setLayerType(View.LAYER_TYPE_SOFTWARE, null); if (isImmediate) { int w = drawable.getIntrinsicWidth(); int viewWidth = mBackgroundImage.getWidth(); float factor = viewWidth / (float) w; int h = (int) (drawable.getIntrinsicHeight() * factor); drawable.setBounds(0, 0, w, h);// w w w. ja va2 s .co m mBackgroundImage.setImageDrawable(drawable); } else { Drawable current = mBackgroundImage.getDrawable(); if (current == null) current = new ColorDrawable(Color.TRANSPARENT); TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] { current, drawable }); transitionDrawable.setCrossFadeEnabled(true); mBackgroundImage.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(500); } }
From source file:com.shizhefei.view.largeimage.LargeImageView.java
@Override public void setImage(BitmapDecoderFactory factory, Drawable defaultDrawable) { mScale = 1.0f;/*from w ww . j av a 2 s .c o m*/ this.mFactory = factory; scrollTo(0, 0); if (defaultDrawable != null) { onLoadImageSize(defaultDrawable.getIntrinsicWidth(), defaultDrawable.getIntrinsicHeight()); } imageBlockLoader.load(factory); }
From source file:com.yk.notification.util.BitmapUtil.java
/** * DrawableBitmap/* w w w.jav a2 s. c o m*/ * * @param drawable * Drawable * @return Bitmap */ public static Bitmap getBitmapFromDrawable(Drawable drawable) { int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888 : Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, width, height); drawable.draw(canvas); return bitmap; }
From source file:com.coreform.open.android.formidablevalidation.SetErrorHandler.java
public void setError(CharSequence error, Drawable icon, boolean showError, boolean showCompoundDrawableOnRight) { if (DEBUG)//from w w w . j a va 2 s . c o m Log.d(TAG, ".setError(error, icon, showError, showCompoundDrawableOnRight)..."); if (icon != null) { if (DEBUG) Log.d(TAG, "...icon is not null..."); icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } error = TextUtils.stringOrSpannedString(error); mErrorWasChanged = true; mError = error; mErrorWasChanged = true; final Drawables dr = mDrawables; if (mView instanceof TextView && error != null) { if (true || dr != null) { if (showCompoundDrawableOnRight) { if (DEBUG) Log.d(TAG, "...showing CompoundDrawable on right)..."); //((TextView) mView).setCompoundDrawables(dr.mDrawableLeft, dr.mDrawableTop, icon, dr.mDrawableBottom); ((TextView) mView).setCompoundDrawables(null, null, icon, null); } else { //((TextView) mView).setCompoundDrawables(icon, dr.mDrawableTop, dr.mDrawableRight, dr.mDrawableBottom); ((TextView) mView).setCompoundDrawables(icon, null, null, null); } } } if (error == null) { if (mPopup != null) { if (mPopup.isShowing()) { mPopup.dismiss(); } if (mView instanceof TextView) { ((TextView) mView).setCompoundDrawables(null, null, null, null); } mPopup = null; } } else if (showError) { //LD - EditTexts use isFocused to show only the focused one, other Views may not be focusable //if (isFocused()) { showError(); //} } }
From source file:com.metinkale.prayerapp.vakit.fragments.MainFragment.java
private void export(int csvpdf, LocalDate from, LocalDate to) throws IOException { File outputDir = getActivity().getCacheDir(); if (!outputDir.exists()) outputDir.mkdirs();// w w w . jav a 2s. c o m File outputFile = new File(outputDir, mTimes.getName().replace(" ", "_") + (csvpdf == 0 ? ".csv" : ".pdf")); if (outputDir.exists()) outputFile.delete(); FileOutputStream outputStream; outputStream = new FileOutputStream(outputFile); if (csvpdf == 0) { outputStream.write("Date;Fajr;Shuruq;Dhuhr;Asr;Maghrib;Ishaa\n".getBytes()); do { outputStream.write((from.toString("yyyy-MM-dd") + ";").getBytes()); outputStream.write((mTimes.getTime(from, 0) + ";").getBytes()); outputStream.write((mTimes.getTime(from, 1) + ";").getBytes()); outputStream.write((mTimes.getTime(from, 2) + ";").getBytes()); outputStream.write((mTimes.getTime(from, 3) + ";").getBytes()); outputStream.write((mTimes.getTime(from, 4) + ";").getBytes()); outputStream.write((mTimes.getTime(from, 5) + "\n").getBytes()); } while (!(from = from.plusDays(1)).isAfter(to)); outputStream.close(); } else { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { PdfDocument document = new PdfDocument(); PdfDocument.PageInfo pageInfo = null; int pw = 595; int ph = 842; pageInfo = new PdfDocument.PageInfo.Builder(pw, ph, 1).create(); PdfDocument.Page page = document.startPage(pageInfo); Drawable launcher = Drawable.createFromStream(getActivity().getAssets().open("pdf/launcher.png"), null); Drawable qr = Drawable.createFromStream(getActivity().getAssets().open("pdf/qrcode.png"), null); Drawable badge = Drawable.createFromStream( getActivity().getAssets().open("pdf/badge_" + Prefs.getLanguage() + ".png"), null); launcher.setBounds(30, 30, 30 + 65, 30 + 65); qr.setBounds(pw - 30 - 65, 30 + 65 + 5, pw - 30, 30 + 65 + 5 + 65); int w = 100; int h = w * badge.getIntrinsicHeight() / badge.getIntrinsicWidth(); badge.setBounds(pw - 30 - w, 30 + (60 / 2 - h / 2), pw - 30, 30 + (60 / 2 - h / 2) + h); Canvas canvas = page.getCanvas(); Paint paint = new Paint(); paint.setARGB(255, 0, 0, 0); paint.setTextSize(10); paint.setTextAlign(Paint.Align.CENTER); canvas.drawText("com.metinkale.prayer", pw - 30 - w / 2, 30 + (60 / 2 - h / 2) + h + 10, paint); launcher.draw(canvas); qr.draw(canvas); badge.draw(canvas); paint.setARGB(255, 61, 184, 230); canvas.drawRect(30, 30 + 60, pw - 30, 30 + 60 + 5, paint); if (mTimes.getSource().resId != 0) { Drawable source = getResources().getDrawable(mTimes.getSource().resId); h = 65; w = h * source.getIntrinsicWidth() / source.getIntrinsicHeight(); source.setBounds(30, 30 + 65 + 5, 30 + w, 30 + 65 + 5 + h); source.draw(canvas); } paint.setARGB(255, 0, 0, 0); paint.setTextSize(40); paint.setTextAlign(Paint.Align.LEFT); canvas.drawText(getText(R.string.appName).toString(), 30 + 65 + 5, 30 + 50, paint); paint.setTextAlign(Paint.Align.CENTER); paint.setFakeBoldText(true); canvas.drawText(mTimes.getName(), pw / 2.0f, 30 + 65 + 50, paint); paint.setTextSize(12); int y = 30 + 65 + 5 + 65 + 30; int p = 30; int cw = (pw - p - p) / 7; canvas.drawText(getString(R.string.date), 30 + (0.5f * cw), y, paint); canvas.drawText(Vakit.IMSAK.getString(), 30 + (1.5f * cw), y, paint); canvas.drawText(Vakit.GUNES.getString(), 30 + (2.5f * cw), y, paint); canvas.drawText(Vakit.OGLE.getString(), 30 + (3.5f * cw), y, paint); canvas.drawText(Vakit.IKINDI.getString(), 30 + (4.5f * cw), y, paint); canvas.drawText(Vakit.AKSAM.getString(), 30 + (5.5f * cw), y, paint); canvas.drawText(Vakit.YATSI.getString(), 30 + (6.5f * cw), y, paint); paint.setFakeBoldText(false); do { y += 20; canvas.drawText((from.toString("dd.MM.yyyy")), 30 + (0.5f * cw), y, paint); canvas.drawText((mTimes.getTime(from, 0)), 30 + (1.5f * cw), y, paint); canvas.drawText((mTimes.getTime(from, 1)), 30 + (2.5f * cw), y, paint); canvas.drawText((mTimes.getTime(from, 2)), 30 + (3.5f * cw), y, paint); canvas.drawText((mTimes.getTime(from, 3)), 30 + (4.5f * cw), y, paint); canvas.drawText((mTimes.getTime(from, 4)), 30 + (5.5f * cw), y, paint); canvas.drawText((mTimes.getTime(from, 5)), 30 + (6.5f * cw), y, paint); } while (!(from = from.plusDays(1)).isAfter(to)); document.finishPage(page); document.writeTo(outputStream); // close the document document.close(); } else { Toast.makeText(getActivity(), R.string.versionNotSupported, Toast.LENGTH_LONG).show(); } } Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType(csvpdf == 0 ? "text/csv" : "application/pdf"); Uri uri = FileProvider.getUriForFile(getActivity(), "com.metinkale.prayer.fileprovider", outputFile); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.export))); }