public void saveImg() {
//mCardView为被截图view
mCardView.setDrawingCacheEnabled(true);
Bitmap drawingCache = mCardView.getDrawingCache();
drawingCache = Bitmap.createBitmap(drawingCache);
mCardView.setDrawingCacheEnabled(false);
File file = new File(FileUtils.getImageCachePath(getContext()), UUID.randomUUID() + ".jpg");
ImageUtils.writeBitmap(file.getAbsolutePath(), drawingCache, 100);
String dbUri = CommonUtils.saveToDb(getContext(), file.getAbsolutePath());
if (dbUri != null) {
ToastUtil.show(getContext(), R.string.save_image_success);
} else {
ToastUtil.show(getContext(), R.string.save_image_fail);
}
}
public static String getImageCachePath(Context context) {
String path = getCachePath(context);
if (!TextUtils.isEmpty(path)) {
String root = path + File.separator