25
25
import org .json .JSONException ;
26
26
import org .json .JSONObject ;
27
27
28
+ import java .util .ArrayList ;
28
29
import java .util .List ;
29
30
30
31
import fuzion24 .device .vulnerability .test .ResultsCallback ;
36
37
37
38
public class MainActivity extends AppCompatActivity {
38
39
40
+ private static final String SERIALIZABLE_RESULTS = "SERIALIZABLE_RESULTS" ;
41
+
39
42
private static final String TAG = "VULN_TEST" ;
40
43
41
44
private DeviceInfo devInfo ;
42
- private List <VulnerabilityTestResult > testResults ;
45
+ private ArrayList <VulnerabilityTestResult > testResults ;
43
46
private RecyclerView recyclerView ;
44
47
private TextView emptyView ;
45
48
private CoordinatorLayout coordinatorLayout ;
49
+ RecyclerAdapter recyclerAdapter ;
46
50
47
51
@ Override
48
52
protected void onCreate (Bundle savedInstanceState ) {
@@ -54,9 +58,19 @@ protected void onCreate(Bundle savedInstanceState) {
54
58
setSupportActionBar (toolbar );
55
59
getSupportActionBar ().setTitle (R .string .app_name );
56
60
61
+ if (savedInstanceState != null && savedInstanceState .containsKey (SERIALIZABLE_RESULTS )) {
62
+ testResults = (ArrayList <VulnerabilityTestResult >) savedInstanceState .getSerializable (SERIALIZABLE_RESULTS );
63
+ } else {
64
+ testResults = new ArrayList <>();
65
+ }
66
+
57
67
coordinatorLayout = (CoordinatorLayout ) findViewById (R .id .coordinatorLayout );
58
68
emptyView = (TextView ) findViewById (R .id .emptyView );
59
69
recyclerView = (RecyclerView ) findViewById (R .id .recyclerView );
70
+ recyclerAdapter = new RecyclerAdapter (MainActivity .this , testResults );
71
+
72
+ recyclerView .setLayoutManager (new LinearLayoutManager (MainActivity .this ));
73
+ recyclerView .setAdapter (recyclerAdapter );
60
74
61
75
final TextView tvKernelVersion = (TextView ) findViewById (R .id .kernelVersion );
62
76
final TextView tvBuildFingerPrint = (TextView ) findViewById (R .id .buildFingerPrint );
@@ -69,7 +83,6 @@ protected void onCreate(Bundle savedInstanceState) {
69
83
70
84
final TextView tvBuildABIList = (TextView ) findViewById (R .id .buildABIList );
71
85
72
-
73
86
devInfo = DeviceInfo .getDeviceInfo ();
74
87
tvBuildFingerPrint .setText (devInfo .getBuildFingerPrint ());
75
88
tvBuildID .setText (devInfo .getBuildID ());
@@ -199,14 +212,11 @@ private void runTestsSuit() {
199
212
public void finished (final List <VulnerabilityTestResult > results ) {
200
213
Log .d (TAG , "Device Vulnerability callback, finished" );
201
214
202
- testResults = results ;
215
+ testResults .clear ();
216
+ testResults .addAll (results );
203
217
204
218
emptyView .setVisibility (View .GONE );
205
- recyclerView .setLayoutManager (new LinearLayoutManager (MainActivity .this ));
206
-
207
- RecyclerAdapter recyclerAdapter = new RecyclerAdapter (MainActivity .this , results );
208
- recyclerView .setAdapter (recyclerAdapter );
209
-
219
+ recyclerAdapter .notifyDataSetChanged ();
210
220
}
211
221
}).execute ();
212
222
}
@@ -216,4 +226,9 @@ public void onConfigurationChanged(Configuration newConfig) {
216
226
super .onConfigurationChanged (newConfig );
217
227
}
218
228
229
+ @ Override
230
+ protected void onSaveInstanceState (final Bundle outState ) {
231
+ outState .putSerializable (SERIALIZABLE_RESULTS , testResults );
232
+ }
233
+
219
234
}
0 commit comments