package com.basic.security.fragment;
|
|
import android.annotation.SuppressLint;
|
import android.graphics.Bitmap;
|
import android.graphics.BitmapFactory;
|
import android.graphics.Color;
|
import android.os.Bundle;
|
import android.text.TextUtils;
|
import android.view.LayoutInflater;
|
import android.view.MotionEvent;
|
import android.view.View;
|
import android.view.ViewGroup;
|
import android.widget.AdapterView;
|
import android.widget.BaseAdapter;
|
import android.widget.Button;
|
import android.widget.CheckBox;
|
import android.widget.GridView;
|
import android.widget.ImageView;
|
import android.widget.LinearLayout;
|
import android.widget.ListView;
|
import android.widget.RelativeLayout;
|
import android.widget.TextView;
|
|
import com.basic.security.base.BaseApplication;
|
import com.basic.security.base.BaseFragment;
|
import com.basic.security.manager.BaseSettingManager;
|
import com.basic.security.manager.IdentityManager;
|
import com.basic.security.manager.PersonIdentityManager;
|
import com.basic.security.manager.PersonManager;
|
import com.basic.security.manager.SystemInitManager;
|
import com.basic.security.model.ModelAdapter;
|
import com.basic.security.model.Org;
|
import com.basic.security.model.Person;
|
import com.basic.security.utils.Constants;
|
import com.basic.security.utils.ResolutionAdaptation;
|
import com.basic.security.utils.ToastUtil;
|
import com.basic.security.widget.ConfirmDialog;
|
import com.basic.security.widget.FileChooserDialog;
|
import com.obsez.android.lib.filechooser.MyChooserDialog;
|
|
import org.androidannotations.annotations.AfterViews;
|
import org.androidannotations.annotations.Click;
|
import org.androidannotations.annotations.EFragment;
|
import org.androidannotations.annotations.UiThread;
|
import org.androidannotations.annotations.ViewById;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.HashSet;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
|
@EFragment
|
public class FaceListFragment extends BaseFragment {
|
public static TreeAdapter treeAdapter = new TreeAdapter(true);
|
@ViewById
|
public GridView face_list_show_image, face_filter_identity;
|
@ViewById
|
public TextView not_sign_up, not_sign_up_underline, signed_up, signed_up_underline,
|
identity, tv_person_number, show_checked_identity;
|
@ViewById
|
public LinearLayout face_filter_identity_parent, face_filter_org_parent, identity_show, org_show, ll_show_no_register_number;
|
@ViewById
|
public ListView face_filter_org;
|
@ViewById
|
public Button face_filter_identity_ok;
|
@ViewById
|
public RelativeLayout face_list;
|
@ViewById
|
public View import_excel, importing;
|
public FaceListAdapter faceListAdapter;
|
public boolean firstLoad = true;
|
public IdentityAdapter identityAdapter;
|
public float downY = 0;
|
public float moveY = 0;
|
public MyChooserDialog chooserDialog;
|
public Set<FaceListAdapter.ViewHolder> viewHolderSet = new HashSet<>();
|
public Set<ModelAdapter> batchPersonList = new HashSet<>();
|
public Set<String> batchPersonIdList = new HashSet<>();
|
public String isRegister = "未注册";
|
FileChooserDialog fileChooserDialog = null;
|
ConfirmDialog confirmDialog;
|
boolean orgLoaded = false;
|
|
public String isRegister() {
|
return isRegister;
|
}
|
|
public void isRegister(String isRegister) {
|
if (firstLoad || this.isRegister.equals(isRegister)) {
|
switchUnderline();
|
}
|
this.isRegister = isRegister;
|
}
|
|
@UiThread
|
public void switchUnderline() {
|
if ("未注册".equals(isRegister())) {
|
ll_show_no_register_number.setVisibility(View.GONE);
|
identity_show.setVisibility(View.GONE);
|
org_show.setVisibility(View.GONE);
|
signed_up.setTextColor(Color.parseColor("#ffffff"));
|
signed_up_underline.setVisibility(View.INVISIBLE);
|
not_sign_up_underline.setVisibility(View.VISIBLE);
|
not_sign_up.setTextColor(Color.parseColor("#D5FCFD"));
|
} else {
|
ll_show_no_register_number.setVisibility(View.GONE);
|
identity_show.setVisibility(View.VISIBLE);
|
if (Constants.useOrg) {
|
org_show.setVisibility(View.VISIBLE);
|
}
|
signed_up.setTextColor(Color.parseColor("#D5FCFD"));
|
signed_up_underline.setVisibility(View.VISIBLE);
|
not_sign_up_underline.setVisibility(View.INVISIBLE);
|
not_sign_up.setTextColor(Color.parseColor("#ffffff"));
|
}
|
}
|
|
public void hide() {
|
super.hide();
|
exitBatchMode();
|
try {
|
if (chooserDialog != null) {
|
chooserDialog.dismiss();
|
chooserDialog = null;
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@UiThread
|
public void exitBatchMode() {
|
faceListAdapter.batchMode = false;
|
faceListAdapter.notifyDataSetChanged();
|
mainActivity().long_click_view.setVisibility(View.GONE);
|
mainActivity().showFace(mainActivity().currentFragment);
|
mainActivity().hideOneFragment(mainActivity().fragment_org_person);
|
}
|
|
@UiThread
|
public void enterBatchMode() {
|
faceListAdapter.batchMode = true;
|
mainActivity().long_click_view.setVisibility(View.GONE);
|
mainActivity().showOneFragment(mainActivity().fragment_face_detail);
|
// mainActivity().showOneFragment(mainActivity().fragment_person_identity);
|
mainActivity().hideOneFragment(mainActivity().fragment_org_person);
|
}
|
|
@UiThread
|
public void showImporting() {
|
importing.setVisibility(View.VISIBLE);
|
}
|
|
@UiThread
|
public void hideImporting() {
|
importing.setVisibility(View.GONE);
|
}
|
|
public void importPersonList(String dir) {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
showImporting();
|
try {
|
((FaceListFragment) this).exitBatchMode();
|
PersonManager.importPersonList(dir);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
hideImporting();
|
});
|
}
|
|
@Click
|
public void import_excel() {
|
if (fileChooserDialog == null) {
|
fileChooserDialog = new FileChooserDialog(mainActivity(), "", "确认", "取消");
|
fileChooserDialog.setClickListener(new FileChooserDialog.ClickListenerInterface() {
|
@Override
|
public void doConfirm() {
|
if (!TextUtils.isEmpty(fileChooserDialog.selectedDir)) {
|
importPersonList(fileChooserDialog.selectedDir);
|
}
|
fileChooserDialog.dismiss();
|
}
|
|
@Override
|
public void doCancel() {
|
fileChooserDialog.dismiss();
|
}
|
});
|
}
|
fileChooserDialog.show();
|
}
|
|
public void findPersonList(ModelAdapter selectedPerson) {
|
findPersonList3();
|
findPersonList2(selectedPerson);
|
}
|
|
public void update_tv_person_number() {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
try {
|
update_tv_person_number(PersonManager.getNotSignUpCount());
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
});
|
}
|
|
@UiThread
|
public void update_tv_person_number(int count) {
|
tv_person_number.setText(count + "");
|
}
|
|
public void findPersonList2(ModelAdapter selectedPerson) {
|
if (!TextUtils.isEmpty(this.isRegister()) && "未注册".equals(this.isRegister())) {
|
if (tv_person_number != null) {
|
int size = faceListAdapter.personList.size();
|
if (size > 0) {
|
tv_person_number.setVisibility(View.VISIBLE);
|
} else {
|
// tv_person_number.setVisibility(View.GONE);
|
}
|
tv_person_number.setText(faceListAdapter.personList.size() + ""
|
// + " 人"
|
);
|
}
|
}
|
if (selectedPerson != null) {
|
ModelAdapter selectedPerson1 = null;
|
for (ModelAdapter person : faceListAdapter.personList) {
|
if (selectedPerson.getId().equals(person.getId())) {
|
selectedPerson1 = person;
|
break;
|
}
|
}
|
if (selectedPerson1 != null) {
|
faceListAdapter.personList.remove(selectedPerson1);
|
}
|
mainActivity().fragment_person_manage.selectedPerson = selectedPerson;
|
faceListAdapter.personList.add(0, selectedPerson);
|
}
|
}
|
|
public void findPersonList3() {
|
faceListAdapter.personList = PersonManager.getPersonList(this.isRegister());
|
if (identityAdapter.checkedIdentityMap != null && identityAdapter.checkedIdentityMap.size() != 0) {
|
faceListAdapter.personList = PersonManager.getIdentityPersonList(
|
faceListAdapter.personList, identityAdapter.checkedIdentityMap);
|
}
|
if (treeAdapter.selectedOrg != null) {
|
String selectedOrgId = treeAdapter.selectedOrg.getString(Org.id);
|
if (!TextUtils.isEmpty(selectedOrgId)) {
|
List<ModelAdapter> personList = faceListAdapter.personList;
|
List<ModelAdapter> newPersonList = new ArrayList<>();
|
for (ModelAdapter person : personList) {
|
String person_org_ids = person.getString(Person.org_ids);
|
if (person_org_ids != null && person_org_ids.contains(Org.separator + selectedOrgId + Org.separator)) {
|
newPersonList.add(person);
|
}
|
}
|
faceListAdapter.personList = newPersonList;
|
}
|
}
|
}
|
|
public FaceListFragment getFaceListFragment() {
|
return (FaceListFragment) this;
|
}
|
|
public void findPersonList1() {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
long begin = System.currentTimeMillis();
|
getFaceListFragment().faceListAdapter.setSelection(-1);
|
getFaceListFragment().faceListAdapter.personList = PersonManager.getPersonList(getFaceListFragment().isRegister());
|
if (getFaceListFragment().identityAdapter.checkedIdentityMap != null && getFaceListFragment().identityAdapter.checkedIdentityMap.size() != 0) {
|
getFaceListFragment().faceListAdapter.personList = PersonManager.getIdentityPersonList(
|
getFaceListFragment().faceListAdapter.personList, getFaceListFragment().identityAdapter.checkedIdentityMap);
|
}
|
if (getFaceListFragment().treeAdapter.selectedOrg != null) {
|
String selectedOrgId = getFaceListFragment().treeAdapter.selectedOrg.getString(Org.id);
|
if (!TextUtils.isEmpty(selectedOrgId)) {
|
List<ModelAdapter> personList = getFaceListFragment().faceListAdapter.personList;
|
getFaceListFragment().faceListAdapter.personList = PersonManager.filterByOrgId(personList, selectedOrgId);
|
}
|
}
|
ModelAdapter selectedPerson;
|
if (getFaceListFragment().faceListAdapter.personList.size() != 0) {
|
selectedPerson = getFaceListFragment().faceListAdapter.personList.get(0);
|
mainActivity().fragment_face_detail.checkedIdentityMapByPerson.clear();
|
mainActivity().fragment_face_detail.checkedIdentityMapByPerson.putAll(PersonIdentityManager.findIdentityMapByPersonId(selectedPerson.getString(Person.id)));
|
} else {
|
selectedPerson = null;
|
mainActivity().fragment_face_detail.checkedIdentityMapByPerson.clear();
|
}
|
findPersonList1UI(selectedPerson);
|
});
|
}
|
|
@UiThread
|
public void findPersonList1UI(ModelAdapter selectedPerson) {
|
mainActivity().fragment_person_manage.selectedPerson = selectedPerson;
|
if (!TextUtils.isEmpty(getFaceListFragment().isRegister()) && "未注册".equals(getFaceListFragment().isRegister())) {
|
int size = getFaceListFragment().faceListAdapter.personList.size();
|
if (size > 0) {
|
getFaceListFragment().tv_person_number.setVisibility(View.VISIBLE);
|
} else {
|
// getFaceListFragment().tv_person_number.setVisibility(View.GONE);
|
}
|
getFaceListFragment().tv_person_number.setText(size + ""
|
// + " 人"
|
);
|
}
|
if (selectedPerson != null) {
|
if ("未验证身份证".equals(selectedPerson.getString("verify_status"))) {
|
mainActivity().fragment_person_manage.setNeedVerifyIDCard(true);
|
} else {
|
mainActivity().fragment_person_manage.setNeedVerifyIDCard(false);
|
}
|
getFaceListFragment().faceListAdapter.setSelection(0);
|
getFaceListFragment().faceListAdapter.notifyDataSetChanged();
|
}
|
mainActivity().fragment_face_detail.updateDetailUI(selectedPerson);
|
mainActivity().fragment_face_detail.updateIdentityListUI1(selectedPerson);
|
}
|
|
public void findPersonList() {
|
findPersonList(null);
|
findPersonList3();
|
}
|
|
public void findPersonList(String isRegisterIgnoreNull, Map<String, ModelAdapter> checkedIdentityMapIgnoreNull) {
|
findPersonList(isRegisterIgnoreNull, checkedIdentityMapIgnoreNull, null);
|
}
|
|
public void findPersonList(String isRegisterIgnoreNull, Map<String, ModelAdapter> checkedIdentityMapIgnoreNull, ModelAdapter selectedPerson) {
|
mainActivity().runOnUiThread(() -> {
|
if (checkedIdentityMapIgnoreNull != null) {
|
identityAdapter.checkedIdentityMap = checkedIdentityMapIgnoreNull;
|
}
|
faceListAdapter.setSelection(-1);
|
findPersonList(selectedPerson);
|
if (faceListAdapter.personList.size() != 0) {
|
setDefaultAndSelectedPerson(0);
|
} else {
|
mainActivity().fragment_person_manage.personChanged(null, false, false);
|
}
|
});
|
}
|
|
public void setDefaultAndSelectedPerson(int position) {
|
if (position < 0) {
|
mainActivity().fragment_person_manage.personChanged(null, true, false);
|
} else {
|
mainActivity().fragment_person_manage.personChanged(faceListAdapter.personList.get(position), true, false);
|
isNeedIDCard(position);
|
}
|
faceListAdapter.setSelection(position);
|
faceListAdapter.notifyDataSetChanged();
|
}
|
|
public void isNeedIDCard(int position) {
|
if ("未验证身份证".equals(faceListAdapter.personList.get(position).getString("verify_status"))) {
|
mainActivity().fragment_person_manage.setNeedVerifyIDCard(true);
|
} else {
|
mainActivity().fragment_person_manage.setNeedVerifyIDCard(false);
|
}
|
}
|
|
public void findNextPosition(ModelAdapter savedOrDeletedPerson, boolean isDelete) {
|
try {
|
int position = faceListAdapter.personList.indexOf(savedOrDeletedPerson);
|
mainActivity().fragment_face_list.findPersonList();
|
if (position >= faceListAdapter.personList.size()) {
|
position = faceListAdapter.personList.size() - 1;
|
}
|
setDefaultAndSelectedPerson(position);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Click
|
public void identity_show() {
|
((FaceListFragment) this).exitBatchMode();
|
identityAdapter.checkedIdentityMapBackup = new HashMap<>(identityAdapter.checkedIdentityMap);
|
face_filter_identity_parent.setVisibility(View.VISIBLE);
|
identityAdapter.findIdentityList();
|
}
|
|
public void findIdentityList(IdentityAdapter identityAdapter) {
|
BaseApplication.getApplication().executorService.execute(() -> {
|
identityAdapter.identityList = IdentityManager.findIdentityList();
|
updateIdentityList(identityAdapter);
|
});
|
}
|
|
@UiThread
|
public void updateIdentityList(IdentityAdapter identityAdapter) {
|
identityAdapter.notifyDataSetChanged();
|
}
|
|
@Click
|
public void face_filter_identity_ok() {
|
((FaceListFragment) this).exitBatchMode();
|
face_filter_identity_parent.setVisibility(View.GONE);
|
if (identityAdapter.checkedIdentityMap.size() != 0) {
|
show_checked_identity.setVisibility(View.VISIBLE);
|
StringBuffer sb = new StringBuffer();
|
for (ModelAdapter value : identityAdapter.checkedIdentityMap.values()) {
|
sb.append(value.getString("name") + ",");
|
}
|
show_checked_identity.setVisibility(View.GONE);
|
show_checked_identity.setText("已选择:" + sb.substring(0, sb.length() - 1));
|
} else {
|
show_checked_identity.setVisibility(View.GONE);
|
}
|
mainActivity().fragment_face_list.findPersonList("已注册", identityAdapter.checkedIdentityMap);
|
treeAdapter.clearUI();
|
}
|
|
public void hideFaceFilterIdentityFromNotOkButton() {
|
if (face_filter_identity_parent.getVisibility() == View.VISIBLE) {
|
face_filter_identity_parent.setVisibility(View.GONE);
|
identityAdapter.checkedIdentityMap = identityAdapter.checkedIdentityMapBackup;
|
}
|
}
|
|
public void batch_move_to_org() {
|
mainActivity().hideOneFragment(mainActivity().fragment_face_detail);
|
mainActivity().showOneFragment(mainActivity().fragment_org_person);
|
}
|
|
public void batch_delete_person() {
|
if (batchPersonList.size() == 0) {
|
ToastUtil.show("请选择要删除的人员");
|
return;
|
}
|
confirmDialog = new ConfirmDialog(mainActivity(), "确认是否删除", "确认删除", "取消");
|
confirmDialog.show();
|
confirmDialog.setClickListener(new ConfirmDialog.ClickListenerInterface() {
|
public void doConfirm() {
|
PersonManager.deletePersonList(new ArrayList<>(batchPersonList));
|
ToastUtil.show("删除成功");
|
mainActivity().fragment_face_list.findPersonList(null, null);
|
mainActivity().fragment_face_list.exitBatchMode();
|
confirmDialog.dismiss();
|
}
|
|
public void doCancel() {
|
mainActivity().fragment_face_list.exitBatchMode();
|
confirmDialog.dismiss();
|
}
|
});
|
}
|
|
public void hideFaceFilterOrgParent() {
|
face_filter_org_parent.setVisibility(View.GONE);
|
}
|
|
@Click
|
public void org_show() {
|
org_show_background();
|
face_filter_org_parent.setVisibility(View.VISIBLE);
|
}
|
|
public void org_show_background() {
|
if (!orgLoaded || 1 == 1) {
|
treeAdapter.findTreeNodeList(false);
|
orgLoaded = true;
|
}
|
}
|
|
public void showPersonListByOrg(ModelAdapter org) {
|
((FaceListFragment) this).exitBatchMode();
|
face_filter_org_parent.setVisibility(View.GONE);
|
mainActivity().fragment_face_list.findPersonList("已注册", new HashMap<>());
|
treeAdapter.selectedOrg = null;
|
}
|
|
@Click
|
public void not_sign_up() {
|
((FaceListFragment) this).exitBatchMode();
|
isRegister("未注册");
|
mainActivity().fragment_face_list.findPersonList("未注册", new HashMap<>());
|
treeAdapter.clearUI();
|
}
|
|
@Click
|
public void signed_up() {
|
((FaceListFragment) this).exitBatchMode();
|
isRegister("已注册");
|
show_checked_identity.setVisibility(View.GONE);
|
mainActivity().fragment_face_list.findPersonList("已注册", new HashMap<>());
|
treeAdapter.clearUI();
|
}
|
|
@Click
|
public void show_camera() {
|
if (BaseSettingManager.isPassMode()) {
|
ToastUtil.show("通行模式不允许注册");
|
} else {
|
if (BaseSettingManager.isAdminAuthSignUpModeNeedIdCard()
|
|| BaseSettingManager.isAutoSignUpIDCardMode()) {
|
mainActivity().showFragment(mainActivity().fragment_su_logged_ic_wait_face);
|
SystemInitManager.hideSecondDisplay(mainActivity());
|
} else {
|
mainActivity().showFragment(mainActivity().fragment_su_logged_nic_wait_face);
|
SystemInitManager.hideSecondDisplay(mainActivity());
|
}
|
}
|
}
|
|
@SuppressLint("ClickableViewAccessibility")
|
@Click
|
public void face_list() {
|
face_list.setOnTouchListener((v, event) -> {
|
switch (event.getAction()) {
|
case MotionEvent.ACTION_DOWN:
|
downY = event.getY();
|
break;
|
case MotionEvent.ACTION_MOVE:
|
break;
|
case MotionEvent.ACTION_UP:
|
moveY = event.getY() - downY;
|
break;
|
}
|
return false;
|
});
|
if (Math.abs(moveY) > 240) {
|
show_camera();
|
}
|
}
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
return inflater.inflate(ResolutionAdaptation.fragment_face_list(), container, false);
|
}
|
|
@AfterViews
|
public void afterViews() {
|
identityAdapter = new IdentityAdapter();
|
face_filter_identity.setAdapter(identityAdapter);
|
treeAdapter.setOrgSelectedListener(this::showPersonListByOrg);
|
face_filter_org.setAdapter(treeAdapter);
|
faceListAdapter = new FaceListAdapter();
|
face_list_show_image.setAdapter(faceListAdapter);
|
face_list_show_image.setOnItemLongClickListener((AdapterView<?> parent, View view, int position, long id) -> {
|
if (!faceListAdapter.batchMode) {
|
batchPersonList.clear();
|
batchPersonIdList.clear();
|
for (FaceListAdapter.ViewHolder viewHolder : viewHolderSet) {
|
viewHolder.imageView_checked.setVisibility(View.GONE);
|
}
|
}
|
faceListAdapter.batchMode = true;
|
mainActivity().long_click_view.setVisibility(View.VISIBLE);
|
return false;
|
});
|
face_list_show_image.setOnItemClickListener((AdapterView<?> adapterView, View view, int position, long l) -> {
|
if (faceListAdapter.batchMode) {
|
ModelAdapter batchPerson = faceListAdapter.personList.get(position);
|
if (batchPersonList.contains(batchPerson)) {
|
batchPersonList.remove(batchPerson);
|
batchPersonIdList.remove(batchPerson.getId());
|
((FaceListAdapter.ViewHolder) view.getTag()).imageView_checked.setVisibility(View.GONE);
|
} else {
|
batchPersonList.add(batchPerson);
|
batchPersonIdList.add(batchPerson.getId());
|
((FaceListAdapter.ViewHolder) view.getTag()).imageView_checked.setVisibility(View.VISIBLE);
|
}
|
} else {
|
try {
|
ModelAdapter person = faceListAdapter.personList.get(position);
|
isNeedIDCard(position);
|
mainActivity().fragment_person_manage.selectedPerson = person;
|
mainActivity().fragment_face_detail.updateIdentityListUI2(person);
|
mainActivity().fragment_face_detail.updateDetailUI(person);
|
faceListAdapter.setSelection(position);
|
faceListAdapter.notifyDataSetChanged();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
});
|
if (Constants.useImport) {
|
import_excel.setVisibility(View.VISIBLE);
|
} else {
|
import_excel.setVisibility(View.GONE);
|
}
|
}
|
|
public class FaceListAdapter extends BaseAdapter {
|
public List<ModelAdapter> personList = new ArrayList<>();
|
public int clickTemp = -1;
|
public boolean batchMode = false;
|
|
public void setSelection(int position) {
|
clickTemp = position;
|
}
|
|
public int getCount() {
|
return personList == null ? 0 : personList.size();
|
}
|
|
public Object getItem(int position) {
|
return personList.get(position);
|
}
|
|
public long getItemId(int position) {
|
return position;
|
}
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
ViewHolder viewHolder;
|
if (convertView == null) {
|
convertView = LayoutInflater.from(getContext()).inflate(com.basic.security.utils.ResolutionAdaptation.face_view(), null);
|
viewHolder = new ViewHolder(convertView);
|
viewHolderSet.add(viewHolder);
|
convertView.setTag(viewHolder);
|
} else {
|
viewHolder = (ViewHolder) convertView.getTag();
|
}
|
viewHolder.person = personList.get(position);
|
viewHolder.position = position;
|
viewHolder.updateData();
|
return convertView;
|
}
|
|
public class ViewHolder {
|
public ImageView imageView;
|
public ModelAdapter person;
|
public RelativeLayout imageView_checked;
|
public int position = 0;
|
|
public ViewHolder(View convertView) {
|
imageView = convertView.findViewById(com.basic.security.utils.RUtils.R_id_face);
|
imageView_checked = convertView.findViewById(com.basic.security.utils.RUtils.R_id_face_checked);
|
}
|
|
public void updateData() {
|
byte[] blob = person.getBlob("camera_image_path");
|
Bitmap bitmap = null;
|
if (blob != null) {
|
try {
|
if (blob.length != 0) {
|
bitmap = BitmapFactory.decodeByteArray(blob, 0, blob.length);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
bitmap = BitmapFactory.decodeResource(mainActivity().getResources(), com.basic.security.utils.RUtils.R_drawable_u1280);
|
}
|
} else {
|
bitmap = BitmapFactory.decodeResource(mainActivity().getResources(), com.basic.security.utils.RUtils.R_drawable_u1280);
|
}
|
imageView.setImageBitmap(bitmap);
|
if (batchMode) {
|
String personId = person.getString(Person.id);
|
if (batchPersonIdList.contains(personId)) {
|
imageView_checked.setVisibility(View.VISIBLE);
|
} else {
|
imageView_checked.setVisibility(View.GONE);
|
}
|
} else {
|
if (clickTemp == position) {
|
imageView_checked.setVisibility(View.VISIBLE);
|
} else {
|
imageView_checked.setVisibility(View.GONE);
|
}
|
}
|
imageView_checked.requestLayout();
|
imageView_checked.invalidate();
|
}
|
}
|
}
|
|
public class IdentityAdapter extends BaseAdapter {
|
public Map<String, ModelAdapter> checkedIdentityMap = new HashMap<>();
|
public Map<String, ModelAdapter> checkedIdentityMapBackup = new HashMap<>();
|
private List<ModelAdapter> identityList;
|
|
public IdentityAdapter() {
|
}
|
|
public void findIdentityList() {
|
FaceListFragment.this.findIdentityList(this);
|
}
|
|
public int getCount() {
|
return identityList == null ? 0 : identityList.size();
|
}
|
|
public Object getItem(int position) {
|
return identityList.get(position);
|
}
|
|
public long getItemId(int position) {
|
return position;
|
}
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
View view;
|
ViewHolder viewHolder;
|
if (convertView == null) {
|
view = LayoutInflater.from(getContext()).inflate(com.basic.security.utils.ResolutionAdaptation.item_identity_list(), null);
|
viewHolder = new ViewHolder();
|
viewHolder.checkBox = view.findViewById(com.basic.security.utils.RUtils.R_id_item_ck);
|
view.setTag(viewHolder);
|
} else {
|
view = convertView;
|
viewHolder = (ViewHolder) view.getTag();
|
}
|
final ModelAdapter singleIdentityInAllIdentity = identityList.get(position);
|
viewHolder.checkBox.setText(identityList.get(position).getString("name"));
|
if (identityAdapter.checkedIdentityMap.containsKey(singleIdentityInAllIdentity.getId())) {
|
viewHolder.checkBox.setChecked(true);
|
} else {
|
viewHolder.checkBox.setChecked(false);
|
}
|
viewHolder.checkBox.setOnClickListener(v -> {
|
if (identityAdapter.checkedIdentityMap.containsKey(singleIdentityInAllIdentity.getId())) {
|
identityAdapter.checkedIdentityMap.remove(singleIdentityInAllIdentity.getId());
|
} else {
|
identityAdapter.checkedIdentityMap.put(singleIdentityInAllIdentity.getId(), singleIdentityInAllIdentity);
|
}
|
});
|
return view;
|
}
|
|
class ViewHolder {
|
CheckBox checkBox;
|
}
|
}
|
}
|