Add floating console support
This commit is contained in:
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