// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/PersonApplication.java
// public class PersonApplication extends Application{
// 
//     private MainComponent mainComponent;
// 
//     @Override public void onCreate() {
//         super.onCreate();
//         mainComponent = DaggerMainComponent.builder()
//                 .mainModule(new MainModule())
//                 .build();
//     }
// 
//     public MainComponent getMainComponent() {
//         return mainComponent;
//     }
// 
//     @VisibleForTesting
//     public void setComponent(MainComponent mainComponent) {
//         this.mainComponent = mainComponent;
//     }
// 
// }
// 
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/domain/Person.java
// public class Person {
// 
//     private String name;
// 
//     public Person(String name) {
//         this.name = name;
//     }
// 
//     public String getName() {
//         return name;
//     }
// }
// 
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/presenter/PersonListPresenter.java
// public class PersonListPresenter implements Presenter<PersonListPresenter.View> {
// 
//     private final GetAllPersonsUseCase personsUseCase;
//     private  PersonListPresenter.View view;
// 
//     private Subscription personsSubscription;
// 
//     @Inject
//     public PersonListPresenter(GetAllPersonsUseCase personsUseCase) {
//         this.personsUseCase = personsUseCase;
//     }
// 
//     @Override
//     public void init() {
//         askForPersons();
//     }
// 
//     private void askForPersons() {
//         personsSubscription = personsUseCase.execute()
//                 .subscribe(this::onPersonReceived, this::showError);
//     }
// 
//     private void onPersonReceived(List<Person> persons) {
//         view.showPersons(persons);
//         view.hideLoading();
//         if (persons.isEmpty()){
//             view.showEmptyView();
//         }else{
//             view.hideEmptyView();
//         }
//     }
// 
//     private void showError(Throwable error){
//         view.hideLoading();
//         view.showError();
//     }
// 
//     @Override
//     public void setView(View view) {
//         this.view = view;
//     }
// 
//     @Override
//     public void onPause() {
//         personsSubscription.unsubscribe();
//     }
// 
//     public interface View extends Presenter.View{
//         void showEmptyView();
//         void hideEmptyView();
//         void showPersons(List<Person> persons);
//         void showError();
//     }
// }


import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.tonilopezmr.dagger2rxjava.PersonApplication;
import com.tonilopezmr.dagger2rxjava.R;
import com.tonilopezmr.dagger2rxjava.domain.Person;
import com.tonilopezmr.dagger2rxjava.presenter.PersonListPresenter;
import java.util.List;
import javax.inject.Inject;
    private void initFloatinActionButton() {
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();
        presenter.onPause();
    }

    private void initToolbar() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/PersonApplication.java
// public class PersonApplication extends Application{
// 
//     private MainComponent mainComponent;
// 
//     @Override public void onCreate() {
//         super.onCreate();
//         mainComponent = DaggerMainComponent.builder()
//                 .mainModule(new MainModule())
//                 .build();
//     }
// 
//     public MainComponent getMainComponent() {
//         return mainComponent;
//     }
// 
//     @VisibleForTesting
//     public void setComponent(MainComponent mainComponent) {
//         this.mainComponent = mainComponent;
//     }
// 
// }
// 
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/domain/Person.java
// public class Person {
// 
//     private String name;
// 
//     public Person(String name) {
//         this.name = name;
//     }
// 
//     public String getName() {
//         return name;
//     }
// }
// 
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/presenter/PersonListPresenter.java
// public class PersonListPresenter implements Presenter<PersonListPresenter.View> {
// 
//     private final GetAllPersonsUseCase personsUseCase;
//     private  PersonListPresenter.View view;
// 
//     private Subscription personsSubscription;
// 
//     @Inject
//     public PersonListPresenter(GetAllPersonsUseCase personsUseCase) {
//         this.personsUseCase = personsUseCase;
//     }
// 
//     @Override
//     public void init() {
//         askForPersons();
//     }
// 
//     private void askForPersons() {
//         personsSubscription = personsUseCase.execute()
//                 .subscribe(this::onPersonReceived, this::showError);
//     }
// 
//     private void onPersonReceived(List<Person> persons) {
//         view.showPersons(persons);
//         view.hideLoading();
//         if (persons.isEmpty()){
//             view.showEmptyView();
//         }else{
//             view.hideEmptyView();
//         }
//     }
// 
//     private void showError(Throwable error){
//         view.hideLoading();
//         view.showError();
//     }
// 
//     @Override
//     public void setView(View view) {
//         this.view = view;
//     }
// 
//     @Override
//     public void onPause() {
//         personsSubscription.unsubscribe();
//     }
// 
//     public interface View extends Presenter.View{
//         void showEmptyView();
//         void hideEmptyView();
//         void showPersons(List<Person> persons);
//         void showError();
//     }
// }


// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/view/MainActivity.java
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.tonilopezmr.dagger2rxjava.PersonApplication;
import com.tonilopezmr.dagger2rxjava.R;
import com.tonilopezmr.dagger2rxjava.domain.Person;
import com.tonilopezmr.dagger2rxjava.presenter.PersonListPresenter;
import java.util.List;
import javax.inject.Inject;

    private void initFloatinActionButton() {
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();
        presenter.onPause();
    }

    private void initToolbar() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {