// Path: app/src/main/java/cat/ppicas/framework/ui/Presenter.java
// public abstract class Presenter<T extends Vista> {
// 
//     private T mVista;
// 
//     /**
//      * Returns the current bound {@link Vista} if any.
//      *
//      * @return The bound {@code Vista} or {@code null}.
//      */
//     @Nullable
//     public T getVista() {
//         return mVista;
//     }
// 
//     /**
//      * Must be called to bind the {@link Vista} and let the {@link Presenter} know that can start
//      * {@code Vista} updates. Normally this method will be called from {@link Activity#onStart()}
//      * or from {@link Fragment#onStart()}.
//      *
//      * @param vista A {@code Vista} instance to bind.
//      */
//     public final void start(T vista) {
//         mVista = vista;
//         onStart(vista);
//     }
// 
//     /**
//      * Must be called un unbind the {@link Vista} and let the {@link Presenter} know that must
//      * stop updating the {@code Vista}. Normally this method will be called from
//      * {@link Activity#onStop()} or from {@link Fragment#onStop()}.
//      */
//     public final void stop() {
//         mVista = null;
//         onStop();
//     }
// 
//     /**
//      * Called when the {@link Presenter} can start {@link Vista} updates.
//      *
//      * @param vista The bound {@code Vista}.
//      */
//     public abstract void onStart(T vista);
// 
//     /**
//      * Called when the {@link Presenter} must stop {@link Vista} updates. The extending
//      * {@code Presenter} can override this method to provide some custom logic.
//      */
//     public void onStop() {
//     }
// 
//     /**
//      * Called to ask the {@link Presenter} to save its current dynamic state, so it
//      * can later be reconstructed in a new instance of its process is
//      * restarted.
//      *
//      * @param state Bundle in which to place your saved state.
//      * @see Activity#onSaveInstanceState(Bundle)
//      */
//     public void saveState(Bundle state) {
//     }
// 
//     /**
//      * Called to ask the {@link Presenter} to restore the previous saved state.
//      *
//      * @param state The data most recently supplied in {@link #saveState}.
//      * @see Activity#onRestoreInstanceState(Bundle)
//      */
//     public void restoreState(Bundle state) {
//     }
// 
//     /**
//      * Called when this {@link Presenter} is going to be destroyed, so it has a chance to
//      * release resources. The extending {@code Presenter} can override this method to provide some
//      * custom logic.
//      */
//     public void onDestroy() {
//     }
// }
// 
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java
// public interface PresenterFactory<T extends Presenter<?>> {
// 
//     T createPresenter();
// 
//     String getPresenterTag();
// 
// }
// 
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java
// public interface PresenterHolder {
// 
//     <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory);
// 
//     void destroyPresenter(PresenterFactory<?> presenterFactory);
// 
// }


import android.app.Fragment;
import android.os.Bundle;
import java.util.HashMap;
import java.util.Map;
import cat.ppicas.framework.ui.Presenter;
import cat.ppicas.framework.ui.PresenterFactory;
import cat.ppicas.framework.ui.PresenterHolder;
        state.putBundle(STATE_PRESENTERS, presentersStates);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        for (Presenter<?> presenter : mPresenterMap.values()) {
            presenter.onDestroy();
        }
    }

    @Override
    public <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory) {
        String tag = presenterFactory.getPresenterTag();

        @SuppressWarnings("unchecked")
        T presenter = (T) mPresenterMap.get(tag);

        if (presenter == null) {
            presenter = presenterFactory.createPresenter();
            if (mPresentersStates != null && mPresentersStates.containsKey(tag)) {
                presenter.restoreState(mPresentersStates.getBundle(tag));
            }
            mPresenterMap.put(tag, presenter);
        }

        return presenter;
    }

    @Override
// Path: app/src/main/java/cat/ppicas/framework/ui/Presenter.java
// public abstract class Presenter<T extends Vista> {
// 
//     private T mVista;
// 
//     /**
//      * Returns the current bound {@link Vista} if any.
//      *
//      * @return The bound {@code Vista} or {@code null}.
//      */
//     @Nullable
//     public T getVista() {
//         return mVista;
//     }
// 
//     /**
//      * Must be called to bind the {@link Vista} and let the {@link Presenter} know that can start
//      * {@code Vista} updates. Normally this method will be called from {@link Activity#onStart()}
//      * or from {@link Fragment#onStart()}.
//      *
//      * @param vista A {@code Vista} instance to bind.
//      */
//     public final void start(T vista) {
//         mVista = vista;
//         onStart(vista);
//     }
// 
//     /**
//      * Must be called un unbind the {@link Vista} and let the {@link Presenter} know that must
//      * stop updating the {@code Vista}. Normally this method will be called from
//      * {@link Activity#onStop()} or from {@link Fragment#onStop()}.
//      */
//     public final void stop() {
//         mVista = null;
//         onStop();
//     }
// 
//     /**
//      * Called when the {@link Presenter} can start {@link Vista} updates.
//      *
//      * @param vista The bound {@code Vista}.
//      */
//     public abstract void onStart(T vista);
// 
//     /**
//      * Called when the {@link Presenter} must stop {@link Vista} updates. The extending
//      * {@code Presenter} can override this method to provide some custom logic.
//      */
//     public void onStop() {
//     }
// 
//     /**
//      * Called to ask the {@link Presenter} to save its current dynamic state, so it
//      * can later be reconstructed in a new instance of its process is
//      * restarted.
//      *
//      * @param state Bundle in which to place your saved state.
//      * @see Activity#onSaveInstanceState(Bundle)
//      */
//     public void saveState(Bundle state) {
//     }
// 
//     /**
//      * Called to ask the {@link Presenter} to restore the previous saved state.
//      *
//      * @param state The data most recently supplied in {@link #saveState}.
//      * @see Activity#onRestoreInstanceState(Bundle)
//      */
//     public void restoreState(Bundle state) {
//     }
// 
//     /**
//      * Called when this {@link Presenter} is going to be destroyed, so it has a chance to
//      * release resources. The extending {@code Presenter} can override this method to provide some
//      * custom logic.
//      */
//     public void onDestroy() {
//     }
// }
// 
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java
// public interface PresenterFactory<T extends Presenter<?>> {
// 
//     T createPresenter();
// 
//     String getPresenterTag();
// 
// }
// 
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java
// public interface PresenterHolder {
// 
//     <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory);
// 
//     void destroyPresenter(PresenterFactory<?> presenterFactory);
// 
// }


// Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/PresenterHolderFragment.java
import android.app.Fragment;
import android.os.Bundle;
import java.util.HashMap;
import java.util.Map;
import cat.ppicas.framework.ui.Presenter;
import cat.ppicas.framework.ui.PresenterFactory;
import cat.ppicas.framework.ui.PresenterHolder;

        state.putBundle(STATE_PRESENTERS, presentersStates);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        for (Presenter<?> presenter : mPresenterMap.values()) {
            presenter.onDestroy();
        }
    }

    @Override
    public <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory) {
        String tag = presenterFactory.getPresenterTag();

        @SuppressWarnings("unchecked")
        T presenter = (T) mPresenterMap.get(tag);

        if (presenter == null) {
            presenter = presenterFactory.createPresenter();
            if (mPresentersStates != null && mPresentersStates.containsKey(tag)) {
                presenter.restoreState(mPresentersStates.getBundle(tag));
            }
            mPresenterMap.put(tag, presenter);
        }

        return presenter;
    }

    @Override
    public void destroyPresenter(PresenterFactory<?> presenterFactory) {