// 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.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import eu.se_bastiaan.tvnl.service.RecommendationService;
package eu.se_bastiaan.tvnl.receiver;



public class BootReceiver extends BroadcastReceiver {
    private static final long INITIAL_DELAY = 5000;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().endsWith(Intent.ACTION_BOOT_COMPLETED)) {
            scheduleRecommendationUpdate(context);
        }
    }

    private void scheduleRecommendationUpdate(Context context) {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// 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/receiver/BootReceiver.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import eu.se_bastiaan.tvnl.service.RecommendationService;

package eu.se_bastiaan.tvnl.receiver;



public class BootReceiver extends BroadcastReceiver {
    private static final long INITIAL_DELAY = 5000;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().endsWith(Intent.ACTION_BOOT_COMPLETED)) {
            scheduleRecommendationUpdate(context);
        }
    }

    private void scheduleRecommendationUpdate(Context context) {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        Intent recommendationIntent = new Intent(context, RecommendationService.class);