fix issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@665 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-11-12 22:09:48 +00:00
parent 979f674ede
commit 64e9fd3b8b
4 changed files with 53 additions and 5 deletions

View file

@ -85,7 +85,10 @@ public class DownloadIndexActivity extends ListActivity {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
((DownloadIndexAdapter)getListAdapter()).getFilter().filter(s);
DownloadIndexAdapter adapter = ((DownloadIndexAdapter)getListAdapter());
if(adapter != null){
adapter.getFilter().filter(s);
}
}
};

View file

@ -494,7 +494,9 @@ public class RoutingHelper {
uiActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(uiActivity, msg, Toast.LENGTH_SHORT).show();
if(uiActivity != null){
Toast.makeText(uiActivity, msg, Toast.LENGTH_SHORT).show();
}
}
});
}

View file

@ -8,12 +8,15 @@ import net.osmand.activities.MapActivity;
import net.osmand.activities.search.SearchHistoryHelper.HistoryEntry;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
@ -45,6 +48,13 @@ public class SearchHistoryActivity extends ListActivity {
setListAdapter(new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this)));
}
});
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
return SearchHistoryActivity.this.onItemLongClick(pos);
}
});
}
@Override
protected void onResume() {
@ -58,6 +68,32 @@ public class SearchHistoryActivity extends ListActivity {
setListAdapter(new HistoryAdapter(historyEntries));
}
private boolean onItemLongClick(int pos) {
final HistoryEntry entry = ((HistoryAdapter) getListAdapter()).getItem(pos);
AlertDialog.Builder builder = new AlertDialog.Builder(SearchHistoryActivity.this);
builder.setTitle(entry.getName());
builder.setItems(new String[] { getString(R.string.show_poi_on_map), getString(R.string.navigate_to) },
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
OsmandSettings.setMapLocationToShow(SearchHistoryActivity.this, entry.getLat(), entry.getLon());
} else if (which == 1) {
OsmandSettings.setPointToNavigate(SearchHistoryActivity.this, entry.getLat(), entry.getLon());
}
Intent newIntent = new Intent(SearchHistoryActivity.this, MapActivity.class);
startActivity(newIntent);
}
});
builder.show();
return true;
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
HistoryEntry model = ((HistoryAdapter)getListAdapter()).getItem(position);
@ -78,7 +114,7 @@ public class SearchHistoryActivity extends ListActivity {
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
if (row == null) {
LayoutInflater inflater = getLayoutInflater();
@ -108,8 +144,16 @@ public class SearchHistoryActivity extends ListActivity {
public void onClick(View v) {
selectModel(model);
}
};
View.OnLongClickListener longClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return onItemLongClick(position);
}
};
distanceLabel.setOnLongClickListener(longClickListener);
label.setOnLongClickListener(longClickListener);
distanceLabel.setOnClickListener(clickListener);
label.setOnClickListener(clickListener);
return row;

View file

@ -210,7 +210,6 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
// ListActivity has a ListView, which you can get with:
ListView lv = getListView();
// Then you can create a listener like so:
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {