// Path: app/src/main/java/com/ge/protein/ui/epoxy/ProteinAdapter.java
// public class ProteinAdapter extends EpoxyAdapter {
// 
//     private final LoadMoreModel loadMoreModel;
// 
//     public ProteinAdapter() {
//         loadMoreModel = new LoadMoreModel_();
//     }
// 
//     public void swap(Collection<? extends EpoxyModel<?>> epoxyModels) {
//         removeAllModels();
//         addModels(epoxyModels);
//     }
// 
//     public void addMore(Collection<? extends EpoxyModel<?>> epoxyModels) {
//         addModels(epoxyModels);
//     }
// 
//     public void addModel(EpoxyModel<?> modelToAdd) {
//         super.addModel(modelToAdd);
//     }
// 
//     public void showLoadMore(boolean visible) {
//         if (visible) {
//             addModel(loadMoreModel);
//         } else {
//             removeModel(loadMoreModel);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/ui/epoxy/RecyclerViewObserver.java
// public class RecyclerViewObserver {
// 
//     private RecyclerView recyclerView;
//     private RecyclerView.LayoutManager layoutManager;
// 
//     private boolean loading;
// 
//     private OnLoadMoreListener onLoadMoreListener;
// 
//     public RecyclerViewObserver subscribeOn(RecyclerView recyclerView) {
//         this.recyclerView = recyclerView;
//         return this;
//     }
// 
//     public void unSubscribe() {
//         recyclerView = null;
//         onLoadMoreListener = null;
//     }
// 
//     public RecyclerViewObserver setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
//         this.onLoadMoreListener = onLoadMoreListener;
//         return this;
//     }
// 
//     public void setLoading(boolean loading) {
//         this.loading = loading;
//     }
// 
//     public boolean isLoading() {
//         return loading;
//     }
// 
//     public RecyclerViewObserver initialize() {
//         layoutManager = recyclerView.getLayoutManager();
//         if (!(layoutManager instanceof LinearLayoutManager)) {
//             throw new IllegalArgumentException("Support only LinearLayoutManager now.");
//         }
//         recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
//             @Override
//             public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//                 super.onScrolled(recyclerView, dx, dy);
// 
//                 int totalItemCount = recyclerView.getAdapter().getItemCount();
//                 int lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
// 
//                 if (!loading && lastVisibleItemPosition == (totalItemCount - 1)) {
//                     if (onLoadMoreListener != null) {
//                         Log.d("RecyclerViewObserver", "onLoadMore");
//                         onLoadMoreListener.onLoadMore();
//                     }
//                 }
//             }
//         });
// 
//         return this;
//     }
// 
//     public interface OnLoadMoreListener {
//         void onLoadMore();
//     }
// 
// }


import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.airbnb.epoxy.EpoxyModel;
import com.ge.protein.R;
import com.ge.protein.ui.epoxy.ProteinAdapter;
import com.ge.protein.ui.epoxy.RecyclerViewObserver;
import java.util.Collection;
import butterknife.BindView;
import butterknife.ButterKnife;
/*
 * Copyright 2017 Jiaheng Ge
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ge.protein.mvp;





/**
 * Base list fragment implemented with {@link RecyclerView}.
 */
