Java 类android.util.FloatMath 实例源码

项目:musicplayer    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:musicplayer    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:Huochexing12306    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:Huochexing12306    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:boohee_v5.6    文件:LinePageIndicator.java   
private int measureWidth(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);
    if (specMode == 1073741824 || this.mViewPager == null) {
        result = (float) specSize;
    } else {
        int count = this.mViewPager.getAdapter().getCount();
        result = (((float) (getPaddingLeft() + getPaddingRight())) + (((float) count) * this
                .mLineWidth)) + (((float) (count - 1)) * this.mGapWidth);
        if (specMode == Integer.MIN_VALUE) {
            result = Math.min(result, (float) specSize);
        }
    }
    return (int) FloatMath.ceil(result);
}
项目:android-project-gallery    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:android-project-gallery    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:narrate-android    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:narrate-android    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:YinjiImageEditor    文件:BitmapUtils.java   
public static Bitmap loadImage(Context context, int resId, int imgWidth, int imgHeight){
    Options opts = new Options();
    opts.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(context.getResources(), resId, opts);
    final int height = opts.outHeight;
    final int width = opts.outWidth;
    int inSampleSize = 1;
    if (height > imgHeight || width > imgWidth) {
        if (width > height) {
            inSampleSize = (int) FloatMath
                    .floor(((float) height / imgHeight) + 0.5f); // Math.round((float)height
        } else {
            inSampleSize = (int) FloatMath
                    .floor(((float) width / imgWidth) + 0.5f); // Math.round((float)width
        }
    }
    opts.inSampleSize = inSampleSize;
    opts.inJustDecodeBounds = false;
    System.out.println("得到的缩放比例为:" + inSampleSize);
    Bitmap copyImg = BitmapFactory.decodeResource(context.getResources(), resId, opts);
    return copyImg;
}
项目:darksms    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:darksms    文件:AnimatorProxy.java   
private void invalidateAfterUpdate() {
    View view = mView.get();
    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));
}
项目:monolog-android    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:monolog-android    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:aptoide-backup-apps    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:aptoide-backup-apps    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:aptoide-backup-apps    文件:AnimatorProxy.java   
private void invalidateAfterUpdate() {
    View view = mView.get();
    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));
}
项目:Benzene    文件:PolygonalDrwable.java   
private Path createHexagon(int size, int centerX, int centerY) {
    final float section = (float) (2.0 * Math.PI / numberOfSides);
    int radius = size / 2;
    Path polygonPath = temporal;
    polygonPath.reset();
    polygonPath.moveTo((centerX + radius * FloatMath.cos(0)),
            (centerY + radius * FloatMath.sin(0)));

    for (int i = 1; i < numberOfSides; i++) {
        polygonPath.lineTo((centerX + radius * FloatMath.cos(section * i)),
                (centerY + radius * FloatMath.sin(section * i)));
    }

    polygonPath.close();
    return polygonPath;
}
项目:BigApp_Discuz_Android    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:android-open-project-demo-master    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:android-open-project-demo-master    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:android-open-project-demo-master    文件:BitmapUtils.java   
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight) {       
    Options options = new Options();
    options.inJustDecodeBounds = true;

    BitmapFactory.decodeFile(filePath, options);

    // Raw height and width of image
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth) {
        if (width > height) {
            inSampleSize = (int)FloatMath.floor(((float)height / reqHeight)+0.5f); //Math.round((float)height / (float)reqHeight);
        } else {
            inSampleSize = (int)FloatMath.floor(((float)width / reqWidth)+0.5f); //Math.round((float)width / (float)reqWidth);
        }
    }

    options.inSampleSize = inSampleSize;
    options.inJustDecodeBounds = false;

    return BitmapFactory.decodeFile(filePath, options);
}
项目:android-open-project-demo-master    文件:Utils.java   
public static Animation createScaleAnimation(View view, int parentWidth, int parentHeight,
        int toX, int toY) {
    // Difference in X and Y
    final int diffX = toX - view.getLeft();
    final int diffY = toY - view.getTop();

    // Calculate actual distance using pythagors
    float diffDistance = FloatMath.sqrt((toX * toX) + (toY * toY));
    float parentDistance = FloatMath
            .sqrt((parentWidth * parentWidth) + (parentHeight * parentHeight));

    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.ABSOLUTE,
            diffX,
            Animation.ABSOLUTE, diffY);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(Math.round(diffDistance / parentDistance
            * Constants.SCALE_ANIMATION_DURATION_FULL_DISTANCE));

    return scaleAnimation;
}
项目:android-open-project-demo-master    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:android-open-project-demo-master    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:PalmCampus    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:BigApp_WordPress_Android    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:BigApp_WordPress_Android    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:simpleirc    文件:LinePageIndicator.java   
/**
 * Determines the width of this view
 *
 * @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);
}
项目:simpleirc    文件:LinePageIndicator.java   
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result = 0;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //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);
}
项目:SunmiUI    文件:EdgeEffect.java   
/**
 * A view should call this when content is pulled away from an edge by the user.
 * This will update the state of the current visual effect and its associated animation.
 * The host view should always {@link android.view.View#invalidate()} after this
 * and draw the results accordingly.
 *
 * @param deltaDistance Change in distance since the last call. Values may be 0 (no change) to
 *                      1.f (full length of the view) or negative values to express change
 *                      back toward the edge reached to initiate the effect.
 * @param displacement The displacement from the starting side of the effect of the point
 *                     initiating the pull. In the case of touch this is the finger position.
 *                     Values may be from 0-1.
 */
