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
144   326   27   18
18   238   0,19   8
8     3,38  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
Line # 19 144 27 86,5% 0.86470586
 
No Tests
 
1    package co.harlequinmettle.healthfoodconcepts;
2   
3    import java.util.ArrayList;
4    import java.util.Arrays;
5   
6    import android.content.Context;
7    import android.graphics.PorterDuff;
8    import android.util.TypedValue;
9    import android.view.Gravity;
10    import android.view.View;
11    import android.view.ViewTreeObserver;
12    import android.view.ViewTreeObserver.OnGlobalLayoutListener;
13    import android.widget.Button;
14    import android.widget.LinearLayout;
15    import android.widget.ProgressBar;
16    import android.widget.TextView;
17    import android.widget.Toast;
18   
 
19    public class MenuScroller extends SubScroll {
20   
21    static final String[] INTRO = { "Food Lists",
22    "Word Search", "Search By Nutrient", "Evaluate Diet" };
23    static final String[] PREFS = { "Food Groups", "Nutrients",
24    "Set Nutrient Goals", "My Foods: View",
25    "My Foods: Remove", "Options" };
26    static final int[] NAV_IDS = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
27    static final int[] NAV_IDS_2 = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
28    FoodDescriptionsScroller results;
29   
30    // initial navigation buttons menu: INTRO
31    protected View.OnClickListener navigationListener = new View.OnClickListener() {
32   
 
33  9 toggle public void onClick(View view) {
34    // introGraphicsCounter = 0;
35  9 int id = view.getId();
36  9 resetDisplayConditions();
37  9 SubScroll.fromKeywordSearch = false;
38  9 SubScroll.fromFoodSuggestions = false;
39    // ADD BOOLEAN FOR LONGER FILELOADING THREAD TO SHOW TOAST
40  9 if (!WhatYouEat._loaded) {
41  0 Toast mToast = Toast
42    .makeText(
43    context,
44    "\n\n\n\n\nPlease adjust some settings while database loads\n\n\n\n\n",
45    1);
46  0 mToast.setGravity(Gravity.TOP, 0, 50);
47   
48  0 mToast.show();
49    }
50    // if done loading db remove progressbar
51  9 if (WhatYouEat._loaded) {
52  9 WhatYouEat.mHandler.post(new Runnable() {
 
53  9 toggle public void run() {
54  9 WhatYouEat.pb.setProgress(0);
55    }
56    });
57  9 instanceChild.removeView(instanceChild
58    .findViewById(WhatYouEat.PROGRESS_BAR_ID));
59   
60    }
61  9 WhatYouEat.appAccess.removeAllViews();
62  9 WhatYouEat.appAccess.addView(WhatYouEat.intro);
63   
64    // index = 1;
65  9 switch (id) {
66  3 case 0:// Search Foods by Food Group
67  3 scrollinflated = new boolean[25];
68    // load food group labeled scrolls
69  3 scrollCount = 1;
70  78 for (int i = 0; i < 25; i++) {
71    // if i not in my food groups dont add to scroll
72  75 if (!WhatYouEat.MY_FOOD_GROUPS[i])
73  20 continue;
74    // original KeywordScroller - label button doesn't scroll
75    // but inflates list of keywords
76  55 KeywordScroller kws = new KeywordScroller(context, i);
77  55 kws.setId(i);
78    // linear layout to prevent title button from scrolling
79  55 LinearLayout title = basicLinearLayout();
80    // title button with kws.inflatorlistener id i
81  55 Button titleButton = titleButton(kws, i);
82    // add title button to layout
83  55 title.addView(titleButton);
84    // add uninflated keywordscroller to linear layout
85  55 title.addView(kws);
86    // add linear layout to application - default possition
87  55 WhatYouEat.appAccess.addView(title);
88   
89    }
90  3 break;
91  2 case 1:// search by typing a keyword
92    // 2 causes search results/nutrition info to be placed to
93    // right of text
94  2 lastFoodsId = 2;
95  2 results = new FoodDescriptionsScroller(context, false);
96  2 SubScroll.fromKeywordSearch = true;
97  2 LinearLayout title = basicLinearLayout();// vertical
98   
99  2 title.setId(scrollCount);
100   
101  2 ourInput = editText("Please enter a keyword");
102   
103  2 Button searchButton = simpleButton();
104  2 searchButton.setText("Search");
105  2 searchButton.setId(KEYWORD_SEARCH_ID);
106  2 searchButton.setOnClickListener(foodGroupSearchListener);
107   
108  2 title.addView(ourInput);
109  2 title.addView(searchButton);
110  2 title.addView(results);
111    // title.addView(kws2);
112   
113  2 WhatYouEat.appAccess.addView(title, 1);
114   
115  2 break;
116  2 case 2:// nutrient priority search view
117  2 NutrientSearchView nsv = new NutrientSearchView(context);
118  2 WhatYouEat.appAccess.addView(nsv);
119   
120  2 break;
121   
122  2 case 3:
123  2 fromFoodSuggestions = true;
124  2 System.out
125    .println("------>IN CASE 4 CREATE NUTRITIONCALC<---------------");
126  2 NutritionCalculatorView caclulateNutritionState = new NutritionCalculatorView();
127  2 caclulateNutritionState.setId(NUTRITION_CALCULATOR_ID);
128  2 WhatYouEat.appAccess.addView(caclulateNutritionState);
129   
130  2 break;
131  0 default:
132  0 break;
133   
134    }
135  9 final ViewTreeObserver viewTreeObserver4 = WhatYouEat.application
136    .getViewTreeObserver();
137  9 if (viewTreeObserver4.isAlive()) {
138  9 viewTreeObserver4
139    .addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
 
140  9 toggle @Override
141    public void onGlobalLayout() {
142   
143  9 WhatYouEat.application.scrollBy(
144    (int) (0.9 * MAX_BUTTON_WIDTH), 0);
145  9 viewTreeObserver4
146    .removeGlobalOnLayoutListener(this);
147    }
148    });
149    }
150    }
151   
152    };
153   
154    protected View.OnClickListener settingsListener = new View.OnClickListener() {
 
155  8 toggle public void onClick(View view) {
156  8 int id = view.getId();
157   
158  8 SubScroll.fromKeywordSearch = false;
159  8 SubScroll.fromFoodSuggestions = false;
160  8 if (WhatYouEat._loaded)
161  8 instanceChild.removeView(instanceChild
162    .findViewById(WhatYouEat.PROGRESS_BAR_ID));
163  8 WhatYouEat.appAccess.removeAllViews();
164  8 WhatYouEat.appAccess.addView(WhatYouEat.intro);
165   
166  8 switch (id) {
167  2 case 10:
168    // food group selection menu
169    // WhatYouEat.appAccess.addView(WhatYouEat.settings);
170   
171  2 PreferencesScroller groupSettings = new PreferencesScroller(
172    context, 0);
173  2 groupSettings.setId(GROUP_CHOICE_MENU_ID);
174  2 WhatYouEat.appAccess.addView(groupSettings);
175   
176  2 break;
177  2 case 11:
178   
179  2 PreferencesScroller nutreintSettings = new PreferencesScroller(
180    context, 1);
181  2 nutreintSettings.setId(NUTRIENT_CHOICE_MENU_ID);
182  2 WhatYouEat.appAccess.addView(nutreintSettings);
183   
184  2 break;
185  1 case 12:
186   
187  1 NutritionSettings nutrientSet = new NutritionSettings();
188  1 WhatYouEat.appAccess.addView(nutrientSet);
189  1 break;
190  1 case 13:
191   
192  1 PreferencesScroller myFoodsEdit = new PreferencesScroller(
193    context, 2);
194  1 myFoodsEdit.setId(FOOD_CHOICE_MENU_ID);
195  1 WhatYouEat.appAccess.addView(myFoodsEdit);
196   
197  1 break;
198  1 case 14:
199   
200  1 FoodRemovalScroller removeFoods = new FoodRemovalScroller(
201    context);
202  1 removeFoods.setId(FOOD_REMOVAL_ID);
203  1 WhatYouEat.appAccess.addView(removeFoods);
204   
205  1 break;
206  1 case 15:
207  1 if(!optionMenuShowing){
208  1 WhatYouEat.intro.instanceChild
209    .removeView(WhatYouEat.intro.instanceChild
210    .findViewById(OPTIONS_MENU_ID));
211  1 OptionsMenu options = new OptionsMenu(context);
212  1 options.setId(OPTIONS_MENU_ID);
213  1 WhatYouEat.intro.instanceChild.addView(options);
214    // WhatYouEat.appAccess.addView(options);
215  1 optionMenuShowing = true;
216    }else{
217   
218  0 WhatYouEat.intro.instanceChild
219    .removeView(WhatYouEat.intro.instanceChild
220    .findViewById(OPTIONS_MENU_ID));
221  0 optionMenuShowing = false;
222    }
223  1 break;
224   
225  0 default:
226  0 break;
227   
228    }
229   
230  8 if(false){
231  0 final ViewTreeObserver viewTreeObserver4 = WhatYouEat.application
232    .getViewTreeObserver();
233  0 if (viewTreeObserver4.isAlive()) {
234  0 viewTreeObserver4
235    .addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
 
236  0 toggle @Override
237    public void onGlobalLayout() {
238   
239  0 WhatYouEat.application.scrollBy(
240    (int) (0.9 * MAX_BUTTON_WIDTH), 0);
241  0 viewTreeObserver4
242    .removeGlobalOnLayoutListener(this);
243    }
244    });
245    }
246    }
247    }
248   
249    };
250   
251    // uses button title to search food descriptions
252    // displays results as a new subsroll with foods description
253    View.OnClickListener foodGroupSearchListener = new View.OnClickListener() {
254    // added to keyword buttons ~2000
 
255  2 toggle public void onClick(View view) {
256  2 int id = view.getId();
257    // id of food group to search
258   
259  2 String searchWord = ourInput.getText().toString();
260   
261  2 WhatYouEat
262    .setSearchResultsFrom(searchWord, WhatYouEat.Foods_Search);
263   
264  2 results.instanceChild.removeAllViews();
265  2 results.addScrollingButtons(WhatYouEat.searchResults,
266    WhatYouEat.foodCodeResults, results.nutritionInfoListener,
267    BUTTON_COLORS[SEARCH_RESULTS]);
268   
269    // WhatYouEat.searchResults;//food description
270    // WhatYouEat.foodCodeResults; //food code
271   
272  2 results.setId(FOOD_RESULTS_ID);
273    // get index of parent subscroll for view insertion
274    // WhatYouEat.appAccess.removeView(WhatYouEat.appAccess.findViewById(FOOD_RESULTS_ID));
275    // WhatYouEat.appAccess.addView(results,2);
276   
277    }
278    };
279   
 
