public void OnAppWidgetOptionsChanged(Context context,
			                                      AppWidgetManager appWidgetManager,
			                                      int appWidgetId,
			                                      Bundle newOptions) {

			RemoteViews layout = RemoteViewsFactory.CreateLayout(context, appWidgetId, newOptions);
			appWidgetManager.UpdateAppWidget(appWidgetId, layout);
		}
        internal static void UpdateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId)
        {
            RemoteViews views = new RemoteViews(context.PackageName, Resource.Layout.widget);

            ImageSize minImageSize = new ImageSize(70, 70); // 70 - approximate size of ImageView in widget
            ImageLoader.Instance
                    .LoadImage(Constants.IMAGES[0], minImageSize, displayOptions, new ThisSimpleImageLoadingListener(appWidgetManager, appWidgetId, views, Resource.Id.image_left));
            ImageLoader.Instance
                    .LoadImage(Constants.IMAGES[1], minImageSize, displayOptions, new ThisSimpleImageLoadingListener(appWidgetManager, appWidgetId, views, Resource.Id.image_right));
        }
        public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            UILApplication.InitImageLoader(context);

            int widgetCount = appWidgetIds.Length;
            for (int i = 0; i < widgetCount; i++)
            {
                int appWidgetId = appWidgetIds[i];
                UpdateAppWidget(context, appWidgetManager, appWidgetId);
            }
        }
Example #4
0
        public override void OnUpdate (Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            // Request widget update.
            var serviceIntent = new Intent (context, typeof (InitWidgetService));
            context.StartService (serviceIntent);

            // Setup widget UI.
            SetupWidget (context);

            base.OnUpdate (context, appWidgetManager, appWidgetIds);
        }
Example #5
0
        public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            RemoteViews updateViews = new RemoteViews(context.PackageName, Resource.Layout.sample_widget);

            // Load image for all appWidgetIds.
            Picasso picasso = Picasso.With(context);
            picasso.Load(Data.Urls[(new Random()).Next(Data.Urls.Length)])
                   .Placeholder(Resource.Drawable.placeholder)
                   .Error(Resource.Drawable.error)
                   .Transform(new GrayscaleTransformation(picasso))
                   .Into(updateViews, Resource.Id.image, appWidgetIds);
        }
Example #6
0
        public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            Log.Info(App.Tag, "In MainWidget.OnUpdate()");

            var remoteViews = new RemoteViews(context.PackageName, Resource.Layout.mainWidget);
            var thisWidget = new ComponentName(context, this.Class);

            Intent intent = new Intent(context, typeof(WidgetService));
            PendingIntent pendingIntent = PendingIntent.GetService(context, 0, intent, PendingIntentFlags.UpdateCurrent);
            remoteViews.SetOnClickPendingIntent(Resource.Id.MyButton, pendingIntent);

            appWidgetManager.UpdateAppWidget(thisWidget, remoteViews);
        }
