Clover Coverage Report - WhatYouEat Coverage Report
Coverage timestamp: sab gen 3 2015 15:14:15 EST
../../../img/srcFileCovDistChart10.png 0% of files have more coverage
55   210   15   5
8   171   0,27   5,5
11     1,36  
2    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  SubScroll       Line # 19 51 12 97% 0.969697
  SubScroll.RandomScroller       Line # 185 4 3 100% 1.0
 
No Tests
 
1    package co.harlequinmettle.healthfoodconcepts;
2   
3    import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
4    import static android.widget.LinearLayout.VERTICAL;
5    import android.content.Context;
6    import android.graphics.PorterDuff;
7    import android.util.TypedValue;
8    import android.view.View;
9    import android.view.ViewGroup;
10    import android.view.ViewTreeObserver.OnGlobalLayoutListener;
11    import android.widget.Button;
12    import android.widget.EditText;
13    import android.widget.LinearLayout;
14    import android.widget.RadioButton;
15    import android.widget.ScrollView;
16    import android.widget.TextView;
17   
18    //base class for other more specific types of scroll:menu,keyword,searchResults,nutritionInfo
 
19    public class SubScroll extends ScrollView {
20    static boolean fromKeywordSearch;
21    static boolean fromFoodSuggestions;
22    static final int BUTTON_COLORS[] = { //
23    0xff77aaaa, // navigaton
24    0xff444488, // searchwords
25    0xff229922, // serch results
26    0xff0000ff, // not used nutrients use several colors defined
27    0xff5555cc, // food group
28    0xffaaaaaa, // not used histogram expected to be its own view
29    0xff3333cc, // settings button colors
30    0XFFDDAA00, // food group preferences
31    0xffee22aa, // nutrient preferences
32    };
33    public static boolean [] scrollinflated = new boolean [25];
34    static final int FOOD_GROUP_LABEL_COLOR = 0xff44aaff;
35   
36    static final int RADIO_OPTIONS_1_COLOR = 0xff77BB55;
37    static final int RADIO_OPTIONS_2_COLOR = 0xff9999cc;
38    static final int RADIO_OPTIONS_3_COLOR = 0xff22cc77;
39    static final int RADIO_OPTIONS_4_COLOR = 0xff22ccff;
40   
41    static final int MAX_BUTTON_WIDTH = 350;
42   
43    static final int FOOD_RESULTS_ID = 1000055001;
44    static final int FOOD_NUTRIENT_ID = 1055055001;
45    static final int STATVIEW_ID = 1010101111;
46    static final int GROUP_CHOICE_MENU_ID = 123311111;
47    static final int NUTRIENT_CHOICE_MENU_ID = 1221000011;
48    static final int FOOD_CHOICE_MENU_ID = 1222244011;
49    static final int KEYWORD_SEARCH_ID = 2111211112;
50    static final int NUTRITION_CHOICES_ID = 211333332;
51    static final int OPTIONS_MENU_ID = 2131313222;
52    static final int ID_PER_100_GRAMS = 343422222;
53    static final int ID_PER_100_KCALS = 43432211;
54    static final int ID_PER_SERVING = 44444411;
55    static final int NUTRIENT_SEARCH_ID = 551155;
56    static final int FOOD_REMOVAL_ID = 5555555;
57    static final int NUTRITION_CALCULATOR_ID = 525252525;
58   
59    static final int NAVIGATION = 0;
60    static final int SEARCHWORDS = 1;
61    static final int SEARCH_RESULTS = 2;
62    static final int NUTRIENTS = 3;
63    static final int FOODGROUP = 4;
64    static final int HISTOGRAM = 5;
65    static final int SETTINGS = 6;
66    static final int GROUPPREFS = 7;
67    static final int NUTRPREFS = 8;
68   
69    static final int GENERAL = 0x002055dd;// 0-7
70    static final int INTERESTING = 0x004FBB1a;// 8-14
71    static final int CARB = 0x00ababab;// 15-24
72    static final int MINERAL = 0x00FF00CC;// 25-35
73    static final int VITAMIN = 0x00CC00FF;// 36-65
74    static final int PROTEIN = 0x00bb2255;// 66-84
75    static final int FAT = 0x00EEEE55;// 85-129
76   
77    static int lastFoodsId;
78    static int index;
79    static int foodPosition;
80    static int nutritionInfoPosition;
81   
82    static int scrollCount = 0;
83   
84    Context context;
85    LinearLayout instanceChild;
86    static int currentFoodID, currentNutrientID;
87    static int currentFoodGroup;
88    static EditText ourInput;
89    Button[] buttons;// setText setID addlistener
90    static KeywordScroller[] foodGroupScrolls;
91    static boolean showingResults, showingNutrients, showingStats;// initially
92    // false
93    static boolean optionMenuShowing = false;
 
94  88 toggle SubScroll(Context c) {
95  88 super(c);
96  88 this.context = c;
97  88 instanceChild = basicLinearLayout();
98    // accessed with view.getParent().getId() to insert scrollers at current
99    // possition
100  88 this.instanceChild.setId(scrollCount++);
101    // add the layout to the scrollview
102  88 this.addView(instanceChild);
103    }
104   
 
105  19 toggle SubScroll(Context c,boolean addChild) {
106  19 super(c);
107  19 this.context = c;
108  19 instanceChild = basicLinearLayout();
109    // accessed with view.getParent().getId() to insert scrollers at current
110    // possition
111  19 this.instanceChild.setId(scrollCount++);
112    // add the layout to the scrollview
113  19 if( addChild)
114  0 this.addView(instanceChild);
115    }
116   
117    // fills instnaceChild linearlayout full of buttons
 
118  5 toggle public void addScrollingButtons(String[] buttonNames, int[] buttonIds,
119    View.OnClickListener listener, int BUTTON_CLR) {
120    // instanceChild.removeAllViews();
121  5 buttons = new Button[buttonNames.length];
122   
123  207 for (int i = 0; i < buttonNames.length; i++) {
124  202 buttons[i] = simpleButton();
125  202 buttons[i].setText(buttonNames[i]);
126  202 buttons[i].setId(buttonIds[i]);
127    // NAVIGATION or SEARCHWORDS or FOODINFO
128  202 buttons[i].setOnClickListener(listener);
129  202 if(BUTTON_CLR!=0){
130  199 buttons[i].getBackground().setColorFilter(BUTTON_CLR,
131    PorterDuff.Mode.MULTIPLY);
132    }
133  202 instanceChild.addView(buttons[i]);
134    }
135    // add layout full of buttons to scrollview
136   
137  5 this.getViewTreeObserver().addOnGlobalLayoutListener(
138    new RandomScroller(this));
139   
140    }
141   
 
142  9 toggle public static void resetDisplayConditions() {
143  9 showingStats = false;
144  9 lastFoodsId = 0;
145  9 showingNutrients = false;
146  9 showingResults = false;
147    }
148   
 
149  2476 toggle public static Button simpleButton() {
150  2476 Button button = new Button(WhatYouEat.ctx);
151  2476 button.setHeight(WRAP_CONTENT);
152  2476 button.setMaxWidth(MAX_BUTTON_WIDTH);
153  2476 button.setMaxLines(5);
154  2476 button.setTextSize(TypedValue.COMPLEX_UNIT_DIP,WhatYouEat.TEXT_MED);
155  2476 return button;
156    }
 
157  30 toggle public static RadioButton simpleRadioButton() {
158  30 RadioButton button = new RadioButton(WhatYouEat.ctx);
159  30 button.setHeight(WRAP_CONTENT);
160  30 button.setMaxWidth(MAX_BUTTON_WIDTH);
161  30 button.setMaxLines(5);
162  30 button.setTextSize(TypedValue.COMPLEX_UNIT_DIP,WhatYouEat.TEXT_SMALL);
163  30 return button;
164    }
165   
 
166  121 toggle public static TextView textView() {
167  121 TextView ta = new TextView(WhatYouEat.ctx);
168  121 ta.setHeight(WRAP_CONTENT);
169  121 ta.setMaxWidth(MAX_BUTTON_WIDTH);
170  121 ta.setMaxLines(5);
171  121 ta.setTextSize(TypedValue.COMPLEX_UNIT_DIP,WhatYouEat.TEXT_MED);
172  121 return ta;
173    }
174   
175    // ///////////////////////////////////////
 
176  194 toggle public LinearLayout basicLinearLayout() {
177  194 LinearLayout basic = new LinearLayout(context);
178  194 ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
179    WRAP_CONTENT, WRAP_CONTENT);
180  194 basic.setLayoutParams(params);
181  194 basic.setOrientation(VERTICAL);
182  194 return basic;
183    }
184   
 
185    public class RandomScroller implements OnGlobalLayoutListener {
186    ScrollView scroll;
187    boolean hasBeenSet = false;
188   
 
189  5 toggle public RandomScroller(ScrollView scroll) {
190  5 this.scroll = scroll;
191    }
192   
 
193  358 toggle public void onGlobalLayout() {
194  358 if (!hasBeenSet) {
195  5 scroll.scrollTo(0,
196    (int) (Math.random() * scroll.getHeight() * 6));
197  5 hasBeenSet = true;
198    }
199    }
200    }
201   
202    // prefer not to use the edittext
 
203  85 toggle static EditText editText(String hint) {
204  85 EditText editText = new EditText(WhatYouEat.ctx);
205    // editText.setId(Integer.valueOf(hint));
206  85 editText.setHint(hint);
207  85 return editText;
208    }
209   
210    }