package com.android.haven.contact;
import java.util.List;
import com.android.haven.adapter.ContactAdapter;
import com.android.haven.adapter.ContactEntity;
import com.android.haven.listener.ContactListener;
import com.android.haven.service.ContactService;
import android.app.ProgressDialog;
import android.app.TabActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.Toast;
public class ContactManagerActvity extends TabActivity {
public TabHost myTabHost;
private ListView phoneListView;
private ListView simListView;
public ContactAdapter phoneAdapter;
public ContactAdapter simAdapter;
public List<ContactEntity> phoneList;
public List<ContactEntity> simList;
public boolean canDelete = true;
private ProgressDialog dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.contact_manager);
myTabHost = getTabHost();
myTabHost.addTab(myTabHost
.newTabSpec("0")
.setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
return ContactManagerActvity.this
.findViewById(R.id.phone_contacts);
}
})
.setIndicator(
"手机联系人",
ContactManagerActvity.this.getResources().getDrawable(
R.drawable.phone)));
myTabHost.addTab(myTabHost
.newTabSpec("1")
.setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
return ContactManagerActvity.this
.findViewById(R.id.sim_contacts);
}
})
.setIndicator(
"SIM联系人",
ContactManagerActvity.this.getResources().getDrawable(
R.drawable.sim)));
TabWidget widget = getTabWidget();
View v0 = widget.getChildAt(0);
View v1 = widget.getChildAt(1);
v0.getLayoutParams().height = 58;
v1.getLayoutParams().height = 58;
phoneListView = (ListView) findViewById(R.id.phone_contacts);
simListView = (ListView) findViewById(R.id.sim_contacts);
phoneListView.setOnItemClickListener(ContactListener.instance().new MyListItemOnClickListener(this));
simListView.setOnItemClickListener(ContactListener.instance().new MyListItemOnClickListener(this));
phoneList = ContactService.instance().loadInfoFromPhone(this,0);
phoneAdapter = new ContactAdapter(ContactManagerActvity.this, phoneList);
phoneListView.setAdapter(phoneAdapter);
simList = ContactService.instance().loadInfoFromPhone(this,1);
simAdapter = new ContactAdapter(ContactManagerActvity.this, simList);
simListView.setAdapter(simAdapter);
myTabHost.setCurrentTab(0);
myTabHost.setCurrentTab(1);
myTabHost.setCurrentTab(0);
dialog = new ProgressDialog(this);
dialog.setMessage("删除中!");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 0, "选择全部").setIcon(
getResources().getDrawable(R.drawable.choose_all));
menu.add(0, 2, 0, "取消选中").setIcon(
getResources().getDrawable(R.drawable.cancel_all));
menu.add(0, 3, 0, "删除选中").setIcon(
getResources().getDrawable(R.drawable.delete));
menu.add(0, 4, 0, "推出系统").setIcon(
getResources().getDrawable(R.drawable.exit));
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
ContactService.instance().checkAll(this);
break;
case 2:
ContactService.instance().cancelAll(this);
break;
case 3:
dialog.show();
ContactService.instance().deleteSelectedItems(this);
break;
case 4:
this.finish();
System.exit(0);
break;
default:
break;
}
return true;
}
public Handler myHandler = new Handler(){
@Override
public void handleMessage(Message msg){
ContactEntity entity = null;
Intent intent = null;
Uri uri = null;
switch(msg.what){
case 0:
phoneAdapter.notifyDataSetChanged();
canDelete = true;
break;
case 1:
simAdapter.notifyDataSetChanged();
canDelete = true;
break;
case 2:
dialog.cancel();
Toast.makeText(getApplicationContext(), "删除操作结束!", Toast.LENGTH_LONG).show();
break;
case 10:
if(myTabHost.getCurrentTab() == 0)
entity = phoneList.get(msg.arg1);
else
entity = simList.get(msg.arg1);
if(entity.getPhoneNum() == null || entity.getPhoneNum().equals("") ){
Toast.makeText(ContactManagerActvity.this, "号码格式错误!", Toast.LENGTH_LONG).show();
ContactListener.instance().dialog.cancel();
return;
}
uri = Uri.parse("tel:"+entity.getPhoneNum());
intent = new Intent(Intent.ACTION_CALL,uri);
startActivity(intent);
ContactListener.instance().dialog.cancel();
break;
case 11:
if(myTabHost.getCurrentTab() == 0)
entity = phoneList.get(msg.arg1);
else
entity = simList.get(msg.arg1);
if(entity.getPhoneNum() == null || entity.getPhoneNum().equals("")){
Toast.makeText(ContactManagerActvity.this, "号码格式错误!", Toast.LENGTH_LONG).show();
ContactListener.instance().dialog.cancel();
return;
}
uri = Uri.parse("smsto:"+entity.getPhoneNum());
intent = new Intent(Intent.ACTION_SENDTO,uri);
startActivity(intent);
ContactListener.instance().dialog.cancel();
break;
case 12:
if(ContactService.instance().deleteSelectedItem(ContactManagerActvity.this, msg.arg1) == 1)
Toast.makeText(ContactManagerActvity.this, "删除成功!", Toast.LENGTH_LONG).show();
ContactListener.instance().dialog.cancel();
break;
case 13:
ContactListener.instance().dialog.cancel();
break;
default:
break;
}
}
};
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序 一个批量删除联系人的Demo.rar
共58个文件
png:20个
class:19个
java:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 127 浏览量
2023-02-03
11:52:41
上传
评论
收藏 204KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序 一个批量删除联系人的Demo.rar (58个子文件)
一个批量删除联系人的Demo
.classpath 280B
assets
src
com
android
haven
adapter
ContactAdapter.java 2KB
GridAdapter.java 2KB
ContactEntity.java 2KB
service
ContactService.java 5KB
contact
ContactManagerActvity.java 6KB
listener
ContactListener.java 3KB
res
drawable-mdpi
icon.png 5KB
drawable-ldpi
icon.png 5KB
values
strings.xml 374B
layout
contact_manager.xml 1KB
gridview_menu.xml 791B
contact_row.xml 2KB
grid_item.xml 673B
drawable
bg_cal_card.png 7KB
cancel_all.png 1KB
line_between.png 423B
cancel_popup.png 2KB
phone.png 5KB
add_popup.png 2KB
call_popup.png 2KB
exit.png 1KB
bg.png 5KB
delete.png 5KB
choose_all.png 2KB
popup_bg.png 3KB
sim.png 5KB
icon.png 5KB
sms.png 3KB
sms_popup.png 5KB
drawable-hdpi
icon.png 5KB
bin
resources.ap_ 42KB
ContactManager.apk 53KB
classes.dex 19KB
com
android
haven
adapter
ContactAdapter.class 3KB
ContactAdapter$1.class 1KB
ContactEntity.class 2KB
GridAdapter.class 2KB
service
ContactService$1.class 3KB
ContactService.class 5KB
contact
R$string.class 563B
ContactManagerActvity$1.class 3KB
R$layout.class 531B
ContactManagerActvity.class 6KB
R$id.class 646B
R$attr.class 361B
ContactManagerActvity$2.class 971B
R$drawable.class 895B
R.class 580B
ContactManagerActvity$3.class 971B
listener
ContactListener$MyListItemOnClickListener.class 4KB
ContactListener$MyGridItemOnClickListener.class 2KB
ContactListener.class 777B
default.properties 364B
.project 850B
AndroidManifest.xml 922B
gen
com
android
haven
contact
R.java 2KB
1-120QP22T20-L.png 21KB
共 58 条
- 1
资源评论
大富大贵7
- 粉丝: 389
- 资源: 8869
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- new_bird_c-c语言入门
- christmasTree-圣诞树html网页代码
- working-shell脚本入门——流程控制
- hadoop_install-sqoop数据导入
- ThinkCMF-mysql安装
- BigData-Notes-sqoop的安装与配置
- C语言-leetcode题解之28-implement-strstr.c
- C语言-leetcode题解之27-remove-element.c
- C语言-leetcode题解之26-remove-duplicates-from-sorted-array.c
- C语言-leetcode题解之24-swap-nodes-in-pairs.c
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功