package com.simperium.android;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.simperium.Simperium;
import com.simperium.client.ClientFactory;
import com.simperium.util.BasicSyncService;
import com.simperium.util.Uuid;

/**
 * Refactoring as much of the android specific components of the client
 * and decoupling different parts of the API.
 */
public class AndroidClient implements ClientFactory {

    public static final String DEFAULT_DATABASE_NAME = "simperium-store";

    protected Context mContext;
    protected SQLiteDatabase mDatabase;

    public AndroidClient(Context context){
        mContext = context;
        mDatabase = mContext.openOrCreateDatabase(DEFAULT_DATABASE_NAME, 0, null);
    }

    @Override
    public VolleyAuthClient buildAuthProvider(String appId, String appSecret){
        VolleyAuthClient client = new VolleyAuthClient(appId, appSecret, mContext);
        return client;
    }

    @Override
    public WebSocketManager buildChannelProvider(String appId){
        // Simperium Bucket API
        return new WebSocketManager(appId, String.format("%s-%s", Simperium.CLIENT_ID, Uuid.uuid().substring(0,6)), new QueueSerializer(mDatabase));
    }

    @Override
    public PersistentStore buildStorageProvider(){
        return new PersistentStore(mDatabase);
    }

    @Override
    public GhostStore buildGhostStorageProvider(){
        return new GhostStore(mDatabase);
    }

    @Override
    public LruCacheProvider buildObjectCacheProvider(){
        return new LruCacheProvider();
    }

    @Override
    public BasicSyncService buildSyncService(){
        return new BasicSyncService();
    }
}
@@ -210,56 +210,135 @@
 til.
-BasicSyncService;%0Aimport com.simperium.util.Uuid
+Uuid;%0A%0Aimport java.util.concurrent.Executor;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.ExecutorService
 ;%0A%0A/
@@ -665,16 +665,90 @@
 abase;%0A%0A
+    protected ExecutorService service = Executors.newFixedThreadPool(1);%0A%0A
     publ
@@ -1751,41 +1751,30 @@
 lic 
-BasicSyncService buildSyncService
+Executor buildExecutor
 ()%7B%0A
@@ -1792,30 +1792,15 @@
 urn 
-new BasicSyncS
+s
 ervice
-()
 ;%0A  

Replace use of BasicSyncService