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

import com.naijab.nextzytimeline.base.BaseMvpPresenter;

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();
    }

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

@@ -107,30 +107,122 @@
 er;%0A
-%0Aimport io.realm.Realm
+import com.naijab.nextzytimeline.ui.people.model.PeopleModel;%0A%0Aimport io.realm.Realm;%0Aimport io.realm.RealmResults
 ;%0A%0Ap
@@ -373,16 +373,17 @@
 resenter
+ 
 %7B%0A%0A    p
@@ -466,16 +466,17 @@
 create()
+ 
 %7B%0A      
@@ -752,11 +752,1445 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void saveIntoRealm(final String name,%0A                              final String birthday,%0A                              final String startJob,%0A                              final String job,%0A                              final String game,%0A                              final String smartphone,%0A                              final String photos) %7B%0A%0A        RealmResults%3CPeopleModel%3E resultRealm = realm.where(PeopleModel.class)%0A                .findAll();%0A        final int id = resultRealm.size() + 1;%0A%0A        realm.executeTransactionAsync(new Realm.Transaction() %7B%0A            @Override%0A            public void execute(Realm bgRealm) %7B%0A                PeopleModel people = realm.createObject(PeopleModel.class, id);%0A                people.setName(name);%0A                people.setBirthday(birthday);%0A                people.setJobstart(startJob);%0A                people.setJob(job);%0A                people.setGame(game);%0A                people.setSmartphone(smartphone);%0A                people.setPhoto(photos);%0A            %7D%0A        %7D, new Realm.Transaction.OnSuccess() %7B%0A            @Override%0A            public void onSuccess() %7B%0A                getView().response(%22onSuccess%22);%0A            %7D%0A        %7D, new Realm.Transaction.OnError() %7B%0A            @Override%0A            public void onError(Throwable error) %7B%0A                getView().response(error.getMessage());%0A            %7D%0A        %7D);%0A%0A%0A%0A    %7D
 %0A%7D%0A

Add Insert Realm in Presenter