@@ -32,9 +32,27 @@ public LogTableAdapter(Activity activity, List<LogRow> rows) {
3232 this .rows = rows ;
3333 }
3434
35+ public LogTableAdapter (Activity activity ) {
36+ super ();
37+ this .activity = activity ;
38+ }
39+
40+ public void setData (List <LogRow > rows ) {
41+ this .rows = rows ;
42+ }
43+
44+ public List <LogRow > getData () {
45+ return this .rows ;
46+ }
47+
3548 @ Override
3649 public int getCount () {
37- return rows .size ();
50+ if (rows == null ) {
51+ return 0 ;
52+ }
53+ else {
54+ return rows .size ();
55+ }
3856 }
3957
4058 @ Override
@@ -55,27 +73,30 @@ public View getView(int position, View convertView, ViewGroup parent) {
5573 LayoutInflater inflater = activity .getLayoutInflater ();
5674 convertView = inflater .inflate (R .layout .log_row , null );
5775 }
76+ TextView col0 = (TextView ) convertView .findViewById (R .id .log_index );
5877 TextView col1 = (TextView ) convertView .findViewById (R .id .log_timestamp );
5978 TextView col2 = (TextView ) convertView .findViewById (R .id .log_ecuid );
6079 TextView col3 = (TextView ) convertView .findViewById (R .id .log_apid );
6180 TextView col4 = (TextView ) convertView .findViewById (R .id .log_ctid );
6281 TextView col5 = (TextView ) convertView .findViewById (R .id .log_subtype );
6382 TextView col6 = (TextView ) convertView .findViewById (R .id .log_payload );
6483
65- String timestamp = rows .get (position ).getColumn (0 );
66- String subtype = rows .get (position ).getColumn (4 );
84+ String timestamp = rows .get (position ).getColumn (LogRow . ROW_TIMESTAMP );
85+ String subtype = rows .get (position ).getColumn (LogRow . ROW_SUBTYPE );
6786
6887 int len = timestamp .length ();
6988 String new_timestamp = timestamp .substring (0 , len -4 ) + "." + timestamp .substring (len -4 , len );
70- Log .i (TAG , timestamp +" vs " +new_timestamp );
89+ // Log.i(TAG, timestamp+" vs "+new_timestamp);
90+ col0 .setText (rows .get (position ).getColumn (LogRow .ROW_INDEX ));
7191 col1 .setText (new_timestamp );
72- col2 .setText (rows .get (position ).getColumn (1 ));
73- col3 .setText (rows .get (position ).getColumn (2 ));
74- col4 .setText (rows .get (position ).getColumn (3 ));
92+ col2 .setText (rows .get (position ).getColumn (LogRow . ROW_ECUID ));
93+ col3 .setText (rows .get (position ).getColumn (LogRow . ROW_APID ));
94+ col4 .setText (rows .get (position ).getColumn (LogRow . ROW_CTID ));
7595 col5 .setText (subtype );
76- col6 .setText (rows .get (position ).getColumn (5 ));
96+ col6 .setText (rows .get (position ).getColumn (LogRow . ROW_PAYLOAD ));
7797
7898 if (subtype .equals ("error" ) || subtype .equals ("fatal" )) {
99+ col0 .setBackgroundResource (R .drawable .border_red );
79100 col1 .setBackgroundResource (R .drawable .border_red );
80101 col2 .setBackgroundResource (R .drawable .border_red );
81102 col3 .setBackgroundResource (R .drawable .border_red );
@@ -84,6 +105,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
84105 col6 .setBackgroundResource (R .drawable .border_red );
85106 }
86107 else if (subtype .equals ("warn" )) {
108+ col0 .setBackgroundResource (R .drawable .border_yellow );
87109 col1 .setBackgroundResource (R .drawable .border_yellow );
88110 col2 .setBackgroundResource (R .drawable .border_yellow );
89111 col3 .setBackgroundResource (R .drawable .border_yellow );
@@ -92,6 +114,7 @@ else if(subtype.equals("warn")) {
92114 col6 .setBackgroundResource (R .drawable .border_yellow );
93115 }
94116 else {
117+ col0 .setBackgroundResource (R .drawable .border );
95118 col1 .setBackgroundResource (R .drawable .border );
96119 col2 .setBackgroundResource (R .drawable .border );
97120 col3 .setBackgroundResource (R .drawable .border );
0 commit comments