// Path: mvp/src/main/java/com/mike/feed/FeedApp.java
// public class FeedApp extends Application{
// 
//     public static FeedApp get(Context context){
//         return (FeedApp) context.getApplicationContext();
//     }
// 
// 
//     AppComponent appComponent;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         appComponent = DaggerAppComponent.builder()
//                 .appModule(new AppModule(this)).build();
// 
//         if (BuildConfig.DEBUG) {
//             Timber.plant(new Timber.DebugTree());
//         }
//     }
// 
//     public AppComponent getAppComponent() {
//         return appComponent;
//     }
// }
// 
// Path: mvvm/src/main/java/com/mike/feed/dependency/injection/AppComponent.java
// @Singleton
// @Component(
//         modules = {
//                 AppModule.class
//         }
// )
// public interface AppComponent {
//     Context context();
// 
//     MainFragment.MainScreenComponent plus(MainFragment.MainScreenModule module);
//     NewFeedFragment.NewFeedComponent plus(NewFeedFragment.NewFeedModule module);
// }
// 
// Path: mvp/src/main/java/com/mike/feed/presenter/NewFeedPresenter.java
// @FragmentScope
// public class NewFeedPresenter extends BasePresenter<NewFeedView> {
// 
//     @NonNull
//     NewFeedUseCaseFactory newFeedUseCaseFactory;
// 
//     @NonNull
//     private FeedModelMapper mapper;
// 
// 
//     @Inject
//     public NewFeedPresenter(NewFeedUseCaseFactory newFeedUseCaseFactory, FeedModelMapper mapper) {
//         this.newFeedUseCaseFactory = newFeedUseCaseFactory;
//         this.mapper = mapper;
//     }
// 
//     public void submit(String title, String body, String img) {
//         Feed feed = new Feed();
//         feed.setBody(body);
//         feed.setTitle(title);
//         feed.setImage(img);
// 
//         NewFeedUseCase newFeedUseCase = newFeedUseCaseFactory.create(feed);
//         newFeedUseCase.execute(new NewFeedSubscriber(newFeedUseCase));
//         unsubscribeOnUnbindView(newFeedUseCase);
//     }
// 
// 
//     
//     protected final class NewFeedSubscriber extends DefaultSubscriber<Written> {
// 
//         WeakReference<UseCase> mUseCase;
// 
//         NewFeedSubscriber(UseCase useCase){
//             this.mUseCase = new WeakReference<UseCase>(useCase);
//         }
// 
//         @Override
//         public void onCompleted() {
//             removeUnsubscribe(mUseCase.get());
//         }
// 
//         @Override
//         public void onError(Throwable e) {
//             super.onError(e);
//             e.printStackTrace();
//             view().showErrorMsg();
// 
//             removeUnsubscribe(mUseCase.get());
//         }
// 
//         @Override
//         public void onNext(Written written) {
//             // can do whatever with WrittenModel here
//             WrittenModel writtenModel = mapper.transform(written);
// 
//             view().close();
//         }
//     }
// }
// 
// Path: mvp/src/main/java/com/mike/feed/view/NewFeedView.java
// public interface NewFeedView {
//     public void close();
//     public void showErrorMsg();
// }
// 
// Path: mvvm/src/main/java/com/mike/feed/view/base/BaseFragment.java
// public abstract class BaseFragment extends Fragment {
// 
//     @Override
//     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//         super.onViewCreated(view, savedInstanceState);
//         setUpComponent();
//     }
// 
//     abstract protected void setUpComponent();
// 
// }


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.mike.feed.R;
import com.mike.feed.FeedApp;
import com.mike.feed.dependency.injection.AppComponent;
import com.mike.feed.dependency.injection.scope.FragmentScope;
import com.mike.feed.presenter.NewFeedPresenter;
import com.mike.feed.view.NewFeedView;
import com.mike.feed.view.base.BaseFragment;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.OnClick;
import dagger.Module;
import dagger.Subcomponent;
package com.mike.feed.view.fragment;





/**
 * Created by MinhNguyen on 8/27/16.
 */
public class NewFeedFragment extends BaseFragment implements NewFeedView{
    public static NewFeedFragment createInstance(){
        NewFeedFragment fragment = new NewFeedFragment();
        return fragment;
    }

    private static final String[] IMAGE_PATHS = new String[]{
            "https://i.ytimg.com/vi/1LqyOX12_nQ/maxresdefault.jpg"
            , "http://static.boredpanda.com/blog/wp-content/uuuploads/cute-baby-animals-2/cute-baby-animals-2-2.jpg"
            , "http://wallpapercave.com/wp/iyXgxue.jpg"
            , "http://1.bp.blogspot.com/-cCfO2hJ_x9Y/UD3zKqY_ueI/AAAAAAAAFmQ/egiQz9de-zc/s1600/cute-baby-animal-8.jpg"
            , "http://static.boredpanda.com/blog/wp-content/uploads/2016/01/baby-otter-sleeps-mother-belly-monterey-bay-aquarium-fb.png"
    };

    @BindView(R.id.etTitle)
    EditText etTitle;

    @BindView(R.id.etBody)
    EditText etBody;

