Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fd8635c5de
4 changed files with 30 additions and 32 deletions
|
@ -93,7 +93,7 @@ public class AdvancedDataFragment extends Fragment {
|
|||
mAdapter.updateViews();
|
||||
mTagsChangedListener = new EditPoiData.TagsChangedListener() {
|
||||
@Override
|
||||
public void onTagsChanged() {
|
||||
public void onTagsChanged(String anyTag) {
|
||||
mAdapter.updateViews();
|
||||
}
|
||||
};
|
||||
|
@ -189,6 +189,7 @@ public class AdvancedDataFragment extends Fragment {
|
|||
(ImageButton) convertView.findViewById(R.id.deleteItemImageButton);
|
||||
valueEditText.setText(vl);
|
||||
deleteItemImageButton.setImageDrawable(deleteDrawable);
|
||||
final String[] previousTag = new String[] {tg};
|
||||
deleteItemImageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -199,6 +200,9 @@ public class AdvancedDataFragment extends Fragment {
|
|||
tagEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (!editPoiData.isInEdit()) {
|
||||
editPoiData.removeTag(s.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -208,7 +212,9 @@ public class AdvancedDataFragment extends Fragment {
|
|||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!editPoiData.isInEdit()) {
|
||||
editPoiData.removeTag(previousTag[0]);
|
||||
editPoiData.putTag(s.toString(), valueEditText.getText().toString());
|
||||
previousTag[0] = s.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -180,13 +180,14 @@ public class BasicDataFragment extends Fragment {
|
|||
listeners.add(new TagsChangedListener() {
|
||||
|
||||
@Override
|
||||
public void onTagsChanged() {
|
||||
public void onTagsChanged(String t) {
|
||||
if (tag.equals(t)) {
|
||||
String vl = getData().getTagValues().get(tag);
|
||||
if(vl == null) {
|
||||
if (vl == null) {
|
||||
vl = "";
|
||||
}
|
||||
e.setText(vl);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -77,8 +77,6 @@ public class EditPoiFragment extends DialogFragment {
|
|||
private EditPoiData editPoiData;
|
||||
private ViewPager viewPager;
|
||||
private boolean isLocalEdit;
|
||||
private boolean mIsUserInput = true;
|
||||
private EditPoiData.TagsChangedListener mTagsChangedListener;
|
||||
private AutoCompleteTextView poiTypeEditText;
|
||||
private Node node;
|
||||
private Map<String, PoiType> allTranslatedSubTypes;
|
||||
|
@ -406,13 +404,9 @@ public class EditPoiFragment extends DialogFragment {
|
|||
}
|
||||
|
||||
public void updateType(Amenity amenity) {
|
||||
mIsUserInput = false;
|
||||
poiTypeEditText.setText(amenity.getSubType());
|
||||
mIsUserInput = true;
|
||||
poiTypeTextInputLayout.setHint(amenity.getType().getTranslation());
|
||||
|
||||
setAdapterForPoiTypeEditText();
|
||||
|
||||
poiTypeEditText.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(final View v, MotionEvent event) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class EditPoiData {
|
|||
}
|
||||
|
||||
private void initTags(Node node, Map<String, PoiType> allTranslatedSubTypes) {
|
||||
|
||||
checkNotInEdit();
|
||||
tryAddTag(OSMSettings.OSMTagKey.ADDR_STREET.getValue(),
|
||||
node.getTag(OSMSettings.OSMTagKey.ADDR_STREET));
|
||||
tryAddTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue(),
|
||||
|
@ -70,38 +70,39 @@ public class EditPoiData {
|
|||
|
||||
|
||||
public void putTag(String tag, String value) {
|
||||
if(isInEdit) {
|
||||
throw new IllegalStateException("Can't modify in edit mode");
|
||||
}
|
||||
checkNotInEdit();
|
||||
try {
|
||||
isInEdit = true;
|
||||
tagValues.put(tag, value);
|
||||
notifyDatasetChanged();
|
||||
notifyDatasetChanged(tag);
|
||||
} finally {
|
||||
isInEdit = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyToUpdateUI() {
|
||||
|
||||
private void checkNotInEdit() {
|
||||
if(isInEdit) {
|
||||
throw new IllegalStateException("Can't modify in edit mode");
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyToUpdateUI() {
|
||||
checkNotInEdit();
|
||||
try {
|
||||
isInEdit = true;
|
||||
notifyDatasetChanged();
|
||||
notifyDatasetChanged(null);
|
||||
} finally {
|
||||
isInEdit = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeTag(String tag) {
|
||||
if(isInEdit) {
|
||||
throw new IllegalStateException("Can't modify in edit mode");
|
||||
}
|
||||
checkNotInEdit();
|
||||
try {
|
||||
isInEdit = true;
|
||||
tagValues.remove(tag);
|
||||
notifyDatasetChanged();
|
||||
notifyDatasetChanged(tag);
|
||||
} finally {
|
||||
isInEdit = false;
|
||||
}
|
||||
|
@ -112,9 +113,9 @@ public class EditPoiData {
|
|||
}
|
||||
|
||||
|
||||
private void notifyDatasetChanged() {
|
||||
private void notifyDatasetChanged(String tag) {
|
||||
for (TagsChangedListener listener : mListeners) {
|
||||
listener.onTagsChanged();
|
||||
listener.onTagsChanged(tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,11 +129,7 @@ public class EditPoiData {
|
|||
|
||||
public interface TagsChangedListener {
|
||||
|
||||
void onTagsChanged();
|
||||
void onTagsChanged(String tag);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue