// Path: app/src/main/java/com/marcohc/architecture/app/domain/interactor/GetUsersUseCase.java
// public class GetUsersUseCase extends BaseRxUseCase<List<UserModel>> {
// 
//     private final boolean mWithPicture;
//     private final boolean mUseCache;
//     private final UserRepository mUserRepository;
// 
//     public GetUsersUseCase(boolean withPicture, boolean useCache) {
//         mWithPicture = withPicture;
//         mUseCache = useCache;
//         mUserRepository = new UserRepositoryImpl();
//     }
// 
//     @NonNull
//     @Override
//     protected Observable<List<UserModel>> getObservable() {
//         if (mWithPicture) {
//             return mUserRepository
//                     .getAllWithPicture(mUseCache)
//                     .map(new Func1<List<UserEntity>, List<UserModel>>() {
//                         @Override
//                         public List<UserModel> call(List<UserEntity> userEntities) {
//                             return UserMapper.getInstance().transformEntityList(userEntities);
//                         }
//                     });
//         } else {
//             return mUserRepository
//                     .getAllWithoutPicture(mUseCache)
//                     .map(new Func1<List<UserEntity>, List<UserModel>>() {
//                         @Override
//                         public List<UserModel> call(List<UserEntity> userEntities) {
//                             return UserMapper.getInstance().transformEntityList(userEntities);
//                         }
//                     });
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/marcohc/architecture/app/domain/model/UserModel.java
// public class UserModel implements Model {
// 
//     // ************************************************************************************************************************************************************************
//     // * Attributes
//     // ************************************************************************************************************************************************************************
// 
//     @SerializedName("name")
//     private String mName;
// 
//     @SerializedName("email")
//     private String mEmail;
// 
//     @SerializedName("pictureUrl")
//     private String mPictureUrl;
// 
//     // ************************************************************************************************************************************************************************
//     // * Constructors
//     // ************************************************************************************************************************************************************************
// 
//     public UserModel() {
//         mName = "Unknown";
//         mEmail = "Unknown";
//     }
// 
//     // ************************************************************************************************************************************************************************
//     // * Getter and setters
//     // ************************************************************************************************************************************************************************
// 
//     public String getName() {
//         return mName;
//     }
// 
//     public void setName(String name) {
//         this.mName = name;
//     }
// 
//     public String getEmail() {
//         return mEmail;
//     }
// 
//     public void setEmail(String email) {
//         this.mEmail = email;
//     }
// 
//     public String getPictureUrl() {
//         return mPictureUrl;
//     }
// 
//     public void setPictureUrl(String pictureUrl) {
//         this.mPictureUrl = pictureUrl;
//     }
// }
// 
// Path: app/src/main/java/com/marcohc/architecture/app/presentation/mvp/BasePresenter.java
// public abstract class BasePresenter<V extends BaseMvpView> extends BaseRxMvpPresenter<V> {
// 
// }
// 
// Path: util/src/main/java/com/marcohc/architecture/common/util/TimerUtils.java
// public class TimerUtils {
// 
//     private long stepTime;
//     private long totalTime;
//     private int stepNumber;
//     private String tag;
// 
//     public static TimerUtils getInstance(String tag) {
//         return new TimerUtils(tag);
//     }
// 
//     private TimerUtils(String tag) {
//         this.tag = tag;
//         stepNumber = 1;
//         stepTime = System.currentTimeMillis();
//         totalTime = System.currentTimeMillis();
//     }
// 
//     /**
//      * Prints a log with the step time.
//      *
//      * @return the step time
//      */
//     public Long logStep() {
//         Long difference = System.currentTimeMillis() - stepTime;
//         Timber.d("%s - Step %d: %d", tag, stepNumber++, difference);
//         stepTime = System.currentTimeMillis();
//         return difference;
//     }
// 
//     /**
//      * Prints a log with the step time.
//      *
//      * @param subTag sub tag used in the log
//      * @return the step time
//      */
//     public Long logStep(String subTag) {
//         Long difference = System.currentTimeMillis() - stepTime;
//         Timber.d("%s (%s) - Step %d: %d", android.R.attr.tag, subTag, stepNumber++, difference);
//         stepTime = System.currentTimeMillis();
//         return difference;
//     }
// 
//     /**
//      * Prints a log with the total time.
//      *
//      * @return the total time
//      */
//     public Long logTotal() {
//         Long difference = System.currentTimeMillis() - totalTime;
//         Timber.d("%s - TOTAL: %d", tag, difference);
//         return difference;
//     }
// }


