ソースを参照

small clean in record over view

Julien Clauter 11 年 前
コミット
d71c027b87

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

@@ -72,6 +72,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
     UglyDbHelper dbh;
 
     private String sectionToOpen = "";
+    private ArrayList<Integer> openSections;
 
     public void setFilter(LogFilter filter){
         this.filter = filter;
@@ -119,28 +120,20 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		View rootView = inflater.inflate(this.getLayoutId(), container, false);
 		ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
 
-        ArrayList<Integer> openSections = new ArrayList<Integer>();
-        if(this.expListView != null){
-            int numOfGroups = this.expListView.getExpandableListAdapter().getGroupCount();
-
-            for (int i = 0; i < numOfGroups; i++){
-                boolean isOpen = this.expListView.isGroupExpanded(i);
-                if (isOpen){
-                    openSections.add(i);
-                }
-            }
-        }
-
 		this.expListView = mylist;
 		populateListViewFromDB(mylist);
 
-        if (openSections.size() != 0){
-            for (int i = 0; i < openSections.size(); i++){
-                int index = openSections.get(i);
+        if (this.openSections != null && this.openSections.size() != 0){
+            for (int i = 0; i < this.openSections.size(); i++){
+                int index = this.openSections.get(i);
                 this.expListView.expandGroup(index);
             }
+        } else {
+            this.openSections = new ArrayList<Integer>();
         }
 
+        //this.expListView.smoothScrollToPosition(scrollPosition);
+
 		registerListClickCallback(mylist);
 
         ImageButton filterButton = (ImageButton) rootView.findViewById(R.id.FilterButton);
@@ -351,7 +344,18 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
                 return true;
             }
         });
-
+        mylist.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
+            @Override
+            public void onGroupExpand(int i) {
+                RecordOverviewFragment.this.openSections.add(i);
+            }
+        });
+        mylist.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
+            @Override
+            public void onGroupCollapse(int i) {
+                RecordOverviewFragment.this.openSections.remove(i);
+            }
+        });
 	}