Search in sources :

Example 1 with ChatDataSource

use of com.fanap.podchat.repository.ChatDataSource in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method init.

/**
 * Initialize the Chat
 *
 * @param context for Async sdk and other usage
 */
public static synchronized Chat init(Context context) {
    if (instance == null) {
        setupSentry(context);
        async = Async.getInstance(context);
        async.rawLog(BuildConfig.DEBUG);
        async.isLoggable(BuildConfig.DEBUG);
        async.setReconnectOnClose(false);
        instance = new Chat();
        gson = new GsonBuilder().setPrettyPrinting().create();
        parser = new JsonParser();
        instance.setContext(context);
        listenerManager = new ChatListenerManager();
        threadCallbacks = new HashMap<>();
        leaveThreadCallbacks = new HashMap<>();
        mSecurePrefs = new SecurePreferences(context, "", "chat_prefs.xml");
        // SecurePreferences.setLoggingEnabled(true);
        runDatabase(context);
        sendingQList = new HashMap();
        uploadingQList = new HashMap();
        waitQList = new HashMap<>();
        hashTagCallBacks = new HashMap<>();
        messageCallbacks = new HashMap<>();
        handlerSend = new HashMap<>();
        gson = new GsonBuilder().create();
        Sentry.setExtra("chat-sdk-version-name", BuildConfig.VERSION_NAME);
        Sentry.setExtra("chat-sdk-version-code", String.valueOf(BuildConfig.VERSION_CODE));
        Sentry.setExtra("chat-sdk-build-type", BuildConfig.BUILD_TYPE);
        Sentry.setExtra("chat-sdk-flavor", BuildConfig.FLAVOR);
        dataSource = new ChatDataSource(new MemoryDataSource(), new CacheDataSource(instance.messageDatabaseHelper));
    }
    return instance;
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) HashMap(java.util.HashMap) CacheDataSource(com.fanap.podchat.repository.CacheDataSource) SecurePreferences(com.securepreferences.SecurePreferences) MemoryDataSource(com.fanap.podchat.repository.MemoryDataSource) ChatDataSource(com.fanap.podchat.repository.ChatDataSource) JsonParser(com.google.gson.JsonParser)

Aggregations

CacheDataSource (com.fanap.podchat.repository.CacheDataSource)1 ChatDataSource (com.fanap.podchat.repository.ChatDataSource)1 MemoryDataSource (com.fanap.podchat.repository.MemoryDataSource)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonParser (com.google.gson.JsonParser)1 SecurePreferences (com.securepreferences.SecurePreferences)1 HashMap (java.util.HashMap)1