Ejemplo n.º 1
0
        // SearchView does not call these methods.
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.menu_item_search:
                currentPage = 1;
                Activity.StartSearch(lastQuery, true, null, false);
                return(true);

            case Resource.Id.menu_item_clear:
                PreferenceManager.GetDefaultSharedPreferences(Activity).Edit().PutString(FlickrFetchr.PREF_SEARCH_QUERY, null).Commit();
                currentPage = 1;
                Task.Run(() => {
                }).ContinueWith(async(t) => {
                    await UpdateItems();
                }, TaskScheduler.FromCurrentSynchronizationContext());
                return(true);

            case Resource.Id.menu_item_toggle_polling:
                bool shouldStartAlarm = !PollService.IsServiceAlarmOn(Activity);
                PollService.SetServiceAlarm(Activity, shouldStartAlarm);
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
                {
                    Activity.InvalidateOptionsMenu();
                }
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
Ejemplo n.º 2
0
        public override void OnReceive(Context context, Intent intent)
        {
            //Console.WriteLine("[{0}] Received broadcast intent: {1}", TAG, intent.Action);

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context);
            bool isOn = prefs.GetBoolean(PollService.PREF_IS_ALARM_ON, false);

            PollService.SetServiceAlarm(context, isOn);
        }