// Path: app/src/main/java/com/example/offline/domain/services/jobs/JobManagerFactory.java
// public class JobManagerFactory {
// 
//     private static JobManager jobManager;
// 
//     public static synchronized JobManager getJobManager() {
//         return jobManager;
//     }
// 
//     public static synchronized JobManager getJobManager(Context context) {
//         if (jobManager == null) {
//             jobManager = configureJobManager(context);
//         }
//         return jobManager;
//     }
// 
//     private static CustomLogger customLogger = new CustomLogger() {
// 
//         @Override
//         public boolean isDebugEnabled() {
//             return true;
//         }
// 
//         @Override
//         public void d(String text, Object... args) {
//             Timber.d(String.format(text, args));
//         }
// 
//         @Override
//         public void e(Throwable t, String text, Object... args) {
//             Timber.e(t, String.format(text, args));
//         }
// 
//         @Override
//         public void e(String text, Object... args) {
//             Timber.e(String.format(text, args));
//         }
// 
//         @Override
//         public void v(String text, Object... args) {
//             // no-op
//         }
//     };
// 
//     private static JobManager configureJobManager(Context context) {
//         Configuration.Builder builder = new Configuration.Builder(context)
//                 .minConsumerCount(1)//always keep at least one consumer alive
//                 .maxConsumerCount(3)//up to 3 consumers at a time
//                 .loadFactor(3)//3 jobs per consumer
//                 .consumerKeepAlive(120)//wait 2 minutes
//                 .customLogger(customLogger);
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//             builder.scheduler(FrameworkJobSchedulerService.createSchedulerFor(context,
//                     SchedulerJobService.class), true);
//         } else {
//             int enableGcm = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
//             if (enableGcm == ConnectionResult.SUCCESS) {
//                 builder.scheduler(GcmJobSchedulerService.createSchedulerFor(context,
//                         GcmJobSchedulerService.class), true);
//             }
//         }
//         return new JobManager(builder.build());
//     }
// }


import android.app.Activity;
import android.app.Application;
import com.example.offline.di.DaggerAppComponent;
import com.example.offline.domain.services.jobs.JobManagerFactory;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import timber.log.Timber;
package com.example.offline;





public class App extends Application implements HasActivityInjector {
    @Inject
    DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

    @Override
    public void onCreate() {
        super.onCreate();

        if (BuildConfig.DEBUG) {
            Timber.plant(new Timber.DebugTree());
        }

        DaggerAppComponent
                .builder()
                .application(this)
                .build()
                .inject(this);

// Path: app/src/main/java/com/example/offline/domain/services/jobs/JobManagerFactory.java
// public class JobManagerFactory {
// 
//     private static JobManager jobManager;
// 
//     public static synchronized JobManager getJobManager() {
//         return jobManager;
//     }
// 
//     public static synchronized JobManager getJobManager(Context context) {
//         if (jobManager == null) {
//             jobManager = configureJobManager(context);
//         }
//         return jobManager;
//     }
// 
//     private static CustomLogger customLogger = new CustomLogger() {
// 
//         @Override
//         public boolean isDebugEnabled() {
//             return true;
//         }
// 
//         @Override
//         public void d(String text, Object... args) {
//             Timber.d(String.format(text, args));
//         }
// 
//         @Override
//         public void e(Throwable t, String text, Object... args) {
//             Timber.e(t, String.format(text, args));
//         }
// 
//         @Override
//         public void e(String text, Object... args) {
//             Timber.e(String.format(text, args));
//         }
// 
//         @Override
//         public void v(String text, Object... args) {
//             // no-op
//         }
//     };
// 
//     private static JobManager configureJobManager(Context context) {
//         Configuration.Builder builder = new Configuration.Builder(context)
//                 .minConsumerCount(1)//always keep at least one consumer alive
//                 .maxConsumerCount(3)//up to 3 consumers at a time
//                 .loadFactor(3)//3 jobs per consumer
//                 .consumerKeepAlive(120)//wait 2 minutes
//                 .customLogger(customLogger);
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//             builder.scheduler(FrameworkJobSchedulerService.createSchedulerFor(context,
//                     SchedulerJobService.class), true);
//         } else {
//             int enableGcm = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
//             if (enableGcm == ConnectionResult.SUCCESS) {
//                 builder.scheduler(GcmJobSchedulerService.createSchedulerFor(context,
//                         GcmJobSchedulerService.class), true);
//             }
//         }
//         return new JobManager(builder.build());
//     }
// }


// Path: app/src/main/java/com/example/offline/App.java
import android.app.Activity;
import android.app.Application;
import com.example.offline.di.DaggerAppComponent;
import com.example.offline.domain.services.jobs.JobManagerFactory;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import timber.log.Timber;

package com.example.offline;





public class App extends Application implements HasActivityInjector {
    @Inject
    DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

    @Override
    public void onCreate() {
        super.onCreate();

        if (BuildConfig.DEBUG) {
            Timber.plant(new Timber.DebugTree());
        }

        DaggerAppComponent
                .builder()
                .application(this)
                .build()
                .inject(this);

        JobManagerFactory.getJobManager(this);