Search in sources :

Example 1 with DeviceAuthService

use of com.letscooee.retrofit.DeviceAuthService in project cooee-android-sdk by letscooee.

the class CooeeFactory method init.

public static synchronized void init(Context context) {
    if (initialized) {
        return;
    }
    appInfo = AppInfo.getInstance(context);
    deviceInfo = DeviceInfo.getInstance(context);
    manifestReader = ManifestReader.getInstance(context);
    sentryHelper = new SentryHelper(context, appInfo, manifestReader);
    sentryHelper.init();
    // Sentry should be initialized first
    ITransaction transaction = Sentry.startTransaction("CooeeFactory.init()", "task");
    baseHTTPService = new BaseHTTPService(context);
    // This is required in PendingTaskService (ultimately). TODO make this a strong dependency
    deviceAuthService = new DeviceAuthService(context, sentryHelper, manifestReader);
    deviceAuthService.populateUserDataFromStorage();
    pendingTaskService = new PendingTaskService(context, sentryHelper);
    runtimeData = RuntimeData.getInstance(context);
    sessionManager = SessionManager.getInstance(context);
    safeHTTPService = new SafeHTTPService(context, pendingTaskService, sessionManager, runtimeData);
    transaction.finish();
    initialized = true;
}
Also used : SafeHTTPService(com.letscooee.network.SafeHTTPService) DeviceAuthService(com.letscooee.retrofit.DeviceAuthService) SentryHelper(com.letscooee.utils.SentryHelper) ITransaction(io.sentry.ITransaction) BaseHTTPService(com.letscooee.network.BaseHTTPService) PendingTaskService(com.letscooee.room.task.PendingTaskService)

Example 2 with DeviceAuthService

use of com.letscooee.retrofit.DeviceAuthService in project cooee-android-sdk by letscooee.

the class PendingTaskJob method onStartJob.

@Override
public boolean onStartJob(JobParameters params) {
    jobParameters = params;
    Context context = getApplicationContext();
    Log.v(Constants.TAG, "PendingTaskJob running");
    DeviceAuthService deviceAuthService = CooeeFactory.getDeviceAuthService();
    if (!deviceAuthService.hasToken()) {
        Log.d(Constants.TAG, "Abort PendingTaskJob. Do not have the SDK token");
        // Job is finished
        return false;
    }
    List<PendingTask> taskList = CooeeDatabase.getInstance(context).pendingTaskDAO().fetchPending();
    // As job was running on main thread so all the network call were getting break
    CooeeExecutors.getInstance().singleThreadExecutor().execute(() -> CooeeFactory.getPendingTaskService().processTasks(taskList, this));
    return true;
}
Also used : Context(android.content.Context) DeviceAuthService(com.letscooee.retrofit.DeviceAuthService) PendingTask(com.letscooee.room.task.PendingTask)

Aggregations

DeviceAuthService (com.letscooee.retrofit.DeviceAuthService)2 Context (android.content.Context)1 BaseHTTPService (com.letscooee.network.BaseHTTPService)1 SafeHTTPService (com.letscooee.network.SafeHTTPService)1 PendingTask (com.letscooee.room.task.PendingTask)1 PendingTaskService (com.letscooee.room.task.PendingTaskService)1 SentryHelper (com.letscooee.utils.SentryHelper)1 ITransaction (io.sentry.ITransaction)1