예제 #1
0
        public override void OnAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions)
        {
            base.OnAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
            var dimensions = WidgetDimensions.FromBundle(newOptions);

            updateWidget(context, appWidgetManager, appWidgetId, dimensions);
        }
예제 #2
0
        public static ISuggestionsWidgetFormFactor Create(WidgetDimensions dimensions)
        {
            if (!WidgetsServiceAndroid.IsLoggedIn)
            {
                return(new SuggestionsWidgetNotLoggedInFormFactor(dimensions.ColumnsCount));
            }

            return(new SuggestionsWidgetListFormFactor());
        }
예제 #3
0
        public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            base.OnUpdate(context, appWidgetManager, appWidgetIds);

            foreach (var appWidgetId in appWidgetIds)
            {
                var options    = appWidgetManager.GetAppWidgetOptions(appWidgetId);
                var dimensions = WidgetDimensions.FromBundle(options);
                updateWidget(context, appWidgetManager, appWidgetId, dimensions);
            }
        }
예제 #4
0
        public static ITimeEntryWidgetFormFactor Create(WidgetDimensions widgetDimensions)
        {
            var dimensions = widgetDimensions ?? WidgetDimensions.Default;

            if (!WidgetsServiceAndroid.IsLoggedIn)
            {
                return(new TimeEntryWidgetNotLoggedInFormFactor(dimensions.ColumnsCount));
            }

            if (dimensions.ColumnsCount == 1)
            {
                return(new TimeEntryWidgetButtonOnlyFormFactor());
            }

            return(new TimeEntryWidgetDefaultFormFactor());
        }
예제 #5
0
        private static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, WidgetDimensions dimensions)
        {
            var widgetFormFactor = SuggestionsWidgetFactory.Create(dimensions);
            var view             = widgetFormFactor.Setup(context, appWidgetId);

            if (widgetFormFactor.ContainsListView)
            {
                appWidgetManager.NotifyAppWidgetViewDataChanged(appWidgetId, Resource.Id.SuggestionsList);
            }

            appWidgetManager.UpdateAppWidget(appWidgetId, view);
        }
예제 #6
0
        private void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, WidgetDimensions dimensions)
        {
            var widgetInfo  = TimeEntryWidgetInfo.FromSharedPreferences();
            var remoteViews = TimeEntryWidgetFactory.Create(dimensions).Setup(context, widgetInfo);

            appWidgetManager.UpdateAppWidget(appWidgetId, remoteViews);
        }