package com.example.profbola.bakingtime.ui;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.example.profbola.bakingtime.R;

public class MainActivity extends AppCompatActivity {

    public static final String RECIPE = "recipe";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

}

@@ -38,16 +38,48 @@
 me.ui;%0A%0A
+import android.database.Cursor;%0A
 import a
@@ -230,249 +230,759 @@
 rt.v
-7.app.AppCompatActivity;%0Aimport android.support.v7.widget.Toolbar;%0Aimport android.view.View;%0A%0Aimport com.example.profbola.bakingtime.R;%0A%0Apublic class MainActivity extends AppCompatActivity %7B%0A%0A    public static final String RECIPE = %22recipe%22;
+4.app.LoaderManager;%0Aimport android.support.v4.content.CursorLoader;%0Aimport android.support.v4.content.Loader;%0Aimport android.support.v7.app.AppCompatActivity;%0Aimport android.support.v7.widget.Toolbar;%0Aimport android.view.View;%0Aimport android.widget.ProgressBar;%0Aimport android.widget.TextView;%0A%0Aimport com.example.profbola.bakingtime.R;%0Aimport com.example.profbola.bakingtime.services.RecipeService;%0A%0Aimport static com.example.profbola.bakingtime.provider.RecipeContract.RecipeEntry.CONTENT_URI;%0A%0Apublic class MainActivity extends AppCompatActivity%0A        implements LoaderManager.LoaderCallbacks%3CCursor%3E %7B%0A%0A    public static final String RECIPE = %22recipe%22;%0A    private static final int LOADER_ID = 456;%0A%0A%0A    private ProgressBar mLoadingIndicator;%0A
 %0A%0A  
@@ -1245,16 +1245,255 @@
 lbar);%0A%0A
+        if (savedInstanceState == null ) %7B%0A            startSync();%0A            mLoadingIndicator = (ProgressBar) findViewById(R.id.pb_loading_indicator);%0A            getSupportLoaderManager().initLoader(LOADER_ID, null, this);%0A        %7D%0A%0A
         
@@ -1868,17 +1868,1039 @@
     %7D);%0A
+%0A
     %7D%0A%0A
+    private void startSync() %7B%0A        RecipeService.startActionSyncRecipes(this);%0A    %7D%0A%0A    @Override%0A    public Loader%3CCursor%3E onCreateLoader(int id, Bundle args) %7B%0A        return new CursorLoader(this, CONTENT_URI, null, null, null, null);%0A    %7D%0A%0A    @Override%0A    public void onLoadFinished(Loader%3CCursor%3E loader, Cursor data) %7B%0A        mLoadingIndicator.setVisibility(View.GONE);%0A        switch (loader.getId()) %7B%0A%0A            case LOADER_ID:%0A                if (data != null) %7B%0A                    MainActivityFragment fragment = (MainActivityFragment) getSupportFragmentManager().findFragmentById(R.id.fragment);%0A                    fragment.changeData(data);%0A                %7D%0A                break;%0A            default:%0A                return;%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onLoaderReset(Loader%3CCursor%3E loader) %7B%0A%0A    %7D%0A%0A%0A//    @Override%0A//    protected void onSaveInstanceState(Bundle outState) %7B%0A//        super.onSaveInstanceState(outState);%0A//        outState.put(RECIPE, mCursor);%0A//    %7D%0A
 %7D%0A

Add Sync-ing logic and query logic to cache data