// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
//     interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
//         void setNavigator(@NonNull Navigator navigator);
// 
//         void onFavoriteArticleClick();
//     }
// 
//     interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
//         void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
//     }
// 
//     interface Navigator {
//         void openArticle(int id);
// 
//         void openFavoriteArticles();
//     }
// 
//     interface NavigatorProvider {
// 
//         @NonNull
//         Navigator getNavigator(ArticleListContract.Presenter presenter);
//     }
// }
// 
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
// 
//     private ArticleListContract.Presenter mPresenter;
// 
//     private RecyclerView mRecyclerView;
// 
//     public ArticleListFragment() {
//         // Required empty public constructor
//     }
// 
//     @Override
//     public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
//             final Bundle savedInstanceState) {
//         mPresenter = createPresenter();
// 
//         // Inflate the layout for this fragment
//         View view = inflater.inflate(R.layout.fragment_article_list, container, false);
//         mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
//         mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
//                 false));
// 
//         view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
//                 @Override
//                 public void onClick(final View v) {
//                     mPresenter.onFavoriteArticleClick();
//                 }
//             });
// 
//         return view;
//     }
// 
//     @NonNull
//     protected ArticleListContract.Presenter createPresenter() {
//         ArticleListContract.Presenter presenter = new ArticleListPresenter();
//         presenter.setNavigator(getNavigator(presenter));
//         return presenter;
//     }
// 
//     @NonNull
//     protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
//         Fragment parentFragment = getParentFragment();
//         if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
//             return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
//         } else {
//             Activity activity = getActivity();
//             if (activity instanceof ArticleListContract.NavigatorProvider) {
//                 return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
//             }
//         }
// 
//         throw new IllegalStateException("Activity or parent Fragment must implement "
//                 + "ArticleListContract.NavigatorProvider");
//     }
// 
//     @Override
//     public void onStart() {
//         super.onStart();
//         mPresenter.onAttachView(this);
//     }
// 
//     @Override
//     public void onStop() {
//         super.onStop();
//         mPresenter.onDetachView();
//     }
// 
//     @Override
//     public void displayArticles(@NonNull final List<Article> articles,
//             @NonNull final OnArticleClickListener onArticleClickListener) {
//         mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
//     }
// }


import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
package org.kaerdan.mvp_navigation.example1_activities;





public class ArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_single_fragment);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
//     interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
//         void setNavigator(@NonNull Navigator navigator);
// 
//         void onFavoriteArticleClick();
//     }
// 
//     interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
//         void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
//     }
// 
//     interface Navigator {
//         void openArticle(int id);
// 
//         void openFavoriteArticles();
//     }
// 
//     interface NavigatorProvider {
// 
//         @NonNull
//         Navigator getNavigator(ArticleListContract.Presenter presenter);
//     }
// }
// 
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
// 
//     private ArticleListContract.Presenter mPresenter;
// 
//     private RecyclerView mRecyclerView;
// 
//     public ArticleListFragment() {
//         // Required empty public constructor
//     }
// 
//     @Override
//     public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
//             final Bundle savedInstanceState) {
//         mPresenter = createPresenter();
// 
//         // Inflate the layout for this fragment
//         View view = inflater.inflate(R.layout.fragment_article_list, container, false);
//         mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
//         mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
//                 false));
// 
//         view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
//                 @Override
//                 public void onClick(final View v) {
//                     mPresenter.onFavoriteArticleClick();
//                 }
//             });
// 
//         return view;
//     }
// 
//     @NonNull
//     protected ArticleListContract.Presenter createPresenter() {
//         ArticleListContract.Presenter presenter = new ArticleListPresenter();
//         presenter.setNavigator(getNavigator(presenter));
//         return presenter;
//     }
// 
//     @NonNull
//     protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
//         Fragment parentFragment = getParentFragment();
//         if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
//             return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
//         } else {
//             Activity activity = getActivity();
//             if (activity instanceof ArticleListContract.NavigatorProvider) {
//                 return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
//             }
//         }
// 
//         throw new IllegalStateException("Activity or parent Fragment must implement "
//                 + "ArticleListContract.NavigatorProvider");
//     }
// 
//     @Override
//     public void onStart() {
//         super.onStart();
//         mPresenter.onAttachView(this);
//     }
// 
//     @Override
//     public void onStop() {
//         super.onStop();
//         mPresenter.onDetachView();
//     }
// 
//     @Override
//     public void displayArticles(@NonNull final List<Article> articles,
//             @NonNull final OnArticleClickListener onArticleClickListener) {
//         mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
//     }
// }


// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleListActivity.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;

package org.kaerdan.mvp_navigation.example1_activities;





public class ArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_single_fragment);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.content_frame, new ArticleListFragment(), null)