/*
 * Copyright (C) 2015 Olmo Gallegos Hernández.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package es.voghdev.prjdagger2.ui.presenter.impl;

import android.content.Context;

import java.util.List;

import es.voghdev.prjdagger2.global.App;
import es.voghdev.prjdagger2.global.di.RootComponent;
import es.voghdev.prjdagger2.global.model.User;
import es.voghdev.prjdagger2.ui.presenter.UserListPresenter;
import es.voghdev.prjdagger2.usecase.GetUsers;

public class UserListPresenterImpl extends UserListPresenter implements GetUsers.Listener {
    protected Context mContext;

    public UserListPresenterImpl(Context ctx){
        mContext = ctx;

        getComponent().inject(this);
    }

    @Override
    public void initialize() {
        view.showLoading();
        interactor.getUsers(this);
    }

    @Override
    public void resume() {

    }

    @Override
    public void pause() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public void onUsersReceived(List<User> users, boolean isCached) {
        view.showUserList(users);
        view.hideLoading();
    }

    @Override
    public void onError(Exception e) {
        view.showUserListError(e);
        view.hideLoading();
    }

    @Override
    public void onNoInternetAvailable() {
        view.showNoInternetMessage();
        view.hideLoading();
    }

    @Override
    public void onUserPictureClicked(User user) {
        view.makeUserSayHello(user);
    }

    @Override
    public void onUserRowClicked(User user) {
        view.showUserClickedMessage(user);
    }

    protected RootComponent getComponent() {
        return ((App)mContext.getApplicationContext()).getComponent();
    }
}

@@ -1025,37 +1025,8 @@
 ter 
-implements GetUsers.Listener 
 %7B%0A  
@@ -1045,18 +1045,17 @@
 Context 
-mC
+c
 ontext;%0A
@@ -1110,18 +1110,17 @@
         
-mC
+c
 ontext =
@@ -1275,169 +1275,42 @@
 ers(
-this);%0A    %7D%0A%0A    @Override%0A    public void resume
+new GetUsers.Listener
 () %7B%0A
-%0A
     
-%7D%0A%0A
     
-@Override%0A    public void pause() %7B%0A%0A    %7D%0A%0A    @Override%0A    public void destroy() %7B%0A%0A    %7D%0A%0A
     
@@ -1311,32 +1311,40 @@
       @Override%0A
+        
     public void 
@@ -1393,24 +1393,32 @@
 isCached) %7B%0A
+        
         view
@@ -1439,32 +1439,40 @@
 users);%0A        
+  
+      
 view.hideLoading
@@ -1471,35 +1471,51 @@
 eLoading();%0A    
-%7D%0A%0A
+        %7D%0A%0A        
     @Override%0A  
@@ -1504,32 +1504,40 @@
       @Override%0A
+        
     public void 
@@ -1555,24 +1555,32 @@
 eption e) %7B%0A
+        
         view
@@ -1602,32 +1602,40 @@
 ror(e);%0A        
+ 
+       
 view.hideLoading
@@ -1634,35 +1634,51 @@
 eLoading();%0A    
-%7D%0A%0A
+        %7D%0A%0A        
     @Override%0A  
@@ -1667,32 +1667,40 @@
       @Override%0A
+        
     public void 
@@ -1721,24 +1721,32 @@
 ailable() %7B%0A
+        
         view
@@ -1767,24 +1767,32 @@
 tMessage();%0A
+        
         view
@@ -1803,24 +1803,198 @@
 eLoading();%0A
+            %7D%0A%0A        %7D);%0A    %7D%0A%0A    @Override%0A    public void resume() %7B%0A%0A    %7D%0A%0A    @Override%0A    public void pause() %7B%0A%0A    %7D%0A%0A    @Override%0A    public void destroy() %7B%0A%0A
     %7D%0A%0A    @
@@ -2276,10 +2276,10 @@
 App)
-mC
+ c
 onte

Refactor var names and callbacks