Do not close Define view dialog

This commit is contained in:
Victor Shcherb 2013-08-03 20:03:46 +02:00
parent 69183b57df
commit 0598389eb5
3 changed files with 24 additions and 9 deletions

View file

@ -53,6 +53,10 @@ public class ContextMenuAdapter {
return selectedList.get(pos);
}
public void setSelection(int pos, int s) {
selectedList.set(pos, s);
}
public int getImageId(int pos, boolean light) {
if(!light || iconListLight.get(pos) == 0) {
return iconList.get(pos);

View file

@ -60,6 +60,8 @@ import android.content.Intent;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
@ -310,7 +312,7 @@ public class MapActivityLayers {
layout = R.layout.list_menu_item_native;
}
ListAdapter listAdapter = new ArrayAdapter<String>(
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(
activity, layout, R.id.title, adapter.getItemNames()){
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
@ -344,20 +346,30 @@ public class MapActivityLayers {
}
};
b.setAdapter(listAdapter, new OnClickListener() {
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
}
};
b.setAdapter(listAdapter, onClickListener);
b.setPositiveButton(R.string.default_buttons_ok, null);
final AlertDialog dlg = b.create();
listener.setDialog(dlg);
dlg.setCanceledOnTouchOutside(true);
dlg.getListView().setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(adapter.getSelection(position) >= 0) {
listener.onClick(position, !(adapter.getSelection(position) > 0));
adapter.setSelection(position, adapter.getSelection(position) > 0 ? 0 : 1);
listAdapter.notifyDataSetInvalidated();
} else {
listener.onClick(position, adapter.getSelection(position) > 0);
}
}
});
final AlertDialog dlg = b.create();
listener.setDialog(dlg);
dlg.setCanceledOnTouchOutside(true);
dlg.show();
}

View file

@ -96,7 +96,6 @@ public class SRTMPlugin extends OsmandPlugin {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (itemId == R.string.layer_hillshade) {
dialog.dismiss();
HILLSHADE.set(!HILLSHADE.get());
updateLayers(mapView, mapActivity);
}