// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
//     private static ApplicationSettings instance;
//     private static SharedPreferences settings;
//     private static final String PREFS_NAME = "settings.txt";
// 
//     private ApplicationSettings(Context context) {
//         settings = context.getSharedPreferences(PREFS_NAME, 1);
//     }
// 
//     public static synchronized ApplicationSettings getInstance(Context context) {
//         if (instance == null) {
//             instance = new ApplicationSettings(context);
//         }
//         return instance;
//     }
// 
//     public int getInt(String varName, int defaultValue) {
//         return settings.getInt(varName, defaultValue);
//     }
// 
//     public String getString(String varName, String defaultValue) {
//         return settings.getString(varName, defaultValue);
//     }
// 
//     public boolean getBoolean(String varName, boolean defaultValue) {
//         return settings.getBoolean(varName, defaultValue);
//     }
// 
//     public boolean putInt(String varName, int value) {
//         return settings.edit().putInt(varName, value).commit();
//     }
// 
//     public boolean putString(String varName, String value) {
//         return settings.edit().putString(varName, value).commit();
//     }
// 
//     public boolean putBoolean(String varName, boolean value) {
//         return settings.edit().putBoolean(varName, value).commit();
//     }
// }
// 
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
//     public final HashMap<String, String> fields = new HashMap<String, String>();
//     public int id;
// 
//     public Lesson() {
//         fields.put("faculty", "");
//         fields.put("year", "");
//         fields.put("course", "");
//         fields.put("term", "");
//         fields.put("stream", "");
//         fields.put("s_group", "");
//         fields.put("subgroup", "");
//         fields.put("weekDay", "");
//         fields.put("timePeriod", "");
//         fields.put("weekList", "");
//         fields.put("subject", "");
//         fields.put("subjectType", "");
//         fields.put("auditorium", "");
//         fields.put("teacher", "");
//         fields.put("date", "");
//         fields.put("timePeriodStart", "");
//         fields.put("timePeriodEnd", "");
//     }
// }
// 
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
//     private final ScheduleDatabase mScheduleDatabase;
//     private StudentCalendar mStudentCalendar = new StudentCalendar();
//     private static ScheduleManager instance;
// 
//     public static ScheduleManager getInstance(Context context) {
//         if (instance == null) {
//             instance = new ScheduleManager(context);
//         }
//         return instance;
//     }
// 
//     public ScheduleManager(Context context) {
//         mScheduleDatabase = new ScheduleDatabase(context);
//         mStudentCalendar = new StudentCalendar();
//     }
// 
//     public ArrayList<StudentGroup> getGroups() {
//         return mScheduleDatabase.getGroups();
//     }
// 
//     public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
//         mScheduleDatabase.addSchedule(lessons, groupId);
//     }
// 
//     public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
//         return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
//     }
// 
//     public void deleteSchedule(String groupId) {
//         mScheduleDatabase.deleteSchedule(groupId);
//     }
// 
//     public boolean isLessonsEndToday(String groupId, int subgroup) {
//         DateTime currentTime = new DateTime();
//         Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
//         if (lessons.length > 0) {
//             Lesson lesson = lessons[lessons.length - 1];
// 
//             DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
//             DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
//             if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
//                 return true;
//             }
//         } else {
//             return true;
//         }
//         return false;
//     }
// 
//     private String getFinishTimeOfLesson(Lesson lesson) {
//         String time = lesson.fields.get("timePeriod");
//         char c = '-';
//         int pos = -1;
//         while (time.charAt(++pos) != c) ;
//         String result = time.substring(pos + 1, time.length());
//         return result;
//     }
// }


import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
package ru.bsuirhelper.android.appwidget;


