12-21 完成了公司的一个bug 想头 学习了 消息处理机制

对于微博解绑定后 好友栏里没跟新的情况 

改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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值