package cn.sharp.android.ncr.display;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.provider.Contacts;
import android.text.InputType;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import cn.sharp.android.ncr.MessageId;
import cn.sharp.android.ncr.R;
import cn.sharp.android.ncr.display.domain.Address;
import cn.sharp.android.ncr.display.domain.BaseDomain;
import cn.sharp.android.ncr.display.domain.Email;
import cn.sharp.android.ncr.display.domain.Organization;
import cn.sharp.android.ncr.display.domain.Phone;
import cn.sharp.android.ncr.display.domain.Url;
import cn.sharp.android.ncr.ocr.OCRItems;
public class ContactPerson {
private final static String TAG = "ContactPerson";
public final static int ITEM_NAME = 1;
public final static int ITEM_PHONE = 2;
public final static int ITEM_EMAIL = 3;
public final static int ITEM_ADDRESS = 4;
public final static int ITEM_ORG = 5;
public final static int ITEM_URL = 6;
public final static int ITEM_NOTE = 7;
public final static int TYPE_HOME = 1;
public final static int TYPE_WORK = 2;
public final static int TYPE_OTHER = 3;
public final static int TYPE_PAGER = 4;
public final static int TYPE_MOBILE = 5;
public final static int TYPE_FAX_HOME = 6;
public final static int TYPE_FAX_WORK = 7;
private long groupId;
private String name;
private List<Email> emails;
private List<Phone> phones;
private List<Organization> orgs;
private List<Address> addresses;
private List<Url> urls;
private String note;
public String typeHome, typeWork, typeOther, typePager, typeMobile,
typeFaxHome, typeFaxWork;
private int[] supportedItemTypes1;
private int[] supportedItemTypes2;
private int[] supportedItemTypes3;
private String[] supportedItemTypeStr1;
private String[] supportedItemTypeStr2;
private String[] supportedItemTypeStr3;
private OnSelectItemType onSelectItemType;
private ContentResolver contentResolver;
private SelectItemTypeListener onSelectTypeListener;
private RemoveItemListener removeItemListener;
private EditText nameView, noteView;
private ViewGroup phoneViewGroup, emailViewGroup, addressViewGroup,
orgViewGroup, urlViewGroup;
private Button itemType;
private EditText itemValue, itemValue2;
private ImageButton removeItem;
private LayoutInflater inflater;
/**
* remove all Context reference, or it will result in memory leak
*/
public void removeAllContextObject() {
onSelectItemType = null;
contentResolver = null;
onSelectTypeListener = null;
removeItemListener = null;
nameView = null;
noteView = null;
phoneViewGroup = emailViewGroup = addressViewGroup = orgViewGroup = urlViewGroup = null;
inflater = null;
itemType = null;
itemValue = null;
itemValue2 = null;
removeItem = null;
}
public void registerNewContext(Context context) {
init(context);
}
private void initPrimitiveObj() {
groupId = -1;
phones = new ArrayList<Phone>();
orgs = new ArrayList<Organization>();
emails = new ArrayList<Email>();
addresses = new ArrayList<Address>();
urls = new ArrayList<Url>();
supportedItemTypes1 = new int[] { TYPE_HOME, TYPE_WORK, TYPE_MOBILE,
TYPE_OTHER, TYPE_PAGER, TYPE_FAX_HOME, TYPE_FAX_WORK };
supportedItemTypes2 = new int[] { TYPE_WORK, TYPE_OTHER };
supportedItemTypes3 = new int[] { TYPE_WORK, TYPE_HOME, TYPE_OTHER };
supportedItemTypeStr1 = new String[] { typeHome, typeWork, typeMobile,
typeOther, typePager, typeFaxHome, typeFaxWork };
supportedItemTypeStr2 = new String[] { typeWork, typeOther };
supportedItemTypeStr3 = new String[] { typeWork, typeHome, typeOther };
onSelectTypeListener = new SelectItemTypeListener();
removeItemListener = new RemoveItemListener();
}
private void init(Context context) {
inflater = LayoutInflater.from(context);
contentResolver = context.getContentResolver();
Resources resources = context.getResources();
typeHome = resources.getString(R.string.type_home);
typeWork = resources.getString(R.string.type_work);
typeOther = resources.getString(R.string.type_other);
typePager = resources.getString(R.string.type_pager);
typeMobile = resources.getString(R.string.type_mobile);
typeFaxHome = resources.getString(R.string.type_fax_home);
typeFaxWork = resources.getString(R.string.type_fax_work);
}
public ContactPerson(Context context) {
init(context);
initPrimitiveObj();
}
public ContactPerson(Context context, OCRItems items) {
init(context);
initPrimitiveObj();
if (items.name != null) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < items.name.length; i++) {
sb.append(items.name[i]);
}
name = sb.toString();
}
if (items.fax != null) {
for (int i = 0; i < items.fax.length; i++) {
Phone phone = new Phone();
phone.type = TYPE_FAX_WORK;
phone.value = items.fax[i];
phones.add(phone);
}
}
if (items.telephone != null) {
for (int i = 0; i < items.telephone.length; i++) {
Phone phone = new Phone();
phone.type = TYPE_MOBILE;
phone.value = items.telephone[i];
phones.add(phone);
}
}
if (items.cellphone != null) {
for (int i = 0; i < items.cellphone.length; i++) {
Phone phone = new Phone();
phone.type = TYPE_MOBILE;
phone.value = items.cellphone[i];
phones.add(phone);
}
}
if (items.organization != null) {
for (int i = 0; i < items.organization.length; i++) {
Organization org = new Organization();
org.company = items.organization[i];
org.type = TYPE_WORK;
if (items.department != null && items.department.length > i) {
org.company += "," + items.department[i];
}
if (items.title != null && items.title.length > i) {
org.title = items.title[i];
} else {
org.title = "";
}
orgs.add(org);
}
/**
* add the remained items.department fields
*/
if (items.department != null) {
for (int i = items.organization.length; i < items.department.length; i++) {
Organization org = new Organization();
org.company = items.department[i];
org.type = TYPE_WORK;
if (items.title != null && items.title.length > i) {
org.title = items.title[i];
} else {
org.title = "";
}
orgs.add(org);
}
}
} else if (items.department != null) {
/**
* if items.orgnization==null&&items.department!=null, treat
* items.department as org.company value
*/
for (int i = 0; i < items.department.length; i++) {
Organization org = new Organization();
org.company = items.department[i];
org.type = TYPE_WORK;
if (items.title != null && items.title.length > i) {
org.title = items.title[i];
} else {
org.title = "";
}
orgs.add(org);
}
}
if (items.email != null) {
for (int i = 0; i < items.email.length; i++) {
Email email = new Email();
email.type = TYPE_WORK;
email.value = items.email[i];
emails.add(email);
}
}
if (items.address != null) {
for (int i = 0; i < items.address.length; i++) {
Address address = new Address();
address.type = TYPE_WORK;
address.value = items.address[i];
addresses.add(address);
if (items.postcode != null && items.postcode.length > i) {
address.postcode = items.postcode[i];
} else {
address.postcode = "";
}
}
}
if (items.url != null) {
for (int i = 0; i < items.url.length; i++) {
Url url = new Url();
url.type = TYPE_WORK;
url.value = items.url[i];
urls.add(url);
}
}
}
/**
* bind the data to corresponding views
*
* @param nameView
* @param phoneViewG
荣华富贵8
- 粉丝: 223
- 资源: 7653
最新资源
- 信捷XC PLC与力士乐VFC-x610变频器通讯程序原创可直接用于生产的程序,程序带注释,并附送触摸屏程序,有接线方式和设置,通讯地址说明等 程序采用轮询,可靠稳定 器件:信捷XC3的PLC,博世
- CMIP6 变量详细表格
- KF2EDGK系列5.08接线端子,带3D封装
- 信捷XC PLC与3台力士乐VFC-x610变频器通讯通讯 原创可直接用于生产的程序,程序带注释,并附送触摸屏程序,有接线方式和设置,通讯地址说明等 程序采用轮询,可靠稳定 器件:信捷XC3的PLC
- org.xmind.ui.mindmap-3.6.1.jar
- 16台搅拌机定时控制程序16台搅拌机定时控制,使用三菱FX系列PLC,威伦通触摸屏,具备完善的控制功能
- 微网双层优化模型matlab 采用yalmip编写三个微网的分层优化模型,考虑电价的负荷响应,综合配电网运营商收益和用户购电成本,程序运行稳定
- rv1126交叉编译工具链gcc-arm-8.3-2019.02-x86-64-arm-linux-gnueabihf.tar.xz和安装步骤
- 1960-2023年世界各国国民总收入数据
- 风储深度调峰模型matlab 考虑风储的调峰模型,采用cplex作为求解器,实现不同主体出力优化控制,程序运行稳定,有参考资料,
- 计算机系统安全性与性能评估:IOMMU在Linux环境下的性能研究及其优化策略
- 电动汽车蒙特卡洛分析matlab 通过matlab程序编写电动汽车蒙特卡洛模型,得到汽车行驶里程的概率分布曲线和充电功率曲线,程序运行可靠,有参考资料
- 考虑交通流量的电动汽车充电站规划matlab 程序采用matlab编制,采用粒子群算法,结合交通网络流量,得到最终充电站规划方案,程序运行可靠
- rustdesk-1.3.6-x86-64.msi
- 电动汽车优化模型matlab 狼群算法
- 你还在为伺服驱动器 FPGA架构苦恼吗,本方案FPGA代码实现电流环 速度环 位置环 SVPWM 坐标变 测速 分频 滤波器等,程序方便移植不同的平台,具有很高的研究价值
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