Clover Coverage Report - WhatYouEat Coverage Report
Coverage timestamp: sab gen 3 2015 15:14:15 EST
../../../img/srcFileCovDistChart9.png 25% of files have more coverage
98   219   35   19,6
44   160   0,36   5
5     7  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  PreferencesScroller       Line # 14 98 35 88,4% 0.88435376
 
No Tests
 
1    package co.harlequinmettle.healthfoodconcepts;
2   
3    import java.util.Map.Entry;
4   
5    import android.content.Context;
6    import android.graphics.PorterDuff;
7    import android.view.View;
8    import android.widget.Button;
9    import android.widget.CheckBox;
10    import android.widget.CompoundButton;
11    import android.widget.LinearLayout;
12    import android.widget.TextView;
13   
 
14    public class PreferencesScroller extends SubScroll {
15    CheckBox[] ckbox;
16   
17    // effect of touching a specific food description button:
18    // show detailed nutrition information
19    View.OnClickListener foodGroupListener = new View.OnClickListener() {
 
20  3 toggle public void onClick(View view) {
21  3 int id = view.getId();// food id code
22  3 Button b = (Button) view;
23    // SET INDIVIDUAL GROUP PREFERENCES FROM CHECKBOXES AND SAVE
24    }
25    };
26    CompoundButton.OnCheckedChangeListener foodGroupPreferencesListener = new CompoundButton.OnCheckedChangeListener() {
27   
 
28  2 toggle @Override
29    public void onCheckedChanged(CompoundButton buttonView,
30    boolean isChecked) {
31    // TODO Auto-generated method stub
32  2 WhatYouEat.MY_FOOD_GROUPS[buttonView.getId()] = isChecked;
33  2 WhatYouEat.saveObject(WhatYouEat.MY_FOOD_GROUPS, "MYFOODGROUPS");
34  2 if (WhatYouEat.USE_MY_FOOD_GROUPS == WhatYouEat.Foods_Search)
35  2 WhatYouEat.setFoodsIds();
36    }
37    };
38    CompoundButton.OnCheckedChangeListener nutrientsPreferencesListener = new CompoundButton.OnCheckedChangeListener() {
39   
 
40  4 toggle @Override
41    public void onCheckedChanged(CompoundButton buttonView,
42    boolean isChecked) {
43  4 int bID = buttonView.getId();
44  4 if (isChecked) {
45  0 WhatYouEat.nutritionStats.put(bID,
46    new StatTool(WhatYouEat.getFoodSearchIds(), bID));
47    }
48  4 WhatYouEat.MY_NUTRIENTS[bID] = isChecked;
49  4 int[] foodIds = WhatYouEat.getFoodSearchIds();
50  4 float[] basically = StatTool.simpleStats(foodIds, bID);
51   
52  4 WhatYouEat.highlightFactors.put(bID, basically);
53   
54  4 WhatYouEat.saveObject(WhatYouEat.MY_NUTRIENTS, "MYNUTRIENTS");
55   
56    }
57    };
58   
 
59  5 toggle PreferencesScroller(Context c, int type) {
60  5 super(c);
61   
62    // choose what food groups to use
63  5 if (type == 0) {
64  2 int[] ids = new int[25];
65  52 for (int i = 0; i < 25; i++)
66  50 ids[i] = i;
67   
68  2 addScrollingButtons(WhatYouEat.foodGroups, ids,
69    WhatYouEat.MY_FOOD_GROUPS, foodGroupListener,
70    FOOD_GROUP_LABEL_COLOR, type);
71   
72    }
73    //
74  5 if (type == 1) {
75   
76  2 int[] ids = new int[130];
77  262 for (int i = 0; i < 130; i++)
78  260 ids[i] = i;
79   
80  2 addScrollingButtons(WhatYouEat.nutrients, ids,
81    WhatYouEat.MY_NUTRIENTS, foodGroupListener,
82    BUTTON_COLORS[GROUPPREFS], type);
83   
84    }
85  5 if (type == 2) {
86  1 boolean alternatecolor = true;
87  26 for (int i = 0; i < 25; i++) {
88    // if i not in my food groups dont add to scroll
89    // if(false)
90  25 if (!WhatYouEat.MY_FOOD_GROUPS[i])
91  6 continue;
92    // Scroller - label button doesn't scroll
93    //
94  19 MyFoodsScroller mfs = new MyFoodsScroller(context, i, false);
95  19 mfs.setId(i);
96   
97    // linear layout to prevent title button from scrolling
98  19 LinearLayout title = basicLinearLayout();
99    // title button with kws.inflatorlistener id i
100  19 TextView groupTitle = new TextView(context);
101  19 if (false)
102  0 if (i % 2 == 0) {
103  0 groupTitle.setBackgroundColor(0xff9999dd);
104    } else {
105  0 groupTitle.setBackgroundColor(0xffdd9999);
106    }
107  19 if(alternatecolor){
108  10 groupTitle
109    .setBackgroundColor(0xff55cccc );
110  10 alternatecolor = false;
111    }else{
112   
113  9 groupTitle
114    .setBackgroundColor( 0xff5555dd);
115  9 alternatecolor = true;
116    }
117  19 groupTitle.setTextSize(22);
118  19 groupTitle.setTextColor(0xff000000);
119  19 groupTitle.setText(WhatYouEat.foodGroups[i]);
120  19 groupTitle.setWidth(370);
121  19 groupTitle.setHeight(46);
122   
123  19 switch (WhatYouEat.myFoods_View) {
124    // case WhatYouEat.VIEW_HORIZONTAL:
125  0 case 100000000://never
126  0 mfs.addView(mfs.instanceChild);
127  0 title.addView(groupTitle);
128    // add uninflated keywordscroller to linear layout
129  0 title.addView(mfs);
130    // add linear layout to application - default possition
131  0 WhatYouEat.appAccess.addView(title);
132  0 break;
133  19 case WhatYouEat.VIEW_VERTICAL:
134  19 instanceChild.addView(groupTitle);
135  19 instanceChild.addView(mfs.instanceChild);
136   
137  19 break;
138    // ADD CASE ID_PER_SERVING:
139  0 default:
140   
141  0 break;
142    }
143    // add title button to layout
144   
145    }
146   
147    }
148   
149    }
150   
 
151  4 toggle public void addScrollingButtons(String[] buttonNames, int[] buttonIds,
152    boolean[] settings, View.OnClickListener listener, int BUTTON_CLR,
153    int type) {
154   
155    // instanceChild.removeAllViews();
156  4 buttons = new Button[buttonNames.length];
157   
158  4 ckbox = new CheckBox[buttonNames.length];
159   
160  314 for (int i = 0; i < buttonNames.length; i++) {
161  310 LinearLayout layout = new LinearLayout(context);
162  310 buttons[i] = simpleButton();
163  310 buttons[i].setText(buttonNames[i]);
164  310 buttons[i].setId(buttonIds[i]);
165    // NAVIGATION or SEARCHWORDS or FOODINFO
166  310 buttons[i].setOnClickListener(listener);
167  310 if (type == 0) {
168  50 buttons[i].getBackground().setColorFilter(BUTTON_CLR,
169    PorterDuff.Mode.MULTIPLY);
170  260 } else if (type == 1) {
171   
172  260 int bgColor = GENERAL;
173  260 if (i >= 8 && i <= 14) {
174  14 bgColor = INTERESTING;
175    }
176  260 if (i >= 15 && i <= 24) {
177  20 bgColor = CARB;
178   
179    }
180  260 if (i >= 25 && i <= 35) {
181  22 bgColor = MINERAL;
182   
183    }
184  260 if (i >= 36 && i <= 65) {
185  60 bgColor = VITAMIN;
186   
187    }
188  260 if (i >= 66 && i <= 84) {
189  38 bgColor = PROTEIN;
190   
191    }
192  260 if (i >= 85 && i <= 129) {
193  90 bgColor = FAT;
194   
195    }
196  260 int alpha = 150;
197  260 int colorCombo = bgColor | (alpha << 24);
198   
199  260 buttons[i].getBackground().setColorFilter(colorCombo,
200    PorterDuff.Mode.SRC_IN);
201   
202    }
203  310 ckbox[i] = new CheckBox(context);
204   
205  310 ckbox[i].setChecked(settings[i]);
206  310 if (type == 0)
207  50 ckbox[i].setOnCheckedChangeListener(foodGroupPreferencesListener);
208  310 if (type == 1)
209  260 ckbox[i].setOnCheckedChangeListener(nutrientsPreferencesListener);
210   
211  310 ckbox[i].setId(buttonIds[i]);// CHANGE TO ACTUAL FOOD ID
212  310 layout.addView(ckbox[i]);
213  310 layout.addView(buttons[i]);
214  310 instanceChild.addView(layout);
215    }
216   
217    }
218   
219    }