1 |
|
package co.harlequinmettle.healthfoodconcepts; |
2 |
|
|
3 |
|
import java.io.FileOutputStream; |
4 |
|
import java.io.IOException; |
5 |
|
import java.io.ObjectOutputStream; |
6 |
|
|
7 |
|
import android.content.Context; |
8 |
|
|
|
|
| 80% |
Uncovered Elements: 5 (25) |
Complexity: 6 |
Complexity Density: 0,32 |
|
9 |
|
public class ObjectStoringThread implements Runnable{ |
10 |
|
|
11 |
|
Context context; |
12 |
|
float[][] db; |
13 |
|
long time ; |
14 |
|
float saveTime; |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
15 |
1
|
public ObjectStoringThread(Context context,float[][] db ) {... |
16 |
1
|
this.context = context; |
17 |
1
|
this.db = db; |
18 |
|
} |
19 |
|
|
|
|
| 76,2% |
Uncovered Elements: 5 (21) |
Complexity: 5 |
Complexity Density: 0,29 |
|
20 |
1
|
public void run() {... |
21 |
1
|
if(!WhatYouEat._loaded){ |
22 |
0
|
try { |
23 |
0
|
WhatYouEat.loadingThread.join(); |
24 |
|
} catch (InterruptedException e) { |
25 |
|
|
26 |
0
|
e.printStackTrace(); |
27 |
|
} |
28 |
|
} |
29 |
1
|
System.out.println("STARTING TO SAVE DATA AS OBJECT NOW: ---->"); |
30 |
1
|
time = System.currentTimeMillis(); |
31 |
131
|
for (int i = 0; i < db.length; i++) { |
32 |
|
|
33 |
130
|
try { |
34 |
130
|
FileOutputStream fos = context.openFileOutput( |
35 |
|
ObjectLoadingThread.DATA_100G + i, Context.MODE_PRIVATE); |
36 |
130
|
ObjectOutputStream objout = new ObjectOutputStream(fos); |
37 |
130
|
objout.writeObject(db[i]); |
38 |
130
|
objout.flush(); |
39 |
130
|
objout.close(); |
40 |
|
|
41 |
|
} catch (IOException ioe) { |
42 |
0
|
System.out.println("NO save: saver"); |
43 |
|
} |
44 |
130
|
Thread.yield(); |
45 |
|
} |
46 |
|
|
47 |
1
|
saveTime = (float) ((System.currentTimeMillis() - time) / 1000.0); |
48 |
1
|
System.out.println("----DONE SAVING DB---time to save db---->" + (saveTime)); |
49 |
|
} |
50 |
|
} |