Browse Source

Added Grouping in record overview

Julien Clauter 10 years ago
parent
commit
0a830cf718

+ 19 - 0
res/layout/expandable_section_header.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:padding="8dp"
+    android:background="#000000">
+
+
+    <TextView
+        android:id="@+id/sectionHeaderTitle"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
+        android:textSize="17dp"
+        android:textColor="#f9f93d" />
+
+</LinearLayout>

+ 2 - 2
res/layout/fragment_record_list.xml

@@ -4,7 +4,7 @@
     android:layout_height="match_parent"
     >
 
-            <ListView
+            <ExpandableListView
                 xmlns:android="http://schemas.android.com/apk/res/android"
                 android:id="@+id/loglistview"
                 android:layout_width="match_parent"
@@ -20,7 +20,7 @@
                 android:dividerHeight="10dp"
                 android:padding="5dp" >
 
-    </ListView>
+    </ExpandableListView>
 
     <RelativeLayout
         style="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"

+ 6 - 0
res/values/arrays.xml

@@ -12,4 +12,10 @@
         <item>All</item>
     </string-array>
 
+    <string-array name="Grouping">
+        <item>Protocol</item>
+        <item>BSSID</item>
+        <item>ESSID</item>
+    </string-array>
+
 </resources>

+ 20 - 9
src/de/tudarmstadt/informatik/hostage/ui/LogFilter.java

