当前位置: 首页>>代码示例>>Java>>正文


Java Utilities.boundToRange方法代码示例

本文整理汇总了Java中com.android.launcher3.Utilities.boundToRange方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.boundToRange方法的具体用法?Java Utilities.boundToRange怎么用?Java Utilities.boundToRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.launcher3.Utilities的用法示例。


在下文中一共展示了Utilities.boundToRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDraw

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (mTotalScroll == 0 || mNumPagesFloat == 0) {
        return;
    }

    // Compute and draw line rect.
    float progress = Utilities.boundToRange(((float) mCurrentScroll) / mTotalScroll, 0f, 1f);
    int availableWidth = canvas.getWidth();
    int lineWidth = (int) (availableWidth / mNumPagesFloat);
    int lineLeft = (int) (progress * (availableWidth - lineWidth));
    int lineRight = lineLeft + lineWidth;
    canvas.drawRect(lineLeft, canvas.getHeight() - mLineHeight, lineRight, canvas.getHeight(),
            mLinePaint);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:16,代码来源:PageIndicatorLineCaret.java

示例2: setProgress

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
/**
 * @param progress       value between 0 and 1, 0 shows all apps and 1 shows workspace
 */
public void setProgress(float progress) {
    float shiftPrevious = mProgress * mShiftRange;
    mProgress = progress;
    float shiftCurrent = progress * mShiftRange;

    float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f);
    float alpha = 1 - workspaceHotseatAlpha;
    float interpolation = mAccelInterpolator.getInterpolation(workspaceHotseatAlpha);

    int color = (Integer) mEvaluator.evaluate(mDecelInterpolator.getInterpolation(alpha),
            mHotseatBackgroundColor, mAllAppsBackgroundColor);
    int bgAlpha = Color.alpha((int) mEvaluator.evaluate(alpha,
            mHotseatBackgroundColor, mAllAppsBackgroundColor));

    mAppsView.setRevealDrawableColor(ColorUtils.setAlphaComponent(color, bgAlpha));
    mAppsView.getContentView().setAlpha(alpha);
    mAppsView.setTranslationY(shiftCurrent);

    if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
        mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, -mShiftRange + shiftCurrent,
                interpolation);
    } else {
        mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y,
                PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent),
                interpolation);
    }

    if (mIsTranslateWithoutWorkspace) {
        return;
    }
    mWorkspace.setWorkspaceYTranslationAndAlpha(
            PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), interpolation);

    if (!mDetector.isDraggingState()) {
        mContainerVelocity = mDetector.computeVelocity(shiftCurrent - shiftPrevious,
                System.currentTimeMillis());
    }

    mCaretController.updateCaret(progress, mContainerVelocity, mDetector.isDraggingState());
    updateLightStatusBar(shiftCurrent);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:45,代码来源:AllAppsTransitionController.java

示例3: wallpaperOffsetForScroll

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
/**
 * TODO: do different behavior if it's  a live wallpaper?
 */
public float wallpaperOffsetForScroll(int scroll) {
    // To match the default wallpaper behavior in the system, we default to either the left
    // or right edge on initialization
    int numScrollingPages = getNumScreensExcludingEmptyAndCustom();
    if (mLockedToDefaultPage || numScrollingPages <= 1) {
        return mIsRtl ? 1f : 0f;
    }

    // Distribute the wallpaper parallax over a minimum of MIN_PARALLAX_PAGE_SPAN workspace
    // screens, not including the custom screen, and empty screens (if > MIN_PARALLAX_PAGE_SPAN)
    if (mWallpaperIsLiveWallpaper) {
        mNumPagesForWallpaperParallax = numScrollingPages;
    } else {
        mNumPagesForWallpaperParallax = Math.max(MIN_PARALLAX_PAGE_SPAN, numScrollingPages);
    }

    // Offset by the custom screen
    int leftPageIndex;
    int rightPageIndex;
    if (mIsRtl) {
        rightPageIndex = mWorkspace.numCustomPages();
        leftPageIndex = rightPageIndex + numScrollingPages - 1;
    } else {
        leftPageIndex = mWorkspace.numCustomPages();
        rightPageIndex = leftPageIndex + numScrollingPages - 1;
    }

    // Calculate the scroll range
    int leftPageScrollX = mWorkspace.getScrollForPage(leftPageIndex);
    int rightPageScrollX = mWorkspace.getScrollForPage(rightPageIndex);
    int scrollRange = rightPageScrollX - leftPageScrollX;
    if (scrollRange == 0) {
        return 0f;
    }

    // Sometimes the left parameter of the pages is animated during a layout transition;
    // this parameter offsets it to keep the wallpaper from animating as well
    int adjustedScroll = scroll - leftPageScrollX -
            mWorkspace.getLayoutTransitionOffsetForPage(0);
    float offset = Utilities.boundToRange((float) adjustedScroll / scrollRange, 0f, 1f);

    // The offset is now distributed 0..1 between the left and right pages that we care about,
    // so we just map that between the pages that we are using for parallax
    float rtlOffset = 0;
    if (mIsRtl) {
        // In RTL, the pages are right aligned, so adjust the offset from the end
        rtlOffset = (float) ((mNumPagesForWallpaperParallax - 1) - (numScrollingPages - 1)) /
                (mNumPagesForWallpaperParallax - 1);
    }
    return rtlOffset + offset *
            ((float) (numScrollingPages - 1) / (mNumPagesForWallpaperParallax - 1));
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:56,代码来源:WallpaperOffsetInterpolator.java


注:本文中的com.android.launcher3.Utilities.boundToRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。