Clover Coverage Report - WhatYouEat Coverage Report
Coverage timestamp: sab gen 3 2015 15:14:15 EST
../../../img/srcFileCovDistChart6.png 85% of files have more coverage
164   270   35   54,67
14   201   0,21   3
3     11,67  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  OptionsMenu       Line # 9 164 35 52,5% 0.5248619
 
No Tests
 
1    package co.harlequinmettle.healthfoodconcepts;
2   
3    import android.content.Context;
4    import android.widget.CheckBox;
5    import android.widget.CompoundButton;
6    import android.widget.RadioButton;
7    import android.widget.RadioGroup;
8   
 
9    public class OptionsMenu extends SubScroll {
10    CompoundButton.OnCheckedChangeListener dbsaver = new CompoundButton.OnCheckedChangeListener() {
 
11  1 toggle @Override
12    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
13    // TODO Auto-generated method stub
14  1 if(isChecked){
15  1 new Thread(new ObjectStoringThread(context, WhatYouEat.db)).start();
16  1 WhatYouEat.saveObject(1, "SAVEDB");
17    }else{
18    //delete saved data?
19  0 WhatYouEat.saveObject(0, "SAVEDB");
20    }
21    }
22    };
23    RadioGroup.OnCheckedChangeListener setState = new RadioGroup.OnCheckedChangeListener() {
24   
 
25  14 toggle @Override
26    public void onCheckedChanged(RadioGroup group, int checkedId) {
27    // clear previously stored statistics now need other stats per
28    // 100kcal or per 100g
29  14 if (!WhatYouEat._loaded || WhatYouEat.calculatingStats) {
30  9 return;
31    }
32   
33  5 WhatYouEat.nutritionStats.clear();
34  5 switch (checkedId) {
35  1 case ID_PER_SERVING:
36  1 WhatYouEat.Nutrient_Measure = WhatYouEat.USING_SERVING;
37  1 break;
38  0 case ID_PER_100_KCALS:
39  0 WhatYouEat.Nutrient_Measure = WhatYouEat.USING_KCAL;
40  0 break;
41  1 case ID_PER_100_GRAMS:
42  1 WhatYouEat.Nutrient_Measure = WhatYouEat.USING_GRAMS;
43  1 break;
44  0 case WhatYouEat.USE_MY_FOOD_GROUPS:
45  0 WhatYouEat.Foods_Search = WhatYouEat.USE_MY_FOOD_GROUPS;
46    // WhatYouEat.setFoodsIds();
47  0 break;
48  1 case WhatYouEat.USE_ALL_FOODS:
49  1 WhatYouEat.Foods_Search = WhatYouEat.USE_ALL_FOODS;
50    // WhatYouEat.setFoodsIds();
51  1 break;
52  0 case WhatYouEat.USE_MY_FOODS:
53  0 WhatYouEat.Foods_Search = WhatYouEat.USE_MY_FOODS;
54    // WhatYouEat.setFoodsIds();
55    // .setChecked(true);
56  0 break;
57  0 case WhatYouEat.SEARCH_TYPE_SUM:
58  0 WhatYouEat.Search_Type = WhatYouEat.SEARCH_TYPE_SUM;
59   
60  0 break;
61  0 case WhatYouEat.SEARCH_TYPE_PRODUCT:
62  0 WhatYouEat.Search_Type = WhatYouEat.SEARCH_TYPE_PRODUCT;
63  0 break;
64   
65  0 case 111111111:
66    //case WhatYouEat.VIEW_HORIZONTAL:
67    // WhatYouEat.myFoods_View = WhatYouEat.VIEW_HORIZONTAL;
68   
69  0 break;
70  0 case WhatYouEat.VIEW_VERTICAL:
71  0 WhatYouEat.myFoods_View = WhatYouEat.VIEW_VERTICAL;
72  0 break;
73    // ADD CASE ID_PER_SERVING:
74  2 default:
75   
76  2 break;
77    }
78   
79  5 if (checkedId < 25) {
80  2 WhatYouEat.Foods_Search = WhatYouEat.USE_ONE_FOOD_GROUP;
81  2 WhatYouEat.Food_Group = checkedId;
82    }else{
83  3 WhatYouEat.saveObject(WhatYouEat.Nutrient_Measure, "SEARCHUNITS");
84   
85  3 if (WhatYouEat.Foods_Search == WhatYouEat.USE_ALL_FOODS ||
86    WhatYouEat.Foods_Search== WhatYouEat.USE_MY_FOOD_GROUPS ||
87    WhatYouEat.Foods_Search == WhatYouEat.USE_MY_FOODS )
88  3 WhatYouEat.saveObject(WhatYouEat.Foods_Search, "SEARCHFOODS");
89    }
90  5 WhatYouEat.setFoodsIds();
91  5 WhatYouEat.highlightFactors.clear();
92  5 WhatYouEat.calculateHighlightNumbers();
93   
94    }
95   
96    };
97   
 