@@ -51,17 +51,19 @@ public class LogFilter implements Parcelable{
 	
 	
 	public LogFilter(){
-		this.belowTimestamp = Long.MAX_VALUE;
-		this.aboveTimestamp = Long.MIN_VALUE;
-		this.sorttype = SortType.timestamp;
-		this.BSSIDs = new ArrayList<String>();
-		this.ESSIDs = new ArrayList<String>();
-		this.protocols = new ArrayList<String>();
+		this.clear();
 
 	}
-	
-	
-	
+
+    public void clear(){
+        this.belowTimestamp = Long.MAX_VALUE;
+        this.aboveTimestamp = Long.MIN_VALUE;
+        this.sorttype = SortType.timestamp;
+        this.BSSIDs = new ArrayList<String>();
+        this.ESSIDs = new ArrayList<String>();
+        this.protocols = new ArrayList<String>();
+    }
+
 	    public int describeContents() {
 	        return 0;
 	    }
@@ -180,6 +182,15 @@ public class LogFilter implements Parcelable{
 		return this.convertArrayListToQueryString(this.protocols, key);
 	}
 
+    public boolean isSet(){
+        boolean hasTime = this.belowTimestamp != Long.MAX_VALUE|| this.aboveTimestamp != Long.MIN_VALUE;
+        boolean hasBSSIDs = this.getBSSIDs().size() > 0;
+        boolean hasESSIDs = this.getBSSIDs().size() > 0;
+        boolean hasProtocols = this.getProtocols().size() > 0;
+
+        return hasBSSIDs || hasESSIDs || hasProtocols | hasTime;
+    }
+
 	
 	public String convertArrayListToQueryString(ArrayList<String> list, String key){
 		String statement = "";

+ 123 - 0
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ExpandableListAdapter.java

@@ -0,0 +1,123 @@
+package de.tudarmstadt.informatik.hostage.ui2.adapter;
+
+import android.view.View;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+        import java.util.List;
+
+        import android.content.Context;
+        import android.view.LayoutInflater;
+        import android.view.ViewGroup;
+        import android.widget.BaseExpandableListAdapter;
+import android.widget.ExpandableListView;
+
+import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
+
+/**
+ * Created by Julien on 06.02.14.
+ */
+public abstract class ExpandableListAdapter extends BaseExpandableListAdapter {
+
+    private Context _context;
+
+    // header titles
+    public List<String> _sectionHeader;
+    // data in format of header title, childs list
+    public HashMap<String, ArrayList<ExpandableListItem>> _sectionTitleToChildData;
+
+    /*CONSTRUCTOR*/
+    public ExpandableListAdapter(Context context, List<String> listSectionHeaders,
+                                 HashMap<String, ArrayList<ExpandableListItem>> dataMapping) {
+        this._context = context;
+        this._sectionHeader = listSectionHeaders;
+        this._sectionTitleToChildData = dataMapping;
+    }
+
+    @Override
+    public Object getChild(int section, int row) {
+        return this._sectionTitleToChildData.get(this._sectionHeader.get(section))
+                .get(row);
+    }
+
+    @Override
+    public long getChildId(int section, int row) {
+        return row;
+    }
+
+    @Override
+    public View getChildView(int section, final int row,
+                             boolean isLastChild, View convertView, ViewGroup parent) {
+        if (convertView == null) {
+            LayoutInflater infalInflater = (LayoutInflater) this._context
+                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            convertView = infalInflater.inflate(this.getCellLayoutID(), null);
+        }
+        this.configureCellView(convertView, section, row);
+        return convertView;
+    }
+
+    @Override
+    public int getChildrenCount(int section) {
+        return this._sectionTitleToChildData.get(this._sectionHeader.get(section))
+                .size();
+    }
+
+    @Override
+    public Object getGroup(int section) {
+        return this._sectionHeader.get(section);
+    }
+
+    @Override
+    public int getGroupCount() {
+        return this._sectionHeader.size();
+    }
+
+    @Override
+    public long getGroupId(int section) {
+        return section;
+    }
+
+    @Override
+    public View getGroupView(int section, boolean isExpanded,
+                             View convertView, ViewGroup parent) {
+
+        if (convertView == null) {
+            LayoutInflater infalInflater = (LayoutInflater) this._context
+                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            convertView = infalInflater.inflate(this.getSectionLayoutID(), null);
+        }
+        this.configureSectionHeaderView(convertView, section);
+
+        return convertView;
+    }
+
+
+    public ExpandableListItem getDataForRow(int section, int row){
+        return this._sectionTitleToChildData.get(this._sectionHeader.get(section)).get(row);
+    }
+
+
+    public abstract void configureCellView(View cell, int section, int row);
+    public abstract void configureSectionHeaderView(View sectionHeader, int section);
+
+    /*
+    * @return R.layout.list_section
+    * */
+    public abstract  int getSectionLayoutID();
+    /*
+     * @return R.layout.list_cell
+     * */
+    public abstract  int getCellLayoutID();
+
+
+    @Override
+    public boolean hasStableIds() {
+        return false;
+    }
+
+    @Override
+    public boolean isChildSelectable(int section, int row) {
+        return true;
+    }
+}

+ 37 - 51
src/de/tudarmstadt/informatik/hostage/ui2/adapter/RecordListAdapter.java

@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 
 import android.annotation.SuppressLint;
 import android.content.Context;
@@ -14,61 +15,46 @@ import android.view.ViewGroup;
 import android.widget.SimpleAdapter;
 import android.widget.TextView;
 import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
+
+public class RecordListAdapter extends ExpandableListAdapter {
+
+    public RecordListAdapter(Context context, List<String> listSectionHeaders, HashMap<String, ArrayList<ExpandableListItem>> dataMapping) {
+        super(context, listSectionHeaders, dataMapping);
+    }
+
+
+    /*****************************
+     *
+     *          Required Methods
+     *
+     * ***************************/
 
-public class RecordListAdapter extends SimpleAdapter {
-    private final Context context;
-    private final ArrayList<HashMap<String, String>> values;
-    private String[] from;
-	private int[] to;
-    
-	public RecordListAdapter(Context context, ArrayList<HashMap<String, String>> objects, int resource, String[] from,
-			int[] to) {
-		super(context, objects, resource, from, to);
-        this.context = context;
-        this.values  = objects;
-        this.from = from;
-        this.to = to;
-	}
-	
     @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-        LayoutInflater inflater = (LayoutInflater) context
-                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-        View rowView = inflater.inflate(R.layout.record_list_item, parent, false);
-        
-        
-        HashMap<String, String> object = this.values.get(position);
-        
-        for(int i = 0; i < this.from.length; i++){
-        	String key = this.from[i];
-        	String text = object.get(key);
-        	int id = this.to[i];
-        	TextView tView = (TextView) rowView.findViewById(id);
-        	tView.setText(text);
+    public void configureCellView(View cell, int section, int row) {
+        ExpandableListItem object = this.getDataForRow(section, row);
+        for (String key : object.getId_Mapping().keySet()){
+            int viewID = object.getId_Mapping().get(key);
+            String textualInfo = object.getData().get(key);
+            TextView tView = (TextView) cell.findViewById(viewID);
+            tView.setText(textualInfo);
         }
-        
-        return rowView;
     }
-    
-    
-	
-	/*****************************
-	 * 
-	 *          Date Transform
-	 * 
-	 * ***************************/
-	
-	
-	@SuppressLint("SimpleDateFormat")
-	private String getDateAsString(long timeStamp) {
 
-		try {
-			DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
-			Date netDate = (new Date(timeStamp));
-			return sdf.format(netDate);
-		} catch (Exception ex) {
-			return "xx";
-		}
-	}
+    @Override
+    public void configureSectionHeaderView(View sectionHeader, int section) {
+        int headerLabelID = R.id.sectionHeaderTitle;
+        TextView tView = (TextView) sectionHeader.findViewById(headerLabelID);
+        tView.setText(this._sectionHeader.get(section));
+    }
+
+    @Override
+    public int getSectionLayoutID() {
+        return R.layout.expandable_section_header;
+    }
 
+    @Override
+    public int getCellLayoutID() {
+        return R.layout.record_list_item;
+    }
 }

+ 17 - 1
src/de/tudarmstadt/informatik/hostage/ui2/dialog/DateTimeDialogFragment.java

@@ -2,6 +2,7 @@ package de.tudarmstadt.informatik.hostage.ui2.dialog;
 
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.Locale;
 
 import de.tudarmstadt.informatik.hostage.R;
@@ -85,7 +86,21 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
             break;
         }
     }
-    
+
+    public void setDate(long timeInMillis){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis (timeInMillis);
+
+        int year    = calendar.get(Calendar.YEAR) ;
+        int month   = calendar.get(Calendar.MONTH);
+        int day     = calendar.get(Calendar.DATE);
+        int hour    = calendar.get(Calendar.HOUR);
+        int min     = calendar.get(Calendar.MINUTE);
+
+        datePicker.updateDate(year, month, day);
+        timePicker.setCurrentHour(hour);
+        timePicker.setCurrentMinute(min);
+    }
 
    public long getDate(){
 	   
@@ -97,6 +112,7 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
        int minute = timePicker.getCurrentMinute();
 
        Calendar calendar = Calendar.getInstance();
+
        calendar.set(year, month, day, hourOfDay, minute);
 
        return calendar.getTime().getTime();

+ 128 - 40
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -24,9 +24,8 @@ import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
+import android.widget.ExpandableListView;
 import android.widget.ImageButton;
-import android.widget.ListAdapter;
-import android.widget.ListView;
 import android.widget.PopupMenu;
 import android.widget.PopupMenu.OnMenuItemClickListener;
 import android.widget.Toast;
@@ -39,6 +38,7 @@ import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
 import de.tudarmstadt.informatik.hostage.ui2.adapter.RecordListAdapter;
 import de.tudarmstadt.informatik.hostage.ui2.dialog.ChecklistDialog;
 import de.tudarmstadt.informatik.hostage.ui2.dialog.DateTimeDialogFragment;
+import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
 
 public class RecordOverviewFragment extends Fragment implements ChecklistDialog.ChecklistDialogListener, DateTimeDialogFragment.DateTimeDialogFragmentListener {
 	static final String SELECTED_KEY = "Selected";
@@ -55,10 +55,13 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	private boolean wasBelowTimePicker;
 
 	private LogFilter filter;
-	private ListView listView;
 	private boolean showFilterButton;
 	DatabaseHandler dbh;
-	
+
+    public String groupingKey;
+
+    private ExpandableListView expListView;
+
 	
     public RecordOverviewFragment(){}
     
@@ -74,22 +77,29 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
 		dbh = new DatabaseHandler(this.getActivity().getBaseContext());
 	    // Get the message from the intent
-	    Intent intent = this.getActivity().getIntent();
-	    LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
 
-	    if(filter == null){
-	    	this.clearFilter();
-	    } else {
-	    	this.filter = filter;
-	    }
+        if (this.filter == null){
+            Intent intent = this.getActivity().getIntent();
+            LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
+
+            if(filter == null){
+                this.clearFilter();
+            } else {
+                this.filter = filter;
+            }
+        }
+
+
+
+        if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(0);
 
 	    this.setShowFilterButton(!this.filter.isNotEditable());
 	    
 	    this.addRecordToDB();
 	    
 		View rootView = inflater.inflate(R.layout.fragment_record_list, container, false);
-		ListView mylist = (ListView) rootView.findViewById(R.id.loglistview);
-		this.listView = mylist;
+		ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
+		this.expListView = mylist;
 		populateListViewFromDB(mylist);
 		
 		registerListClickCallback(mylist);
@@ -154,30 +164,49 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	 * 
 	 * ***************************/
 	
-	private void populateListViewFromDB(ListView mylist) {
+	private void populateListViewFromDB(ExpandableListView mylist) {
 		
-		ArrayList<HashMap<String, String>> items = new ArrayList<HashMap<String, String>>();
+		HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
 
-		ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);    
-		
+		ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);
+
+        // Adding Items to ListView
+        String keys[] = new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp)};
+        int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
+
+        HashMap<String, Integer> mapping = new HashMap<String, Integer>();
+        int i = 0;
+        for(String key : keys){
+            mapping.put(key, ids[i]);
+            i++;
+        }
 
 		for (Record val : data) {
+            // DO GROUPING IN HERE
 			HashMap<String, String> map = new HashMap<String, String>();
 			map.put(this.getString(R.string.RecordBSSID), val.getBSSID());
 			map.put(this.getString(R.string.RecordSSID), val.getSSID());
 			map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
 			map.put(this.getString(R.string.RecordTimestamp),
 					this.getDateAsString(val.getTimestamp()));
-			items.add(map);
+
+            ExpandableListItem item = new ExpandableListItem();
+            item.setData(map);
+            item.setId_Mapping(mapping);
+
+            String groupID = this.getGroupValue(val);
+
+            ArrayList<ExpandableListItem> items = sectionData.get(groupID);
+            if (items == null) {
+                items = new ArrayList<ExpandableListItem>();
+                sectionData.put(groupID, items);
+            }
+			items.add(item);
 		}
-	        
-	     // Adding Items to ListView
-	        String keys[] = new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp)};
-	        int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
-	        
-	        ListAdapter adapter = new RecordListAdapter(this.getActivity(), items, R.layout.loglist_row, keys, ids);
-	        
-	        mylist.setAdapter(adapter);
+
+        RecordListAdapter adapter = new RecordListAdapter(this.getApplicationContext(),this.getGroupTitle(), sectionData);
+
+        mylist.setAdapter(adapter);
 	}
 	
 	private Context getBaseContext(){
@@ -188,7 +217,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		return this.getActivity().getApplicationContext();
 	}
 	
