Fixed bug with non clickable items in dialog (tags in edit poi).

This commit is contained in:
GaidamakUA 2015-11-12 11:48:12 +02:00
parent e8c926d1ec
commit 56ec628f8d

View file

@ -1,24 +1,5 @@
package net.osmand.plus.osmedit;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.osmand.PlatformUtil;
import net.osmand.StringMatcher;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.Point;
@ -41,6 +22,25 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.StringMatcher;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class AdvancedEditPoiFragment extends Fragment
implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final String TAG = "AdvancedEditPoiFragment";
@ -218,25 +218,7 @@ public class AdvancedEditPoiFragment extends Fragment
}
}
});
tagEditText.setAdapter(tagAdapter);
tagEditText.setThreshold(1);
tagEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setAdapter(tagAdapter, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tagAdapter.getItem(which);
}
});
builder.create();
builder.show();
}
});
initAutocompleteTextView(tagEditText, tagAdapter);
valueEditText.setText(vl);
valueEditText.addTextChangedListener(new TextWatcher() {
@ -256,23 +238,7 @@ public class AdvancedEditPoiFragment extends Fragment
}
});
valueEditText.setAdapter(valueAdapter);
valueEditText.setThreshold(1);
valueEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setAdapter(valueAdapter, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
valueAdapter.getItem(which);
}
});
builder.create();
builder.show();
}
});
initAutocompleteTextView(valueEditText, valueAdapter);
linearLayout.addView(convertView);
tagEditText.requestFocus();
@ -293,6 +259,34 @@ public class AdvancedEditPoiFragment extends Fragment
}
}
private static void initAutocompleteTextView(final AutoCompleteTextView textView,
final ArrayAdapter<String> adapter) {
textView.setAdapter(adapter);
textView.setThreshold(1);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setAdapter(adapter, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
textView.setText(adapter.getItem(which));
}
});
builder.create().show();
}
});
textView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
adapter.getFilter().filter(textView.getText());
}
}
});
}
private static void addPoiToStringSet(AbstractPoiType abstractPoiType, Set<String> stringSet,
Set<String> values) {
if (abstractPoiType instanceof PoiType) {