From 603cb36a5123e46656b06a5deb8d7ac7ff81307f Mon Sep 17 00:00:00 2001 From: 554325746@qq.com <554325746@qq.com> Date: 星期三, 25 十二月 2019 08:48:51 +0800 Subject: [PATCH] a --- app/src/main/java/com/basic/security/manager/GuestManager.java | 119 +++++++++++------------------------------------------------ 1 files changed, 22 insertions(+), 97 deletions(-) diff --git a/app/src/main/java/com/basic/security/manager/GuestManager.java b/app/src/main/java/com/basic/security/manager/GuestManager.java index 2bf0008..f310efd 100644 --- a/app/src/main/java/com/basic/security/manager/GuestManager.java +++ b/app/src/main/java/com/basic/security/manager/GuestManager.java @@ -4,12 +4,10 @@ import android.text.TextUtils; import com.basic.security.base.BaseApplication; -import com.basic.security.fragment.GuestModeFragment; import com.basic.security.model.Guest; import com.basic.security.model.ModelAdapter; -import com.basic.security.model.Outdoor; import com.basic.security.model.Person; -import com.basic.security.utils.FaceId; +import com.basic.security.utils.Constants; import org.apache.commons.io.FileUtils; @@ -18,27 +16,21 @@ import java.util.List; public class GuestManager extends BaseManager { - public static boolean cameraOneEnable = false; - public static boolean cameraTwoEnable = false; static long deleteMoreThanLastTime = 0; - static String cameraTitle = ""; - static int guestListCameraType = 1; - static boolean isEnable = false; - static ModelAdapter outdoor = null; - static int prevCameraCount = 2; public static void saveGuest(ModelAdapter guest) { save(guest); deleteMoreThan(guest, 50); } - public static ModelAdapter findGuestListRecentOne() { - return findOne("select * from guest order by " + Guest.create_time + " desc limit 1"); + public static ModelAdapter findGuestListRecentOne(int guestListCameraType) { + String sql = "select * from guest where " + Guest.camera_id + "='" + guestListCameraType + "' order by " + Guest.create_time + " desc limit 1"; + return findOne(sql); } public static List<ModelAdapter> findGuestList(String cameraId) { List<ModelAdapter> guestList = findList("select * from guest where 1=1 " + -// " and " + Guest.camera_id + "='" + cameraId + "'"+ + " and " + Guest.camera_id + "='" + cameraId + "'" + " order by " + Guest.create_time + " desc limit 50"); List<ModelAdapter> guestToRemoveList = new ArrayList<>(); for (ModelAdapter guest : guestList) { @@ -75,95 +67,13 @@ FileUtils.forceDelete(camera_image_pathFile); } } catch (Exception e) { - System.out.println("GuestManager.deleteGuestAttachment " + e.getMessage()); + System1.out.println("GuestManager.deleteGuestAttachment " + e.getMessage()); } deletePhysically(modelAdapter); } public static void deleteGuest(ModelAdapter checkedGuest) { deleteGuestAttachment(checkedGuest); - } - - public static void deleteSavedGuest(byte[] cameraImageFeature) { - if (cameraImageFeature != null && cameraImageFeature.length > 0) { - BaseApplication.getApplication().executorService.execute(() -> { - try { - int deleteCount = 1; - List<ModelAdapter> guestList = findList("select * from guest"); - for (ModelAdapter guest : guestList) { - byte[] dbFeature = guest.getBlob(Guest.camera_image_feature); - float score = FaceId.instance.compareFeature(cameraImageFeature, dbFeature); - if (score >= 70 || dbFeature == null || dbFeature.length < 10) { - deleteGuest(guest); - deleteCount++; - } - } - if (deleteCount > 0) { - BaseApplication.getApplication().activity.fragment_guest_mode.reloadCameraList(); - } - } catch (Exception e) { - e.printStackTrace(); - } - }); - } - } - - public static void enableCamera() { - enableCamera(guestListCameraType, isEnable, outdoor); - } - - public static void enableCamera(int guestListCameraType, boolean isEnable, ModelAdapter outdoor) { - GuestManager.guestListCameraType = guestListCameraType; - GuestManager.isEnable = isEnable; - GuestManager.outdoor = outdoor; - try { - GuestModeFragment guestModeFragment = BaseApplication.getApplication().activity.fragment_guest_mode; - cameraTitle = ""; - if (outdoor != null) { - cameraTitle = outdoor.getString(Outdoor.outdoor_device_name); - } - if (guestListCameraType == 1) { -// if (guestModeFragment.camera1Title != null) { -// GuestManager.cameraOneEnable = isEnable; -// BaseApplication.getApplication().activity.runOnUiThread(() -> { -// -// if (isEnable) { -// if (!TextUtils.isEmpty(cameraTitle)) { -// guestModeFragment.camera1Title.setVisibility(View.VISIBLE); -// guestModeFragment.camera1Title.setText(cameraTitle); -// } else { -// guestModeFragment.camera1Title.setVisibility(View.GONE); -// } -// } else { -// guestModeFragment.camera1Title.setVisibility(View.GONE); -// } -// }); -// -// } - guestModeFragment.reloadCameraOneList(); - } - if (guestListCameraType == 2) { -// if (guestModeFragment.camera2Title != null) { -// GuestManager.cameraTwoEnable = isEnable; -// BaseApplication.getApplication().activity.runOnUiThread(() -> { -// if (isEnable) { -// if (!TextUtils.isEmpty(cameraTitle)) { -// guestModeFragment.camera2Title.setVisibility(View.VISIBLE); -// guestModeFragment.camera2Title.setText(cameraTitle); -// } else { -// guestModeFragment.camera2Title.setVisibility(View.GONE); -// } -// } else { -// guestModeFragment.camera2Title.setVisibility(View.GONE); -// } -// }); -// guestModeFragment.reloadCameraTwoList(); -// } - guestModeFragment.reloadCameraTwoList(); - } - } catch (Exception e) { - System.out.println("GuestManager.enableCamera " + e.getMessage()); - } } public static void removePersonId(String personId) { @@ -193,6 +103,21 @@ } public static boolean twoCameras() { - return false; + if (Constants.USE_GRAY_CAMERA) { + return false; + } + return true; + } + + public static void updateGuestName(ModelAdapter person) { + try { + String personId = person.getString(Person.id); + if (!TextUtils.isEmpty(personId)) { + String personName = person.getString(Person.name); + DatabaseManager.execSQL("update " + Guest.tableName + " set " + Guest.name + "='" + personName + "' where 1=1 and " + Guest.person_id + "='" + personId + "'"); + } + } catch (Exception e) { + e.printStackTrace(); + } } } -- Gitblit v1.8.0