280  1 toggle MenuScroller(Context c, ProgressBar pb, int type) {
281   
282  1 super(c);
283    // intro menu
284   
285  1 if (type == 0) {
286   
287  1 instanceChild.addView(pb);
288   
289  1 TextView label = new TextView(c);
290  1 label.setBackgroundColor(0xff3377cc);
291  1 label.setTextSize(TypedValue.COMPLEX_UNIT_DIP,
292    WhatYouEat.TEXT_SMALL);
293  1 label.setTextColor(0xff000000);
294  1 label.setText("-Explore Foods-");
295  1 label.setGravity(Gravity.CENTER);
296  1 instanceChild.addView(label);
297   
298  1 addScrollingButtons(INTRO, NAV_IDS, navigationListener,
299    BUTTON_COLORS[NAVIGATION]);
300   
301  1 label = new TextView(c);
302  1 label.setBackgroundColor(0xff3377cc);
303  1 label.setTextSize(TypedValue.COMPLEX_UNIT_DIP,
304    WhatYouEat.TEXT_SMALL);
305  1 label.setTextColor(0xff000000);
306  1 label.setText("-Settings-");
307  1 label.setGravity(Gravity.CENTER);
308  1 instanceChild.addView(label);
309   
310  1 addScrollingButtons(PREFS, NAV_IDS_2, settingsListener,
311    BUTTON_COLORS[SETTINGS]);
312   
313    }
314    }
315   
 
316  55 toggle public Button titleButton(KeywordScroller keywordTitleScroll, int group) {
317   
318  55 Button label = simpleButton();
319  55 label.setText(WhatYouEat.foodGroups[group]);
320  55 label.setId(group);
321  55 label.setOnClickListener(keywordTitleScroll.foodGroupDisplayKeywordsListener);
322  55 label.getBackground().setColorFilter(FOOD_GROUP_LABEL_COLOR,
323    PorterDuff.Mode.MULTIPLY);
324  55 return label;
325    }
326    }