package com.verybadalloc.designlib.presenters;


import com.hannesdorfmann.mosby.mvp.MvpBasePresenter;
import com.verybadalloc.designlib.model.Book;
import com.verybadalloc.designlib.network.DataCallback;
import com.verybadalloc.designlib.network.DataFetcher;
import com.verybadalloc.designlib.views.BooksListView;

/**
 * Created by aambri on 15-06-09.
 */
public class BooksListPresenter extends MvpBasePresenter<BooksListView> {

    private static final String TAG = "BooksListPresenter";

    public void loadEateries(final boolean pullToRefresh) {

        if(isViewAttached()) {
            getView().showLoading(pullToRefresh);
        }

        DataFetcher.getBooks(new DataCallback<Book[]>() {

            @Override
            public void onSuccess(Book[] books) {
                if (isViewAttached()) {
                    getView().setData(books);
                    getView().showContent();
                }
            }

            @Override
            public void onFailure(String reason) {
                String message = "Failed to load books because " + reason;
                if (isViewAttached()) {
                    getView().showError(new Throwable(message), pullToRefresh);
                }
            }
        });
    }
}

@@ -511,15 +511,12 @@
 load
-Eaterie
+Book
 s(fi
@@ -629,32 +629,32 @@
 sh);%0A        %7D%0A%0A
-
         DataFetc
@@ -924,32 +924,835 @@
 %0A            %7D%0A%0A
+            @Override%0A            public void onFailure(String reason) %7B%0A                String message = %22Failed to load books because %22 + reason;%0A                if (isViewAttached()) %7B%0A                    getView().showError(new Throwable(message), pullToRefresh);%0A                %7D%0A            %7D%0A        %7D);%0A    %7D%0A%0A    public void loadBooksOfType(String bookType, final boolean pullToRefresh) %7B%0A%0A        if(isViewAttached()) %7B%0A            getView().showLoading(pullToRefresh);%0A        %7D%0A%0A        DataFetcher.getBooksOfType(bookType, new DataCallback%3CBook%5B%5D%3E() %7B%0A%0A            @Override%0A            public void onSuccess(Book%5B%5D books) %7B%0A                if (isViewAttached()) %7B%0A                    getView().setData(books);%0A                    getView().showContent();%0A                %7D%0A            %7D%0A%0A
             @Ove

Add presenter methods to retrieve books by type