98  1 toggle public OptionsMenu(Context context) {
99  1 super(context);
100  1 boolean setFoodGroup = false;
101  1 CheckBox optimize = new CheckBox(WhatYouEat.ctx);
102  1 if (WhatYouEat.save_db == 1) {
103  0 optimize.setChecked(true);
104    }
105  1 optimize.setId(848484848);
106  1 optimize.setOnCheckedChangeListener(dbsaver );
107  1 optimize.setText("Optimize database loading - requires 4 MB - loads 4X as fast");
108  1 optimize.setMaxWidth(SubScroll.MAX_BUTTON_WIDTH);
109  1 instanceChild.addView(optimize);
110    ////////////////////////////////////////////////
111  1 RadioGroup cal = new RadioGroup(context);
112  1 cal.setBackgroundColor(RADIO_OPTIONS_1_COLOR);
113  1 cal.setOnCheckedChangeListener(setState);
114  1 RadioButton gram100 = simpleRadioButton();
115  1 RadioButton cal100 = simpleRadioButton();
116  1 RadioButton serving = simpleRadioButton();
117   
118  1 gram100.setText("Nutrients per 100 grams");
119  1 cal100.setId(ID_PER_100_KCALS);
120   
121  1 cal100.setText("Nutrients per 100 Calories");
122  1 gram100.setId(ID_PER_100_GRAMS);
123   
124  1 serving.setText("Nutrients per serving");
125  1 serving.setId(ID_PER_SERVING);
126   
127  1 switch (WhatYouEat.Nutrient_Measure) {
128  0 case WhatYouEat.USING_KCAL:
129  0 cal100.setChecked(true);
130   
131  0 break;
132  1 case WhatYouEat.USING_GRAMS:
133  1 gram100.setChecked(true);
134   
135  1 break;
136  0 case WhatYouEat.USING_SERVING:
137  0 serving.setChecked(true);
138   
139  0 break;
140    // ADD CASE ID_PER_SERVING:
141  0 default:
142   
143  0 break;
144    }
145  1 cal.addView(serving);
146  1 cal.addView(gram100);
147  1 cal.addView(cal100);
148  1 instanceChild.addView(cal);
149   
150    // //////////////////////////////////////////////
151   
152    // //////////////////////////////////////////////
153  1 if(false){
154  0 RadioGroup algoritym = new RadioGroup(context);
155  0 algoritym.setBackgroundColor(RADIO_OPTIONS_3_COLOR);
156  0 algoritym.setOnCheckedChangeListener(setState);
157  0 RadioButton sum = simpleRadioButton();
158  0 RadioButton product = simpleRadioButton();
159   
160  0 sum.setText("Search algorithym: Sum");
161  0 product.setText("Search algorithym: Product");
162  0 sum.setId(WhatYouEat.SEARCH_TYPE_SUM);
163  0 product.setId(WhatYouEat.SEARCH_TYPE_PRODUCT);
164  0 switch (WhatYouEat.Search_Type) {
165  0 case WhatYouEat.SEARCH_TYPE_SUM:
166  0 sum.setChecked(true);
167   
168  0 break;
169  0 case WhatYouEat.SEARCH_TYPE_PRODUCT:
170  0 product.setChecked(true);
171  0 break;
172    // ADD CASE ID_PER_SERVING:
173  0 default:
174   
175  0 break;
176    }
177   
178  0 algoritym.addView(sum);
179  0 algoritym.addView(product);
180  0 instanceChild.addView(algoritym);
181    }
182    // /////////////////////////////////////
183    // //////////////////////////////////////////////
184  1 if(false){
185  0 RadioGroup foodView = new RadioGroup(context);
186  0 foodView.setBackgroundColor(RADIO_OPTIONS_3_COLOR);
187  0 foodView.setOnCheckedChangeListener(setState);
188  0 RadioButton horizontal = simpleRadioButton();
189  0 RadioButton vertical = simpleRadioButton();
190   
191  0 horizontal.setText("MyFoods view: horizontal");
192  0 vertical.setText("MyFoods view: vertical");
193    //horizontal.setId(WhatYouEat.VIEW_HORIZONTAL);
194  0 vertical.setId(WhatYouEat.VIEW_VERTICAL);
195  0 switch (WhatYouEat.myFoods_View) {
196  0 case 10:
197    //case WhatYouEat.VIEW_HORIZONTAL:
198  0 horizontal.setChecked(true);
199   
200  0 break;
201  0 case WhatYouEat.VIEW_VERTICAL:
202  0 vertical.setChecked(true);
203  0 break;
204    // ADD CASE ID_PER_SERVING:
205  0 default:
206   
207  0 break;
208    }
209   
210  0 foodView.addView(vertical);
211  0 foodView.addView(horizontal);
212  0 instanceChild.addView(foodView);
213    }
214    // /////////////////////////////////////
215  1 RadioGroup search = new RadioGroup(context);
216  1 search.setBackgroundColor(RADIO_OPTIONS_4_COLOR);
217  1 search.setOnCheckedChangeListener(setState);
218  1 RadioButton myfoodgroups = simpleRadioButton();
219  1 RadioButton allfoodgroups = simpleRadioButton();
220  1 myfoodgroups.setBackgroundColor(RADIO_OPTIONS_2_COLOR);
221  1 allfoodgroups.setBackgroundColor(RADIO_OPTIONS_2_COLOR);
222  1 myfoodgroups.setText("Search my food groups");
223  1 allfoodgroups.setText("Search all foods");
224  1 myfoodgroups.setId(WhatYouEat.USE_MY_FOOD_GROUPS);
225  1 allfoodgroups.setId(WhatYouEat.USE_ALL_FOODS);
226  1 switch (WhatYouEat.Foods_Search) {
227  1 case WhatYouEat.USE_MY_FOOD_GROUPS:
228  1 myfoodgroups.setChecked(true);
229   
230  1 break;
231  0 case WhatYouEat.USE_ALL_FOODS:
232  0 allfoodgroups.setChecked(true);
233   
234  0 break;
235  0 case WhatYouEat.USE_ONE_FOOD_GROUP:
236    // .setChecked(true);
237  0 setFoodGroup = true;
238  0 break;
239  0 case WhatYouEat.USE_MY_FOODS:
240    // .setChecked(true);
241   
242  0 break;
243    // ADD CASE ID_PER_SERVING:
244  0 default:
245   
246  0 break;
247    }
248   
249  1 search.addView(myfoodgroups);
250  1 search.addView(allfoodgroups);
251  1 instanceChild.addView(search);
252    // ///////////////////////////////////////
253    // add all foodgroup radios
254    // RadioGroup fdgp = new RadioGroup(context);
255    // fdgp.setBackgroundColor(RADIO_OPTIONS_4_COLOR);
256    // fdgp.setOnCheckedChangeListener(setState);
257  26 for (int i = 0; i < WhatYouEat.foodGroups.length; i++) {
258  25 RadioButton grp = simpleRadioButton();
259  25 if (setFoodGroup && WhatYouEat.Food_Group == i) {
260  0 grp.setChecked(true);
261    }
262  25 grp.setText("Search only: " + WhatYouEat.foodGroups[i]);
263  25 grp.setId(i);
264    // fdgp.addView(grp);
265  25 search.addView(grp);
266    }
267    // instanceChild.addView(fdgp);
268    }
269   
270    }