Bladeren bron

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/scm-ssi-student-hostagev2

Fabio Arnold 10 jaren geleden
bovenliggende
commit
357286a0e6

+ 29 - 0
src/de/tudarmstadt/informatik/hostage/logging/UglyDbHelper.java

@@ -713,6 +713,35 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 		return recordList;
 	}
 
+
+    /*
+    * Returns the Conversation of a specific attack id
+    * @param attack_id
+    *           Tha attack id to match the query against.
+    *
+    *  @return A arraylist with all {@link Record Records}s for an attack id.
+    *
+    * */
+    public ArrayList<Record> getConversationForAttackID(long attack_id) {
+        ArrayList<Record> recordList = new ArrayList<Record>();
+        String selectQuery = "SELECT  * FROM " + TABLE_RECORDS
+                + " NATURAL JOIN " + TABLE_ATTACK_INFO + " JOIN "
+                + TABLE_BSSIDS + " USING " + "(" + KEY_BSSID + ")" + " WHERE " + TABLE_RECORDS+"."+KEY_ATTACK_ID + " = " + attack_id;
+
+        SQLiteDatabase db = this.getReadableDatabase();
+        Cursor cursor = db.rawQuery(selectQuery, null);
+
+        if (cursor.moveToFirst()) {
+            do {
+                Record record = createRecord(cursor);
+                recordList.add(record);
+            } while (cursor.moveToNext());
+        }
+        cursor.close();
+
+        db.close();
+        return recordList;
+    }
 	/**
 	 * Gets a representative {@link Record} for every attack with a higher
 	 * attack id than the specified.

+ 12 - 3
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -65,6 +65,9 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
     private LogFilter filter;
     private boolean showFilterButton;
 
+    private int mListPosition = -1;
+    private int mItemPosition = -1;
+
     public String groupingKey;
 
     private ExpandableListView expListView;
@@ -132,7 +135,11 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
             this.openSections = new ArrayList<Integer>();
         }
 
-        //this.expListView.smoothScrollToPosition(scrollPosition);
+        if (mListPosition != -1 && mItemPosition != -1)
+            this.expListView.setSelectedChild(mListPosition, mItemPosition, true);
+
+        mListPosition = -1;
+        mItemPosition = -1;
 
 		registerListClickCallback(mylist);
 
@@ -338,6 +345,8 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
                 ExpandableListItem item = (ExpandableListItem)adapter.getChild(i,i2);
 
+                mListPosition = i;
+                mItemPosition = i2;
                 UglyDbHelper dbh = new UglyDbHelper(getBaseContext());
                 Record rec = dbh.getRecordOfAttackId((int) item.getTag());
                 RecordOverviewFragment.this.pushRecordDetailViewForRecord(rec);
@@ -347,13 +356,13 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
         mylist.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
             @Override
             public void onGroupExpand(int i) {
-                RecordOverviewFragment.this.openSections.add(i);
+                RecordOverviewFragment.this.openSections.add(new Integer(i));
             }
         });
         mylist.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
             @Override
             public void onGroupCollapse(int i) {
-                RecordOverviewFragment.this.openSections.remove(i);
+                RecordOverviewFragment.this.openSections.remove(new Integer(i));
             }
         });
 	}