/**
 * Created by Влад on 15.10.13.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
    private final ScheduleManager mScheduleManager;
    private Lesson[] mLessons;
    private final Context mContext;
    private final Intent mIntent;
    private final int mWidgetId;
    private int mLessonCount;
    private final ApplicationSettings mSettings;

    public ScheduleFactoryViews(Context context, Intent intent) {
        mScheduleManager = ScheduleManager.getInstance(context);
        mIntent = intent;
        mWidgetId = mIntent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        mContext = context;
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
//     private static ApplicationSettings instance;
//     private static SharedPreferences settings;
//     private static final String PREFS_NAME = "settings.txt";
// 
//     private ApplicationSettings(Context context) {
//         settings = context.getSharedPreferences(PREFS_NAME, 1);
//     }
// 
//     public static synchronized ApplicationSettings getInstance(Context context) {
//         if (instance == null) {
//             instance = new ApplicationSettings(context);
//         }
//         return instance;
//     }
// 
//     public int getInt(String varName, int defaultValue) {
//         return settings.getInt(varName, defaultValue);
//     }
// 
//     public String getString(String varName, String defaultValue) {
//         return settings.getString(varName, defaultValue);
//     }
// 
//     public boolean getBoolean(String varName, boolean defaultValue) {
//         return settings.getBoolean(varName, defaultValue);
//     }
// 
//     public boolean putInt(String varName, int value) {
//         return settings.edit().putInt(varName, value).commit();
//     }
// 
//     public boolean putString(String varName, String value) {
//         return settings.edit().putString(varName, value).commit();
//     }
// 
//     public boolean putBoolean(String varName, boolean value) {
//         return settings.edit().putBoolean(varName, value).commit();
//     }
// }
// 
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
//     public final HashMap<String, String> fields = new HashMap<String, String>();
//     public int id;
// 
//     public Lesson() {
//         fields.put("faculty", "");
//         fields.put("year", "");
//         fields.put("course", "");
//         fields.put("term", "");
//         fields.put("stream", "");
//         fields.put("s_group", "");
//         fields.put("subgroup", "");
//         fields.put("weekDay", "");
//         fields.put("timePeriod", "");
//         fields.put("weekList", "");
//         fields.put("subject", "");
//         fields.put("subjectType", "");
//         fields.put("auditorium", "");
//         fields.put("teacher", "");
//         fields.put("date", "");
//         fields.put("timePeriodStart", "");
//         fields.put("timePeriodEnd", "");
//     }
// }
// 
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
//     private final ScheduleDatabase mScheduleDatabase;
//     private StudentCalendar mStudentCalendar = new StudentCalendar();
//     private static ScheduleManager instance;
// 
//     public static ScheduleManager getInstance(Context context) {
//         if (instance == null) {
//             instance = new ScheduleManager(context);
//         }
//         return instance;
//     }
// 
//     public ScheduleManager(Context context) {
//         mScheduleDatabase = new ScheduleDatabase(context);
//         mStudentCalendar = new StudentCalendar();
//     }
// 
//     public ArrayList<StudentGroup> getGroups() {
//         return mScheduleDatabase.getGroups();
//     }
// 
//     public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
//         mScheduleDatabase.addSchedule(lessons, groupId);
//     }
// 
//     public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
//         return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
//     }
// 
//     public void deleteSchedule(String groupId) {
//         mScheduleDatabase.deleteSchedule(groupId);
//     }
// 
//     public boolean isLessonsEndToday(String groupId, int subgroup) {
//         DateTime currentTime = new DateTime();
//         Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
//         if (lessons.length > 0) {
//             Lesson lesson = lessons[lessons.length - 1];
// 
//             DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
//             DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
//             if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
//                 return true;
//             }
//         } else {
//             return true;
//         }
//         return false;
//     }
// 
//     private String getFinishTimeOfLesson(Lesson lesson) {
//         String time = lesson.fields.get("timePeriod");
//         char c = '-';
//         int pos = -1;
//         while (time.charAt(++pos) != c) ;
//         String result = time.substring(pos + 1, time.length());
//         return result;
//     }
// }


// Path: app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;

package ru.bsuirhelper.android.appwidget;


/**
 * Created by Влад on 15.10.13.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
    private final ScheduleManager mScheduleManager;
    private Lesson[] mLessons;
    private final Context mContext;
    private final Intent mIntent;
    private final int mWidgetId;
    private int mLessonCount;
    private final ApplicationSettings mSettings;

    public ScheduleFactoryViews(Context context, Intent intent) {
        mScheduleManager = ScheduleManager.getInstance(context);
        mIntent = intent;
        mWidgetId = mIntent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        mContext = context;
        mSettings = ApplicationSettings.getInstance(context);