java购物网站源代码 购物商城java源代码( 二 )


private ListOfflineMapItem itemsAll; // 所有城市,与热门城市及下载管理对象相同
private ListOfflineMapItem itemsProvince;
private ListListOfflineMapItem itemsProvinceCity;
// ----------------------- Constructors ----------------------
// -------- Methods for/from SuperClass/Interfaces -----------
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
【java购物网站源代码 购物商城java源代码】setContentView(R.layout.activity_offline_map);
//final String packname = this.getPackageName();
//PackageInfo packageInfo;
//try
//{
//packageInfo = this.getPackageManager().getPackageInfo(packname, PackageManager.GET_SIGNATURES);
//
//
//if (code == -00)
//{
// 初始化离线地图管理
mOffline = new MKOfflineMap();
mOffline.init(this);
initViews();
viewpager.setCurrentItem(1);
//}
//}
//catch (NameNotFoundException e)
//{
//e.printStackTrace();
//}
}
private boolean isResumed = false;
@Override
protected void onResume()
{
super.onResume();
if (!isResumed)
{
isResumed = true;
loadData();
}
}
@Override
protected void onDestroy()
{
super.onDestroy();
mOffline.destroy();
}
/**
*
* @author chenshiqiang E-mail:csqwyyx@163.com
* @param type
*事件类型: MKOfflineMap.TYPE_NEW_OFFLINE, MKOfflineMap.TYPE_DOWNLOAD_UPDATE, MKOfflineMap.TYPE_VER_UPDATE.
* @param state
*事件状态: 当type为TYPE_NEW_OFFLINE时,表示新安装的离线地图数目. 当type为TYPE_DOWNLOAD_UPDATE时,表示更新的城市ID.
*/
@Override
public void onGetOfflineMapState(int type, int state)
{
switch (type)
{
case MKOfflineMap.TYPE_DOWNLOAD_UPDATE:
MKOLUpdateElement update = mOffline.getUpdateInfo(state);
if (setElement(update, true) != null)
{
if (itemsDown != nullitemsDown.size()1)
{
Collections.sort(itemsDown);
}
refreshDownList();
}
else
{
downAdapter.notifyDataSetChanged();
}
allSearchAdapter.notifyDataSetChanged();
allCountryAdapter.notifyDataSetChanged();
break;
case MKOfflineMap.TYPE_NEW_OFFLINE:
// 有新离线地图安装
Log.d("OfflineDemo", String.format("add offlinemap num:%d", state));
break;
case MKOfflineMap.TYPE_VER_UPDATE:
// 版本更新提示
break;
}
}
/**
* 百度下载状态改变(暂停--》恢复)居然不回调,所以改变状态时自己得增加接口监听状态改变刷新界面
*
* @author chenshiqiang E-mail:csqwyyx@163.com
* @param item
*有状态改变的item
* @param removed
*item是否被删除
*/
@Override
public void statusChanged(OfflineMapItem item, boolean removed)
{
if (removed)
{
for (int i = itemsDown.size() - 1; i = 0; i--)
{
OfflineMapItem temp = itemsDown.get(i);
if (temp.getCityId() == item.getCityId())
{
itemsDown.remove(i);
}
}
refreshDownList();
}
else
{
loadData();
downAdapter.notifyDataSetChanged();
}
allSearchAdapter.notifyDataSetChanged();
allCountryAdapter.notifyDataSetChanged();
}
// --------------------- Methods public ----------------------
public void toDownloadPage()
{
viewpager.setCurrentItem(0);
}
// --------------------- Methods private ---------------------
private void initViews()
{
// TODO
viewpager = (ViewPager) findViewById(R.id.viewpager);
pagertab = (PagerTabStrip) findViewById(R.id.pagertab);

推荐阅读