|
@@ -24,6 +24,7 @@ import com.ynstkz.shitu.android.R;
|
|
|
import com.ynstkz.shitu.android.adapter.HistoryCityGridAdapter;
|
|
|
import com.ynstkz.shitu.android.base.TitleBarActivity;
|
|
|
import com.ynstkz.shitu.android.bean.LocalCityBean;
|
|
|
+import com.ynstkz.shitu.android.bean.LocationDataBean;
|
|
|
import com.ynstkz.shitu.android.data.RequestGroup;
|
|
|
import com.ynstkz.shitu.android.data.SharedPreferencesUtils;
|
|
|
import com.ynstkz.shitu.android.view.sortlist.CharacterParser;
|
|
@@ -68,6 +69,7 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
private PinyinComparator pinyinComparator;
|
|
|
private CharacterParser characterParser;
|
|
|
private List<String> listCacheHistoryCity;
|
|
|
+ private String selectCity;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
@@ -131,7 +133,8 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
gvHistoryCity.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- cacheLocationHistory((String)adapterView.getAdapter().getItem(i));
|
|
|
+ selectCity = (String)adapterView.getAdapter().getItem(i);
|
|
|
+ cacheLocationHistory();
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -141,7 +144,8 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
llLocationCity.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- finish();
|
|
|
+ selectCity = SharedPreferencesUtils.getLocation();
|
|
|
+ cacheLocationHistory();
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -151,7 +155,8 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
lvCountry.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
|
|
- cacheLocationHistory(((SortModel)sortAdapter.getItem(position)).getName());
|
|
|
+ selectCity = ((SortModel)sortAdapter.getItem(position)).getName();
|
|
|
+ cacheLocationHistory();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -231,14 +236,13 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
|
|
|
/**
|
|
|
* 缓存历史城市
|
|
|
- * @param city
|
|
|
*/
|
|
|
- private void cacheLocationHistory(String city){
|
|
|
+ private void cacheLocationHistory(){
|
|
|
if(listCacheHistoryCity == null){
|
|
|
listCacheHistoryCity = new ArrayList<>();
|
|
|
}
|
|
|
- if(!listCacheHistoryCity.contains(city)){
|
|
|
- listCacheHistoryCity.add(0, city);
|
|
|
+ if(!listCacheHistoryCity.contains(selectCity)){
|
|
|
+ listCacheHistoryCity.add(0, selectCity);
|
|
|
}
|
|
|
if(listCacheHistoryCity.size() > 4){
|
|
|
listCacheHistoryCity.remove(4);
|
|
@@ -246,10 +250,10 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
Cache.put(KRY_LISTCACHEHISTORYCITY, listCacheHistoryCity);
|
|
|
|
|
|
Intent intent = new Intent();
|
|
|
- intent.putExtra("result", city);
|
|
|
+ intent.putExtra("result", selectCity);
|
|
|
setResult(RESULT_OK, intent);
|
|
|
//搜索经纬度
|
|
|
- getAmapGeocode(city);
|
|
|
+ getAmapGeocode(selectCity);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -281,9 +285,16 @@ public class LocationSelectActivity extends TitleBarActivity implements GeocodeS
|
|
|
double longitude = latLonPoint.getLongitude();
|
|
|
|
|
|
Intent intent = new Intent();
|
|
|
- intent.putExtra("city", geocodeAddress.getCity());
|
|
|
+ intent.putExtra("city", selectCity);
|
|
|
intent.putExtra("latitude", latitude);
|
|
|
intent.putExtra("longitude", longitude);
|
|
|
+
|
|
|
+ LocationDataBean locationDataBean = new LocationDataBean();
|
|
|
+ locationDataBean.setCity(selectCity);
|
|
|
+ locationDataBean.setLongitude(longitude);
|
|
|
+ locationDataBean.setLatitude(latitude);
|
|
|
+ Cache.put("locationDataBean", locationDataBean);
|
|
|
+
|
|
|
setResult(RESULT_OK, intent);
|
|
|
finish();
|
|
|
}
|