EMMA Coverage Report (generated Tue Jun 26 14:54:12 CEST 2012)
[all classes][org.tomdroid.sync]

COVERAGE SUMMARY FOR SOURCE FILE [SyncManager.java]

nameclass, %method, %block, %line, %
SyncManager.java100% (1/1)90%  (9/10)91%  (85/93)86%  (25/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SyncManager100% (1/1)90%  (9/10)91%  (85/93)86%  (25/29)
startSynchronization (): void 0%   (0/1)0%   (0/6)0%   (0/3)
getService (String): SyncService 100% (1/1)92%  (22/24)80%  (4/5)
<static initializer> 100% (1/1)100% (3/3)100% (1/1)
SyncManager (): void 100% (1/1)100% (10/10)100% (4/4)
createServices (): void 100% (1/1)100% (22/22)100% (4/4)
getCurrentService (): SyncService 100% (1/1)100% (7/7)100% (2/2)
getInstance (): SyncManager 100% (1/1)100% (8/8)100% (3/3)
getServices (): ArrayList 100% (1/1)100% (3/3)100% (1/1)
setActivity (Activity): void 100% (1/1)100% (5/5)100% (3/3)
setHandler (Handler): void 100% (1/1)100% (5/5)100% (3/3)

1/*
2 * Tomdroid
3 * Tomboy on Android
4 * http://www.launchpad.net/tomdroid
5 * 
6 * Copyright 2009, Benoit Garret <benoit.garret_launchpad@gadz.org>
7 * 
8 * This file is part of Tomdroid.
9 * 
10 * Tomdroid is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 * 
15 * Tomdroid is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 * 
20 * You should have received a copy of the GNU General Public License
21 * along with Tomdroid.  If not, see <http://www.gnu.org/licenses/>.
22 */
23package org.tomdroid.sync;
24 
25import java.util.ArrayList;
26 
27import org.tomdroid.sync.sd.SdCardSyncService;
28import org.tomdroid.sync.web.SnowySyncService;
29import org.tomdroid.util.Preferences;
30 
31import android.app.Activity;
32import android.os.Handler;
33 
34public class SyncManager {
35        
36        private static final String TAG = "SyncManager";
37        
38        private ArrayList<SyncService> services = new ArrayList<SyncService>();
39        
40        public SyncManager() {
41                createServices();
42        }
43 
44        public ArrayList<SyncService> getServices() {
45                return services;
46        }
47        
48        public SyncService getService(String name) {
49                
50                for (int i = 0; i < services.size(); i++) {
51                        SyncService service = services.get(i);                        
52                        if (name.equals(service.getName()))
53                                return service;
54                }
55                
56                return null;
57        }
58        
59        public void startSynchronization() {
60                
61                SyncService service = getCurrentService();
62                service.startSynchronization();
63        }
64        
65        public SyncService getCurrentService() {
66                String serviceName = Preferences.getString(Preferences.Key.SYNC_SERVICE);
67                return getService(serviceName);
68        }
69        
70        private static SyncManager instance = null;
71        private static Activity activity;
72        private static Handler handler;
73        
74        public static SyncManager getInstance() {
75                
76                if (instance == null)
77                        instance = new SyncManager();
78                
79                return instance;
80        }
81        
82        public static void setActivity(Activity a) {
83                activity = a;
84                getInstance().createServices();
85        }
86        
87        public static void setHandler(Handler h) {
88                handler = h;
89                getInstance().createServices();
90        }
91 
92        private void createServices() {
93                services.clear();
94                
95                services.add(new SnowySyncService(activity, handler));
96                services.add(new SdCardSyncService(activity, handler));
97        }
98}

[all classes][org.tomdroid.sync]
EMMA 0.0.0 (unsupported private build) (C) Vladimir Roubtsov