This commit is contained in:
Victor Shcherb 2011-08-27 12:57:06 +02:00
parent 1f5af8ba34
commit b077081d2f

View file

@ -10,7 +10,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import net.osmand.Algoritms; import net.osmand.Algoritms;
import net.osmand.FavouritePoint;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -35,7 +34,6 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.BaseExpandableListAdapter; import android.widget.BaseExpandableListAdapter;
@ -44,7 +42,6 @@ import android.widget.CheckBox;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo; import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
public class LocalIndexesActivity extends ExpandableListActivity { public class LocalIndexesActivity extends ExpandableListActivity {
@ -84,18 +81,21 @@ public class LocalIndexesActivity extends ExpandableListActivity {
@Override @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
long packedPos = ((ExpandableListContextMenuInfo)menuInfo).packedPosition; long packedPos = ((ExpandableListContextMenuInfo)menuInfo).packedPosition;
int group = ExpandableListView.getPackedPositionGroup(packedPos);
final LocalIndexInfo point = (LocalIndexInfo) listAdapter.getChild(ExpandableListView.getPackedPositionGroup(packedPos), int child = ExpandableListView.getPackedPositionChild(packedPos);
ExpandableListView.getPackedPositionChild(packedPos)); if (child >= 0 && group >= 0) {
if(point.getGpxFile() != null){ final LocalIndexInfo point = (LocalIndexInfo) listAdapter.getChild(group, child);
if (point != null && point.getGpxFile() != null) {
Location loc = point.getGpxFile().findFistLocation(); Location loc = point.getGpxFile().findFistLocation();
if (loc != null) { if (loc != null) {
OsmandSettings.getOsmandSettings(LocalIndexesActivity.this).setMapLocationToShow(loc.getLatitude(),loc.getLongitude()); OsmandSettings.getOsmandSettings(LocalIndexesActivity.this).setMapLocationToShow(loc.getLatitude(),
loc.getLongitude());
} }
((OsmandApplication) getApplication()).setGpxFileToDisplay(point.getGpxFile()); ((OsmandApplication) getApplication()).setGpxFileToDisplay(point.getGpxFile());
MapActivity.launchMapActivityMoveToTop(LocalIndexesActivity.this); MapActivity.launchMapActivityMoveToTop(LocalIndexesActivity.this);
} }
} }
}
}); });
setListAdapter(listAdapter); setListAdapter(listAdapter);