public abstract class ListFragment extends BaseFragment implements
        SwipeRefreshLayout.OnRefreshListener, ListContract.View<ListContract.Presenter> {

    @BindView(R.id.toolbar)
    protected Toolbar toolbar;
    @BindView(R.id.swipe_refresh_layout)
    protected SwipeRefreshLayout swipeRefreshLayout;
    @BindView(R.id.recycler_view)
    protected RecyclerView recyclerView;
    @BindView(R.id.empty_view)
    protected View emptyView;
    @BindView(R.id.error_view)
    protected View errorView;
    @BindView(R.id.button_retry)
    protected Button retry;

    protected ListContract.Presenter listPresenter;

    protected ProteinAdapter proteinAdapter;
// Path: app/src/main/java/com/ge/protein/ui/epoxy/ProteinAdapter.java
// public class ProteinAdapter extends EpoxyAdapter {
// 
//     private final LoadMoreModel loadMoreModel;
// 
//     public ProteinAdapter() {
//         loadMoreModel = new LoadMoreModel_();
//     }
// 
//     public void swap(Collection<? extends EpoxyModel<?>> epoxyModels) {
//         removeAllModels();
//         addModels(epoxyModels);
//     }
// 
//     public void addMore(Collection<? extends EpoxyModel<?>> epoxyModels) {
//         addModels(epoxyModels);
//     }
// 
//     public void addModel(EpoxyModel<?> modelToAdd) {
//         super.addModel(modelToAdd);
//     }
// 
//     public void showLoadMore(boolean visible) {
//         if (visible) {
//             addModel(loadMoreModel);
//         } else {
//             removeModel(loadMoreModel);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/ui/epoxy/RecyclerViewObserver.java
// public class RecyclerViewObserver {
// 
//     private RecyclerView recyclerView;
//     private RecyclerView.LayoutManager layoutManager;
// 
//     private boolean loading;
// 
//     private OnLoadMoreListener onLoadMoreListener;
// 
//     public RecyclerViewObserver subscribeOn(RecyclerView recyclerView) {
//         this.recyclerView = recyclerView;
//         return this;
//     }
// 
//     public void unSubscribe() {
//         recyclerView = null;
//         onLoadMoreListener = null;
//     }
// 
//     public RecyclerViewObserver setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
//         this.onLoadMoreListener = onLoadMoreListener;
//         return this;
//     }
// 
//     public void setLoading(boolean loading) {
//         this.loading = loading;
//     }
// 
//     public boolean isLoading() {
//         return loading;
//     }
// 
//     public RecyclerViewObserver initialize() {
//         layoutManager = recyclerView.getLayoutManager();
//         if (!(layoutManager instanceof LinearLayoutManager)) {
//             throw new IllegalArgumentException("Support only LinearLayoutManager now.");
//         }
//         recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
//             @Override
//             public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//                 super.onScrolled(recyclerView, dx, dy);
// 
//                 int totalItemCount = recyclerView.getAdapter().getItemCount();
//                 int lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
// 
//                 if (!loading && lastVisibleItemPosition == (totalItemCount - 1)) {
//                     if (onLoadMoreListener != null) {
//                         Log.d("RecyclerViewObserver", "onLoadMore");
//                         onLoadMoreListener.onLoadMore();
//                     }
//                 }
//             }
//         });
// 
//         return this;
//     }
// 
//     public interface OnLoadMoreListener {
//         void onLoadMore();
//     }
// 
// }


// Path: app/src/main/java/com/ge/protein/mvp/ListFragment.java
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.airbnb.epoxy.EpoxyModel;
import com.ge.protein.R;
import com.ge.protein.ui.epoxy.ProteinAdapter;
import com.ge.protein.ui.epoxy.RecyclerViewObserver;
import java.util.Collection;
import butterknife.BindView;
import butterknife.ButterKnife;

/*
 * Copyright 2017 Jiaheng Ge
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ge.protein.mvp;





/**
 * Base list fragment implemented with {@link RecyclerView}.
 */
public abstract class ListFragment extends BaseFragment implements
        SwipeRefreshLayout.OnRefreshListener, ListContract.View<ListContract.Presenter> {

    @BindView(R.id.toolbar)
    protected Toolbar toolbar;
    @BindView(R.id.swipe_refresh_layout)
    protected SwipeRefreshLayout swipeRefreshLayout;
    @BindView(R.id.recycler_view)
    protected RecyclerView recyclerView;
    @BindView(R.id.empty_view)
    protected View emptyView;
    @BindView(R.id.error_view)
    protected View errorView;
    @BindView(R.id.button_retry)
    protected Button retry;

    protected ListContract.Presenter listPresenter;

    protected ProteinAdapter proteinAdapter;
    protected RecyclerViewObserver recyclerViewObserver;