// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// public interface ServiceContainer {
// 
//     CityRepository getCityRepository();
// 
//     CurrentWeatherRepository getCurrentWeatherRepository();
// 
//     DailyForecastRepository getDailyForecastRepository();
// 
//     TaskExecutor getTaskExecutor();
// 
// }
// 
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
// 
//     private ServiceContainers() {
//         throw new RuntimeException("Instances are not allowed for this class");
//     }
// 
//     public static ServiceContainer getFromApp(Context context) {
//         Context app = context.getApplicationContext();
//         ServiceContainerProvider provider = (ServiceContainerProvider) app;
//         return provider.getServiceContainer();
//     }
// }
// 
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDailyForecastPresenter.java
// public class CityDailyForecastPresenter extends Presenter<CityDailyForecastVista> {
// 
//     private final TaskExecutor mTaskExecutor;
//     private final DailyForecastRepository mRepository;
//     private final String mCityId;
//     private final int mDaysFromToday;
// 
//     private GetDailyForecastsTask mGetDailyForecastsTask;
//     private DailyForecast mLastDailyForecast;
// 
//     public CityDailyForecastPresenter(TaskExecutor taskExecutor, DailyForecastRepository repository,
//             String cityId, int daysFromToday) {
//         mTaskExecutor = taskExecutor;
//         mRepository = repository;
//         mCityId = cityId;
//         mDaysFromToday = daysFromToday;
//     }
// 
//     @Override
//     public void onStart(CityDailyForecastVista vista) {
//         if (mLastDailyForecast != null) {
//             updateVista(vista, mLastDailyForecast);
//         } else {
//             vista.displayLoading(true);
//             if (!mTaskExecutor.isRunning(mGetDailyForecastsTask)) {
//                 mGetDailyForecastsTask = new GetDailyForecastsTask(mRepository, mCityId);
//                 mTaskExecutor.execute(mGetDailyForecastsTask, new GetDailyForecastTaskCallback());
//             }
//         }
//     }
// 
//     private void updateVista(CityDailyForecastVista vista, DailyForecast df) {
//         vista.setForecastDescription(capitalizeFirstLetter(
//                 df.getDescription()));
//         vista.setDayTemp(NumberFormat.formatTemperature(df.getDayTemp()));
//         vista.setMinTemp(NumberFormat.formatTemperature(df.getMinTemp()));
//         vista.setMaxTemp(NumberFormat.formatTemperature(df.getMaxTemp()));
//         vista.setHumidity(NumberFormat.formatHumidity(df.getHumidity()));
//         vista.setWindSpeed(NumberFormat.formatWindSpeed(df.getWindSpeed()));
//     }
// 
//     private String capitalizeFirstLetter(String text) {
//         return text.substring(0, 1).toUpperCase() + text.substring(1);
//     }
// 
//     private class GetDailyForecastTaskCallback extends DisplayErrorTaskCallback<List<DailyForecast>> {
//         public GetDailyForecastTaskCallback() {
//             super(CityDailyForecastPresenter.this);
//         }
// 
//         @Override
//         public void onSuccess(List<DailyForecast> list) {
//             DailyForecast dailyForecast = null;
//             if (list.size() >= mDaysFromToday + 1) {
//                 dailyForecast = list.get(mDaysFromToday);
//             }
// 
//             mLastDailyForecast = dailyForecast;
// 
//             CityDailyForecastVista vista = getVista();
//             if (vista != null) {
//                 vista.displayLoading(false);
//                 if (dailyForecast != null) {
//                     updateVista(vista, dailyForecast);
//                 } else {
//                     vista.displayError(R.string.error__connection);
//                 }
//             }
//         }
//     }
// }
// 
// 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/vista/CityDailyForecastVista.java
// public interface CityDailyForecastVista extends TaskResultVista {
// 
//     void setForecastDescription(String description);
// 
//     void setDayTemp(String temp);
// 
//     void setMinTemp(String temp);
// 
//     void setMaxTemp(String temp);
// 
//     void setHumidity(String humidity);
// 
//     void setWindSpeed(String windSpeed);
// 
// }


