@@ -0,0 +1,3043 @@
+package de.cs.fau.mad.quickshop_android;%0A%0A/**%0A * Created by Robert on 01.05.2015.%0A */%0A%0Aimport android.app.Activity;%0Aimport android.content.SharedPreferences;%0Aimport android.os.Bundle;%0Aimport android.support.v4.app.Fragment;%0Aimport android.support.v4.app.FragmentManager;%0Aimport android.util.Log;%0Aimport android.view.LayoutInflater;%0Aimport android.view.Menu;%0Aimport android.view.MenuInflater;%0Aimport android.view.MenuItem;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.widget.EditText;%0Aimport android.widget.ListView;%0A%0Aimport java.util.Set;%0Aimport java.util.TreeSet;%0A%0Aimport cs.fau.mad.quickshop_android.R;%0A%0A%0Apublic  class AddListFragment extends Fragment %7B%0A%0A    private static final String ARG_SECTION_NUMBER = %22section_number%22;%0A    private static final String DATA = %22data%22;%0A    private static final String SHOPPING_LIST = %22shopping_list%22;%0A%0A    private ListView listView;%0A    private ListRowAdapter mListRowAdapter;%0A    private EditText etNewListName;%0A%0A    public static AddListFragment newInstance(int sectionNumber) %7B%0A        AddListFragment fragment = new AddListFragment();%0A        Bundle args = new Bundle();%0A        args.putInt(ARG_SECTION_NUMBER, sectionNumber);%0A        fragment.setArguments(args);%0A        return fragment;%0A    %7D%0A%0A    @Override%0A    public View onCreateView(LayoutInflater inflater, ViewGroup container,%0A                             Bundle savedInstanceState) %7B%0A        View rootView = inflater.inflate(R.layout.fragment_add_list, container, false);%0A        etNewListName = (EditText) rootView.findViewById(R.id.et_add_list_name);%0A        setHasOptionsMenu(true); // Report that this fragment would like to participate in populating the options menu%0A%0A        return rootView;%0A    %7D%0A%0A    @Override%0A    public void onAttach(Activity activity) %7B%0A        super.onAttach(activity);%0A        ((MainActivity) activity).onSectionAttached(%0A                getArguments().getInt(ARG_SECTION_NUMBER));%0A    %7D%0A%0A    @Override%0A    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) %7B%0A        inflater.inflate(R.menu.add_list_menu, menu);%0A    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A%0A%0A        switch (item.getItemId())%7B%0A            case R.id.action_add_list_save:%0A                saveNewShoppingList();%0A                return true;%0A%0A            default:%0A                return true;%0A        %7D%0A    %7D%0A%0A    private void saveNewShoppingList() %7B%0A%0A        SharedPreferences data = getActivity().getSharedPreferences(DATA, 0);%0A        SharedPreferences.Editor editor = data.edit();%0A        Set%3CString%3E shoppingList = data.getStringSet(SHOPPING_LIST, null);%0A%0A        if(shoppingList == null)%7B%0A            shoppingList = new TreeSet%3CString%3E();%0A            Log.d(%22AddListFragment%22, %22shoppingList is null%22);%0A        %7D%0A%0A        Set%3CString%3E copyShoppinsList = new TreeSet%3CString%3E(shoppingList);%0A        copyShoppinsList.add(etNewListName.getText().toString());%0A        editor.putStringSet(SHOPPING_LIST,copyShoppinsList);%0A        editor.apply();%0A%0A        // TODO%0A%0A    %7D%0A%7D%0A

save list name in SharePreferences