1 |
|
package co.harlequinmettle.healthfoodconcepts; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
|
5 |
|
import android.content.Context; |
6 |
|
import android.graphics.PorterDuff; |
7 |
|
import android.view.View; |
8 |
|
import android.widget.Button; |
9 |
|
|
|
|
| 72,3% |
Uncovered Elements: 18 (65) |
Complexity: 13 |
Complexity Density: 0,3 |
|
10 |
|
public class KeywordScroller extends SubScroll implements FG2_I { |
11 |
|
int group; |
12 |
|
|
13 |
|
public View.OnClickListener foodGroupDisplayKeywordsListener = new View.OnClickListener() { |
|
|
| 90,9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0,43 |
|
14 |
2
|
public void onClick(View view) {... |
15 |
2
|
int id = view.getId(); |
16 |
2
|
int[] groupIDS = new int[(FOODGROUPS[group].length)]; |
17 |
191
|
for (int i = 0; i < groupIDS.length; i++) |
18 |
189
|
groupIDS[i] = group; |
19 |
|
|
20 |
|
|
21 |
2
|
if(!scrollinflated[group]){ |
22 |
2
|
addScrollingButtons(FOODGROUPS[group], groupIDS, |
23 |
|
foodGroupSearchListener, BUTTON_COLORS[SEARCHWORDS]); |
24 |
2
|
scrollinflated[group] = true; |
25 |
|
} |
26 |
|
|
27 |
|
} |
28 |
|
}; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
View.OnClickListener foodGroupSearchListener = new View.OnClickListener() { |
33 |
|
|
|
|
| 73,8% |
Uncovered Elements: 11 (42) |
Complexity: 9 |
Complexity Density: 0,32 |
|
34 |
2
|
public void onClick(View view) {... |
35 |
2
|
int id = view.getId(); |
36 |
2
|
currentFoodGroup = group; |
37 |
|
|
38 |
|
|
39 |
2
|
Button b = (Button) view; |
40 |
2
|
b.getBackground().setColorFilter(0xff999999, |
41 |
|
PorterDuff.Mode.MULTIPLY); |
42 |
2
|
String searchWord = b.getText().toString(); |
43 |
|
|
44 |
2
|
index = ((View) view.getParent()).getId() + 1; |
45 |
|
|
46 |
2
|
if (index <= lastFoodsId || lastFoodsId == 0) { |
47 |
1
|
WhatYouEat.application.scrollBy((int) (MAX_BUTTON_WIDTH * 0.9), |
48 |
|
0); |
49 |
|
} else { |
50 |
1
|
if (showingNutrients) { |
51 |
0
|
WhatYouEat.application.scrollBy(-MAX_BUTTON_WIDTH, 0); |
52 |
|
} |
53 |
1
|
if (showingResults) { |
54 |
1
|
WhatYouEat.application.scrollBy(-MAX_BUTTON_WIDTH, 0); |
55 |
|
} |
56 |
1
|
if (showingStats) { |
57 |
0
|
WhatYouEat.application.scrollBy((int) (-2 |
58 |
|
* MAX_BUTTON_WIDTH * 0.9), 0); |
59 |
|
} |
60 |
|
} |
61 |
2
|
if (showingResults) { |
62 |
1
|
WhatYouEat.appAccess.removeView(WhatYouEat.appAccess |
63 |
|
.findViewById(FOOD_RESULTS_ID)); |
64 |
1
|
showingResults = false; |
65 |
|
} |
66 |
2
|
if (showingNutrients) { |
67 |
0
|
WhatYouEat.appAccess.removeView(WhatYouEat.appAccess |
68 |
|
.findViewById(FOOD_NUTRIENT_ID)); |
69 |
0
|
showingNutrients = false; |
70 |
|
} |
71 |
2
|
if (showingStats) { |
72 |
0
|
WhatYouEat.appAccess.removeView(WhatYouEat.appAccess |
73 |
|
.findViewById(STATVIEW_ID)); |
74 |
0
|
showingStats = false; |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
2
|
WhatYouEat.setSearchResultsFrom(searchWord, id); |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
2
|
FoodDescriptionsScroller results = new FoodDescriptionsScroller( |
85 |
|
context,true); |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
2
|
WhatYouEat.appAccess.addView(results, index); |
91 |
|
|
92 |
2
|
lastFoodsId = index; |
93 |
|
|
94 |
2
|
showingResults = true; |
95 |
|
} |
96 |
|
}; |
97 |
|
|
|
|
| 33,3% |
Uncovered Elements: 6 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
|
98 |
55
|
KeywordScroller(Context c, int group) {... |
99 |
|
|
100 |
55
|
super(c); |
101 |
|
|
102 |
55
|
this.group = group; |
103 |
|
|
104 |
55
|
if (false) { |
105 |
|
|
106 |
0
|
Button label = simpleButton(); |
107 |
0
|
label.setText(WhatYouEat.foodGroups[group]); |
108 |
0
|
label.setId(group); |
109 |
0
|
label.setOnClickListener(foodGroupDisplayKeywordsListener); |
110 |
0
|
label.getBackground().setColorFilter(FOOD_GROUP_LABEL_COLOR, |
111 |
|
PorterDuff.Mode.MULTIPLY); |
112 |
|
|
113 |
0
|
instanceChild.addView(label); |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
} |
119 |
|
|
120 |
|
} |