private static Bitmap getAvatarBit() { String avatar = AppSharedPreference.getInstance().getUserAvatar(); Bitmap avatarBit = null; if (!StringUtil.isEmpty(avatar)) { File file = ImageFileUtil.getSmallAvatarFile(avatar); avatarBit = ImageManageUtil.getBitmapNearestSize(file, ImageManageUtil.IMAGE_SMALL_SIZE); } return avatarBit; }
@Override public void run() { final Bitmap qrCode = Qr.bitmap(content, size, fgColor, bgColor, MarginSize); final int qrCodeSize = Math.min(qrCode.getWidth(), qrCode.getHeight()); if (addAvatar && AppSharedPreference.getInstance().hasUserAvatar()) { ImageManageUtil.getAvatarForFancyQrCode( new IGetAvatarListener() { @Override public void success(Bitmap bit) { if (bit != null) { Canvas c = new Canvas(qrCode); int avatarSize = (int) (qrCodeSize * AvatarSizeRate); int avaterOffset = (qrCodeSize - avatarSize) / 2; Paint paint = new Paint(); paint.setAntiAlias(true); c.drawBitmap( bit, null, new Rect( avaterOffset, avaterOffset, avaterOffset + avatarSize, avaterOffset + avatarSize), paint); } } @Override public void fileNoExist() {} }); } if (listener != null) { ThreadUtil.runOnMainThread( new Runnable() { @Override public void run() { listener.generated(qrCode); } }); } }
private void firstInit() { statusBarHeight = ImageManageUtil.getStatusBarHeight(BitherApplication.hotActivity.getWindow()); screenHeight = UIUtil.getScreenHeight(); screenWidth = UIUtil.getScreenWidth(); }