@@ -0,0 +1,2893 @@
+package com.example.profbola.bakingtime.ui.widget;%0A%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.database.Cursor;%0Aimport android.view.View;%0Aimport android.widget.RemoteViews;%0Aimport android.widget.RemoteViewsService;%0A%0Aimport com.example.profbola.bakingtime.R;%0Aimport com.example.profbola.bakingtime.models.Recipe;%0Aimport com.example.profbola.bakingtime.provider.RecipeContract;%0Aimport com.example.profbola.bakingtime.ui.MainActivity;%0Aimport com.example.profbola.bakingtime.utils.RecipeUtils;%0A%0A/**%0A * Created by prof.BOLA on 7/6/2017.%0A */%0A%0Apublic class GridWidgetService extends RemoteViewsService %7B%0A    @Override%0A    public RemoteViewsFactory onGetViewFactory(Intent intent) %7B%0A        return new GridRemoteViewFactory(this.getApplicationContext());%0A    %7D%0A%7D%0A%0Aclass GridRemoteViewFactory implements RemoteViewsService.RemoteViewsFactory %7B%0A%0A    private Context mContext;%0A    private Cursor mCursor;%0A%0A    public GridRemoteViewFactory(Context appContext) %7B%0A        mContext = appContext;%0A    %7D%0A%0A    @Override%0A    public void onCreate() %7B%0A%0A    %7D%0A%0A    @Override%0A    public void onDataSetChanged() %7B%0A        if (mCursor != null) mCursor.close();%0A        mCursor = mContext.getContentResolver().query(%0A                RecipeContract.RecipeEntry.CONTENT_URI,%0A                null,%0A                null,%0A                null,%0A                RecipeContract.RecipeEntry.COLUMN_WIDGET_LAST_DISPLAYED%0A        );%0A    %7D%0A%0A    @Override%0A    public void onDestroy() %7B%0A        mCursor.close();%0A    %7D%0A%0A    @Override%0A    public int getCount() %7B%0A        if (mCursor == null) return 0;%0A        return mCursor.getCount();%0A    %7D%0A%0A    @Override%0A    public RemoteViews getViewAt(int position) %7B%0A        if (mCursor == null %7C%7C mCursor.getCount() == 0) return null;%0A%0A        mCursor.moveToPosition(position);%0A        Recipe recipe = new Recipe(mCursor);%0A%0A        RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.recipes_widget_provider);%0A%0A        int imgRes = RecipeUtils.getResourceIdFromName(mContext, recipe.image);%0A        views.setTextViewText(R.id.widget_recipe_name, recipe.name);%0A        views.setTextViewText(R.id.widget_recipe_servings, RecipeUtils.formatServings(recipe.servings));%0A        views.setImageViewResource(R.id.widget_recipe_image, imgRes);%0A        views.setViewVisibility(R.id.widget_sync_recipes, View.GONE);%0A%0A        Intent fillInIntent = new Intent();%0A        fillInIntent.putExtra(MainActivity.RECIPE, recipe);%0A%0A        views.setOnClickFillInIntent(R.id.widget_recipe_image, fillInIntent);%0A%0A        return views;%0A    %7D%0A%0A    @Override%0A    public RemoteViews getLoadingView() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public int getViewTypeCount() %7B%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public long getItemId(int position) %7B%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public boolean hasStableIds() %7B%0A        return false;%0A    %7D%0A%7D%0A

Add WidgetGridService