|
|
package com.stu.assistant.uitls;
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
import android.content.Context;
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.os.Build;
|
|
|
import android.os.Handler;
|
|
|
import android.util.Log;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
import android.widget.EditText;
|
|
|
|
|
|
import com.stu.assistant.base.BaseApplion;
|
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
|
|
public class Config {
|
|
|
ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5);
|
|
|
Handler handler = new Handler();
|
|
|
|
|
|
public void search(final Todo todo) {
|
|
|
|
|
|
fixedThreadPool.execute(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
todo.onInOhter();
|
|
|
|
|
|
handler.post(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
todo.onInMain();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
public interface Todo {
|
|
|
void onInOhter();
|
|
|
|
|
|
String onInMain();
|
|
|
}
|
|
|
|
|
|
public void outAppInfo() {
|
|
|
SharedUtil.create(BaseApplion.application).clear();
|
|
|
BaseApplion.getActivityManage().finishAll();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* author : stf
|
|
|
* created: 2017-04-26 20:27
|
|
|
* acts on: editview 点击不显示软件盘,但是显示光标,关闭软件盘 ,可以通过PDA的键盘输入
|
|
|
*/
|
|
|
public static void colseKey(final EditText editText) {
|
|
|
Boolean isPda = SharedNoClearUtil.create(BaseApplion.application).getBoolean(SharedConfig.isPda, true);
|
|
|
Log.i("hx","---colseKey---->"+isPda);
|
|
|
if(isPda){
|
|
|
setFocuse(editText);
|
|
|
}
|
|
|
editText.setOnTouchListener(new View.OnTouchListener() {
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
if (isPda) {
|
|
|
editText.setShowSoftInputOnFocus(false); // true 可以正常输入,fasle editview 点击不显示软件盘,但是显示光标,关闭软件盘
|
|
|
} else {
|
|
|
editText.setShowSoftInputOnFocus(true);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
|
public void setFocuse(EditText fitsted, EditText seconded, Context mContext) {
|
|
|
fitsted.clearFocus();
|
|
|
seconded.setFocusable(true);
|
|
|
seconded.setFocusableInTouchMode(true);
|
|
|
seconded.requestFocus();
|
|
|
seconded.requestFocusFromTouch();
|
|
|
InputMethodManager inputManager = (InputMethodManager) seconded.getContext().getSystemService(mContext.INPUT_METHOD_SERVICE);
|
|
|
inputManager.showSoftInput(seconded, 0);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* author : stf
|
|
|
* created: 2017-04-13 10:24
|
|
|
* acts on:进入页面主动获取焦点
|
|
|
* @param editview
|
|
|
*/
|
|
|
|
|
|
public static void setFocuse(EditText editview) {
|
|
|
editview.setFocusable(true);
|
|
|
editview.setFocusableInTouchMode(true);
|
|
|
editview.requestFocus();
|
|
|
editview.requestFocusFromTouch();
|
|
|
}
|
|
|
}
|