Android开发合并相同通话记录并显示通话记录条数

CommonUtil.java

public class CommonUtil {

public static List<ContactInfo> handleList(List<ContactInfo> list) {
Map<String, Integer> map = new HashMap<String, Integer>();
ArrayList<ContactInfo> result = new ArrayList<ContactInfo>();
for (int i = 0; i < list.size(); i++) {
int k = 1;
for (int j = i + 1; j < list.size(); j++) {
if (list.get(i).getPhoneNum().equals(list.get(j).getPhoneNum())) {
k++;
} else {
continue;
}
}
if (!map.containsKey(list.get(i).getPhoneNum()))
map.put(list.get(i).getPhoneNum(), k);
}
Set<Entry<String, Integer>> entrySet = map.entrySet();
Iterator<Entry<String, Integer>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
for (int i = 0; i < map.size(); i++) {
Entry<String, Integer> next = iterator.next();
for (int j = 0; j < list.size(); j++) {
if (next.getKey().equals(list.get(j).getPhoneNum())) {
list.get(j).setNumber(String.valueOf(next.getValue()));
result.add(list.get(j));
break;
}
}


}


}
return result;
}

}


ContactInfo.java

package com.ran.wedial.info;


public class ContactInfo {


private Long id;
private String name;
private String formattedNumber;
private String phoneNum;
private String pinyin;
private int type;
private String date;
private String Numbers;


public Long getId() {
return id;
}


public void setId(Long id) {
this.id = id;
}


public String getName() {
return name;
}


public void setName(String name) {
this.name = name;
}


public String getFormattedNumber() {
return formattedNumber;
}


public void setFormattedNumber(String formattedNumber) {
this.formattedNumber = formattedNumber;
}


public String getPhoneNum() {
return phoneNum;
}


public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}


public String getPinyin() {
return pinyin;
}


public void setPinyin(String pinyin) {
this.pinyin = pinyin;
}


public int getType() {
return type;
}


public void setType(int type) {
this.type = type;
}


public String getDate() {
return date;
}


public void setDate(String date) {
this.date = date;
}


public void setNumber(String Numbers) {
this.Numbers = Numbers;
}


public String getNumbers() {
return Numbers;
}
}

阅读更多
个人分类: android
想对作者说点什么? 我来说一句

android项目通话记录源代码

2012年09月22日 683KB 下载

没有更多推荐了,返回首页

关闭
关闭