// Path: app/src/main/java/com/starter/data/AppRepository.java
// public class AppRepository implements Repository {
// 
//     private final LocalRepository localRepository;
//     private final RemoteRepository remoteRepository;
// 
//     @Inject
//     public AppRepository(final LocalRepository localRepository,
//         final RemoteRepository remoteRepository) {
//         this.localRepository = localRepository;
//         this.remoteRepository = remoteRepository;
//     }
// 
//     @Override
//     public Observable<List<Contributor>> contributors(final String owner, final String repo) {
//         return Observable.concat(remoteRepository.contributors(owner, repo),
//             localRepository.contributors(owner, repo))
//             .first(contributorsResponse -> !contributorsResponse.isEmpty());
//     }
// }
// 
// Path: app/src/main/java/com/starter/data/model/Contributor.java
// public final class Contributor {
//     private final String login;
//     private final int contributions;
//     private final String avatarUrl;
// 
//     public Contributor(final String login, final int contributions, final String avatarUrl) {
//         this.login = login;
//         this.contributions = contributions;
//         this.avatarUrl = avatarUrl;
//     }
// 
//     public Contributor(final ContributorJson contributorJson) {
//         this.login = contributorJson.getLogin();
//         this.contributions = contributorJson.getContributions();
//         this.avatarUrl = contributorJson.getAvatarUrl();
//     }
// 
//     public Contributor(final ContributorEntity contributorEntity) {
//         this.login = contributorEntity.getLogin();
//         this.contributions = contributorEntity.getContributions();
//         this.avatarUrl = contributorEntity.getAvatarUrl();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final Contributor that = (Contributor) o;
// 
//         if (contributions != that.contributions) return false;
//         if (login != null ? !login.equals(that.login) : that.login != null) return false;
//         return avatarUrl != null ? avatarUrl.equals(that.avatarUrl) : that.avatarUrl == null;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = login != null ? login.hashCode() : 0;
//         result = 31 * result + contributions;
//         result = 31 * result + (avatarUrl != null ? avatarUrl.hashCode() : 0);
//         return result;
//     }
// 
//     public String getLogin() {
//         return login;
//     }
// 
//     public int getContributions() {
//         return contributions;
//     }
// 
//     public String getAvatarUrl() {
//         return avatarUrl;
//     }
// }
// 
// Path: app/src/main/java/com/starter/ui/base/mvp/core/MvpBasePresenter.java
// public class MvpBasePresenter<V extends MvpView> implements MvpPresenter<V> {
// 
//     private WeakReference<V> viewRef;
// 
//     @Override
//     public void attachView(V view) {
//         viewRef = new WeakReference<V>(view);
//     }
// 
//     @Override
//     public void detachView() {
//         if (viewRef != null) {
//             viewRef.clear();
//             viewRef = null;
//         }
//     }
// 
//     /**
//      * Get the attached view. You should always call {@link #isViewAttached()} to check if the view
//      * is
//      * attached to avoid NullPointerExceptions.
//      *
//      * @return <code>null</code>, if view is not attached, otherwise the concrete view instance
//      */
//     @Nullable
//     public V getView() {
//         return viewRef == null ? null : viewRef.get();
//     }
// 
//     /**
//      * Checks if a view is attached to this presenter. You should always call this method before
//      * calling {@link #getView()} to get the view instance.
//      */
//     public boolean isViewAttached() {
//         return viewRef != null && viewRef.get() != null;
//     }
// }


import com.starter.data.AppRepository;
import com.starter.data.model.Contributor;
import com.starter.ui.base.mvp.core.MvpBasePresenter;
import java.util.List;
import rx.Subscriber;
import rx.Subscription;
import timber.log.Timber;
        subscription =
            appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() {
                @Override
                public void onCompleted() {
                    Timber.d("Finished loading contributors.");
                }

                @Override
                public void onError(final Throwable e) {
                    if (isViewAttached()) {
                        getView().showError(e.toString());
                    }
                }

                @Override
                public void onNext(final List<Contributor> contributors) {
                    if (!isViewAttached()) {
                        return;
                    }

                    if (contributors != null && !contributors.isEmpty()) {
                        getView().showContributors(contributors);
                    } else {
                        getView().showEmpty();
                    }
                }
            });
    }

    @Override