Example #7
0
        public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            Console.WriteLine("PlayerWidgetProvider - OnUpdate - appWidgetIds.length: {0}", appWidgetIds.Length);
            AlarmManager alarmManager = (AlarmManager)context.GetSystemService(Context.AlarmService);

            Intent intentAlarm = new Intent(context, typeof(WidgetService));
            intentAlarm.SetAction(AppWidgetManager.ActionAppwidgetUpdate);
            intentAlarm.PutExtra(AppWidgetManager.ExtraAppwidgetIds, appWidgetIds);
            if (_pendingIntentWidgetService == null)
                _pendingIntentWidgetService = PendingIntent.GetService(context, 0, intentAlarm, PendingIntentFlags.CancelCurrent);

            Calendar time = Calendar.Instance;
            time.Set(CalendarField.Minute, 0);
            time.Set(CalendarField.Second, 0);
            time.Set(CalendarField.Millisecond, 0);
            alarmManager.SetRepeating(AlarmType.Rtc, time.Time.Time, 1000 * 10, _pendingIntentWidgetService);
            //alarmManager.SetRepeating(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime(), 1000, _pendingIntentWidgetService);

            for (int a = 0; a < appWidgetIds.Length; a++)
            {
                int appWidgetId = appWidgetIds[a];
                RemoteViews views = new RemoteViews(context.PackageName, Resource.Layout.WidgetPlayer);

                //var intentBackground = new Intent(context, typeof (WidgetService));
                //intentBackground.SetAction(SessionsWidgetActions.op.ToString());
                //intentBackground.PutExtra(AppWidgetManager.ExtraAppwidgetIds, appWidgetIds);
                //var pendingIntentBackgroundClick = PendingIntent.GetService(context, appWidgetId, intentBackground, PendingIntentFlags.UpdateCurrent);
                //views.SetOnClickPendingIntent(Resource.Id.widgetPlayer, pendingIntentBackgroundClick);

                var intentPrevious = new Intent(context, typeof(WidgetService));
                intentPrevious.SetAction(SessionsWidgetActions.SessionsWidgetPrevious.ToString());
                intentPrevious.PutExtra(AppWidgetManager.ExtraAppwidgetIds, appWidgetIds);
                var pendingIntentPreviousClick = PendingIntent.GetService(context, appWidgetId, intentPrevious, PendingIntentFlags.UpdateCurrent);
                views.SetOnClickPendingIntent(Resource.Id.widgetPlayer_btnPrevious, pendingIntentPreviousClick);

                var intentPlayPause = new Intent(context, typeof(WidgetService));
                intentPlayPause.SetAction(SessionsWidgetActions.SessionsWidgetPlayPause.ToString());
                intentPlayPause.PutExtra(AppWidgetManager.ExtraAppwidgetIds, appWidgetIds);
                var pendingIntentPlayPauseClick = PendingIntent.GetService(context, appWidgetId, intentPlayPause, PendingIntentFlags.UpdateCurrent);
                views.SetOnClickPendingIntent(Resource.Id.widgetPlayer_btnPlayPause, pendingIntentPlayPauseClick);

                var intentNext = new Intent(context, typeof(WidgetService));
                intentNext.SetAction(SessionsWidgetActions.SessionsWidgetNext.ToString());
                intentNext.PutExtra(AppWidgetManager.ExtraAppwidgetIds, appWidgetIds);
                var pendingIntentNextClick = PendingIntent.GetService(context, appWidgetId, intentNext, PendingIntentFlags.UpdateCurrent);
                views.SetOnClickPendingIntent(Resource.Id.widgetPlayer_btnNext, pendingIntentNextClick);

                appWidgetManager.UpdateAppWidget(appWidgetId, views);
            }
        }
			public void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
			// Update each of the widgets with the remote adapter
			foreach (int id in appWidgetIds) {
				RemoteViews layout = null;

				// API 16 and above supports reconfigurable layouts
				if ((int) Build.VERSION.SdkInt >= 16) {
					Bundle options = appWidgetManager.GetAppWidgetOptions(id);
					layout = RemoteViewsFactory.CreateLayout(context, id, options);
				} else {
					layout = RemoteViewsFactory.CreateLayout(context, id);
				}

				appWidgetManager.UpdateAppWidget(id, layout);
			}
			base.OnUpdate(context, appWidgetManager, appWidgetIds);
		}
Example #9
0
		public override void OnUpdate (Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
		{
			// To prevent any ANR timeouts, we perform the update in a service
			context.StartService (new Intent (context, typeof (UpdateService)));
		}
 public ThisSimpleImageLoadingListener(AppWidgetManager appWidgetManager, int appWidgetId, RemoteViews remoteViews, int imageResId)
 {
     mAppWidgetManager = appWidgetManager;
     mAppWidgetId = appWidgetId;
     mRemoteViews = remoteViews;
     mImageResId = imageResId;
 }
Example #11
0
 public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
 {
     context.StartService (new Intent (context, typeof (UpdateService)));
 }