package com.naijab.nextzytimeline.ui.people.addform;

import android.content.Context;

import com.naijab.nextzytimeline.base.BaseMvpPresenter;
import com.naijab.nextzytimeline.ui.people.model.PeopleManager;
import com.naijab.nextzytimeline.ui.people.model.PeopleModel;

import io.realm.Realm;

public class AddPeopleFragmentPresenter extends BaseMvpPresenter<AddPeopleFragmentInterface.View>
        implements AddPeopleFragmentInterface.Presenter {

    private Realm realm;

    public static AddPeopleFragmentInterface.Presenter create() {
        return new AddPeopleFragmentPresenter();
    }

    @Override
    public void onViewStart() {
        super.onViewStart();
        realm = Realm.getDefaultInstance();
        String name = PeopleManager.getInstance().getPeople().get(4).getName();
        String job = PeopleManager.getInstance().getPeople().get(4).getJob();
        String photos = PeopleManager.getInstance().getPeople().get(4).getPhoto();
        getView().response(name + " " + job + " " + photos);
    }

    @Override
    public void onViewStop() {
        super.onViewStop();
        realm.close();
    }


    @Override
    public void saveIntoRealm(PeopleModel peopleModel, Context context) {
        PeopleManager.getInstance().saveRealm(peopleModel, context, new PeopleManager.SaveCallback() {
            @Override
            public void onSaveSuccess(String message) {
                getView().response(message);
            }

            @Override
            public void onSaveError(String message) {
                getView().response(message);
            }
        });
    }
}

@@ -1302,16 +1302,18 @@
 ger.
+on
 SaveCall
 back
@@ -1308,17 +1308,17 @@
 SaveCall
-b
+B
 ack() %7B%0A
@@ -1469,32 +1469,32 @@
       @Override%0A
-
             publ
@@ -1607,11 +1607,465 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void deleteAllRealm(Context context) %7B%0A        PeopleManager.getInstance().deleteAll(context, new PeopleManager.onDeleteCallBack() %7B%0A            @Override%0A            public void onDeleteSuccess(String message) %7B%0A                getView().response(message);%0A            %7D%0A%0A            @Override%0A            public void onDeleteError(String message) %7B%0A                getView().response(message);%0A            %7D%0A        %7D);%0A    %7D
 %0A%7D%0A

Test Delete All in Presenter