package com.example.profbola.bakingtime.ui.widget;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.widget.RemoteViews;

import com.example.profbola.bakingtime.R;

/**
 * Created by prof.BOLA on 7/4/2017.
 */

public class RecipesWidgetProvider extends AppWidgetProvider {

    static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                                int appWidgetId) {

        CharSequence widgetText = context.getString(R.string.appwidget_text);

        RemoteViews views = new RemoteViews(context.getPackageName(),
                R.layout.recipes_widget_provider);
        views.setTextViewText(R.id.appwidget_text, widgetText);

        appWidgetManager.updateAppWidget(appWidgetId, views);
    }

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

        for (int appWidgetId: appWidgetIds) {
            updateAppWidget(context, appWidgetManager, appWidgetId);
        }
    }

    @Override
    public void onEnabled(Context context) {
        super.onEnabled(context);
    }
}

@@ -36,21 +36,45 @@
 time
-.ui.widge
+;%0A%0Aimport android.app.PendingInten
 t;%0A
-%0A
 impo
@@ -188,16 +188,47 @@
 ontext;%0A
+import android.content.Intent;%0A
 import a
@@ -296,16 +296,72 @@
 gtime.R;
+%0Aimport com.example.profbola.bakingtime.ui.MainActivity;
 %0A%0A/**%0A *
@@ -604,87 +604,8 @@
  %7B%0A%0A
-        CharSequence widgetText = context.getString(R.string.appwidget_text);%0A%0A
     
@@ -721,24 +721,25 @@
 vider);%0A
+%0A
         
 views.se
@@ -734,60 +734,230 @@
     
-views.setTextViewText(R.id.appwidget_text, widgetTex
+Intent intent = new Intent(context, MainActivity.class);%0A        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);%0A%0A        views.setOnClickPendingIntent(R.id.recipe_widget_image, pendingInten
 t);%0A
@@ -1308,53 +1308,289 @@
 d on
-Enabled(Context context) %7B%0A        super.onEn
+Deleted(Context context, int%5B%5D appWidgetIds) %7B%0A        super.onDeleted(context, appWidgetIds);%0A    %7D%0A%0A    @Override%0A    public void onEnabled(Context context) %7B%0A        super.onEnabled(context);%0A    %7D%0A%0A    @Override%0A    public void onDisabled(Context context) %7B%0A        super.onDis
 able

Add widget OnClickListener