Add floating console support
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.stardust.pio;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
* Created by Stardust on 2017/4/1.
|
||||
*/
|
||||
|
||||
public class PReadableTextFile extends PFile {
|
||||
public class PReadableTextFile extends PFile implements Closeable {
|
||||
|
||||
private BufferedReader mBufferedReader;
|
||||
private FileInputStream mFileInputStream;
|
||||
@@ -91,6 +91,7 @@ public class PReadableTextFile extends PFile {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
if (mBufferedReader != null) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.stardust.pio;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.Closeable;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -13,7 +14,7 @@ import java.util.List;
|
||||
* Created by Stardust on 2017/4/1.
|
||||
*/
|
||||
|
||||
public class PWritableTextFile extends PFile {
|
||||
public class PWritableTextFile extends PFile implements Closeable {
|
||||
|
||||
public static PWritableTextFile open(String path, String encoding, int bufferSize) {
|
||||
return new PWritableTextFile(path, encoding, bufferSize, false);
|
||||
|
||||
43
common/src/main/java/com/stardust/util/UiHandler.java
Normal file
43
common/src/main/java/com/stardust/util/UiHandler.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.stardust.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/2.
|
||||
*/
|
||||
|
||||
public class UiHandler extends Handler {
|
||||
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public UiHandler(Context context) {
|
||||
super(Looper.getMainLooper());
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public void toast(final String message) {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void toast(final int resId) {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mContext, resId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.stardust.util;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/2.
|
||||
*/
|
||||
|
||||
public class UnderuseExecutors {
|
||||
|
||||
private static Executor mExecutor = Executors.newSingleThreadExecutor();
|
||||
|
||||
public static void execute(Runnable runnable) {
|
||||
mExecutor.execute(runnable);
|
||||
}
|
||||
|
||||
public static Executor getExecutor() {
|
||||
return mExecutor;
|
||||
}
|
||||
}
|
||||
@@ -41,4 +41,10 @@ public class ViewUtil {
|
||||
}
|
||||
|
||||
|
||||
public static void setViewMeasure(View view, int width, int height) {
|
||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||
params.width = width;
|
||||
params.height = height;
|
||||
view.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user