new ui for script list
This commit is contained in:
29
common/src/main/java/com/stardust/io/EFile.java
Normal file
29
common/src/main/java/com/stardust/io/EFile.java
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user