MapTabPresenter.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:Farmacias 作者:
@Override
public String onGetAddressFromLocation(Location currentLocation) {


    List<Address> addresses = null;
    try {
        addresses = mGeocoder.getFromLocation(
                currentLocation.getLatitude(),
                currentLocation.getLongitude(),
                1);
    } catch (IOException ioe) {

    }

    if (addresses == null || addresses.size() == 0) {
        Utils.logD(LOG_TAG, "no address found");
        return null;
    } else {
        Address address = addresses.get(0);
        StringBuilder stringBuilder = new StringBuilder();

        // Fetch the address lines using getAddressLine,
        // join them, and send them to the thread.
        for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
            if (i == 0) {
                preferencesManager.saveStreet(address.getAddressLine(i));
            }
            stringBuilder.append(address.getAddressLine(i));
            if (i != address.getMaxAddressLineIndex() - 1) {
                stringBuilder.append(Constants.COMMA);
            }
        }
        Utils.logD(LOG_TAG, "address found");
        mAddress = stringBuilder.toString();
        return mAddress;
    }


}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号