new ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity>();
}
}
}catch (Exception e){
LogUtil.e(e);
}finally {
return hotNewsListData;
}
private class NewsAdapter extends BaseRecycleAdapter<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> {
public NewsAdapter(List<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> mData) {
super(mData);
}
@Override
public BaseHolder<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> getHolder(int viewType) {
View itemView = UIUtils.inflate(R.layout.item_news);
return new NewsHolder(itemView);
}
@Override
protected List<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> onLoadMore() {
pageNum++;
List<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> moreHotNewsData = loadNewsData(pageNum);
return moreHotNewsData;
}
}
private HotNews processNewsData(String resultString){
Gson gson = new Gson();
Type type = new TypeToken<HotNews>() {
}.getType();
HotNews hotNews = gson.fromJson(resultString, type);
return hotNews;
}
5.2.2 服务模块
服务模块由“定位”、“附近”、“路线查询”“翻译”等功能组成。用户可以点击对应菜单,跳转出相应的功能界面,进行使用。
1 定位查询
定位自身位置,依靠百度地图SDK提供的平台,通过接入GPS或者无线网络获取定位信息。定位模块如图5.3所示:
图5.3 定位模块图
主要实现代码如下所示:
private void initLocation() {
// 打开定位图层
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration
(MyLocationConfiguration.LocationMode.FOLLOWING,
true,// 是否显示方向
null));// 使用默认的显示图标
mLocationClient = new LocationClient(this);
mLocationClient.registerLocationListener(new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
if (bdLocation == null) {
return;
}
double lat = bdLocation.getLatitude(); 基于Android的大学生生活小助手设计与开发(8):http://www.751com.cn/jisuanji/lunwen_1423.html