use of com.amap.api.services.core.PoiItem in project KL2 by jweihao.
the class AddressAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(MyHolder holder, int position) {
holder.itemView.setTag(position);
PoiItem poiItem = mList.get(position);
if (position == selectPosition) {
holder.mCheckBox.setChecked(true);
} else {
holder.mCheckBox.setChecked(false);
}
holder.mTvTitle.setText(poiItem.getTitle());
holder.mTvMessage.setText(poiItem.getProvinceName() + poiItem.getCityName() + poiItem.getAdName() + poiItem.getSnippet());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = (Integer) view.getTag();
setSelectPosition(position);
if (null != mOnItemClickLisenter) {
mOnItemClickLisenter.onItemClick(position);
}
}
});
}
use of com.amap.api.services.core.PoiItem in project KL2 by jweihao.
the class SearchActivity method initListener.
private void initListener() {
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.iv_back:
finish();
break;
default:
break;
}
}
};
mIvBack.setOnClickListener(mOnClickListener);
mEtSearch.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (null != editable) {
if (0 == editable.length()) {
// 没有输入则清空搜索记录
mList.clear();
mSearchAddressAdapter.setList(mList, "");
} else {
if (null != location) {
doSearchQuery(editable.toString(), location.getCity(), new LatLonPoint(location.getLatitude(), location.getLongitude()));
} else {
doSearchQuery(editable.toString(), "", null);
}
}
}
}
});
mOnItemClickLisenter = new OnItemClickLisenter() {
@Override
public void onItemClick(int position) {
PoiItem poiItem = mList.get(position);
if (null != poiItem) {
// 获取信息并回传上一页面
Intent intent = new Intent();
intent.putExtra(DatasKey.SEARCH_INFO, poiItem);
setResult(RESULT_OK, intent);
finish();
}
}
};
mSearchAddressAdapter.setOnItemClickLisenter(mOnItemClickLisenter);
mOnPoiSearchListener = new PoiSearch.OnPoiSearchListener() {
@Override
public void onPoiSearched(PoiResult result, int i) {
if (i == 1000) {
if (result != null && result.getQuery() != null) {
// 搜索poi的结果
if (result.getQuery().equals(mQuery)) {
// 是否是同一条
if (null != mList) {
mList.clear();
}
// 取得第一页的poiitem数据,页数从数字0开始
mList.addAll(result.getPois());
if (null != mSearchAddressAdapter) {
mSearchAddressAdapter.setList(mList, mEtSearch.getText().toString().trim());
mRecyclerView.smoothScrollToPosition(0);
}
}
}
}
}
@Override
public void onPoiItemSearched(PoiItem poiItem, int i) {
}
};
}
use of com.amap.api.services.core.PoiItem in project KL2 by jweihao.
the class DataConversionUtils method changeToPoiItem.
public static PoiItem changeToPoiItem(AMapLocation data) {
if (null != data) {
try {
String title = data.getDescription();
if (TextUtils.isEmpty(title)) {
title = data.getPoiName();
}
if (TextUtils.isEmpty(title)) {
title = data.getStreet();
}
if (TextUtils.isEmpty(title)) {
title = "[位置]";
}
PoiItem poiItem = new PoiItem(data.getBuildingId(), new LatLonPoint(data.getLatitude(), data.getLongitude()), title, data.getAddress());
poiItem.setAdCode(data.getAdCode());
poiItem.setAdName(data.getDistrict());
poiItem.setBusinessArea(data.getStreet());
poiItem.setCityCode(data.getCityCode());
poiItem.setCityName(data.getCity());
poiItem.setProvinceName(data.getProvince());
return poiItem;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
return null;
}
use of com.amap.api.services.core.PoiItem in project KL2 by jweihao.
the class DataConversionUtils method changeToPoiItem.
public static PoiItem changeToPoiItem(RegeocodeResult data) {
if (null != data) {
try {
String title = data.getRegeocodeAddress().getBuilding();
if (TextUtils.isEmpty(title)) {
title = data.getRegeocodeAddress().getNeighborhood();
}
if (TextUtils.isEmpty(title)) {
title = data.getRegeocodeAddress().getTownship();
}
if (TextUtils.isEmpty(title)) {
title = "[位置]";
}
PoiItem poiItem = new PoiItem(data.getRegeocodeAddress().getBuilding(), data.getRegeocodeQuery().getPoint(), title, data.getRegeocodeAddress().getFormatAddress());
poiItem.setAdCode(data.getRegeocodeAddress().getAdCode());
poiItem.setAdName(data.getRegeocodeAddress().getDistrict());
poiItem.setBusinessArea(data.getRegeocodeAddress().getBusinessAreas().get(0).getName());
poiItem.setCityCode(data.getRegeocodeAddress().getCityCode());
poiItem.setCityName(data.getRegeocodeAddress().getCity());
poiItem.setProvinceName(data.getRegeocodeAddress().getProvince());
return poiItem;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
return null;
}
Aggregations