// Path: domain/src/main/java/domain/foundation/BaseView.java
// public interface BaseView {
// }
// 
// Path: domain/src/main/java/domain/foundation/Presenter.java
// public abstract class Presenter<V extends BaseView> {
//     protected V view;
//     protected final Wireframe wireframe;
//     private final SubscribeOn subscribeOn;
//     private final ObserveOn observeOn;
//     private final ParserException parserException;
//     protected final UI ui;
//     private final CompositeSubscription subscriptions;
// 
//     public Presenter(Wireframe wireframe, SubscribeOn subscribeOn, ObserveOn observeOn, ParserException parserException, UI ui) {
//         this.wireframe = wireframe;
//         this.subscribeOn = subscribeOn;
//         this.observeOn = observeOn;
//         this.parserException = parserException;
//         this.ui = ui;
//         this.subscriptions = new CompositeSubscription();
//     }
// 
//     /**
//      * Called when view is required to initialize. On the Android lifecycle ecosystem, it would be onCreated.
//      */
//     public void attachView(V view) {
//         this.view = view;
//     }
// 
//     /**
//      * Called when view is required to resume. On the Android lifecycle ecosystem, it would be onResume.
//      */
//     public void resumeView() {}
// 
//     /**
//      * Handles observable subscriptions, not throw any exception and report it using feedback.
//      */
//     protected <T> Disposing<T> safetyReportError(Observable<T> observable) {
//         Observable<T> configured = schedulers(observable)
//                 .doOnError(throwable -> ui.showFeedback(parserException.with(throwable).react()))
//                 .onErrorResumeNext(throwable -> Observable.empty());
// 
//         return new Disposing(configured, subscriptions);
//     }
// 
//     /**
//      * Handles observable subscriptions, not throw any exception and report it using anchoredScreenFeedback.
//      */
//     protected <T> Disposing<T> safetyReportErrorAnchored(Observable<T> observable) {
//         Observable<T> configured = schedulers(observable)
//                 .doOnError(throwable -> ui.showAnchoredScreenFeedback(parserException.with(throwable).react()))
//                 .onErrorResumeNext(throwable -> Observable.empty());
// 
//         return new Disposing(configured, subscriptions);
//     }
// 
//     /**
//      * Handles observable subscriptions and not throw any exception.
//      */
//     protected <T> Disposing<T> safety(Observable<T> observable) {
//         Observable<T> configured = schedulers(observable)
//                 .onErrorResumeNext(throwable -> Observable.empty());
// 
//         return new Disposing(configured, subscriptions);
//     }
// 
//     /**
//      * Handles observable schedulers.
//      */
//     private  <T> Observable<T> schedulers(Observable<T> observable) {
//         return observable.subscribeOn(subscribeOn.getScheduler())
//                 .observeOn(observeOn.getScheduler());
//     }
// 
//     public void dispose() {
//         if (!subscriptions.isUnsubscribed()) {
//             subscriptions.clear();
//         }
//     }
// 
//     /**
//      * Wrapper to hold a reference to the observable and the expected subscription.
//      */
//     protected static class Disposing<T> {
//         private Observable<T> observable;
//         private final CompositeSubscription subscriptions;
// 
//         private Disposing(Observable<T> observable, CompositeSubscription subscriptions) {
//             this.observable = observable;
//             this.subscriptions = subscriptions;
//         }
// 
//         public void disposable(Disposable<T> disposable) {
//             subscriptions.add(disposable.subscription(observable));
//         }
// 
//         public interface Disposable<T> {
//             Subscription subscription(Observable<T> observable);
//         }
//     }
// }
// 
// Path: presentation/src/main/java/presentation/internal/di/ApplicationComponent.java
// @Singleton @Component(modules = {DomainPresentationModule.class, DataPresentationModule.class, ApplicationModule.class})
// public interface ApplicationComponent {
//     void inject(LaunchActivity launchActivity);
// 
//     void inject(DashBoardActivity dashBoardActivity);
//     void inject(UserFragment userFragment);
//     void inject(UsersFragment usersFragment);
//     void inject(SearchUserFragment searchUserFragment);
// }