    @BindView(R.id.etImage)
    EditText etImage;

// Path: mvp/src/main/java/com/mike/feed/FeedApp.java
// public class FeedApp extends Application{
// 
//     public static FeedApp get(Context context){
//         return (FeedApp) context.getApplicationContext();
//     }
// 
// 
//     AppComponent appComponent;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         appComponent = DaggerAppComponent.builder()
//                 .appModule(new AppModule(this)).build();
// 
//         if (BuildConfig.DEBUG) {
//             Timber.plant(new Timber.DebugTree());
//         }
//     }
// 
//     public AppComponent getAppComponent() {
//         return appComponent;
//     }
// }
// 
// Path: mvvm/src/main/java/com/mike/feed/dependency/injection/AppComponent.java
// @Singleton
// @Component(
//         modules = {
//                 AppModule.class
//         }
// )
// public interface AppComponent {
//     Context context();
// 
//     MainFragment.MainScreenComponent plus(MainFragment.MainScreenModule module);
//     NewFeedFragment.NewFeedComponent plus(NewFeedFragment.NewFeedModule module);
// }
// 
// Path: mvp/src/main/java/com/mike/feed/presenter/NewFeedPresenter.java
// @FragmentScope
// public class NewFeedPresenter extends BasePresenter<NewFeedView> {
// 
//     @NonNull
//     NewFeedUseCaseFactory newFeedUseCaseFactory;
// 
//     @NonNull
//     private FeedModelMapper mapper;
// 
// 
//     @Inject
//     public NewFeedPresenter(NewFeedUseCaseFactory newFeedUseCaseFactory, FeedModelMapper mapper) {
//         this.newFeedUseCaseFactory = newFeedUseCaseFactory;
//         this.mapper = mapper;
//     }
// 
//     public void submit(String title, String body, String img) {
//         Feed feed = new Feed();
//         feed.setBody(body);
//         feed.setTitle(title);
//         feed.setImage(img);
// 
//         NewFeedUseCase newFeedUseCase = newFeedUseCaseFactory.create(feed);
//         newFeedUseCase.execute(new NewFeedSubscriber(newFeedUseCase));
//         unsubscribeOnUnbindView(newFeedUseCase);
//     }
// 
// 
//     
//     protected final class NewFeedSubscriber extends DefaultSubscriber<Written> {
// 
//         WeakReference<UseCase> mUseCase;
// 
//         NewFeedSubscriber(UseCase useCase){
//             this.mUseCase = new WeakReference<UseCase>(useCase);
//         }
// 
//         @Override
//         public void onCompleted() {
//             removeUnsubscribe(mUseCase.get());
//         }
// 
//         @Override
//         public void onError(Throwable e) {
//             super.onError(e);
//             e.printStackTrace();
//             view().showErrorMsg();
// 
//             removeUnsubscribe(mUseCase.get());
//         }
// 
//         @Override
//         public void onNext(Written written) {
//             // can do whatever with WrittenModel here
//             WrittenModel writtenModel = mapper.transform(written);
// 
//             view().close();
//         }
//     }
// }
// 
// Path: mvp/src/main/java/com/mike/feed/view/NewFeedView.java
// public interface NewFeedView {
//     public void close();
//     public void showErrorMsg();
// }
// 
// Path: mvvm/src/main/java/com/mike/feed/view/base/BaseFragment.java
// public abstract class BaseFragment extends Fragment {
// 
//     @Override
//     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//         super.onViewCreated(view, savedInstanceState);
//         setUpComponent();
//     }
// 
//     abstract protected void setUpComponent();
// 
// }


// Path: mvp/src/main/java/com/mike/feed/view/fragment/NewFeedFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.mike.feed.R;
import com.mike.feed.FeedApp;
import com.mike.feed.dependency.injection.AppComponent;
import com.mike.feed.dependency.injection.scope.FragmentScope;
import com.mike.feed.presenter.NewFeedPresenter;
import com.mike.feed.view.NewFeedView;
import com.mike.feed.view.base.BaseFragment;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.OnClick;
import dagger.Module;
import dagger.Subcomponent;

package com.mike.feed.view.fragment;





/**
 * Created by MinhNguyen on 8/27/16.
 */
public class NewFeedFragment extends BaseFragment implements NewFeedView{
    public static NewFeedFragment createInstance(){
        NewFeedFragment fragment = new NewFeedFragment();
        return fragment;
    }

    private static final String[] IMAGE_PATHS = new String[]{
            "https://i.ytimg.com/vi/1LqyOX12_nQ/maxresdefault.jpg"
            , "http://static.boredpanda.com/blog/wp-content/uuuploads/cute-baby-animals-2/cute-baby-animals-2-2.jpg"
            , "http://wallpapercave.com/wp/iyXgxue.jpg"
            , "http://1.bp.blogspot.com/-cCfO2hJ_x9Y/UD3zKqY_ueI/AAAAAAAAFmQ/egiQz9de-zc/s1600/cute-baby-animal-8.jpg"
            , "http://static.boredpanda.com/blog/wp-content/uploads/2016/01/baby-otter-sleeps-mother-belly-monterey-bay-aquarium-fb.png"
    };

    @BindView(R.id.etTitle)
    EditText etTitle;

    @BindView(R.id.etBody)
    EditText etBody;

    @BindView(R.id.etImage)
    EditText etImage;

    @Inject