// Path: app/src/main/java/com/tonilopezmr/sample/domain/Subject.java
// public class Subject {
// 
//     private int id;
//     private String name;
// 
//     public Subject(String name) {
//         this.name = name;
//     }
// 
//     public Subject(int id, String name) {
//         this.id = id;
//         this.name = name;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public String toString() {
//         return "ID: "+this.id+" Subject: "+this.name;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/exception/SubjectException.java
// public class SubjectException extends RuntimeException {
// 
//     private String message;
// 
//     public SubjectException(String detailMessage) {
//         super(detailMessage);
//         this.message = detailMessage;
//     }
// 
//     public SubjectException(Exception exception) {
//         this.setStackTrace(exception.getStackTrace());
//         this.message = exception.getMessage();
//     }
// 
//     @Override
//     public String getMessage() {
//         return message;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/interactor/SubjectUseCase.java
// public interface SubjectUseCase extends Interactor {
// 
//     interface Callback {
//         void onMissionAccomplished(Subject subject);
//         void onError(SubjectException ex);
//     }
// 
//     public void execute(Subject subject, final Callback callback);
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/interactor/GetSubjectListUseCase.java
// public interface GetSubjectListUseCase extends Interactor {
// 
//     interface Callback{
//         void onSubjectListLoaded(Collection<Subject> subjects);
//         void onError(SubjectException exception);
//     }
// 
//     public void execute(final Callback callback);
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/ui/viewmodel/SubjectViewModelImp.java
// public class SubjectViewModelImp implements SubjectViewModel {
// 
//     private Subject subject;
// 
//     public SubjectViewModelImp(String name) {
//         subject = new Subject(name);
//     }
// 
//     public SubjectViewModelImp(Subject subject) {
//         this.subject = subject;
//     }
// 
//     public int getId(){
//         return this.subject.getId();
//     }
// 
//     public String getName(){
//         return this.subject.getName();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         boolean result = false;
//         if (o instanceof SubjectViewModel){
//             SubjectViewModel model = (SubjectViewModel)o;
//             if (this.subject.getId() == model.getId() && this.subject.getName().equals(model.getName())){
//                 result = true;
//             }
//         }
//         return result;
//     }
// 
//     @Override
//     public String toString() {
//         return subject.getId()+" "+subject.getName();
//     }
// }


