Browse Source

source clean in record overview

Julien Clauter 10 years ago
parent
commit
f31a7aab50

+ 11 - 16
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -75,6 +75,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
     static final String FILTER_MENU_POPUP_TITLE = MainActivity.getContext().getString(
 			R.string.rec_filter_by);
 
+    static final int DEFAULT_GROUPING_KEY_INDEX = 0;
+
     private boolean wasBelowTimePicker;
 
     private LogFilter filter;
@@ -142,7 +144,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
             }
         }
 
-        if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(0);
+        if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(DEFAULT_GROUPING_KEY_INDEX);
 
 	    this.setShowFilterButton(!this.filter.isNotEditable());
 
@@ -211,8 +213,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
                             if (adapter != null){
                                 adapter.notifyDataSetChanged();
 
-                                if (adapter.getGroupCount() == 1){
-                                    RecordOverviewFragment.this.expListView.expandGroup(0);
+                                if (adapter.getGroupCount() == 1 || sectionToOpen == null || sectionToOpen.length() == 0){
+                                    RecordOverviewFragment.this.expListView.expandGroup(DEFAULT_GROUPING_KEY_INDEX);
                                 } else {
                                     RecordOverviewFragment.this.setSectionToOpen(RecordOverviewFragment.this.sectionToOpen);
                                 }
@@ -491,7 +493,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
             items.add(item);
         }
 
-        if (this.groupingKey.equals(this.groupingTitles().get(0))){
+        if (this.groupingKey.equals(this.groupingTitles().get(DEFAULT_GROUPING_KEY_INDEX))){
             Collections.sort(groupTitle,new StringDateComparator());
         } else {
             Collections.sort(groupTitle, new Comparator<String>() {
@@ -804,7 +806,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
             case 0:
                 return this.getFormattedDate(rec.getTimestamp());
             default:
-                return rec.getProtocol();
+                return this.getFormattedDate(rec.getTimestamp());
         }
     }
 
@@ -819,21 +821,14 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
                 return this.bssids();
             case 3:
                 return this.essids();
-            case 0:{
-                RecordListAdapter adapter = (RecordListAdapter) this.expListView.getExpandableListAdapter();
-                if (adapter != null){
-                    return adapter.getSectionHeaders();
-                }
-                return new ArrayList<String>();
-            }
-            default:{
+            case 0:
+            default:
                 RecordListAdapter adapter = (RecordListAdapter) this.expListView.getExpandableListAdapter();
                 if (adapter != null){
                     return adapter.getSectionHeaders();
                 }
                 return new ArrayList<String>();
             }
-            }
     }
 
 
@@ -1139,14 +1134,14 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		if(title.equals(FILTER_MENU_TITLE_SORTING)){
 			ArrayList<String> titles = dialog.getSelectedItemTitles();
             if (titles.size() == 0) return;
-			String t = titles.get(0);
+			String t = titles.get(DEFAULT_GROUPING_KEY_INDEX);
 			int sortType = this.sortTypeTiles().indexOf(t);
 			this.filter.setSorttype(SortType.values()[sortType]);
 		}
         if (title.equals(FILTER_MENU_TITLE_GROUP)){
             ArrayList<String> titles = dialog.getSelectedItemTitles();
             if (titles.size() == 0) return;
-            this.groupingKey =  titles.get(0);
+            this.groupingKey =  titles.get(DEFAULT_GROUPING_KEY_INDEX);
         }
         this.actualiseListViewInBackground();