new ui for script list

This commit is contained in:
hyb1996
2017-08-20 21:46:51 +08:00
parent 68de90b718
commit 5440788922
31 changed files with 783 additions and 337 deletions

View File

@@ -0,0 +1,29 @@
package com.stardust.io;
import android.support.annotation.NonNull;
import java.io.File;
import java.net.URI;
/**
* Created by Stardust on 2017/8/19.
*/
public class EFile extends File {
public EFile(@NonNull String pathname) {
super(pathname);
}
public EFile(String parent, @NonNull String child) {
super(parent, child);
}
public EFile(File parent, @NonNull String child) {
super(parent, child);
}
public EFile(@NonNull URI uri) {
super(uri);
}
}

View File

@@ -16,6 +16,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.Locale;
/**
* Created by Stardust on 2017/4/1.
@@ -346,4 +347,12 @@ public class PFile {
public static String join(String parent, String child) {
return new File(parent, child).getPath();
}
public static String getHumanReadableSize(long bytes) {
int unit = 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = "KMGTPE".substring(exp - 1, exp);
return String.format(Locale.getDefault(), "%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
}