public void onPull(float deltaDistance, float displacement) {
    final long now = AnimationUtils.currentAnimationTimeMillis();
    mTargetDisplacement = displacement;
    if (mState == STATE_PULL_DECAY && now - mStartTime < mDuration) {
        //动画未完成 return
        return;
    }
    if (mState != STATE_PULL) {
        mGlowScaleY = Math.max(PULL_GLOW_BEGIN, mGlowScaleY);
    }
    mState = STATE_PULL;

    mStartTime = now;
    mDuration = PULL_TIME;

    mPullDistance += deltaDistance;

    final float absdd = Math.abs(deltaDistance);
    mGlowAlpha = mGlowAlphaStart = Math.min(MAX_ALPHA,
            mGlowAlpha + (absdd * PULL_DISTANCE_ALPHA_GLOW_FACTOR));

    if (mPullDistance == 0) {
        mGlowScaleY = mGlowScaleYStart = 0;
    } else {
        final float scale = Math.max(0, 1 - 1 /
                FloatMath.sqrt(Math.abs(mPullDistance) * mBounds.height()) - 0.3f) / 0.7f;

        mGlowScaleY = mGlowScaleYStart = scale;
    }

    mGlowAlphaFinish = mGlowAlpha;
    mGlowScaleYFinish = mGlowScaleY;
}
项目:ywApplication    文件:Shake2Share.java   
public void onSensorChanged(SensorEvent event) {
    long currentTime = System.currentTimeMillis();
    long diffTime = currentTime - mLastUpdateTime;
    if (diffTime > UPDATE_INTERVAL) {
        if(mLastUpdateTime != 0) {
            float x = event.values[0];
            float y = event.values[1];
            float z = event.values[2];
            float deltaX = x - mLastX;
            float deltaY = y - mLastY;
            float deltaZ = z - mLastZ;
            float delta = FloatMath.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / diffTime * 10000;
            if (delta > SHAKE_THRESHOLD) {
                if (!shaken) {
                    shaken = true;
                    finish();
                }

                if (listener != null) {
                    listener.onShake();
                }
            }
            mLastX = x;
            mLastY = y;
            mLastZ = z;
        }
        mLastUpdateTime = currentTime;
    }
}
项目:ywApplication    文件:PicViewer.java   
/**
    * 两点的距离
    */
   @SuppressLint("FloatMath")
private float spacing(MotionEvent event) {
       float x = event.getX(0) - event.getX(1);
       float y = event.getY(0) - event.getY(1);
       return FloatMath.sqrt(x * x + y * y);
   }
