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
50   108   9   25
12   78   0,18   2
2     4,5  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  LoadWeightsConversion       Line # 12 50 9 95,3% 0.953125
 
No Tests
 
1    package co.harlequinmettle.healthfoodconcepts;
2   
3    import java.io.BufferedReader;
4    import java.io.IOException;
5    import java.io.InputStream;
6    import java.io.InputStreamReader;
7    import java.util.ArrayList;
8    import java.util.Arrays;
9   
10    import android.content.res.AssetManager;
11   
 
12    public class LoadWeightsConversion implements Runnable {
13    // reluctant to use but seems necessary by convention
14    // divide [3]/[1] for per unit
15   
 
16  1 toggle public LoadWeightsConversion() {
17   
18    }
19   
 
20  1 toggle public void run() {
21   
22  1 ArrayList<ArrayList<String>> uns = new ArrayList<ArrayList<String>>();
23  1 ArrayList<ArrayList<Float>> quants = new ArrayList<ArrayList<Float>>();
24  1 ArrayList<ArrayList<Float>> grams = new ArrayList<ArrayList<Float>>();
25   
26  8195 for (int i = 0; i < WhatYouEat.FOOD_COUNT; i++) {
27  8194 uns.add(new ArrayList<String>());
28  8194 quants.add(new ArrayList<Float>());
29  8194 grams.add(new ArrayList<Float>());
30    }
31  1 long start = System.currentTimeMillis();
32  1 int readCount = 0;
33  1 AssetManager am = WhatYouEat.ctx.getAssets();
34  1 BufferedReader br = null;
35  1 try {
36  1 InputStream is = am.open("wt_con.txt");
37  1 br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
38   
39  1 String holder = "";
40  ? while ((holder = br.readLine()) != null) {
41   
42  14162 String[] values = holder.split("~");
43  14162 int id = GeneralLoadingThread.doInt(values[0]);
44   
45    // 2460~1~oz~28.35
46    // 2460~1~cubic inch~17
47    // 2460~1~cup, crumbled, not packed~135
48   
49  14162 uns.get(id).add(values[2]);
50  14162 quants.get(id).add(
51    (float) GeneralLoadingThread.doDouble(values[1]));
52  14162 grams.get(id).add(
53    (float) GeneralLoadingThread.doDouble(values[3]));
54   
55  14162 if (readCount++ % 1000 == 10) {
56  15 Thread.yield();
57    }
58    }
59  1 br.close();
60    } catch (IOException e) {
61    // TODO Auto-generated catch block
62  0 e.printStackTrace();
63    }
64   
65  1 for (int i: WhatYouEat.HAS_SERVING_INFO) {
66  7933 WhatYouEat.oddUnits[i] = new String[uns.get(i).size()];
67  7933 WhatYouEat.metricConversion[i] = new float[grams.get(i).size()];
68  7933 WhatYouEat.quantityFactor[i] = new float[quants.get(i).size()];
69  22095 for (int j = 0; j < uns.get(i).size(); j++) {
70  14162 WhatYouEat.oddUnits[i][j] = uns.get(i).get(j);
71  14162 WhatYouEat.metricConversion[i][j] = grams.get(i).get(j);
72  14162 WhatYouEat.quantityFactor[i][j] = quants.get(i).get(j);
73    }
74   
75    }
76   
77  1 for (int i: WhatYouEat.HAS_SERVING_INFO) {
78  22095 for (int j = 0; j < uns.get(i).size(); j++) {
79  14162 WhatYouEat.oddUnits[i][j] = uns.get(i).get(j);
80  14162 WhatYouEat.metricConversion[i][j] = grams.get(i).get(j);
81  14162 WhatYouEat.quantityFactor[i][j] = quants.get(i).get(j);
82    }
83   
84    }
85    // WhatYouEat.oddUnits string
86    // WhatYouEat.metricConversion float number of grams in quantity of odd
87    // units
88    // WhatYouEat.quantityFactor float number of odd units conventioanlly
89    // applied
90   
91  1 for (int id : WhatYouEat.WITH_SERVING_SIZE) {
92  7933 int optimalServingSizeID = 0;
93  7933 float smallestServing = 1000000;
94  7933 int index = 0;
95  7933 for (float weightOfServing : WhatYouEat.metricConversion[id]) {
96  14162 if (weightOfServing < smallestServing) {
97  10606 smallestServing = weightOfServing;
98  10606 optimalServingSizeID = index;
99    }
100  14162 index++;
101    }
102  7933 WhatYouEat.optimalServingId[id] = optimalServingSizeID;
103    }
104  1 float threadTime = (float) ((System.currentTimeMillis() - start) / 1000.0);
105   
106  1 System.out.println("--------------------------->" + threadTime+"\n"+WhatYouEat.oddUnits[0].length);
107    }
108    }