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
56   125   10   14
8   96   0,18   4
4     2,5  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  MyFoodsScroller       Line # 14 56 10 86,8% 0.86764705
 
No Tests
 
1    package co.harlequinmettle.healthfoodconcepts;
2   
3    import java.util.Map.Entry;
4    import java.util.TreeMap;
5   
6    import android.content.Context;
7    import android.graphics.PorterDuff;
8    import android.view.View;
9    import android.widget.Button;
10    import android.widget.CheckBox;
11    import android.widget.CompoundButton;
12    import android.widget.LinearLayout;
13   
 
14    public class MyFoodsScroller extends SubScroll {
15    CheckBox[] ckbox;
16    int groupID;
17    // effect of touching a specific food description button:
18    // show detailed nutrition information
19    View.OnClickListener nutritionInfoListener = 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  3 currentFoodID = id;
24  3 b.getBackground()
25    .setColorFilter(0xff999999, PorterDuff.Mode.SRC_IN);
26  3 if (showingNutrients)
27  2 WhatYouEat.appAccess.removeView(WhatYouEat.appAccess
28    .findViewById(FOOD_NUTRIENT_ID));
29   
30  3 NutritionScroller nutr = new NutritionScroller(context, id);
31   
32  3 if (showingStats) {
33  1 WhatYouEat.appAccess.removeView(WhatYouEat.appAccess
34    .findViewById(STATVIEW_ID));
35  1 showingStats = false;
36    }
37  3 nutr.setId(FOOD_NUTRIENT_ID);
38  3 index = groupID + 2;
39  3 switch(WhatYouEat.myFoods_View){
40    // case WhatYouEat.VIEW_HORIZONTAL:
41  0 case 10:
42   
43  0 WhatYouEat.appAccess.addView(nutr, index);
44  0 break;
45  3 case WhatYouEat.VIEW_VERTICAL:
46   
47  3 WhatYouEat.appAccess.addView(nutr, 2);
48  3 break;
49  0 default:
50  0 break;
51    }
52   
53  3 WhatYouEat.application.scrollBy((int) (MAX_BUTTON_WIDTH * 0.9), 0);
54  3 showingNutrients = true;
55    }
56    };
57   
58    CompoundButton.OnCheckedChangeListener foodPreferencesListener = new CompoundButton.OnCheckedChangeListener() {
59   
 
60  0 toggle @Override
61    public void onCheckedChanged(CompoundButton buttonView,
62    boolean isChecked) {
63   
64  0 int foodId = buttonView.getId();
65   
66  0 WhatYouEat.allMyFoods.get(groupID).put(foodId, isChecked);
67   
68  0 WhatYouEat.saveObject(WhatYouEat.allMyFoods, "MYFOODS");
69    }
70    };
71   
 
72  19 toggle MyFoodsScroller(Context c, int groupID, boolean addChild) {
73  19 super(c , addChild);
74  19 this.groupID = groupID;
75  19 TreeMap<Integer, Boolean> myGroupFoods = WhatYouEat.allMyFoods
76    .get(groupID);
77  19 if (myGroupFoods.size() > 0) {
78  2 String[] myFoodNames = new String[myGroupFoods.size()];
79  2 int[] myFoodNumbers = new int[myGroupFoods.size()];
80  2 boolean[] myFoodBool = new boolean[myGroupFoods.size()];
81  2 int i = 0;
82  2 for (Entry<Integer, Boolean> ent : myGroupFoods.entrySet()) {
83  3 myFoodNames[i] = WhatYouEat.foods[ent.getKey()];
84  3 myFoodNumbers[i] = ent.getKey();
85  3 myFoodBool[i] = ent.getValue();
86  3 i++;
87    }
88  2 addScrollingButtons(myFoodNames, myFoodNumbers, myFoodBool,
89    BUTTON_COLORS[GROUPPREFS]);
90   
91    }
92   
93    }
94   
 
95  2 toggle public void addScrollingButtons(String[] buttonNames, int[] buttonIds,
96    boolean[] settings, int BUTTON_CLR) {
97   
98    // instanceChild.removeAllViews();
99  2 buttons = new Button[buttonNames.length];
100   
101  2 ckbox = new CheckBox[buttonNames.length];
102   
103  5 for (int i = 0; i < buttonNames.length; i++) {
104  3 LinearLayout layout = new LinearLayout(context);
105  3 buttons[i] = simpleButton();
106  3 buttons[i].setText(buttonNames[i]);
107  3 buttons[i].setId(buttonIds[i]);
108    // NAVIGATION or SEARCHWORDS or FOODINFO
109  3 buttons[i].setOnClickListener(nutritionInfoListener);
110  3 buttons[i].getBackground().setColorFilter(BUTTON_CLR,
111    PorterDuff.Mode.MULTIPLY);
112   
113  3 ckbox[i] = new CheckBox(context);
114   
115  3 ckbox[i].setChecked(settings[i]);
116   
117  3 ckbox[i].setOnCheckedChangeListener(foodPreferencesListener);
118  3 ckbox[i].setId(buttonIds[i]);// CHANGE TO ACTUAL FOOD ID
119  3 layout.addView(ckbox[i]);
120  3 layout.addView(buttons[i]);
121  3 instanceChild.addView(layout);
122    }
123   
124    }
125    }