package com.basic.security.manager.impl.sqlite;
|
|
import android.text.TextUtils;
|
|
import com.couchbase.lite.Expression;
|
import com.basic.security.model.ModelAdapter;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
public class SlHintRecognizeManager extends SlBaseManager {
|
public static ModelAdapter hintMessage;
|
|
static long getHintRecognizeMassageLastTime = 0;
|
static List<ModelAdapter> getHintRecognizeMassageLastList = new ArrayList<>();
|
|
/*得到hint设置信息*/
|
public static ModelAdapter getHintRecognizeMassage() {
|
long currentGetHintRecognizeMassage = System.currentTimeMillis();
|
if (currentGetHintRecognizeMassage - getHintRecognizeMassageLastTime > 5 * 1000) {
|
getHintRecognizeMassageLastTime = currentGetHintRecognizeMassage;
|
getHintRecognizeMassageLastList = findList("select * from hint_recognize_message");
|
}
|
if (getHintRecognizeMassageLastList.size() == 1) {
|
hintMessage = getHintRecognizeMassageLastList.get(0);
|
} else {
|
if (getHintRecognizeMassageLastList.size() == 0) {
|
hintMessage = new ModelAdapter();
|
} else {
|
hintMessage = getHintRecognizeMassageLastList.get(0);
|
for (int i = 1; i < getHintRecognizeMassageLastList.size(); i++) {
|
delete(getHintRecognizeMassageLastList.get(i));
|
}
|
}
|
}
|
return hintMessage;
|
}
|
|
public static double getHeadUpAngle() {
|
getHintRecognizeMassage();
|
if (hintMessage != null) {
|
try {
|
return -Double.parseDouble(hintMessage.getString("head_up"));
|
} catch (Exception e) {
|
System.out.println(e.getMessage());
|
// e.printStackTrace();
|
}
|
}
|
return -10;
|
}
|
|
public static String getHeadUpAngleMessage() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("head_up_message"))) {
|
return hintMessage.getString("head_up_message");
|
} else {
|
return "请抬头";
|
}
|
}
|
|
public static double getHeadDownAngle() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("head_down"))) {
|
try {
|
return Double.parseDouble(hintMessage.getString("head_down"));
|
} catch (NumberFormatException e) {
|
e.printStackTrace();
|
}
|
}
|
return 15;
|
}
|
|
public static String getHeadDownAngleMessage() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("head_down_message"))) {
|
return hintMessage.getString("head_down_message");
|
} else {
|
return "请低头";
|
}
|
}
|
|
public static double getFaceMaxAngle() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("face_max"))) {
|
try {
|
String face_max = hintMessage.getString("face_max");
|
if (!TextUtils.isEmpty(face_max)) {
|
return Double.parseDouble(face_max);
|
}
|
} catch (NumberFormatException e) {
|
e.printStackTrace();
|
}
|
}
|
return 0.2;
|
}
|
|
public static String getFaceMaxAngleMessage() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("face_max_message"))) {
|
return hintMessage.getString("face_max_message");
|
} else {
|
return "请向后站";
|
}
|
}
|
|
public static double getFaceMinAngle() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("face_min"))) {
|
try {
|
return Double.parseDouble(hintMessage.getString("face_min"));
|
} catch (NumberFormatException e) {
|
// e.printStackTrace();
|
}
|
}
|
return 0.2;
|
}
|
|
public static String getFaceMinAngleMessage() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("face_min_message"))) {
|
return hintMessage.getString("face_min_message");
|
} else {
|
return "请向前站";
|
}
|
}
|
|
public static double getLeftRotationAngle() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("rotation_left"))) {
|
try {
|
return -Double.parseDouble(hintMessage.getString("rotation_left"));
|
} catch (NumberFormatException e) {
|
e.printStackTrace();
|
}
|
}
|
return -10;
|
}
|
|
public static String getLeftRotationMessage() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("rotation_left_message"))) {
|
return hintMessage.getString("rotation_left_message");
|
} else {
|
return "请向左看";
|
}
|
}
|
|
public static double getRightRotationAngle() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("rotation_right"))) {
|
try {
|
return Double.parseDouble(hintMessage.getString("rotation_right"));
|
} catch (NumberFormatException e) {
|
e.printStackTrace();
|
}
|
}
|
return 10;
|
}
|
|
public static String getRightRotationMessage() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("rotation_right_message"))) {
|
return hintMessage.getString("rotation_right_message");
|
} else {
|
return "请向右看";
|
}
|
}
|
|
public static String getAllFit() {
|
getHintRecognizeMassage();
|
if (hintMessage != null && !TextUtils.isEmpty(hintMessage.getString("all_fit"))) {
|
return hintMessage.getString("all_fit");
|
} else {
|
return "";
|
}
|
}
|
|
public static void saveHintRecognize(ModelAdapter hintRecognize) {
|
SlBaseManager.save(hintRecognize);
|
}
|
|
}
|