项目:letv    文件:c.java   
private float a(MotionEvent motionEvent) {
    if (motionEvent.getPointerCount() < 2) {
        return 0.0f;
    }
    float x = motionEvent.getX(0) - motionEvent.getX(1);
    float y = motionEvent.getY(0) - motionEvent.getY(1);
    return FloatMath.sqrt((x * x) + (y * y));
}
项目:Huochexing12306    文件:Shake2Share.java   
public void onSensorChanged(SensorEvent event) {
    long currentTime = System.currentTimeMillis();
    long diffTime = currentTime - mLastUpdateTime;
    if (diffTime > UPDATE_INTERVAL) {
        if(mLastUpdateTime != 0) {
            float x = event.values[0];
            float y = event.values[1];
            float z = event.values[2];
            float deltaX = x - mLastX;
            float deltaY = y - mLastY;
            float deltaZ = z - mLastZ;
            float delta = FloatMath.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / diffTime * 10000;
            if (delta > SHAKE_THRESHOLD) {
                if (!shaken) {
                    shaken = true;
                    finish();
                }

                if (listener != null) {
                    listener.onShake();
                }
            }
            mLastX = x;
            mLastY = y;
            mLastZ = z;
        }
        mLastUpdateTime = currentTime;
    }
}
项目:boohee_v5.6    文件:LinePageIndicator.java   
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);
    if (specMode == 1073741824) {
        result = (float) specSize;
    } else {
        result = (this.mPaintSelected.getStrokeWidth() + ((float) getPaddingTop())) + (
                (float) getPaddingBottom());
        if (specMode == Integer.MIN_VALUE) {
            result = Math.min(result, (float) specSize);
        }
    }
    return (int) FloatMath.ceil(result);
}
项目:zabbkit-android    文件:MathUtils.java   
/**
 * Rotates p1 around p2 by angle degrees.
 * @param p1
 * @param p2
 * @param angle
 */
public void rotate(PointF p1, PointF p2, float angle) {
    float px = p1.x;
    float py = p1.y;
    float ox = p2.x;
    float oy = p2.y;
    p1.x = (FloatMath.cos(angle) * (px-ox) - FloatMath.sin(angle) * (py-oy) + ox);
    p1.y = (FloatMath.sin(angle) * (px-ox) + FloatMath.cos(angle) * (py-oy) + oy);
}
项目:android-project-gallery    文件:BitmapUtils.java   
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight)
{
    Options options = new Options();
    options.inJustDecodeBounds = true;

    BitmapFactory.decodeFile(filePath, options);

    // Raw height and width of image
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth)
    {
        if (width > height)
        {
            inSampleSize = (int)FloatMath.floor(((float)height / reqHeight)+0.5f); //Math.round((float)height / (float)reqHeight);
        }
        else
        {
            inSampleSize = (int)FloatMath.floor(((float)width / reqWidth)+0.5f); //Math.round((float)width / (float)reqWidth);
        }
    }

    options.inSampleSize = inSampleSize;
    options.inJustDecodeBounds = false;

    return BitmapFactory.decodeFile(filePath, options);
}
项目:android-project-gallery    文件:BitmapUtils.java   
public static BitmapSize getScaledSize(int originalWidth, int originalHeight, int numPixels)
{
    float ratio = (float) originalWidth / originalHeight;

    int scaledHeight = (int) FloatMath.sqrt((float) numPixels / ratio);
    int scaledWidth = (int) (ratio * FloatMath.sqrt((float) numPixels / ratio));

    return new BitmapSize(scaledWidth, scaledHeight);
}
项目:InsanityRadio-Android    文件:ActionBarSliderHandle.java   
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    Rect rect = new Rect();
    closeButton.getHitRect(rect);
    adjustHitRect(rect);
    if(rect.contains((int)FloatMath.ceil(ev.getX()), (int)FloatMath.ceil(ev.getY()))) {
        getSlider().close();
    }
    else {
        getSlider().slide();
    }
    return true;
}