LauncherIcons.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:LaunchEnr 作者:
/**
 * If the platform is running O but the app is not providing AdaptiveIconDrawable, then
 * shrink the legacy icon and set it as foreground. Use color drawable as background to
 * create AdaptiveIconDrawable.
 */
private static Drawable wrapToAdaptiveIconDrawable(Context context, Drawable drawable, float scale) {
    if (!(AndroidVersion.isAtLeastOreo())) {
        return drawable;
    }

    try {
        if (!(drawable instanceof AdaptiveIconDrawable)) {
            AdaptiveIconDrawable iconWrapper = (AdaptiveIconDrawable)
                    context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
            FixedScaleDrawable fsd = ((FixedScaleDrawable) iconWrapper.getForeground());
            fsd.setDrawable(drawable);
            fsd.setScale(scale);
            return (Drawable) iconWrapper;
        }
    } catch (Exception e) {
        return drawable;
    }
    return drawable;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号