-	private void registerListClickCallback(ListView mylist) {
+	private void registerListClickCallback(ExpandableListView mylist) {
 
 		mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
 			public void onItemClick(AdapterView<?> parent, View viewClicked,
@@ -285,19 +314,54 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		this.wasBelowTimePicker = false;
 		DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
+        if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
 	}
 	
 	private void openTimestampToFilterDialog(){
 		this.wasBelowTimePicker = true;
 		DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
-	}
+        if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
+    }
 	
 	private void openSortingDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTtiles(), this.selectedSorttype(), false , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
 	}
-	
+
+    /*****************************
+     *
+     *          Grouping Stuff
+     *
+     * ***************************/
+
+    public String getGroupValue(Record rec){
+        int index = this.groupingTitles().indexOf(this.groupingKey);
+        switch (index){
+            case 0:
+                return rec.getProtocol();
+            case 1:
+                return rec.getBSSID();
+            case 2:
+                return rec.getSSID();
+            default:
+                return rec.getProtocol();
+        }
+    }
+
+    public ArrayList<String> getGroupTitle(){
+        int index = this.groupingTitles().indexOf(this.groupingKey);
+        switch (index){
+            case 0:
+                return this.protocolTitles();
+            case 1:
+                return this.bssids();
+            case 2:
+                return this.essids();
+            default:
+                return this.protocolTitles();
+        }
+    }
 
 	/*****************************
 	 * 
@@ -325,12 +389,18 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	
 	
 	private void clearFilter(){
-    	this.filter = new LogFilter();
-    	this.filter.setProtocols(this.protocolTitles());
-    	this.filter.setBSSIDs(this.bssids());
-    	this.filter.setESSIDs(this.essids());
+    	if(filter == null) this.filter = new LogFilter();
+    	this.filter.clear();
 	}
-	
+
+    public ArrayList<String> groupingTitles(){
+        ArrayList<String> titles = new ArrayList<String>();
+        for (String groupTitle : this.getResources().getStringArray(
+                R.array.Grouping)) {
+            titles.add(groupTitle);
+        }
+        return titles;
+    }
 	
 	public ArrayList<String> protocolTitles(){
 		ArrayList<String> titles = new ArrayList<String>();
@@ -416,7 +486,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		titles.add(FILTER_MENU_TITLE_PROTOCOLS);
 		titles.add(FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
 		titles.add(FILTER_MENU_TITLE_TIMESTAMP_BELOW);
-		titles.add(FILTER_MENU_TITLE_REMOVE);
+        if (this.filter.isSet())titles.add(FILTER_MENU_TITLE_REMOVE);
 		return titles;
 	}
 
@@ -433,7 +503,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		} else {
 			this.filter.setAboveTimestamp(dialog.getDate());
 		}
-		this.populateListViewFromDB(listView);
+		this.populateListViewFromDB(this.expListView);
 	}
 
 	public void onDateTimePickerNegativeClick(DateTimeDialogFragment dialog) {
@@ -447,13 +517,28 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	public void onDialogPositiveClick(ChecklistDialog dialog) {
 		String title = dialog.getTitle();
 		if(title.equals(FILTER_MENU_TITLE_BSSID)){
-			this.filter.setBSSIDs(dialog.getSelectedItemTitles());
+            ArrayList<String> titles =dialog.getSelectedItemTitles();
+            if (titles.size() == this.bssids().size()){
+                this.filter.setBSSIDs(new ArrayList<String>());
+            } else {
+                this.filter.setBSSIDs(titles);
+            }
 		}
 		if(title.equals(FILTER_MENU_TITLE_ESSID)){
-			this.filter.setESSIDs(dialog.getSelectedItemTitles());
+            ArrayList<String> titles =dialog.getSelectedItemTitles();
+            if (titles.size() == this.essids().size()){
+                this.filter.setESSIDs(new ArrayList<String>());
+            } else {
+                this.filter.setESSIDs(titles);
+            }
 		}
 		if(title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
-			this.filter.setProtocols(dialog.getSelectedItemTitles());
+            ArrayList<String> protocols = dialog.getSelectedItemTitles();
+            if (protocols.size() == this.protocolTitles().size()){
+                this.filter.setProtocols(new ArrayList<String>());
+            } else {
+			    this.filter.setProtocols(dialog.getSelectedItemTitles());
+            }
 		}
 		if(title.equals(FILTER_MENU_TITLE_SORTING)){
 			ArrayList<String> titles = dialog.getSelectedItemTitles();
@@ -461,7 +546,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 			int sortType = this.sortTypeTtiles().indexOf(t);
 			this.filter.setSorttype(SortType.values()[sortType]);
 		}
-		this.populateListViewFromDB(this.listView);
+		this.populateListViewFromDB(this.expListView);
 	}
 
 	public void onDialogNegativeClick(ChecklistDialog dialog) {
@@ -476,6 +561,9 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	 * ***************************/
 	
 	private void addRecordToDB() {
+
+        if (dbh.getAllRecords().size() > 0) return;
+
 		Calendar cal = Calendar.getInstance();
 
 		int maxProtocolsIndex = this.getResources().getStringArray(

+ 33 - 0
src/de/tudarmstadt/informatik/hostage/ui2/model/ExpandableListItem.java

@@ -0,0 +1,33 @@
+package de.tudarmstadt.informatik.hostage.ui2.model;
+
+import java.util.HashMap;
+
+import de.tudarmstadt.informatik.hostage.handler.StringHandler;
+
+/**
+ * Created by Julien on 06.02.14.
+ */
+public class ExpandableListItem {
+
+    /*Mapping Data Key To ViewID*/
+    public HashMap<String, Integer> id_Mapping;
+
+    /*Data Key To Textual Information*/
+    public HashMap<String, String> data;
+
+
+
+    public HashMap<String, Integer> getId_Mapping() {
+        return id_Mapping;
+    }
+    public void setId_Mapping(HashMap<String, Integer> id_Mapping) {
+        this.id_Mapping = id_Mapping;
+    }
+
+    public HashMap<String, String> getData(){
+        return this.data;
+    }
+    public void setData(HashMap<String, String> _data){
+        this.data = _data;
+    }
+}