import android.support.annotation.NonNull;
import com.marcohc.architecture.app.domain.interactor.GetUsersUseCase;
import com.marcohc.architecture.app.domain.model.UserModel;
import com.marcohc.architecture.app.presentation.mvp.BasePresenter;
import com.marcohc.architecture.common.util.TimerUtils;
import java.util.List;

    //region Subscription methods
    @Override
    public void onUserListSuccess(@NonNull List<UserModel> modelList) {
        getView().hideDialog();
        getView().enableCancelButton(false);
        getView().renderModelList(modelList);
        getView().setTimeSpent(mTimer.logTotal());
    }

    @Override
    public void onUserListFailure(@NonNull Throwable throwable) {
        getView().showRefreshSpinner(false);
        getView().enableCancelButton(false);
        getView().showMessage(throwable.getMessage());
    }
    //endregion

    //region Private methods
    private void requestData(boolean useCache) {
        getView().showLoadingDialog();
        getView().enableCancelButton(true);
        mTimer = TimerUtils.getInstance("GetUsersUseCase");
        mGetUsersUseCase = new GetUsersUseCase(mDataSourceWithPicture, useCache);
        executeUseCase(mGetUsersUseCase, new GetUsersSubscriber(this));
    }

    private void requestFreshData() {
        getView().showLoadingDialog();
        getView().enableCancelButton(true);
// Path: app/src/main/java/com/marcohc/architecture/app/domain/interactor/GetUsersUseCase.java
// public class GetUsersUseCase extends BaseRxUseCase<List<UserModel>> {
// 
//     private final boolean mWithPicture;
//     private final boolean mUseCache;
//     private final UserRepository mUserRepository;
// 
//     public GetUsersUseCase(boolean withPicture, boolean useCache) {
//         mWithPicture = withPicture;
//         mUseCache = useCache;
//         mUserRepository = new UserRepositoryImpl();
//     }
// 
//     @NonNull
//     @Override
//     protected Observable<List<UserModel>> getObservable() {
//         if (mWithPicture) {
//             return mUserRepository
//                     .getAllWithPicture(mUseCache)
//                     .map(new Func1<List<UserEntity>, List<UserModel>>() {
//                         @Override
//                         public List<UserModel> call(List<UserEntity> userEntities) {
//                             return UserMapper.getInstance().transformEntityList(userEntities);
//                         }
//                     });
//         } else {
//             return mUserRepository
//                     .getAllWithoutPicture(mUseCache)
//                     .map(new Func1<List<UserEntity>, List<UserModel>>() {
//                         @Override
//                         public List<UserModel> call(List<UserEntity> userEntities) {
//                             return UserMapper.getInstance().transformEntityList(userEntities);
//                         }
//                     });
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/marcohc/architecture/app/domain/model/UserModel.java
// public class UserModel implements Model {
// 
//     // ************************************************************************************************************************************************************************
//     // * Attributes
//     // ************************************************************************************************************************************************************************
// 
//     @SerializedName("name")
//     private String mName;
// 
//     @SerializedName("email")
//     private String mEmail;
// 
//     @SerializedName("pictureUrl")
//     private String mPictureUrl;
// 
//     // ************************************************************************************************************************************************************************
//     // * Constructors
//     // ************************************************************************************************************************************************************************
// 
//     public UserModel() {
//         mName = "Unknown";
//         mEmail = "Unknown";
//     }
// 
//     // ************************************************************************************************************************************************************************
//     // * Getter and setters
//     // ************************************************************************************************************************************************************************
// 
//     public String getName() {
//         return mName;
//     }
// 
//     public void setName(String name) {
//         this.mName = name;
//     }
// 
//     public String getEmail() {
//         return mEmail;
//     }
// 
//     public void setEmail(String email) {
//         this.mEmail = email;
//     }
// 
//     public String getPictureUrl() {
//         return mPictureUrl;
//     }
// 
//     public void setPictureUrl(String pictureUrl) {
//         this.mPictureUrl = pictureUrl;
//     }
// }
// 
// Path: app/src/main/java/com/marcohc/architecture/app/presentation/mvp/BasePresenter.java
// public abstract class BasePresenter<V extends BaseMvpView> extends BaseRxMvpPresenter<V> {
// 
// }
// 
// Path: util/src/main/java/com/marcohc/architecture/common/util/TimerUtils.java
// public class TimerUtils {
// 
//     private long stepTime;
//     private long totalTime;
//     private int stepNumber;
//     private String tag;
// 
//     public static TimerUtils getInstance(String tag) {
//         return new TimerUtils(tag);
//     }
// 
//     private TimerUtils(String tag) {
//         this.tag = tag;
//         stepNumber = 1;
//         stepTime = System.currentTimeMillis();
//         totalTime = System.currentTimeMillis();
//     }
// 
//     /**
//      * Prints a log with the step time.
//      *
//      * @return the step time
//      */
//     public Long logStep() {
//         Long difference = System.currentTimeMillis() - stepTime;
//         Timber.d("%s - Step %d: %d", tag, stepNumber++, difference);
//         stepTime = System.currentTimeMillis();
//         return difference;
//     }
// 
//     /**
//      * Prints a log with the step time.
//      *
//      * @param subTag sub tag used in the log
//      * @return the step time
//      */
//     public Long logStep(String subTag) {
//         Long difference = System.currentTimeMillis() - stepTime;
//         Timber.d("%s (%s) - Step %d: %d", android.R.attr.tag, subTag, stepNumber++, difference);
//         stepTime = System.currentTimeMillis();
//         return difference;
//     }
// 
//     /**
//      * Prints a log with the total time.
//      *
//      * @return the total time
//      */
//     public Long logTotal() {
//         Long difference = System.currentTimeMillis() - totalTime;
//         Timber.d("%s - TOTAL: %d", tag, difference);
//         return difference;
//     }
// }


// Path: app/src/main/java/com/marcohc/architecture/app/presentation/story/user/userlist/view/UsersListPresenterImpl.java
import android.support.annotation.NonNull;
import com.marcohc.architecture.app.domain.interactor.GetUsersUseCase;
import com.marcohc.architecture.app.domain.model.UserModel;
import com.marcohc.architecture.app.presentation.mvp.BasePresenter;
import com.marcohc.architecture.common.util.TimerUtils;
import java.util.List;


    //region Subscription methods
    @Override
    public void onUserListSuccess(@NonNull List<UserModel> modelList) {
        getView().hideDialog();
        getView().enableCancelButton(false);
        getView().renderModelList(modelList);
        getView().setTimeSpent(mTimer.logTotal());
    }

    @Override
    public void onUserListFailure(@NonNull Throwable throwable) {
        getView().showRefreshSpinner(false);
        getView().enableCancelButton(false);
        getView().showMessage(throwable.getMessage());
    }
    //endregion

    //region Private methods
    private void requestData(boolean useCache) {
        getView().showLoadingDialog();
        getView().enableCancelButton(true);
        mTimer = TimerUtils.getInstance("GetUsersUseCase");
        mGetUsersUseCase = new GetUsersUseCase(mDataSourceWithPicture, useCache);
        executeUseCase(mGetUsersUseCase, new GetUsersSubscriber(this));
    }

    private void requestFreshData() {
        getView().showLoadingDialog();
        getView().enableCancelButton(true);
        mTimer = TimerUtils.getInstance("GetUsersUseCase");