Add progress bars to search activities
This commit is contained in:
parent
e864bee7cb
commit
3e0350a963
6 changed files with 203 additions and 127 deletions
|
@ -18,7 +18,7 @@ import android.widget.RadioButton;
|
|||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SearchAddressActivity extends Activity {
|
||||
public class SearchAddressActivity extends Activity {
|
||||
|
||||
private Button showOnMap;
|
||||
private Button streetButton;
|
||||
|
@ -37,7 +37,6 @@ public class SearchAddressActivity extends Activity {
|
|||
private Button searchOnline;
|
||||
|
||||
private OsmandSettings osmandSettings;
|
||||
|
||||
private LatLon searchPoint = null;
|
||||
|
||||
|
||||
|
@ -58,6 +57,27 @@ public class SearchAddressActivity extends Activity {
|
|||
attachListeners();
|
||||
}
|
||||
|
||||
private Intent createIntent(Class<?> cl){
|
||||
LatLon location = null;
|
||||
Intent intent = getIntent();
|
||||
if(intent != null){
|
||||
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
|
||||
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
|
||||
if(lat != 0 || lon != 0){
|
||||
location = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
if (location == null && getParent() instanceof SearchActivity) {
|
||||
location = ((SearchActivity) getParent()).getSearchPoint();
|
||||
}
|
||||
Intent newIntent = new Intent(SearchAddressActivity.this, cl);
|
||||
if (location != null) {
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, location.getLatitude());
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LON, location.getLongitude());
|
||||
}
|
||||
return newIntent;
|
||||
}
|
||||
|
||||
private void attachListeners() {
|
||||
if (getParent() instanceof SearchActivity) {
|
||||
searchOnline.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -72,28 +92,28 @@ public class SearchAddressActivity extends Activity {
|
|||
countryButton.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(SearchAddressActivity.this, SearchRegionByNameActivity.class));
|
||||
startActivity(createIntent(SearchRegionByNameActivity.class));
|
||||
}
|
||||
});
|
||||
cityButton.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(SearchAddressActivity.this, SearchCityByNameActivity.class));
|
||||
startActivity(createIntent(SearchCityByNameActivity.class));
|
||||
}
|
||||
});
|
||||
streetButton.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(SearchAddressActivity.this, SearchStreetByNameActivity.class));
|
||||
startActivity(createIntent(SearchStreetByNameActivity.class));
|
||||
}
|
||||
});
|
||||
buildingButton.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(radioBuilding){
|
||||
startActivity(new Intent(SearchAddressActivity.this, SearchBuildingByNameActivity.class));
|
||||
startActivity(createIntent(SearchBuildingByNameActivity.class));
|
||||
} else {
|
||||
startActivity(new Intent(SearchAddressActivity.this, SearchStreet2ByNameActivity.class));
|
||||
startActivity(createIntent(SearchStreet2ByNameActivity.class));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -113,6 +133,7 @@ public class SearchAddressActivity extends Activity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
building = null;
|
||||
searchPoint = null;
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
|
@ -122,6 +143,7 @@ public class SearchAddressActivity extends Activity {
|
|||
street = null;
|
||||
building = null;
|
||||
street2 = null;
|
||||
searchPoint = null;
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
|
@ -133,6 +155,7 @@ public class SearchAddressActivity extends Activity {
|
|||
street = null;
|
||||
street2 = null;
|
||||
building = null;
|
||||
searchPoint = null;
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
|
@ -145,6 +168,7 @@ public class SearchAddressActivity extends Activity {
|
|||
street = null;
|
||||
street2 = null;
|
||||
building = null;
|
||||
searchPoint = null;
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
|
@ -218,6 +242,8 @@ public class SearchAddressActivity extends Activity {
|
|||
}
|
||||
|
||||
protected void updateUI(){
|
||||
showOnMap.setEnabled(searchPoint != null);
|
||||
navigateTo.setEnabled(searchPoint != null);
|
||||
findViewById(R.id.ResetCountry).setEnabled(!Algoritms.isEmpty(region));
|
||||
if(Algoritms.isEmpty(region)){
|
||||
countryButton.setText(R.string.ChooseCountry);
|
||||
|
@ -286,8 +312,6 @@ public class SearchAddressActivity extends Activity {
|
|||
super.onResume();
|
||||
|
||||
searchPoint = osmandSettings.getLastSearchedPoint();
|
||||
showOnMap.setEnabled(searchPoint != null);
|
||||
navigateTo.setEnabled(searchPoint != null);
|
||||
|
||||
region = null;
|
||||
postcode = null;
|
||||
|
@ -297,23 +321,6 @@ public class SearchAddressActivity extends Activity {
|
|||
region = osmandSettings.getLastSearchedRegion();
|
||||
loadData();
|
||||
updateUI();
|
||||
|
||||
// TODO other can be moved to specific searches
|
||||
// if (region != null) {
|
||||
// Long cityId = osmandSettings.getLastSearchedCity();
|
||||
// String postcode = osmandSettings.getLastSearchedPostcode();
|
||||
// if (!region.areCitiesPreloaded()) {
|
||||
// progressMsg = getString(R.string.loading_cities);
|
||||
// } else if (postcode != null && !region.arePostcodesPreloaded()) {
|
||||
// progressMsg = getString(R.string.loading_postcodes);
|
||||
// } else if (cityId != -1 && region.getCityById(cityId) != null && region.getCityById(cityId).isEmptyWithStreets()) {
|
||||
// progressMsg = getString(R.string.loading_streets_buildings);
|
||||
// } else if (postcode != null && region.getPostcode(postcode) != null && region.getPostcode(postcode).isEmptyWithStreets()) {
|
||||
// progressMsg = getString(R.string.loading_streets_buildings);
|
||||
// } else if (osmandSettings.USE_ENGLISH_NAMES.get() != region.useEnglishNames()) {
|
||||
// progressMsg = getString(R.string.converting_names);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.RegionAddressRepository;
|
||||
import net.osmand.plus.activities.OsmandApplication;
|
||||
import android.os.Bundle;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<Building> {
|
||||
|
@ -19,23 +20,38 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
|
|||
private City city;
|
||||
private Street street;
|
||||
private PostCode postcode;
|
||||
private OsmandSettings settings;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
settings = OsmandSettings.getOsmandSettings(this);
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
if(region != null){
|
||||
postcode = region.getPostcode(settings.getLastSearchedPostcode());
|
||||
city = region.getCityById(settings.getLastSearchedCity());
|
||||
if(postcode != null){
|
||||
street = region.getStreetByName(postcode, settings.getLastSearchedStreet());
|
||||
} else if(city != null){
|
||||
street = region.getStreetByName(city, settings.getLastSearchedStreet());
|
||||
public AsyncTask<Object, ?, ?> getInitializeTask() {
|
||||
return new AsyncTask<Object, Void, Void>(){
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_building);
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
resetText();
|
||||
}
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_building);
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.loading_streets_buildings);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
if(region != null){
|
||||
postcode = region.getPostcode(settings.getLastSearchedPostcode());
|
||||
city = region.getCityById(settings.getLastSearchedCity());
|
||||
if(postcode != null){
|
||||
street = region.getStreetByName(postcode, settings.getLastSearchedStreet());
|
||||
} else if(city != null){
|
||||
street = region.getStreetByName(city, settings.getLastSearchedStreet());
|
||||
}
|
||||
}
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,12 +2,17 @@ package net.osmand.plus.activities.search;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.AsyncTask.Status;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -26,11 +31,17 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
|
||||
private EditText searchText;
|
||||
private Handler handlerToLoop;
|
||||
private ProgressBar progress;
|
||||
private AsyncTask<Object, ?, ?> initializeTask;
|
||||
|
||||
protected ProgressBar progress;
|
||||
protected LatLon locationToSearch;
|
||||
protected OsmandSettings settings;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
settings = OsmandSettings.getOsmandSettings(this);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
setContentView(R.layout.search_by_name);
|
||||
|
@ -42,7 +53,9 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
setText(s.toString());
|
||||
if(initializeTask.getStatus() == Status.FINISHED){
|
||||
setText(s.toString());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
@ -56,16 +69,26 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
findViewById(R.id.ResetButton).setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
searchText.setText(""); //$NON-NLS-1$
|
||||
resetText();
|
||||
}
|
||||
|
||||
});
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
|
||||
initializeTask = getInitializeTask();
|
||||
if(initializeTask != null){
|
||||
initializeTask.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AsyncTask<Object, ?, ?> getInitializeTask(){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFilterableByDefault(){
|
||||
return false;
|
||||
}
|
||||
|
@ -74,6 +97,10 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
return searchText.getText();
|
||||
}
|
||||
|
||||
public void resetText(){
|
||||
setText("");
|
||||
}
|
||||
|
||||
protected void updateUIList(final List<T> objects){
|
||||
runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
|
@ -140,6 +167,7 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
synchronized (this) {
|
||||
if (handlerToLoop == null) {
|
||||
new Thread("Filter data") { //$NON-NLS-1$
|
||||
|
@ -153,7 +181,18 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
}
|
||||
|
||||
}
|
||||
super.onResume();
|
||||
Intent intent = getIntent();
|
||||
if(intent != null){
|
||||
if(intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)){
|
||||
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
|
||||
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
|
||||
locationToSearch = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
if(locationToSearch == null){
|
||||
locationToSearch = settings.getLastKnownMapLocation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,28 +13,43 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.RegionAddressRepository;
|
||||
import net.osmand.plus.activities.OsmandApplication;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SearchCityByNameActivity extends SearchByNameAbstractActivity<MapObject> {
|
||||
private RegionAddressRepository region;
|
||||
private LatLon location;
|
||||
private OsmandSettings settings;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
settings = ((OsmandApplication)getApplication()).getSettings();
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
location = settings.getLastKnownMapLocation();
|
||||
super.onCreate(savedInstanceState);
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_city);
|
||||
public AsyncTask<Object, ?, ?> getInitializeTask() {
|
||||
return new AsyncTask<Object, Void, Void>(){
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_city);
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
resetText();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.loading_cities);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MapObject> getObjects(String filter) {
|
||||
List<MapObject> l = new ArrayList<MapObject>();
|
||||
if(region != null){
|
||||
region.fillWithSuggestedCities(filter, l, location);
|
||||
region.fillWithSuggestedCities(filter, l, locationToSearch);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
@ -42,9 +57,9 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<MapOb
|
|||
@Override
|
||||
public void updateTextView(MapObject obj, TextView txt) {
|
||||
LatLon l = obj.getLocation();
|
||||
if (getFilter().length() > 2 && location != null && l != null) {
|
||||
if (getFilter().length() > 2 && locationToSearch != null && l != null) {
|
||||
txt.setText(obj.getName(region.useEnglishNames()) + " - " + //$NON-NLS-1$
|
||||
OsmAndFormatter.getFormattedDistance((int) MapUtils.getDistance(l, location), this));
|
||||
OsmAndFormatter.getFormattedDistance((int) MapUtils.getDistance(l, locationToSearch), this));
|
||||
} else {
|
||||
txt.setText(obj.getName(region.useEnglishNames()));
|
||||
}
|
||||
|
|
|
@ -10,8 +10,9 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.RegionAddressRepository;
|
||||
import net.osmand.plus.activities.OsmandApplication;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<Street> {
|
||||
|
@ -20,66 +21,50 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
|
|||
private PostCode postcode;
|
||||
private Street street1;
|
||||
private List<Street> initialList = new ArrayList<Street>();
|
||||
private ProgressDialog progressDlg;
|
||||
private OsmandSettings settings;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
settings = OsmandSettings.getOsmandSettings(this);
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
if(region != null){
|
||||
postcode = region.getPostcode(settings.getLastSearchedPostcode());
|
||||
city = region.getCityById(settings.getLastSearchedCity());
|
||||
if(postcode != null){
|
||||
street1 = region.getStreetByName(postcode, (settings.getLastSearchedStreet()));
|
||||
if(street1 != null){
|
||||
city = street1.getCity();
|
||||
}
|
||||
} else if(city != null){
|
||||
street1 = region.getStreetByName(city, (settings.getLastSearchedStreet()));
|
||||
}
|
||||
if(city != null){
|
||||
startLoadDataInThread(getString(R.string.loading_streets));
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_street);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
if(progressDlg != null){
|
||||
progressDlg.dismiss();
|
||||
progressDlg = null;
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
protected void startLoadDataInThread(String progressMsg){
|
||||
progressDlg = ProgressDialog.show(this, getString(R.string.loading), progressMsg, true);
|
||||
new Thread("Loader search data") { //$NON-NLS-1$
|
||||
public AsyncTask<Object, ?, ?> getInitializeTask() {
|
||||
return new AsyncTask<Object, Void, Void>(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
List<Street> t = new ArrayList<Street>();
|
||||
region.fillWithSuggestedStreetsIntersectStreets(city, street1, t);
|
||||
initialList = t;
|
||||
} finally {
|
||||
if(progressDlg != null){
|
||||
progressDlg.dismiss();
|
||||
progressDlg = null;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setText(getFilter().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
protected void onPostExecute(Void result) {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_street);
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_building);
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
resetText();
|
||||
}
|
||||
}.start();
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.loading_streets);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
if(region != null){
|
||||
postcode = region.getPostcode(settings.getLastSearchedPostcode());
|
||||
city = region.getCityById(settings.getLastSearchedCity());
|
||||
if(postcode != null){
|
||||
street1 = region.getStreetByName(postcode, (settings.getLastSearchedStreet()));
|
||||
if(street1 != null){
|
||||
city = street1.getCity();
|
||||
}
|
||||
} else if(city != null){
|
||||
street1 = region.getStreetByName(city, (settings.getLastSearchedStreet()));
|
||||
}
|
||||
if(city != null){
|
||||
List<Street> t = new ArrayList<Street>();
|
||||
region.fillWithSuggestedStreetsIntersectStreets(city, street1, t);
|
||||
initialList = t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Street> getObjects(String filter) {
|
||||
int ind = 0;
|
||||
|
@ -111,6 +96,5 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
|
|||
public void itemSelected(Street obj) {
|
||||
settings.setLastSearchedIntersectedStreet(obj.getName(region.useEnglishNames()), region.findStreetIntersection(street1, obj));
|
||||
finish();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,31 +6,46 @@ import java.util.List;
|
|||
import net.osmand.data.City;
|
||||
import net.osmand.data.PostCode;
|
||||
import net.osmand.data.Street;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.RegionAddressRepository;
|
||||
import net.osmand.plus.activities.OsmandApplication;
|
||||
import android.os.Bundle;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Street> {
|
||||
private RegionAddressRepository region;
|
||||
private City city;
|
||||
private PostCode postcode;
|
||||
private OsmandSettings settings;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
settings = OsmandSettings.getOsmandSettings(this);
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
if(region != null){
|
||||
postcode = region.getPostcode(settings.getLastSearchedPostcode());
|
||||
if (postcode == null) {
|
||||
city = region.getCityById(settings.getLastSearchedCity());
|
||||
public AsyncTask<Object, ?, ?> getInitializeTask() {
|
||||
return new AsyncTask<Object, Void, Void>(){
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_street);
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
resetText();
|
||||
}
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_street);
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
((TextView)findViewById(R.id.Label)).setText(R.string.loading_streets);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
|
||||
if(region != null){
|
||||
postcode = region.getPostcode(settings.getLastSearchedPostcode());
|
||||
if (postcode == null) {
|
||||
city = region.getCityById(settings.getLastSearchedCity());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue