List of usage examples for android.util FloatMath ceil
public static float ceil(float value)
From source file:com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy.java
private void invalidateAfterUpdate() { View view = mView.get();//from w ww. ja v a2 s .c om if (view == null) { return; } View parent = (View) view.getParent(); if (parent == null) { return; } view.setAnimation(this); final RectF after = mAfter; computeRect(after, view); after.union(mBefore); parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom)); }
From source file:com.keithandthegirl.services.download.DownloadService.java
private void savePodcast(Long id, String title, String urlPath, File output) { Log.v(TAG, "savePodcast : enter"); sendNotification("Downloading Episode: " + title); URL url;/* ww w . j a v a2 s.c om*/ URLConnection con; InputStream is; FileOutputStream fos; byte[] buffer = new byte[4096]; try { url = new URL(urlPath); con = url.openConnection(); is = con.getInputStream(); fos = new FileOutputStream(output); boolean notified = false; int length = con.getContentLength(); int total = 0, read = -1; while ((read = is.read(buffer)) != -1) { fos.write(buffer, 0, read); total += read; int percent = (int) FloatMath.ceil(((100 * (float) total) / (float) length)); //Log.v( TAG, "savePodcast : download percent=" + percent + "%" ); if (percent % 5 == 0 && !notified) { progressUpdate(percent); notified = true; } else { notified = false; } } is.close(); fos.close(); result = FragmentActivity.RESULT_OK; ContentValues values = new ContentValues(); values.put(EpisodeConstants.FIELD_FILE, output.getAbsolutePath()); getContentResolver().update(ContentUris.withAppendedId(EpisodeConstants.CONTENT_URI, id), values, null, null); } catch (Exception e) { Log.e(TAG, "savePodcast : error", e); } finally { completed(); } Log.v(TAG, "savePodcast : exit"); }
From source file:fr.eoit.activity.fragment.blueprint.InventionFragment.java
private void updateInventionChances() { inventionChances = FormulaCalculator.calculateInventionChances( FormulaCalculator.getBaseInventionChances(producedItemId, producedItemGroupId), encryptionSkillLevel, datacore1SkillLevel, datacore2SkillLevel, metaLevel, currentDecryptorBonuses.probabilityMultiplier); numberOfChances = (int) FloatMath.ceil(1 / (inventionChances)); inventionChancesTextView.setText(nfPercent.format(inventionChances)); requiredItemsInventionFragment.setParentFragment(this); requiredItemsInventionFragment.setDecryptorId(decryptorId); requiredItemsInventionFragment.setNumberOfChances(numberOfChances); }
From source file:com.lightbox.android.bitmap.BitmapUtils.java
public static Bitmap decodeFile(String pathName, int maxWidth, int maxHeight) { Options options = new Options(); options.inJustDecodeBounds = true;// ww w.j a v a2 s . c o m int sampleSize = 1; options.inSampleSize = sampleSize; BitmapFactory.decodeFile(pathName, options); if (maxWidth < options.outWidth || maxHeight < options.outHeight) { int sampleSizeW = (int) FloatMath.ceil((float) options.outWidth / maxWidth); int sampleSizeH = (int) FloatMath.ceil((float) options.outHeight / maxHeight); sampleSize = Math.max(sampleSizeW, sampleSizeH); options.inSampleSize = sampleSize; } options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(pathName, options); }
From source file:com.android.fastergallery.ui.TileImageView.java
private void getRange(Rect out, int cX, int cY, int level, float scale, int rotation) { double radians = Math.toRadians(-rotation); double w = getWidth(); double h = getHeight(); double cos = Math.cos(radians); double sin = Math.sin(radians); int width = (int) Math.ceil(Math.max(Math.abs(cos * w - sin * h), Math.abs(cos * w + sin * h))); int height = (int) Math.ceil(Math.max(Math.abs(sin * w + cos * h), Math.abs(sin * w - cos * h))); int left = (int) FloatMath.floor(cX - width / (2f * scale)); int top = (int) FloatMath.floor(cY - height / (2f * scale)); int right = (int) FloatMath.ceil(left + width / scale); int bottom = (int) FloatMath.ceil(top + height / scale); // align the rectangle to tile boundary int size = sTileSize << level; left = Math.max(0, size * (left / size)); top = Math.max(0, size * (top / size)); right = Math.min(mImageWidth, right); bottom = Math.min(mImageHeight, bottom); out.set(left, top, right, bottom);/*from ww w.ja va 2 s . c o m*/ }
From source file:com.student.oclass.view.pagerindicator.LinePageIndicator.java
/** * Determines the width of this view// ww w . j av a2s . co m * * @param measureSpec * A measureSpec packed into an int * @return The width of the view, honoring constraints from measureSpec */ private int measureWidth(int measureSpec) { float result = 0; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) { //We were told how big to be result = specSize; } else { //Calculate the width according the views count final int count = mViewPager.getAdapter().getCount(); result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth); //Respect AT_MOST value if that was what is called for by measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return (int) FloatMath.ceil(result); }
From source file:com.viewpagerindicator.LoopingLinePageIndicator.java
/** * Determines the width of this view//from ww w .j a v a 2 s. com * * @param measureSpec * A measureSpec packed into an int * @return The width of the view, honoring constraints from measureSpec */ private int measureWidth(int measureSpec) { float result; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) { //We were told how big to be result = specSize; } else { //Calculate the width according the views count final int count = getRealCount(); result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth); //Respect AT_MOST value if that was what is called for by measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return (int) FloatMath.ceil(result); }
From source file:kr.co.redstrap.campusting.util.indicator.LinePageIndicator.java
/** * Determines the width of this view//from w w w. j a va 2 s . c om * * @param measureSpec * A measureSpec packed into an int * @return The width of the view, honoring constraints from measureSpec */ private int measureWidth(int measureSpec) { float result; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) { // We were told how big to be result = specSize; } else { // Calculate the width according the views count final int count = mViewPager.getAdapter().getCount(); result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth); // Respect AT_MOST value if that was what is called for by measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return (int) FloatMath.ceil(result); }
From source file:android_hddl_framework.viewpagerindicator.LinePageIndicator.java
/** * Determines the width of this view/* www. j a va 2 s . com*/ * * @param measureSpec * A measureSpec packed into an int * @return The width of the view, honoring constraints from measureSpec */ private int measureWidth(int measureSpec) { float result; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) { //We were told how big to be result = specSize; } else { //Calculate the width according the views count final int count = mViewPager.getAdapter().getCount(); result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth); //Respect AT_MOST value if that was what is called for by measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return (int) FloatMath.ceil(result); }
From source file:com.along.altmcssd.pda.widget.viewpagerindicator.LinePageIndicator.java
/** * Determines the width of this view/* w ww .j ava 2 s. c om*/ * * @param measureSpec * A measureSpec packed into an int * @return The width of the view, honoring constraints from measureSpec */ private int measureWidth(int measureSpec) { float result; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) { // We were told how big to be result = specSize; } else { // Calculate the width according the views count final int count = mViewPager.getAdapter().getCount(); result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth); // Respect AT_MOST value if that was what is called for by // measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return (int) FloatMath.ceil(result); }