Skip to content

Commit 0146097

Browse files
committed
for burst data test
1 parent 5fec654 commit 0146097

File tree

6 files changed

+207
-112
lines changed

6 files changed

+207
-112
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ So I use some special way to build this project.
5050
[How to run the same asynctask more than once?](https://stackoverflow.com/questions/6879584/how-to-run-the-same-asynctask-more-than-once)
5151

5252
[Show a context menu for long-clicks in an Android ListView](https://www.mikeplate.com/2010/01/21/show-a-context-menu-for-long-clicks-in-an-android-listview/)
53+
54+
[Using an ArrayAdapter with ListView](https://github.com/codepath/android_guides/wiki/Using-an-ArrayAdapter-with-ListView)
55+

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.
2525
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/ControlActivity.java
2626
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/LogRow.java
2727
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/LogTableAdapter.java
28-
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/MainActivity.java
28+
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 -Xlint:deprecation java/src/com/zeerd/dltviewer/MainActivity.java
2929
javac -d obj -classpath java/src -bootclasspath $PLATFORM -source 1.7 -target 1.7 java/src/com/zeerd/dltviewer/R.java
3030

3131
echo "Translating in Dalvik bytecode..."

java/src/com/zeerd/dltviewer/LogRow.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616

1717
public class LogRow {
1818

19-
private String[] column = new String[7];
20-
2119
public static final int ROW_INDEX = 0;
2220
public static final int ROW_TIMESTAMP = 1;
2321
public static final int ROW_ECUID = 2;
2422
public static final int ROW_APID = 3;
2523
public static final int ROW_CTID = 4;
2624
public static final int ROW_SUBTYPE = 5;
2725
public static final int ROW_PAYLOAD = 6;
26+
public static final int ROW_COUNT = 7;
27+
28+
private String[] column = new String[ROW_COUNT];
2829

2930
public LogRow(
3031
String index,

java/src/com/zeerd/dltviewer/LogTableAdapter.java

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public class LogTableAdapter extends BaseAdapter {
2626
private List<LogRow> rows;
2727
private static final String TAG = "DLT-Viewer";
2828

29+
private static class ViewHolder {
30+
private TextView[] column = new TextView[LogRow.ROW_COUNT];
31+
}
32+
2933
public LogTableAdapter(Activity activity, List<LogRow> rows) {
3034
super();
3135
this.activity = activity;
@@ -69,60 +73,60 @@ public long getItemId(int position) {
6973
@Override
7074
public View getView(int position, View convertView, ViewGroup parent) {
7175

76+
int i;
77+
LogRow logRow = (LogRow)getItem(position);
78+
79+
ViewHolder viewHolder;
7280
if (convertView == null) {
81+
viewHolder = new ViewHolder();
7382
LayoutInflater inflater = activity.getLayoutInflater();
7483
convertView = inflater.inflate(R.layout.log_row, null);
84+
85+
viewHolder.column[LogRow.ROW_INDEX] = (TextView) convertView.findViewById(R.id.log_index);
86+
viewHolder.column[LogRow.ROW_TIMESTAMP] = (TextView) convertView.findViewById(R.id.log_timestamp);
87+
viewHolder.column[LogRow.ROW_ECUID] = (TextView) convertView.findViewById(R.id.log_ecuid);
88+
viewHolder.column[LogRow.ROW_APID] = (TextView) convertView.findViewById(R.id.log_apid);
89+
viewHolder.column[LogRow.ROW_CTID] = (TextView) convertView.findViewById(R.id.log_ctid);
90+
viewHolder.column[LogRow.ROW_SUBTYPE] = (TextView) convertView.findViewById(R.id.log_subtype);
91+
viewHolder.column[LogRow.ROW_PAYLOAD] = (TextView) convertView.findViewById(R.id.log_payload);
92+
93+
convertView.setTag(viewHolder);
94+
}
95+
else {
96+
viewHolder = (ViewHolder) convertView.getTag();
7597
}
76-
TextView col0 = (TextView) convertView.findViewById(R.id.log_index);
77-
TextView col1 = (TextView) convertView.findViewById(R.id.log_timestamp);
78-
TextView col2 = (TextView) convertView.findViewById(R.id.log_ecuid);
79-
TextView col3 = (TextView) convertView.findViewById(R.id.log_apid);
80-
TextView col4 = (TextView) convertView.findViewById(R.id.log_ctid);
81-
TextView col5 = (TextView) convertView.findViewById(R.id.log_subtype);
82-
TextView col6 = (TextView) convertView.findViewById(R.id.log_payload);
8398

8499
String timestamp = rows.get(position).getColumn(LogRow.ROW_TIMESTAMP);
85100
String subtype = rows.get(position).getColumn(LogRow.ROW_SUBTYPE);
86101

87102
int len = timestamp.length();
88103
String new_timestamp = timestamp.substring(0, len-4) + "." + timestamp.substring(len-4, len);
89104
// Log.i(TAG, timestamp+" vs "+new_timestamp);
90-
col0.setText(rows.get(position).getColumn(LogRow.ROW_INDEX));
91-
col1.setText(new_timestamp);
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));
95-
col5.setText(subtype);
96-
col6.setText(rows.get(position).getColumn(LogRow.ROW_PAYLOAD));
105+
106+
viewHolder.column[LogRow.ROW_INDEX].setText(rows.get(position).getColumn(LogRow.ROW_INDEX));
107+
viewHolder.column[LogRow.ROW_TIMESTAMP].setText(new_timestamp);
108+
viewHolder.column[LogRow.ROW_ECUID].setText(rows.get(position).getColumn(LogRow.ROW_ECUID));
109+
viewHolder.column[LogRow.ROW_APID].setText(rows.get(position).getColumn(LogRow.ROW_APID));
110+
viewHolder.column[LogRow.ROW_CTID].setText(rows.get(position).getColumn(LogRow.ROW_CTID));
111+
viewHolder.column[LogRow.ROW_SUBTYPE].setText(subtype);
112+
viewHolder.column[LogRow.ROW_PAYLOAD].setText(rows.get(position).getColumn(LogRow.ROW_PAYLOAD));
97113

98114
if(subtype.equals("error") || subtype.equals("fatal")) {
99-
col0.setBackgroundResource(R.drawable.border_red);
100-
col1.setBackgroundResource(R.drawable.border_red);
101-
col2.setBackgroundResource(R.drawable.border_red);
102-
col3.setBackgroundResource(R.drawable.border_red);
103-
col4.setBackgroundResource(R.drawable.border_red);
104-
col5.setBackgroundResource(R.drawable.border_red);
105-
col6.setBackgroundResource(R.drawable.border_red);
115+
for(i=0;i<LogRow.ROW_COUNT;i++) {
116+
viewHolder.column[i].setBackgroundResource(R.drawable.border_red);
117+
}
106118
}
107119
else if(subtype.equals("warn")) {
108-
col0.setBackgroundResource(R.drawable.border_yellow);
109-
col1.setBackgroundResource(R.drawable.border_yellow);
110-
col2.setBackgroundResource(R.drawable.border_yellow);
111-
col3.setBackgroundResource(R.drawable.border_yellow);
112-
col4.setBackgroundResource(R.drawable.border_yellow);
113-
col5.setBackgroundResource(R.drawable.border_yellow);
114-
col6.setBackgroundResource(R.drawable.border_yellow);
120+
for(i=0;i<LogRow.ROW_COUNT;i++) {
121+
viewHolder.column[i].setBackgroundResource(R.drawable.border_yellow);
122+
}
115123
}
116124
else {
117-
col0.setBackgroundResource(R.drawable.border);
118-
col1.setBackgroundResource(R.drawable.border);
119-
col2.setBackgroundResource(R.drawable.border);
120-
col3.setBackgroundResource(R.drawable.border);
121-
col4.setBackgroundResource(R.drawable.border);
122-
col5.setBackgroundResource(R.drawable.border);
123-
col6.setBackgroundResource(R.drawable.border);
125+
for(i=0;i<LogRow.ROW_COUNT;i++) {
126+
viewHolder.column[i].setBackgroundResource(R.drawable.border);
127+
}
124128
}
125129

126130
return convertView;
127131
}
128-
}
132+
}

0 commit comments

Comments
 (0)