import domain.foundation.Presenter;
import presentation.internal.di.ApplicationComponent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import javax.inject.Inject;
import butterknife.ButterKnife;
import domain.foundation.BaseView;
/*
 * Copyright 2015 RefineriaWeb
 *
 * 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 presentation.foundation;




public abstract class BasePresenterFragment<P extends Presenter> extends Fragment implements BaseView {
    @Inject protected P presenter;

    @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(layoutRes(), container, false);
        ButterKnife.bind(this, view);

        injectDagger();
        return view;
    }

    private Integer layoutRes() {
        LayoutResFragment layoutRes = this.getClass().getAnnotation(LayoutResFragment.class);
        return layoutRes != null ? layoutRes.value() : null;
    }

    @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initViews();
        presenter.attachView(this);
    }

    protected abstract void injectDagger();
    protected void initViews() {}

    @Override public void onDestroyView() {
        super.onDestroyView();
        presenter.dispose();
        ButterKnife.unbind(this);
    }

    @Override public void onResume() {
// Path: domain/src/main/java/domain/foundation/BaseView.java
// public interface BaseView {
// }
// 
// Path: domain/src/main/java/domain/foundation/Presenter.java
// public abstract class Presenter<V extends BaseView> {
//     protected V view;
//     protected final Wireframe wireframe;
//     private final SubscribeOn subscribeOn;
//     private final ObserveOn observeOn;
//     private final ParserException parserException;
//     protected final UI ui;
//     private final CompositeSubscription subscriptions;
// 
//     public Presenter(Wireframe wireframe, SubscribeOn subscribeOn, ObserveOn observeOn, ParserException parserException, UI ui) {
//         this.wireframe = wireframe;
//         this.subscribeOn = subscribeOn;
//         this.observeOn = observeOn;
//         this.parserException = parserException;
//         this.ui = ui;
//         this.subscriptions = new CompositeSubscription();
//     }
// 
//     /**
//      * Called when view is required to initialize. On the Android lifecycle ecosystem, it would be onCreated.
//      */
//     public void attachView(V view) {
//         this.view = view;
//     }
// 
//     /**
//      * Called when view is required to resume. On the Android lifecycle ecosystem, it would be onResume.
//      */
//     public void resumeView() {}
// 
//     /**
//      * Handles observable subscriptions, not throw any exception and report it using feedback.
//      */
//     protected <T> Disposing<T> safetyReportError(Observable<T> observable) {
//         Observable<T> configured = schedulers(observable)
//                 .doOnError(throwable -> ui.showFeedback(parserException.with(throwable).react()))
//                 .onErrorResumeNext(throwable -> Observable.empty());
// 
//         return new Disposing(configured, subscriptions);
//     }
// 
//     /**
//      * Handles observable subscriptions, not throw any exception and report it using anchoredScreenFeedback.
//      */
//     protected <T> Disposing<T> safetyReportErrorAnchored(Observable<T> observable) {
//         Observable<T> configured = schedulers(observable)
//                 .doOnError(throwable -> ui.showAnchoredScreenFeedback(parserException.with(throwable).react()))
//                 .onErrorResumeNext(throwable -> Observable.empty());
// 
//         return new Disposing(configured, subscriptions);
//     }
// 
//     /**
//      * Handles observable subscriptions and not throw any exception.
//      */
//     protected <T> Disposing<T> safety(Observable<T> observable) {
//         Observable<T> configured = schedulers(observable)
//                 .onErrorResumeNext(throwable -> Observable.empty());
// 
//         return new Disposing(configured, subscriptions);
//     }
// 
//     /**
//      * Handles observable schedulers.
//      */
//     private  <T> Observable<T> schedulers(Observable<T> observable) {
//         return observable.subscribeOn(subscribeOn.getScheduler())
//                 .observeOn(observeOn.getScheduler());
//     }
// 
//     public void dispose() {
//         if (!subscriptions.isUnsubscribed()) {
//             subscriptions.clear();
//         }
//     }
// 
//     /**
//      * Wrapper to hold a reference to the observable and the expected subscription.
//      */
//     protected static class Disposing<T> {
//         private Observable<T> observable;
//         private final CompositeSubscription subscriptions;
// 
//         private Disposing(Observable<T> observable, CompositeSubscription subscriptions) {
//             this.observable = observable;
//             this.subscriptions = subscriptions;
//         }
// 
//         public void disposable(Disposable<T> disposable) {
//             subscriptions.add(disposable.subscription(observable));
//         }
// 
//         public interface Disposable<T> {
//             Subscription subscription(Observable<T> observable);
//         }
//     }
// }
// 
// Path: presentation/src/main/java/presentation/internal/di/ApplicationComponent.java
// @Singleton @Component(modules = {DomainPresentationModule.class, DataPresentationModule.class, ApplicationModule.class})
// public interface ApplicationComponent {
//     void inject(LaunchActivity launchActivity);
// 
//     void inject(DashBoardActivity dashBoardActivity);
//     void inject(UserFragment userFragment);
//     void inject(UsersFragment usersFragment);
//     void inject(SearchUserFragment searchUserFragment);
// }


// Path: presentation/src/main/java/presentation/foundation/BasePresenterFragment.java
import domain.foundation.Presenter;
import presentation.internal.di.ApplicationComponent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import javax.inject.Inject;
import butterknife.ButterKnife;
import domain.foundation.BaseView;

/*
 * Copyright 2015 RefineriaWeb
 *
 * 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 presentation.foundation;




public abstract class BasePresenterFragment<P extends Presenter> extends Fragment implements BaseView {
    @Inject protected P presenter;

    @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(layoutRes(), container, false);
        ButterKnife.bind(this, view);

        injectDagger();
        return view;
    }

    private Integer layoutRes() {
        LayoutResFragment layoutRes = this.getClass().getAnnotation(LayoutResFragment.class);
        return layoutRes != null ? layoutRes.value() : null;
    }

    @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initViews();
        presenter.attachView(this);
    }

    protected abstract void injectDagger();
    protected void initViews() {}

    @Override public void onDestroyView() {
        super.onDestroyView();
        presenter.dispose();
        ButterKnife.unbind(this);
    }

    @Override public void onResume() {
        super.onResume();