import cat.ppicas.framework.ui.PresenterHolder;
import cat.ppicas.cleanarch.ui.vista.CityDailyForecastVista;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainer;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.ui.presenter.CityDailyForecastPresenter;
import cat.ppicas.framework.ui.PresenterFactory;
    public void setMinTemp(String temp) {
        mMinTemp.setText(temp);
    }

    @Override
    public void setMaxTemp(String temp) {
        mMaxTemp.setText(temp);
    }

    @Override
    public void setHumidity(String humidity) {
        mHumidity.setText(humidity);
    }

    @Override
    public void setWindSpeed(String windSpeed) {
        mWindSpeed.setText(windSpeed);
    }

    @Override
    public void displayLoading(boolean display) {
        mLoading.setVisibility(display ? View.VISIBLE : View.GONE);
    }

    @Override
    public void displayError(int stringResId, Object... args) {
        Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show();
    }

    @Override
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// public interface ServiceContainer {
// 
//     CityRepository getCityRepository();
// 
//     CurrentWeatherRepository getCurrentWeatherRepository();
// 
//     DailyForecastRepository getDailyForecastRepository();
// 
//     TaskExecutor getTaskExecutor();
// 
// }
// 
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
// 
//     private ServiceContainers() {
//         throw new RuntimeException("Instances are not allowed for this class");
//     }
// 
//     public static ServiceContainer getFromApp(Context context) {
//         Context app = context.getApplicationContext();
//         ServiceContainerProvider provider = (ServiceContainerProvider) app;
//         return provider.getServiceContainer();
//     }
// }
// 
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDailyForecastPresenter.java
// public class CityDailyForecastPresenter extends Presenter<CityDailyForecastVista> {
// 
//     private final TaskExecutor mTaskExecutor;
//     private final DailyForecastRepository mRepository;
//     private final String mCityId;
//     private final int mDaysFromToday;
// 
//     private GetDailyForecastsTask mGetDailyForecastsTask;
//     private DailyForecast mLastDailyForecast;
// 
//     public CityDailyForecastPresenter(TaskExecutor taskExecutor, DailyForecastRepository repository,
//             String cityId, int daysFromToday) {
//         mTaskExecutor = taskExecutor;
//         mRepository = repository;
//         mCityId = cityId;
//         mDaysFromToday = daysFromToday;
//     }
// 
//     @Override
//     public void onStart(CityDailyForecastVista vista) {
//         if (mLastDailyForecast != null) {
//             updateVista(vista, mLastDailyForecast);
//         } else {
//             vista.displayLoading(true);
//             if (!mTaskExecutor.isRunning(mGetDailyForecastsTask)) {
//                 mGetDailyForecastsTask = new GetDailyForecastsTask(mRepository, mCityId);
//                 mTaskExecutor.execute(mGetDailyForecastsTask, new GetDailyForecastTaskCallback());
//             }
//         }
//     }
// 
//     private void updateVista(CityDailyForecastVista vista, DailyForecast df) {
//         vista.setForecastDescription(capitalizeFirstLetter(
//                 df.getDescription()));
//         vista.setDayTemp(NumberFormat.formatTemperature(df.getDayTemp()));
//         vista.setMinTemp(NumberFormat.formatTemperature(df.getMinTemp()));
//         vista.setMaxTemp(NumberFormat.formatTemperature(df.getMaxTemp()));
//         vista.setHumidity(NumberFormat.formatHumidity(df.getHumidity()));
//         vista.setWindSpeed(NumberFormat.formatWindSpeed(df.getWindSpeed()));
//     }
// 
//     private String capitalizeFirstLetter(String text) {
//         return text.substring(0, 1).toUpperCase() + text.substring(1);
//     }
// 
//     private class GetDailyForecastTaskCallback extends DisplayErrorTaskCallback<List<DailyForecast>> {
//         public GetDailyForecastTaskCallback() {
//             super(CityDailyForecastPresenter.this);
//         }
// 
//         @Override
//         public void onSuccess(List<DailyForecast> list) {
//             DailyForecast dailyForecast = null;
//             if (list.size() >= mDaysFromToday + 1) {
//                 dailyForecast = list.get(mDaysFromToday);
//             }
// 
//             mLastDailyForecast = dailyForecast;
// 
//             CityDailyForecastVista vista = getVista();
//             if (vista != null) {
//                 vista.displayLoading(false);
//                 if (dailyForecast != null) {
//                     updateVista(vista, dailyForecast);
//                 } else {
//                     vista.displayError(R.string.error__connection);
//                 }
//             }
//         }
//     }
// }
// 
// 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/vista/CityDailyForecastVista.java
// public interface CityDailyForecastVista extends TaskResultVista {
// 
//     void setForecastDescription(String description);
// 
//     void setDayTemp(String temp);
// 
//     void setMinTemp(String temp);
// 
//     void setMaxTemp(String temp);
// 
//     void setHumidity(String humidity);
// 
//     void setWindSpeed(String windSpeed);
// 
// }


// Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDailyForecastFragment.java
import cat.ppicas.framework.ui.PresenterHolder;
import cat.ppicas.cleanarch.ui.vista.CityDailyForecastVista;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainer;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.ui.presenter.CityDailyForecastPresenter;
import cat.ppicas.framework.ui.PresenterFactory;

    public void setMinTemp(String temp) {
        mMinTemp.setText(temp);
    }

    @Override
    public void setMaxTemp(String temp) {
        mMaxTemp.setText(temp);
    }

    @Override
    public void setHumidity(String humidity) {
        mHumidity.setText(humidity);
    }

    @Override
    public void setWindSpeed(String windSpeed) {
        mWindSpeed.setText(windSpeed);
    }

    @Override
    public void displayLoading(boolean display) {
        mLoading.setVisibility(display ? View.VISIBLE : View.GONE);
    }

    @Override
    public void displayError(int stringResId, Object... args) {
        Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show();
    }

    @Override
    public CityDailyForecastPresenter createPresenter() {