改3个地方
1.gexinMainActivity 的 handle 处理方法中
case Const.UPDATEUI_UnBind2SinaOk:
settingsPage.unBindSinaOk(); 下加
contactsPage.refreshWeibo();
2.在 contatsPage 的 refreshWeibo() 方法中 加入如下
// Alex
if (!GexinBasicDataManager.bindSina)
{
contactsAdapter.initData(originalData = AddresslistDataManager.getInstance().getSeachInfoList());
AddresslistDataManager.getInstance().clearList();
updateView(UiConst.PAGE_WEIBO);
}
contactsPage.refreshWeibo();
3.在AddresslistDataManager类 中 getSeachInfoAllList() 方法 改成如下内容
public final SearchInfo[] getSeachInfoAllList() {
if(GexinBasicDataManager.bindSina)
return SearchPy.ReadLock ? null : allSearchInfos;
else
return SearchPy.ReadLock ? null : contactInfos;
}
今天学习了 消息处理机制
将 要处理的 任务通过 bundle 绑定,sendCMD 进行广播
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putInt(Const.CMD, Const.SERVERACTION_UNBIND_2_SINA);
mainActivity.sendCMD(bundle);
广播如下
public final void sendCMD(Bundle bundle) {
if (bundle != null)
{
broadcastQueue.add(bundle);
}
if (queue_state == 0 && !broadcastQueue.isEmpty())
{
ArrayList<Bundle> bundleList = new ArrayList<Bundle>(broadcastQueue);
broadcastQueue.removeAll(bundleList);
Intent intent = new Intent(Const.SERVER_ACTION);
intent.putParcelableArrayListExtra("bundle", bundleList);
queue_state = 1;
sendBroadcast(intent);
}
}
在自己写的 ActionReceiver 后台进行处理
public void onReceive(Context context, Intent intent) {
case Const.SERVERACTION_UNBIND_2_SINA:
action = new UnBindAction(service, Const.appkeySina, UnBindAction.THIRD_PART.SINA);
}
处理完后 广播到前台 UnBindAction
case SINA:
service.updateUI(Const.UPDATEUI_UnBind2SinaOk, null);
前台 handle 处理广播
public Handler myHandler = new Handler()
{
case Const.UPDATEUI_UnBind2SinaOk:
settingsPage.unBindSinaOk();
// Alex 跟新 联系人的列表
contactsPage.refreshWeibo();
}
参考文章 http://lhc966.iteye.com/blog/803645