Add: Task manager
This commit is contained in:
@@ -28,5 +28,4 @@ dependencies {
|
||||
})
|
||||
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'org.testng:testng:6.9.6'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.stardust.pio;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -16,6 +17,8 @@ import java.io.OutputStream;
|
||||
|
||||
public class PFile {
|
||||
|
||||
private static final String TAG = "PFile";
|
||||
|
||||
private static final int BUFFER_SIZE = 8192;
|
||||
|
||||
public static PFile open(String path, String mode) {
|
||||
@@ -203,12 +206,11 @@ public class PFile {
|
||||
int a = fileName.lastIndexOf('/');
|
||||
if (a < 0)
|
||||
a = fileName.lastIndexOf('\\');
|
||||
int b = fileName.lastIndexOf('.');
|
||||
if (a < 0)
|
||||
a = -1;
|
||||
int b = fileName.indexOf('.', a + 1);
|
||||
if (b < 0)
|
||||
b = fileName.length();
|
||||
// FIXME: 2017/4/3 StringOutOfBoundsException
|
||||
fileName = fileName.substring(a + 1, b);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.stardust.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -24,56 +21,4 @@ public class FileSorter {
|
||||
});
|
||||
}
|
||||
|
||||
public static class TestSuite {
|
||||
|
||||
@Test
|
||||
public void testEngFileSort() {
|
||||
File file1 = new File("d:/a.txt");
|
||||
File file2 = new File("e:/b.txt");
|
||||
File file3 = new File("c:/c.txt");
|
||||
File[] files = {file2, file3, file1};
|
||||
sort(files);
|
||||
Assert.assertArrayEquals(new File[]{file1, file2, file3}, files);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEngFileSortWithDirectory() {
|
||||
File dir1 = new File("d:/");
|
||||
File dir2 = new File("e:/");
|
||||
File file1 = new File("e:/a.txt");
|
||||
File file2 = new File("e:/b.txt");
|
||||
File file3 = new File("d:/c.txt");
|
||||
Assert.assertTrue(dir1.isDirectory());
|
||||
Assert.assertTrue(dir2.isDirectory());
|
||||
File[] files = {file2, file3, dir1, file1, dir2};
|
||||
sort(files);
|
||||
Assert.assertArrayEquals(new File[]{dir1, dir2, file1, file2, file3}, files);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCnFileSort() {
|
||||
File file1 = new File("a.txt");
|
||||
File file2 = new File("b.txt");
|
||||
File file3 = new File("啊.txt");
|
||||
File file4 = new File("啊啊.txt");
|
||||
File[] files = {file2, file4, file3, file1};
|
||||
sort(files);
|
||||
Assert.assertArrayEquals(new File[]{file1, file2, file3, file4}, files);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCnFileSortWithDirectory() {
|
||||
File dir1 = new File("d:/整理/");
|
||||
File dir2 = new File("d:/迅雷下载/");
|
||||
File file1 = new File("d:/整理/a.txt");
|
||||
File file2 = new File("啊.txt");
|
||||
File file3 = new File("啊啊.txt");
|
||||
Assert.assertTrue(dir1.isDirectory());
|
||||
Assert.assertTrue(dir2.isDirectory());
|
||||
File[] files = {file2, file3, dir1, file1, dir2};
|
||||
sort(files);
|
||||
Assert.assertArrayEquals(new File[]{dir1, dir2, file1, file2, file3}, files);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.stardust.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/31.
|
||||
*/
|
||||
@@ -26,33 +21,4 @@ public class LimitedHashMap<K, V> extends LinkedHashMap<K, V> {
|
||||
}
|
||||
|
||||
|
||||
public static class TestSuite {
|
||||
|
||||
@org.testng.annotations.Test
|
||||
public void testAutoRemove() {
|
||||
LimitedHashMap<String, Integer> hashMap = new LimitedHashMap<>(5);
|
||||
hashMap.put("a", 1);
|
||||
hashMap.put("b", 2);
|
||||
hashMap.put("c", 3);
|
||||
hashMap.put("d", 4);
|
||||
hashMap.put("e", 5);
|
||||
hashMap.put("f", 6);
|
||||
assertFalse(hashMap.containsKey("a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoReorder() {
|
||||
LimitedHashMap<String, Integer> hashMap = new LimitedHashMap<>(5);
|
||||
hashMap.put("a", 1);
|
||||
hashMap.put("b", 2);
|
||||
hashMap.put("c", 3);
|
||||
hashMap.put("d", 4);
|
||||
hashMap.put("e", 5);
|
||||
hashMap.get("a");
|
||||
hashMap.put("f", 6);
|
||||
assertTrue(hashMap.containsKey("a"));
|
||||
assertFalse(hashMap.containsKey("b"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
package com.stardust.util;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/3.
|
||||
*/
|
||||
@@ -27,14 +20,5 @@ public class SdkVersionUtil {
|
||||
return SDK_VERSIONS[i - 1];
|
||||
}
|
||||
|
||||
public static final class TestSuite {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertEquals("5.0", sdkIntToString(21));
|
||||
assertEquals("8.0", sdkIntToString(26));
|
||||
assertEquals("Unknown", sdkIntToString(27));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.stardust.util;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/24.
|
||||
@@ -23,4 +25,6 @@ public class ViewUtil {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user