4
4
import android .graphics .Color ;
5
5
import android .support .v7 .widget .RecyclerView ;
6
6
import android .text .TextUtils ;
7
+ import android .util .Pair ;
7
8
import android .view .LayoutInflater ;
8
9
import android .view .View ;
9
10
import android .view .ViewGroup ;
14
15
import org .json .JSONObject ;
15
16
16
17
import java .util .ArrayList ;
18
+ import java .util .Iterator ;
17
19
import java .util .List ;
20
+ import java .util .Map ;
18
21
22
+ import fuzion24 .device .vulnerability .test .VulnerabilityDescriptor ;
19
23
import fuzion24 .device .vulnerability .test .VulnerabilityTestResult ;
20
24
import fuzion24 .device .vulnerability .test .adapter .viewholder .RecyclerItemViewHolder ;
21
25
import fuzion24 .device .vulnerability .vulnerabilities .helper .BinaryAssets ;
22
26
23
27
public class RecyclerAdapter extends RecyclerView .Adapter <RecyclerView .ViewHolder > {
24
28
25
- private List <VulnerabilityTestResult > mResults ;
29
+ final private List <Pair < VulnerabilityTestResult , VulnerabilityDescriptor > > mResults ;
26
30
private Context mContext ;
27
31
28
32
public RecyclerAdapter (Context context , List <VulnerabilityTestResult > itemList ) {
29
33
this .mContext = context ;
30
- this . mResults = itemList ;
34
+ Map < String , VulnerabilityDescriptor > vMap = VulnerabilityDescriptor . getParsedVulnMap ( context ) ;
31
35
36
+ List <Pair <VulnerabilityTestResult , VulnerabilityDescriptor >> res =
37
+ new ArrayList <Pair <VulnerabilityTestResult , VulnerabilityDescriptor >>();
38
+
39
+ for (VulnerabilityTestResult vtr : itemList ){
40
+ VulnerabilityDescriptor vd = vMap .get (vtr .getCVEorID ());
41
+ res .add (Pair .create (vtr , vd ));
42
+ }
43
+
44
+ this .mResults = res ;
32
45
33
46
}
34
47
@@ -49,25 +62,19 @@ private class VulnObject {
49
62
@ Override
50
63
public void onBindViewHolder (RecyclerView .ViewHolder viewHolder , int position ) {
51
64
RecyclerItemViewHolder holder = (RecyclerItemViewHolder ) viewHolder ;
52
- VulnerabilityTestResult item = mResults .get (position );
65
+ Pair < VulnerabilityTestResult , VulnerabilityDescriptor > item = mResults .get (position );
53
66
54
- holder .setItemTestName (item .getCVEorID ());
67
+ VulnerabilityTestResult vulnRes = item .first ;
68
+ VulnerabilityDescriptor vulnDesc = item .second ;
55
69
70
+ holder .setItemTestName (vulnRes .getCVEorID ());
56
71
57
- try {
58
- jobj = mVulnMap .getJSONObject (item .getCVEorID ());
59
-
60
-
61
- } catch (Exception e ) {
62
- //We dont have an entry or are missing necessary components of it
63
- e .printStackTrace ();
64
- }
65
72
66
- if (item .getException () != null ) {
73
+ if (vulnRes .getException () != null ) {
67
74
holder .setItemTestResult (mContext .getString (R .string .error_test , item .getException ().getMessage ()));
68
75
holder .setItemTestResultColor (mContext .getResources ().getColor (R .color .orange ));
69
76
} else {
70
- if (item .getResult ()) {
77
+ if (vulnRes .getResult ()) {
71
78
holder .setItemTestResultColor (mContext .getResources ().getColor (R .color .red ));
72
79
holder .setItemTestResult (mContext .getString (R .string .test_result_failure ));
73
80
} else {
0 commit comments