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
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 生活相关 名片识别源码.rar
共174个文件
class:75个
java:28个
png:28个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 50 浏览量
2023-03-29
19:53:25
上传
评论
收藏 7MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 生活相关 名片识别源码.rar (174个子文件)
resources.ap_ 253KB
NameCardRec.apk 2.6MB
ContactPerson.class 25KB
DisplayRecResult.class 18KB
StaticRecFromCamera.class 17KB
NamecardImageGallery.class 14KB
PgmImage.class 8KB
OCRItems.class 6KB
OriginalImageView.class 6KB
RecFromSdcard.class 5KB
StaticRecFromCamera$1.class 4KB
StaticRecFromCamera$JpegPictureCallback.class 4KB
NamecardImageGallery$ThumbImageAdapter.class 3KB
NameCardRec.class 3KB
StaticRecFromCamera$SaveJpegThread.class 3KB
ScannerAnimation.class 3KB
DisplayRecResult$DialogClickListener.class 3KB
OCRManager.class 3KB
ContactPerson$SelectItemTypeListener.class 3KB
RecThread.class 3KB
NamecardImageGallery$1.class 3KB
StaticRecFromCamera$AutoFocusCallback.class 3KB
ContactPerson$RemoveItemListener.class 2KB
PrefSettings.class 2KB
R$string.class 2KB
StaticRecFromCamera$4.class 2KB
NamecardImageGallery$5.class 2KB
NamecardImageGallery$MyGestureListener.class 2KB
DisplayRecResult$ContactInfoAdapter.class 2KB
RecInProgress.class 2KB
RecFromSdcard$1.class 2KB
StaticRecFromCamera$PreviewCallback.class 2KB
RecFromFileThread.class 2KB
ContactPerson$SaveContactThread.class 2KB
StaticRecFromCamera$5.class 2KB
R$id.class 2KB
OCRManager$PgmOCRThread.class 2KB
ImageHelper.class 2KB
R$drawable.class 2KB
ScannerView.class 1KB
NamecardImageGallery$4.class 1KB
StaticRecFromCamera$3.class 1KB
StaticRecFromCamera$RawPictureCallback.class 1KB
NamecardImageGallery$2.class 1KB
NamecardImageGallery$3.class 1KB
NamecardImageGallery$6.class 1KB
RecFromSdcard$PgmFileFilter.class 1KB
StaticRecFromCamera$2.class 1KB
DisplayRecResult$4.class 1KB
DisplayRecResult$2.class 1KB
StopWorkThread.class 1KB
DisplayRecResult$1.class 1KB
NamecardImageGallery$JpgFileFilter.class 1KB
DisplayRecResult$DataHolder.class 944B
DisplayRecResult$3.class 926B
StaticRecFromCamera$ShutterCallback.class 897B
R$layout.class 858B
Constants.class 851B
R.class 751B
NativeOCRItems.class 691B
ContactPerson$ItemIdentifier.class 652B
DisplayRecResult$ContactGroup.class 621B
R$styleable.class 597B
MessageId.class 560B
Organization.class 546B
Address.class 532B
Email.class 507B
Phone.class 507B
Url.class 501B
R$array.class 467B
BaseDomain.class 459B
R$anim.class 453B
R$style.class 436B
ContactPerson$OnSelectItemType.class 347B
R$attr.class 346B
OriginalImageView$OnZoomOutToMinListener.class 300B
OriginalImageView$OnZoomInToMaxListener.class 297B
.classpath 273B
Thumbs.db 92KB
classes.dex 107KB
logo_sharp.gif 804B
rec_selected_card.ico 4KB
contact_discard.ico 2KB
settings.ico 2KB
contact_save.ico 2KB
ContactPerson.java 33KB
DisplayRecResult.java 25KB
StaticRecFromCamera.java 19KB
NamecardImageGallery.java 14KB
PgmImage.java 11KB
R.java 10KB
OCRItems.java 9KB
OriginalImageView.java 6KB
RecFromSdcard.java 4KB
OCRManager.java 4KB
NameCardRec.java 3KB
ScannerAnimation.java 3KB
RecThread.java 2KB
PrefSettings.java 2KB
RecFromFileThread.java 1KB
共 174 条
- 1
- 2
资源评论
荣华富贵8
- 粉丝: 151
- 资源: 7645
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 小程序版基于人工智能的卷积网络训练识别花卉颜色-不含数据集图片-含逐行注释和说明文档.zip
- 小程序版通过CNN卷积神经网络的甜点识别-不含数据集图片-含逐行注释和说明文档.zip
- 小程序版基于深度学习对辣椒类别识别-不含数据集图片-含逐行注释和说明文档.zip
- 小程序版python语言pytorch框架的图像分类室内照明布局风格识别-不含数据集图片-含逐行注释和说明文档.zip
- Linux系统常用命令.md
- 小程序版图像分类算法对人脸识别-不含数据集图片-含逐行注释和说明文档.zip
- 小程序版python语言pytorch框架的图像分类蔬菜根系结构识别-不含数据集图片-含逐行注释和说明文档.zip
- Linux系统常用命令.md
- 英飞凌MCAL和VADC模块配置资料说明TC234L
- 表白HTML网站源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功