// Path: app/src/main/java/com/starter/data/AppRepository.java
// public class AppRepository implements Repository {
// 
//     private final LocalRepository localRepository;
//     private final RemoteRepository remoteRepository;
// 
//     @Inject
//     public AppRepository(final LocalRepository localRepository,
//         final RemoteRepository remoteRepository) {
//         this.localRepository = localRepository;
//         this.remoteRepository = remoteRepository;
//     }
// 
//     @Override
//     public Observable<List<Contributor>> contributors(final String owner, final String repo) {
//         return Observable.concat(remoteRepository.contributors(owner, repo),
//             localRepository.contributors(owner, repo))
//             .first(contributorsResponse -> !contributorsResponse.isEmpty());
//     }
// }
// 
// Path: app/src/main/java/com/starter/data/model/Contributor.java
// public final class Contributor {
//     private final String login;
//     private final int contributions;
//     private final String avatarUrl;
// 
//     public Contributor(final String login, final int contributions, final String avatarUrl) {
//         this.login = login;
//         this.contributions = contributions;
//         this.avatarUrl = avatarUrl;
//     }
// 
//     public Contributor(final ContributorJson contributorJson) {
//         this.login = contributorJson.getLogin();
//         this.contributions = contributorJson.getContributions();
//         this.avatarUrl = contributorJson.getAvatarUrl();
//     }
// 
//     public Contributor(final ContributorEntity contributorEntity) {
//         this.login = contributorEntity.getLogin();
//         this.contributions = contributorEntity.getContributions();
//         this.avatarUrl = contributorEntity.getAvatarUrl();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final Contributor that = (Contributor) o;
// 
//         if (contributions != that.contributions) return false;
//         if (login != null ? !login.equals(that.login) : that.login != null) return false;
//         return avatarUrl != null ? avatarUrl.equals(that.avatarUrl) : that.avatarUrl == null;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = login != null ? login.hashCode() : 0;
//         result = 31 * result + contributions;
//         result = 31 * result + (avatarUrl != null ? avatarUrl.hashCode() : 0);
//         return result;
//     }
// 
//     public String getLogin() {
//         return login;
//     }
// 
//     public int getContributions() {
//         return contributions;
//     }
// 
//     public String getAvatarUrl() {
//         return avatarUrl;
//     }
// }
// 
// Path: app/src/main/java/com/starter/ui/base/mvp/core/MvpBasePresenter.java
// public class MvpBasePresenter<V extends MvpView> implements MvpPresenter<V> {
// 
//     private WeakReference<V> viewRef;
// 
//     @Override
//     public void attachView(V view) {
//         viewRef = new WeakReference<V>(view);
//     }
// 
//     @Override
//     public void detachView() {
//         if (viewRef != null) {
//             viewRef.clear();
//             viewRef = null;
//         }
//     }
// 
//     /**
//      * Get the attached view. You should always call {@link #isViewAttached()} to check if the view
//      * is
//      * attached to avoid NullPointerExceptions.
//      *
//      * @return <code>null</code>, if view is not attached, otherwise the concrete view instance
//      */
//     @Nullable
//     public V getView() {
//         return viewRef == null ? null : viewRef.get();
//     }
// 
//     /**
//      * Checks if a view is attached to this presenter. You should always call this method before
//      * calling {@link #getView()} to get the view instance.
//      */
//     public boolean isViewAttached() {
//         return viewRef != null && viewRef.get() != null;
//     }
// }


// Path: app/src/main/java/com/starter/ui/contributors/ContributorsPresenter.java
import com.starter.data.AppRepository;
import com.starter.data.model.Contributor;
import com.starter.ui.base.mvp.core.MvpBasePresenter;
import java.util.List;
import rx.Subscriber;
import rx.Subscription;
import timber.log.Timber;

        subscription =
            appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() {
                @Override
                public void onCompleted() {
                    Timber.d("Finished loading contributors.");
                }

                @Override
                public void onError(final Throwable e) {
                    if (isViewAttached()) {
                        getView().showError(e.toString());
                    }
                }

                @Override
                public void onNext(final List<Contributor> contributors) {
                    if (!isViewAttached()) {
                        return;
                    }

                    if (contributors != null && !contributors.isEmpty()) {
                        getView().showContributors(contributors);
                    } else {
                        getView().showEmpty();
                    }
                }
            });
    }

    @Override
    public void detachView() {