// Path: sample/src/main/java/com/example/flow/mortar/DaggerService.java
// public class DaggerService {
// 
//     public static final String SERVICE_NAME = DaggerService.class.getName();
// 
//     /**
//      * Caller is required to know the type of the component for this context.
//      */
//     @SuppressWarnings("unchecked") //
//     public static <T> T getDaggerComponent(Context context) {
//         return (T) context.getSystemService(SERVICE_NAME);
//     }
// }
// 
// Path: sample/src/main/java/com/example/flow/ui/screen/PostsScreen.java
// @Layout(R.layout.screen_posts)
// public class PostsScreen extends Path implements ComponentFactory<RootActivity.Component> {
// 
//     @Override
//     public Object createComponent(RootActivity.Component component) {
//         return DaggerPostsScreen_Component.builder()
//                 .component(component)
//                 .build();
//     }
// 
//     @dagger.Component(dependencies = RootActivity.Component.class)
//     @ScreenScope(Component.class)
//     public interface Component extends RootActivity.Component {
// 
//         void inject(PostsView view);
//     }
// 
//     @ScreenScope(Component.class)
//     public static class Presenter extends ViewPresenter<PostsView> implements PostAdapter.Listener {
// 
//         private final RestClient restClient;
// 
//         private PostAdapter adapter;
//         private List<Post> posts = new ArrayList<>();
// 
//         @Inject
//         public Presenter(RestClient restClient) {
//             this.restClient = restClient;
//         }
// 
//         @Override
//         protected void onLoad(Bundle savedInstanceState) {
//             LinearLayoutManager layoutManager = new LinearLayoutManager(getView().getContext());
//             layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//             getView().recyclerView.setLayoutManager(layoutManager);
// 
//             adapter = new PostAdapter(getView().getContext(), posts, this);
//             getView().recyclerView.setAdapter(adapter);
// 
//             if (posts.isEmpty()) {
//                 load();
//             }
//         }
// 
//         private void load() {
// 
//             restClient.getService().getPosts(new Callback<List<Post>>() {
//                 @Override
//                 public void success(List<Post> loadedPosts, Response response) {
//                     if (!hasView()) return;
//                     Timber.d("Success loaded %s", loadedPosts.size());
// 
//                     posts.clear();
//                     posts.addAll(loadedPosts);
//                     adapter.notifyDataSetChanged();
//                 }
// 
//                 @Override
//                 public void failure(RetrofitError error) {
//                     if (!hasView()) return;
//                     Timber.d("Failure %s", error.getMessage());
//                 }
//             });
//         }
// 
//         @Override
//         protected void onSave(Bundle outState) {
//             super.onSave(outState);
// 
// 
//         }
// 
//         @Override
//         public void onItemClick(int position) {
//             if (!hasView()) return;
// 
//             Post post = posts.get(position);
//             Flow.get(getView()).set(new ViewPostScreen(post));
//         }
//     }
// }


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.example.flow.R;
import com.example.flow.mortar.DaggerService;
import com.example.flow.ui.screen.PostsScreen;
import javax.inject.Inject;
import butterknife.ButterKnife;
import butterknife.InjectView;
package com.example.flow.ui.view;





/**
 * @author Lukasz Piliszczuk <lukasz.pili@gmail.com>
 */
public class PostsView extends FrameLayout {

    @InjectView(R.id.recycler_view)
    public RecyclerView recyclerView;

    @Inject
// Path: sample/src/main/java/com/example/flow/mortar/DaggerService.java
// public class DaggerService {
// 
//     public static final String SERVICE_NAME = DaggerService.class.getName();
// 
//     /**
//      * Caller is required to know the type of the component for this context.
//      */
//     @SuppressWarnings("unchecked") //
//     public static <T> T getDaggerComponent(Context context) {
//         return (T) context.getSystemService(SERVICE_NAME);
//     }
// }
// 
// Path: sample/src/main/java/com/example/flow/ui/screen/PostsScreen.java
// @Layout(R.layout.screen_posts)
// public class PostsScreen extends Path implements ComponentFactory<RootActivity.Component> {
// 
//     @Override
//     public Object createComponent(RootActivity.Component component) {
//         return DaggerPostsScreen_Component.builder()
//                 .component(component)
//                 .build();
//     }
// 
//     @dagger.Component(dependencies = RootActivity.Component.class)
//     @ScreenScope(Component.class)
//     public interface Component extends RootActivity.Component {
// 
//         void inject(PostsView view);
//     }
// 
//     @ScreenScope(Component.class)
//     public static class Presenter extends ViewPresenter<PostsView> implements PostAdapter.Listener {
// 
//         private final RestClient restClient;
// 
//         private PostAdapter adapter;
//         private List<Post> posts = new ArrayList<>();
// 
//         @Inject
//         public Presenter(RestClient restClient) {
//             this.restClient = restClient;
//         }
// 
//         @Override
//         protected void onLoad(Bundle savedInstanceState) {
//             LinearLayoutManager layoutManager = new LinearLayoutManager(getView().getContext());
//             layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//             getView().recyclerView.setLayoutManager(layoutManager);
// 
//             adapter = new PostAdapter(getView().getContext(), posts, this);
//             getView().recyclerView.setAdapter(adapter);
// 
//             if (posts.isEmpty()) {
//                 load();
//             }
//         }
// 
//         private void load() {
// 
//             restClient.getService().getPosts(new Callback<List<Post>>() {
//                 @Override
//                 public void success(List<Post> loadedPosts, Response response) {
//                     if (!hasView()) return;
//                     Timber.d("Success loaded %s", loadedPosts.size());
// 
//                     posts.clear();
//                     posts.addAll(loadedPosts);
//                     adapter.notifyDataSetChanged();
//                 }
// 
//                 @Override
//                 public void failure(RetrofitError error) {
//                     if (!hasView()) return;
//                     Timber.d("Failure %s", error.getMessage());
//                 }
//             });
//         }
// 
//         @Override
//         protected void onSave(Bundle outState) {
//             super.onSave(outState);
// 
// 
//         }
// 
//         @Override
//         public void onItemClick(int position) {
//             if (!hasView()) return;
// 
//             Post post = posts.get(position);
//             Flow.get(getView()).set(new ViewPostScreen(post));
//         }
//     }
// }


// Path: sample/src/main/java/com/example/flow/ui/view/PostsView.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.example.flow.R;
import com.example.flow.mortar.DaggerService;
import com.example.flow.ui.screen.PostsScreen;
import javax.inject.Inject;
import butterknife.ButterKnife;
import butterknife.InjectView;

package com.example.flow.ui.view;





/**
 * @author Lukasz Piliszczuk <lukasz.pili@gmail.com>
 */
public class PostsView extends FrameLayout {

    @InjectView(R.id.recycler_view)
    public RecyclerView recyclerView;

    @Inject
    protected PostsScreen.Presenter presenter;