// Path: app/src/main/java/eu/se_bastiaan/tvnl/service/RecommendationService.java
// public class RecommendationService extends IntentService {
// 
//     private static final int MAX_RECOMMENDATIONS = 3;
// 
//     @Inject
//     UGApiService ugApiService;
// 
//     public RecommendationService() {
//         super("RecommendationService");
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         TVNLApplication.get().appComponent().inject(this);
//     }
// 
//     @Override
//     protected void onHandleIntent(Intent intent) {
//         try {
//             Thread.sleep(10000);
//         } catch (InterruptedException e) {
//             e.printStackTrace();
//         }
// 
//         final RecommendationBuilder builder = new RecommendationBuilder()
//                 .setContext(getApplicationContext())
//                 .setSmallIcon(R.drawable.ic_recommendation);
// 
// 
//         ugApiService.getRecommendations()
//                 .subscribeOn(Schedulers.newThread())
//                 .observeOn(Schedulers.newThread())
//                 .subscribe(new Action1<List<Recommendation>>() {
//                     @Override
//                     public void call(List<Recommendation> recommendations) {
//                         try {
//                             for(int i = 0; i < MAX_RECOMMENDATIONS; i++) {
//                                 Recommendation recommendation = recommendations.get(i);
//                                 builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(recommendation.getImage(), "UTF-8"))
//                                         .setId(i)
//                                         .setPriority(i)
//                                         .setTitle(recommendation.getName())
//                                         .setDescription(recommendation.getDescription())
//                                         .setImage(recommendation.getImage())
//                                         .setIntent(buildPendingIntent(recommendation.toOverviewGridItem(), i))
//                                         .build();
//                             }
// 
//                         } catch (IOException e) {
//                             Timber.e(e, "Unable to update recommendation");
//                         }
//                     }
//                 }, new Action1<Throwable>() {
//                     @Override
//                     public void call(Throwable throwable) {
//                         Timber.e(throwable, "Unable to update recommendation");
//                     }
//                 });
//     }
// 
//     private PendingIntent buildPendingIntent(OverviewGridItem media, int notifId) {
//         Intent detailIntent = DetailsActivity.buildIntent(this, media, notifId);
//         return PendingIntent.getActivity(this, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//     }
// 
// }


import android.app.Application;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.multidex.MultiDexApplication;
import eu.se_bastiaan.tvnl.service.RecommendationService;
import timber.log.Timber;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
package eu.se_bastiaan.tvnl;



public class TVNLApplication extends MultiDexApplication {

    @Nullable
    private volatile AppInjectionComponent appInjectionComponent;
    private static TVNLApplication sThis;

    @Override
    public void onCreate() {
        super.onCreate();
        sThis = this;

        if(BuildConfig.DEBUG) {
            Timber.plant(new Timber.DebugTree());
        } else {
            //Timber.plant(new CrashlyticsLogTree(Log.INFO));
        }

        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/Regular.ttf")
                .setFontAttrId(R.attr.fontPath)
                .build()
        );

// Path: app/src/main/java/eu/se_bastiaan/tvnl/service/RecommendationService.java
// public class RecommendationService extends IntentService {
// 
//     private static final int MAX_RECOMMENDATIONS = 3;
// 
//     @Inject
//     UGApiService ugApiService;
// 
//     public RecommendationService() {
//         super("RecommendationService");
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         TVNLApplication.get().appComponent().inject(this);
//     }
// 
//     @Override
//     protected void onHandleIntent(Intent intent) {
//         try {
//             Thread.sleep(10000);
//         } catch (InterruptedException e) {
//             e.printStackTrace();
//         }
// 
//         final RecommendationBuilder builder = new RecommendationBuilder()
//                 .setContext(getApplicationContext())
//                 .setSmallIcon(R.drawable.ic_recommendation);
// 
// 
//         ugApiService.getRecommendations()
//                 .subscribeOn(Schedulers.newThread())
//                 .observeOn(Schedulers.newThread())
//                 .subscribe(new Action1<List<Recommendation>>() {
//                     @Override
//                     public void call(List<Recommendation> recommendations) {
//                         try {
//                             for(int i = 0; i < MAX_RECOMMENDATIONS; i++) {
//                                 Recommendation recommendation = recommendations.get(i);
//                                 builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(recommendation.getImage(), "UTF-8"))
//                                         .setId(i)
//                                         .setPriority(i)
//                                         .setTitle(recommendation.getName())
//                                         .setDescription(recommendation.getDescription())
//                                         .setImage(recommendation.getImage())
//                                         .setIntent(buildPendingIntent(recommendation.toOverviewGridItem(), i))
//                                         .build();
//                             }
// 
//                         } catch (IOException e) {
//                             Timber.e(e, "Unable to update recommendation");
//                         }
//                     }
//                 }, new Action1<Throwable>() {
//                     @Override
//                     public void call(Throwable throwable) {
//                         Timber.e(throwable, "Unable to update recommendation");
//                     }
//                 });
//     }
// 
//     private PendingIntent buildPendingIntent(OverviewGridItem media, int notifId) {
//         Intent detailIntent = DetailsActivity.buildIntent(this, media, notifId);
//         return PendingIntent.getActivity(this, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//     }
// 
// }


// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java
import android.app.Application;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.multidex.MultiDexApplication;
import eu.se_bastiaan.tvnl.service.RecommendationService;
import timber.log.Timber;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;

package eu.se_bastiaan.tvnl;



public class TVNLApplication extends MultiDexApplication {

    @Nullable
    private volatile AppInjectionComponent appInjectionComponent;
    private static TVNLApplication sThis;

    @Override
    public void onCreate() {
        super.onCreate();
        sThis = this;

        if(BuildConfig.DEBUG) {
            Timber.plant(new Timber.DebugTree());
        } else {
            //Timber.plant(new CrashlyticsLogTree(Log.INFO));
        }

        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/Regular.ttf")
                .setFontAttrId(R.attr.fontPath)
                .build()
        );

        Intent recommendationIntent = new Intent(this, RecommendationService.class);