import android.content.Context;
import android.util.Log;
import com.tonilopezmr.sample.di.BasePresenter;
import com.tonilopezmr.sample.domain.Subject;
import com.tonilopezmr.sample.domain.exception.SubjectException;
import com.tonilopezmr.sample.domain.interactor.SubjectUseCase;
import com.tonilopezmr.sample.domain.interactor.GetSubjectListUseCase;
import com.tonilopezmr.sample.ui.view.SubjectListView;
import com.tonilopezmr.sample.ui.viewmodel.SubjectViewModel;
import com.tonilopezmr.sample.ui.viewmodel.SubjectViewModelImp;
import java.util.ArrayList;
import java.util.Collection;
import javax.inject.Inject;
import javax.inject.Named;
            @Override
            public void onError(SubjectException exception) {
                view.showMessage(exception.getMessage()); //For example
                view.hideProgress();
                view.showLayoutError();
                Log.i(getClass().toString(), "¡¡Show error!!");
            }
        });
    }

    private Collection<SubjectViewModel> convertToViewModel(Collection<Subject> subjectsCollection){
        Collection<SubjectViewModel> subjectsViewModel = new ArrayList<>();

        for (Subject subject : subjectsCollection){
            subjectsViewModel.add(new SubjectViewModelImp(subject));
        }

        return subjectsViewModel;
    }

    @Override
    public void onClickItem(SubjectViewModel subjectModel) {
        view.showMessage("the subject: "+subjectModel);
    }

    @Override
    public void onLongItemClick(SubjectViewModel subjectModel) {
        deleteSubjectUseCase.execute(new Subject(subjectModel.getId(), subjectModel.getName()), new SubjectUseCase.Callback() {
            @Override
            public void onMissionAccomplished(Subject subject) {
// Path: app/src/main/java/com/tonilopezmr/sample/domain/Subject.java
// public class Subject {
// 
//     private int id;
//     private String name;
// 
//     public Subject(String name) {
//         this.name = name;
//     }
// 
//     public Subject(int id, String name) {
//         this.id = id;
//         this.name = name;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public String toString() {
//         return "ID: "+this.id+" Subject: "+this.name;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/exception/SubjectException.java
// public class SubjectException extends RuntimeException {
// 
//     private String message;
// 
//     public SubjectException(String detailMessage) {
//         super(detailMessage);
//         this.message = detailMessage;
//     }
// 
//     public SubjectException(Exception exception) {
//         this.setStackTrace(exception.getStackTrace());
//         this.message = exception.getMessage();
//     }
// 
//     @Override
//     public String getMessage() {
//         return message;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/interactor/SubjectUseCase.java
// public interface SubjectUseCase extends Interactor {
// 
//     interface Callback {
//         void onMissionAccomplished(Subject subject);
//         void onError(SubjectException ex);
//     }
// 
//     public void execute(Subject subject, final Callback callback);
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/interactor/GetSubjectListUseCase.java
// public interface GetSubjectListUseCase extends Interactor {
// 
//     interface Callback{
//         void onSubjectListLoaded(Collection<Subject> subjects);
//         void onError(SubjectException exception);
//     }
// 
//     public void execute(final Callback callback);
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/ui/viewmodel/SubjectViewModelImp.java
// public class SubjectViewModelImp implements SubjectViewModel {
// 
//     private Subject subject;
// 
//     public SubjectViewModelImp(String name) {
//         subject = new Subject(name);
//     }
// 
//     public SubjectViewModelImp(Subject subject) {
//         this.subject = subject;
//     }
// 
//     public int getId(){
//         return this.subject.getId();
//     }
// 
//     public String getName(){
//         return this.subject.getName();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         boolean result = false;
//         if (o instanceof SubjectViewModel){
//             SubjectViewModel model = (SubjectViewModel)o;
//             if (this.subject.getId() == model.getId() && this.subject.getName().equals(model.getName())){
//                 result = true;
//             }
//         }
//         return result;
//     }
// 
//     @Override
//     public String toString() {
//         return subject.getId()+" "+subject.getName();
//     }
// }


// Path: app/src/main/java/com/tonilopezmr/sample/ui/presenter/SubjectListPresenterImp.java
import android.content.Context;
import android.util.Log;
import com.tonilopezmr.sample.di.BasePresenter;
import com.tonilopezmr.sample.domain.Subject;
import com.tonilopezmr.sample.domain.exception.SubjectException;
import com.tonilopezmr.sample.domain.interactor.SubjectUseCase;
import com.tonilopezmr.sample.domain.interactor.GetSubjectListUseCase;
import com.tonilopezmr.sample.ui.view.SubjectListView;
import com.tonilopezmr.sample.ui.viewmodel.SubjectViewModel;
import com.tonilopezmr.sample.ui.viewmodel.SubjectViewModelImp;
import java.util.ArrayList;
import java.util.Collection;
import javax.inject.Inject;
import javax.inject.Named;

            @Override
            public void onError(SubjectException exception) {
                view.showMessage(exception.getMessage()); //For example
                view.hideProgress();
                view.showLayoutError();
                Log.i(getClass().toString(), "¡¡Show error!!");
            }
        });
    }

    private Collection<SubjectViewModel> convertToViewModel(Collection<Subject> subjectsCollection){
        Collection<SubjectViewModel> subjectsViewModel = new ArrayList<>();

        for (Subject subject : subjectsCollection){
            subjectsViewModel.add(new SubjectViewModelImp(subject));
        }

        return subjectsViewModel;
    }

    @Override
    public void onClickItem(SubjectViewModel subjectModel) {
        view.showMessage("the subject: "+subjectModel);
    }

    @Override
    public void onLongItemClick(SubjectViewModel subjectModel) {
        deleteSubjectUseCase.execute(new Subject(subjectModel.getId(), subjectModel.getName()), new SubjectUseCase.Callback() {
            @Override
            public void onMissionAccomplished(Subject subject) {
                view.remove(new SubjectViewModelImp(subject));