// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/SampleApplication.java
// public class SampleApplication extends Application {
// 
//     @Override public void onCreate() {
//         super.onCreate();
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/model/presentation/MainPresentationModel.java
// public class MainPresentationModel implements Serializable {
//     private String login;
//     private User   user;
// 
//     public String getLogin() {
//         return login;
//     }
// 
//     public void setLogin(String login) {
//         this.login = login;
//     }
// 
//     public void setUser(User user) {
//         this.user = user;
//     }
// 
//     public String getName() {
//         if (user == null) {
//             return null;
//         } else {
//             if (user.name == null) {
//                 return user.login;
//             } else {
//                 return user.name;
//             }
//         }
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/ui/base/BaseActivity.java
// public abstract class BaseActivity<M, V extends DroidMVPView, P extends DroidMVPPresenter<V, M>>
//     extends DroidMVPActivity<M, V, P> {
// 
//     @Override protected void performFieldInjection() {
//         //since we don't use any dependency injection framework here, lets make this method no-op.
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/ui/mvpviews/MainView.java
// public interface MainView extends DroidMVPView {
//     void showProgress();
// 
//     void showUserInfo(String showUserFetchSuccess);
// 
//     void showResponseError();
// 
//     void showRepositoriesScreen(String currentUsername);
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/ui/presenters/MainPresenter.java
// public class MainPresenter extends SimpleDroidMVPPresenter<MainView, MainPresentationModel> {
//     private final GithubApi githubApi;
// 
//     public MainPresenter(GithubApi githubApi) {
//         this.githubApi = githubApi;
//     }
// 
//     @Override public void attachView(MainView mvpView, MainPresentationModel presentationModel) {
//         super.attachView(mvpView, presentationModel);
//         if (presentationModel.getName() != null) {
//             mvpView.showUserInfo(presentationModel.getName());
//         }
//     }
// 
//     public void onSubmitClicked(String username) {
//         if (getMvpView() != null) {
//             getMvpView().showProgress();
//         }
//         getPresentationModel().setLogin(username);
//         githubApi.getUserProfile(username).enqueue(new Callback<User>() {
//             @Override public void onResponse(Call<User> call, Response<User> response) {
//                 if (response.isSuccessful()) {
//                     onUserProfileFetched(response.body());
//                 } else {
//                     onUserProfileFetchError();
//                 }
//             }
// 
//             @Override public void onFailure(Call<User> call, Throwable t) {
//                 onUserProfileFetchError();
//             }
//         });
//     }
// 
//     public void onShowReposClicked() {
//         if (getMvpView() != null) {
//             getMvpView().showRepositoriesScreen(getPresentationModel().getLogin());
//         }
//     }
// 
//     private void onUserProfileFetchError() {
//         if (getMvpView() != null) {
//             getMvpView().showResponseError();
//         }
//     }
// 
//     private void onUserProfileFetched(User user) {
//         getPresentationModel().setUser(user);
//         if (getMvpView() != null) {
//             getMvpView().showUserInfo(getPresentationModel().getName());
//         }
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/utils/KeyboardUtils.java
// public class KeyboardUtils {
//     public static void hideKeyboard(Activity activity) {
//         InputMethodManager inputManager =
//             (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
//         inputManager.hideSoftInputFromWindow(
//             activity.findViewById(android.R.id.content).getWindowToken(),
//             InputMethodManager.HIDE_NOT_ALWAYS);
//     }
// }


import io.appflate.droidvmp.androidsample.ui.mvpviews.MainView;
import io.appflate.droidvmp.androidsample.ui.presenters.MainPresenter;
import io.appflate.droidvmp.androidsample.utils.KeyboardUtils;
import java.util.Locale;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ViewAnimator;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.appflate.droidvmp.androidsample.R;
import io.appflate.droidvmp.androidsample.SampleApplication;
import io.appflate.droidvmp.androidsample.model.presentation.MainPresentationModel;
import io.appflate.droidvmp.androidsample.ui.base.BaseActivity;
    @Override protected void performFieldInjection() {
        SampleApplication.getComponent().inject(this);
    }

    @NonNull @Override protected MainPresentationModel createPresentationModel() {
        return new MainPresentationModel();
    }

    @Override public void showProgress() {
        resultAnimator.setDisplayedChild(POSITION_PROGRESS_VIEW);
    }

    @Override public void showUserInfo(String name) {
        resultAnimator.setDisplayedChild(POSITION_CONTENT_VIEW);
        fullNameTextView.setText(String.format(Locale.US, "Hello %s!", name));
        showReposButton.setVisibility(View.VISIBLE);
    }

    @Override public void showResponseError() {
        resultAnimator.setDisplayedChild(POSITION_CONTENT_VIEW);
        fullNameTextView.setText(R.string.something_went_wrong);
        showReposButton.setVisibility(View.GONE);
    }

    @Override public void showRepositoriesScreen(String currentUsername) {
        startActivity(RepositoriesActivity.intent(this, currentUsername));
    }

    // clicks

// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/SampleApplication.java
// public class SampleApplication extends Application {
// 
//     @Override public void onCreate() {
//         super.onCreate();
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/model/presentation/MainPresentationModel.java
// public class MainPresentationModel implements Serializable {
//     private String login;
//     private User   user;
// 
//     public String getLogin() {
//         return login;
//     }
// 
//     public void setLogin(String login) {
//         this.login = login;
//     }
// 
//     public void setUser(User user) {
//         this.user = user;
//     }
// 
//     public String getName() {
//         if (user == null) {
//             return null;
//         } else {
//             if (user.name == null) {
//                 return user.login;
//             } else {
//                 return user.name;
//             }
//         }
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/ui/base/BaseActivity.java
// public abstract class BaseActivity<M, V extends DroidMVPView, P extends DroidMVPPresenter<V, M>>
//     extends DroidMVPActivity<M, V, P> {
// 
//     @Override protected void performFieldInjection() {
//         //since we don't use any dependency injection framework here, lets make this method no-op.
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/ui/mvpviews/MainView.java
// public interface MainView extends DroidMVPView {
//     void showProgress();
// 
//     void showUserInfo(String showUserFetchSuccess);
// 
//     void showResponseError();
// 
//     void showRepositoriesScreen(String currentUsername);
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/ui/presenters/MainPresenter.java
// public class MainPresenter extends SimpleDroidMVPPresenter<MainView, MainPresentationModel> {
//     private final GithubApi githubApi;
// 
//     public MainPresenter(GithubApi githubApi) {
//         this.githubApi = githubApi;
//     }
// 
//     @Override public void attachView(MainView mvpView, MainPresentationModel presentationModel) {
//         super.attachView(mvpView, presentationModel);
//         if (presentationModel.getName() != null) {
//             mvpView.showUserInfo(presentationModel.getName());
//         }
//     }
// 
//     public void onSubmitClicked(String username) {
//         if (getMvpView() != null) {
//             getMvpView().showProgress();
//         }
//         getPresentationModel().setLogin(username);
//         githubApi.getUserProfile(username).enqueue(new Callback<User>() {
//             @Override public void onResponse(Call<User> call, Response<User> response) {
//                 if (response.isSuccessful()) {
//                     onUserProfileFetched(response.body());
//                 } else {
//                     onUserProfileFetchError();
//                 }
//             }
// 
//             @Override public void onFailure(Call<User> call, Throwable t) {
//                 onUserProfileFetchError();
//             }
//         });
//     }
// 
//     public void onShowReposClicked() {
//         if (getMvpView() != null) {
//             getMvpView().showRepositoriesScreen(getPresentationModel().getLogin());
//         }
//     }
// 
//     private void onUserProfileFetchError() {
//         if (getMvpView() != null) {
//             getMvpView().showResponseError();
//         }
//     }
// 
//     private void onUserProfileFetched(User user) {
//         getPresentationModel().setUser(user);
//         if (getMvpView() != null) {
//             getMvpView().showUserInfo(getPresentationModel().getName());
//         }
//     }
// }
// 
// Path: sample/src/main/java/io/appflate/droidvmp/androidsample/utils/KeyboardUtils.java
// public class KeyboardUtils {
//     public static void hideKeyboard(Activity activity) {
//         InputMethodManager inputManager =
//             (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
//         inputManager.hideSoftInputFromWindow(
//             activity.findViewById(android.R.id.content).getWindowToken(),
//             InputMethodManager.HIDE_NOT_ALWAYS);
//     }
// }


// Path: sample-parcelable/src/main/java/io/appflate/droidvmp/androidsample/ui/activities/MainActivity.java
import io.appflate.droidvmp.androidsample.ui.mvpviews.MainView;
import io.appflate.droidvmp.androidsample.ui.presenters.MainPresenter;
import io.appflate.droidvmp.androidsample.utils.KeyboardUtils;
import java.util.Locale;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ViewAnimator;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.appflate.droidvmp.androidsample.R;
import io.appflate.droidvmp.androidsample.SampleApplication;
import io.appflate.droidvmp.androidsample.model.presentation.MainPresentationModel;
import io.appflate.droidvmp.androidsample.ui.base.BaseActivity;

    @Override protected void performFieldInjection() {
        SampleApplication.getComponent().inject(this);
    }

    @NonNull @Override protected MainPresentationModel createPresentationModel() {
        return new MainPresentationModel();
    }

    @Override public void showProgress() {
        resultAnimator.setDisplayedChild(POSITION_PROGRESS_VIEW);
    }

    @Override public void showUserInfo(String name) {
        resultAnimator.setDisplayedChild(POSITION_CONTENT_VIEW);
        fullNameTextView.setText(String.format(Locale.US, "Hello %s!", name));
        showReposButton.setVisibility(View.VISIBLE);
    }

    @Override public void showResponseError() {
        resultAnimator.setDisplayedChild(POSITION_CONTENT_VIEW);
        fullNameTextView.setText(R.string.something_went_wrong);
        showReposButton.setVisibility(View.GONE);
    }

    @Override public void showRepositoriesScreen(String currentUsername) {
        startActivity(RepositoriesActivity.intent(this, currentUsername));
    }

    // clicks

    @OnClick(R.id.submitButton) void onSubmitClicked() {