public override void OnReceive(Context context, Intent intent)
        {
            bool   bootCompleted;
            string action = intent.Action;

            //TODO Switch to UserManagerCompat, BuildCompat
            Log.Info(TAG, $"Recieved action {action}, user unlocked: ");              //{UserManagerCompat.IsUserUnlocked (context))}");

            if (Build.VERSION.SdkInt > BuildVersionCodes.M)
            {
                bootCompleted = Intent.ActionLockedBootCompleted == action;
            }
            else
            {
                bootCompleted = Intent.ActionBootCompleted == action;
            }

            if (!bootCompleted)
            {
                return;
            }

            var util         = new AlarmUtil(context);
            var alarmStorage = new AlarmStorage(context);

            foreach (Alarm alarm in alarmStorage.GetAlarms())
            {
                util.ScheduleAlarm(alarm);
            }
        }
示例#2
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            var fab = (FloatingActionButton)view.FindViewById(Resource.Id.fab_add_alarm);

            fab.Click += delegate {
                var fragment = TimePickerFragment.NewInstance();
                fragment.SetAlarmAddListener(new AlarmAddListenerImpl(this));
                fragment.Show(FragmentManager, FRAGMENT_TIME_PICKER_TAG);
            };

            TextViewIntroMessage = (TextView)view.FindViewById(Resource.Id.text_intro_message);
            var alarmStorage = new AlarmStorage(Activity);

            AlarmAdapter = new AlarmAdapter(Activity, alarmStorage.GetAlarms());

            if (AlarmAdapter.ItemCount == 0)
            {
                TextViewIntroMessage.Visibility = ViewStates.Visible;
            }

            var recyclerView = (RecyclerView)view.FindViewById(Resource.Id.recycler_view_alarms);

            recyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            recyclerView.SetAdapter(AlarmAdapter);
            recyclerView.AddItemDecoration(new DividerItemDecorrection(Activity));
            AlarmUtil = new AlarmUtil(Activity);
        }
		public AlarmAdapter (Context context, List<Alarm> alarms)
		{
			Context = context;
			Alarmlist = new List<Alarm> ();
			Alarmlist.AddRange (alarms);
			Alarmlist.Sort ();
			AlarmStorage = new AlarmStorage (context);
			AlarmUtil = new AlarmUtil (context);
		}
示例#4
0
 public AlarmAdapter(Context context, List <Alarm> alarms)
 {
     Context   = context;
     Alarmlist = new List <Alarm> ();
     Alarmlist.AddRange(alarms);
     Alarmlist.Sort();
     AlarmStorage = new AlarmStorage(context);
     AlarmUtil    = new AlarmUtil(context);
 }
示例#5
0
        public override void OnReceive(Context context, Intent intent)
        {
            bool bootCompleted;
            string action = intent.Action;
            //TODO Switch to UserManagerCompat, BuildCompat
            Log.Info (TAG, $"Recieved action {action}, user unlocked: "); //{UserManagerCompat.IsUserUnlocked (context))}");

            if (Build.VERSION.SdkInt > BuildVersionCodes.M)
                bootCompleted = Intent.ActionLockedBootCompleted == action;
            else
                bootCompleted = Intent.ActionBootCompleted == action;

            if (!bootCompleted)
                return;

            var util = new AlarmUtil (context);
            var alarmStorage = new AlarmStorage (context);
            foreach (Alarm alarm in alarmStorage.GetAlarms ())
                util.ScheduleAlarm (alarm);
        }
		public override void OnViewCreated (View view, Bundle savedInstanceState)
		{
			base.OnViewCreated (view, savedInstanceState);

			var fab = (FloatingActionButton)view.FindViewById (Resource.Id.fab_add_alarm);
			fab.Click += delegate {
				var fragment = TimePickerFragment.NewInstance ();
				fragment.SetAlarmAddListener (new AlarmAddListenerImpl (this));
				fragment.Show (FragmentManager, FRAGMENT_TIME_PICKER_TAG);
			};

			TextViewIntroMessage = (TextView)view.FindViewById (Resource.Id.text_intro_message);
			var alarmStorage = new AlarmStorage (Activity);
			AlarmAdapter = new AlarmAdapter (Activity, alarmStorage.GetAlarms ());

			if (AlarmAdapter.ItemCount == 0)
				TextViewIntroMessage.Visibility = ViewStates.Visible;

			var recyclerView = (RecyclerView)view.FindViewById (Resource.Id.recycler_view_alarms);
			recyclerView.SetLayoutManager (new LinearLayoutManager (Activity));
			recyclerView.SetAdapter (AlarmAdapter);
			recyclerView.AddItemDecoration (new DividerItemDecorrection (Activity));
			AlarmUtil = new AlarmUtil (Activity);
		}
示例#7
0
 public override void OnActivityCreated(Bundle savedInstanceState)
 {
     base.OnActivityCreated(savedInstanceState);
     alarmStorage = new AlarmStorage(Activity);
     alarmUtil    = new AlarmUtil(Activity);
 }
		public override void OnActivityCreated (Bundle savedInstanceState)
		{
			base.OnActivityCreated (savedInstanceState);
			alarmStorage = new AlarmStorage (Activity);
			alarmUtil = new AlarmUtil (Activity);
		}