修复部分bug

This commit is contained in:
huangzhuanghua
2016-10-26 18:03:09 +08:00
parent 383b7bce21
commit b3e2f3545d
8 changed files with 18 additions and 14 deletions

View File

@ -37,7 +37,11 @@ public class FileUtils {
File file = new File(dir + File.separator + TEST_FILE_NAME);
if (!file.exists()) {
try {
file.createNewFile();
if (!file.createNewFile()) {
// cannot create file
Utils.log("cannot create file");
dir = null;
}
} catch (IOException e) {
e.printStackTrace();
//cannot create file
@ -124,7 +128,7 @@ public class FileUtils {
return availableBlocks * blockSize / 1024f / 1024f;
}
public static String isCanDownload(String size) {
public static String isCanDownload(Context context, String size) {
String msg = null;
String packageSizeStr = "";
for (int i = 0; i < size.length(); i++) {
@ -136,8 +140,7 @@ public class FileUtils {
if (packageSizeStr.length() != 0) {
packageSize = Float.valueOf(packageSizeStr);
}
float freeSpace = getFreeSpaceByPath(Environment
.getExternalStorageDirectory().getAbsolutePath());
float freeSpace = getFreeSpaceByPath(getDownloadDir(context));
if (freeSpace < packageSize) {
msg = "手机存储空间不足,无法进行下载!";
}