package com.sogouchat.popnewmsg; import java.util.HashMap; import java.util.Map; import java.util.Vector; import com.sogouchat.util.SmsFunc; import android.provider.MediaStore.Video; public class PopConversationMgr { public Vector<PopConversation> popConversations; public Map<String, PopConversation> mapConversation; private MultiPopTabActivity activity; private static final PopConversationMgr s_lpthis = new PopConversationMgr(); public static PopConversationMgr GetI(){ return s_lpthis; } private PopConversationMgr(){ } public void Init(MultiPopTabActivity activity){ this.activity = activity; popConversations = new Vector<PopConversation>(); mapConversation = new HashMap<String, PopConversation>(); } public PopConversation findItemByNumber(String strNumber){ return mapConversation.get(strNumber); } public void addNewMessage(String strNumber,String strBody){ PopConversation popConversation =null; popConversation = findItemByNumber(strNumber); if (popConversation==null) { popConversation =new PopConversation(strNumber,popConversations.size()); activity.addNewTab(popConversation); mapConversation.put(strNumber, popConversation); popConversations.add(popConversation); } popConversation.AddMessage(new PopMessage(strBody)); activity.Update(popConversation); } public void DeleteTab(PopConversation conversation){ String strTag = conversation.strShow; if (strTag!=null && !strTag.equals("")) { PopConversation popConversation = findItemByNumber(strTag); if (popConversation!=null) { activity.DeleteTab(); mapConversation.remove(strTag); popConversations.remove(popConversation); addNewAll(); } } } public void SendMessage(String strNumber,String strText){ SmsFunc.sendSms(strNumber, strText, activity); } public void addNewAll() { // TODO Auto-generated method stub int nCount = popConversations.size(); for (int i= 0; i < nCount; i++) { PopConversation popConversation = popConversations.get(i); if (popConversation!=null) { popConversation.nIndex = i; activity.addNewTab(popConversation); } } } }