src/main/java/de/blau/android/propertyeditor/tagform/TagFormFragment.java
/**
     * Update the contents of the Fragment
     */
Update the contents of the Fragment
Update the contents of the Fragment
public void update() {
        Log.d(DEBUG_TAG, "update");
        View sv = getView();
        LinearLayout ll = (LinearLayout) sv.findViewById(R.id.form_container_layout);
        if (ll != null) {
            while (ll.getChildAt(0) instanceof EditableLayout) {
                ll.removeViewAt(0);
            }
        } else {
            Log.d(DEBUG_TAG, "update container layout null");
            return;
        }
        final EditableLayout editableView = (EditableLayout) inflater.inflate(R.layout.tag_form_editable, ll, false);
        editableView.setSaveEnabled(false);
        int pos = 0;
        ll.addView(editableView, pos++);
        LinearLayout nonEditableView = (LinearLayout) getImmutableView();
        if (nonEditableView != null && nonEditableView.getChildCount() > 0) {
            nonEditableView.removeAllViews();
        }
        LinkedHashMap<String, String> allTags = tagListener.getKeyValueMapSingle(true);
        PresetItem mainPreset = tagListener.getBestPreset();
        editableView.setTitle(mainPreset, allTags.isEmpty());
        editableView.setListeners(tagListener, this);
        editableView.applyPresetButton.setVisibility(View.GONE);
        editableView.applyPresetWithOptionalButton.setVisibility(View.GONE);
        Map<String, String> nonEditable;
        if (mainPreset != null) {
            nonEditable = addTagsToViews(editableView, mainPreset, allTags);
            for (PresetItem preset : tagListener.getSecondaryPresets()) {
                final EditableLayout editableView1 = (EditableLayout) inflater.inflate(R.layout.tag_form_editable, ll, false);
                editableView1.setSaveEnabled(false);
                editableView1.setTitle(preset, false);
                editableView1.setListeners(tagListener, this);
                ll.addView(editableView1, pos++);
                nonEditable = addTagsToViews(editableView1, preset, nonEditable);
            }
        } else {
            nonEditable = allTags;
        }
        LinearLayout nel = (LinearLayout) getView().findViewById(R.id.form_immutable_header_layout);
        if (nel != null) {
            nel.setVisibility(View.GONE);
            if (nonEditable.size() > 0) {
                nel.setVisibility(View.VISIBLE);
                for (Entry<String, String> entry : nonEditable.entrySet()) {
                    PresetTextField textField = new PresetTextField(entry.getKey());
                    addRow(nonEditableView, textField, entry.getValue(), null, allTags);
                }
            }
        }
        if (displayMRUpresets) {
            de.blau.android.propertyeditor.Util.addAlternativePresetItemsFragment(getChildFragmentManager(), R.id.alternative_layout,
                    tagListener.getBestPreset());
        }
        if (focusOnAddress) {
            focusOnAddress = false; 
            if (!focusOnTag(Tags.KEY_ADDR_HOUSENUMBER) && !focusOnTag(Tags.KEY_ADDR_STREET)) {
                focusOnEmpty();
            }
        } else if (focusTag != null) {
            if (!focusOnTag(focusTag)) {
                focusOnEmpty();
            }
            focusTag = null;
        } else {
            focusOnEmpty();
        }
    }
public void update ( ) { Log . d ( DEBUG_TAG , "update" ) ; View sv = getView ( ) ; LinearLayout ll = ( LinearLayout ) sv . findViewById ( R . id . form_container_layout ) ; if ( ll != null ) { while ( ll . getChildAt ( 0 ) instanceof EditableLayout ) { ll . removeViewAt ( 0 ) ; } } else { Log . d ( DEBUG_TAG , "update container layout null" ) ; return ; } final EditableLayout editableView = ( EditableLayout ) inflater . inflate ( R . layout . tag_form_editable , ll , false ) ; editableView . setSaveEnabled ( false ) ; int pos = 0 ; ll . addView ( editableView , pos ++ ) ; LinearLayout nonEditableView = ( LinearLayout ) getImmutableView ( ) ; if ( nonEditableView != null && nonEditableView . getChildCount ( ) > 0 ) { nonEditableView . removeAllViews ( ) ; } LinkedHashMap < String , String > allTags = tagListener . getKeyValueMapSingle ( true ) ; PresetItem mainPreset = tagListener . getBestPreset ( ) ; editableView . setTitle ( mainPreset , allTags . isEmpty ( ) ) ; editableView . setListeners ( tagListener , this ) ; editableView . applyPresetButton . setVisibility ( View . GONE ) ; editableView . applyPresetWithOptionalButton . setVisibility ( View . GONE ) ; Map < String , String > nonEditable ; if ( mainPreset != null ) { nonEditable = addTagsToViews ( editableView , mainPreset , allTags ) ; for ( PresetItem preset : tagListener . getSecondaryPresets ( ) ) { final EditableLayout editableView1 = ( EditableLayout ) inflater . inflate ( R . layout . tag_form_editable , ll , false ) ; editableView1 . setSaveEnabled ( false ) ; editableView1 . setTitle ( preset , false ) ; editableView1 . setListeners ( tagListener , this ) ; ll . addView ( editableView1 , pos ++ ) ; nonEditable = addTagsToViews ( editableView1 , preset , nonEditable ) ; } } else { nonEditable = allTags ; } LinearLayout nel = ( LinearLayout ) getView ( ) . findViewById ( R . id . form_immutable_header_layout ) ; if ( nel != null ) { nel . setVisibility ( View . GONE ) ; if ( nonEditable . size ( ) > 0 ) { nel . setVisibility ( View . VISIBLE ) ; for ( Entry < String , String > entry : nonEditable . entrySet ( ) ) { PresetTextField textField = new PresetTextField ( entry . getKey ( ) ) ; addRow ( nonEditableView , textField , entry . getValue ( ) , null , allTags ) ; } } } if ( displayMRUpresets ) { de . blau . android . propertyeditor . Util . addAlternativePresetItemsFragment ( getChildFragmentManager ( ) , R . id . alternative_layout , tagListener . getBestPreset ( ) ) ; } if ( focusOnAddress ) { focusOnAddress = false ; if ( ! focusOnTag ( Tags . KEY_ADDR_HOUSENUMBER ) && ! focusOnTag ( Tags . KEY_ADDR_STREET ) ) { focusOnEmpty ( ) ; } } else if ( focusTag != null ) { if ( ! focusOnTag ( focusTag ) ) { focusOnEmpty ( ) ; } focusTag = null ; } else { focusOnEmpty ( ) ; } }
Update the contents of the Fragment
Update the contents of the Fragment
// remove all editable stuff // if we have alternative tagging suggestions display them // some final UI stuff // only do it once