private void saveImage(int index) { String dest = AcApp.getPreferenceImageSaveDir(); String path = mList.get(index); Uri uri = Uri.parse(path); File saveFile; if (uri.getScheme().equals("http")) { // FIXME: volley 的缓存任务还没有被执行的时候是会获取不到数据的 byte[] diskCache = AcApp.getDataInDiskCache(path); if (diskCache != null) { saveFile = new File(dest + "/" + FileUtil.getHashName(path)); if (!FileUtil.save(diskCache, saveFile.getAbsolutePath())) { saveFile = null; } } else { File cache = FileUtil.generateImageCacheFile(path); saveFile = FileUtil.copy(cache, dest); } } else { File cache = new File(uri.getPath()); saveFile = FileUtil.copy(cache, dest); } if (saveFile != null && saveFile.exists()) { MobclickAgent.onEvent(this, "save_pic"); Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(saveFile)); sendBroadcast(intent); AcApp.showToast(getString(R.string.save_success) + ":" + saveFile.getAbsolutePath()); } else AcApp.showToast(getString(R.string.save_failed)); }