<commit_before>package com.idogfooding.backbone.ui;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.github.clans.fab.FloatingActionButton;
import com.idogfooding.backbone.R;
import com.idogfooding.backbone.utils.ViewUtils;
import com.jude.easyrecyclerview.EasyRecyclerView;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.jude.easyrecyclerview.decoration.DividerDecoration;

/**
 * ListFragment
 *
 * @author Charles
 */
public abstract class ListFragment<T, A extends RecyclerArrayAdapter<T>> extends BaseFragment {

    private EasyRecyclerView recyclerView;
    protected FloatingActionButton btnTop;
    protected A adapter;

    protected int pageNumber = 1;

    @Override
    protected int getLayoutId() {
        return R.layout.view_list;
    }

    @Override
    protected void onSetupFragment(View view, Bundle savedInstanceState) {
        // find view
        btnTop = (FloatingActionButton) view.findViewById(R.id.btn_top);
        recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);

        btnTop.setOnClickListener(v -> recyclerView.scrollToPosition(0));

        // init recyclerView
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(layoutManager);
        DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, ViewUtils.dip2px(getContext(), 0.5f), ViewUtils.dip2px(getContext(), 72), 0);
        itemDecoration.setDrawLastItem(false);
        itemDecoration.setDrawHeaderFooter(true);
        recyclerView.addItemDecoration(itemDecoration);

        // init adapter
        createAdapter();
        recyclerView.setAdapterWithProgress(adapter);
        adapter.setOnItemClickListener(position -> onListItemClick(position, adapter.getItem(position)));
        adapter.setOnItemLongClickListener(position -> {
            onListItemLongClick(position, adapter.getItem(position));
            return true;
        });
        adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {
            @Override
            public void onErrorShow() {
                adapter.resumeMore();
            }

            @Override
            public void onErrorClick() {
                adapter.resumeMore();
            }
        });
        if (isLoadMore()) {
            adapter.setMore(R.layout.view_more, new RecyclerArrayAdapter.OnMoreListener() {
                @Override
                public void onMoreShow() {
                    loadData(false, true);
                }

                @Override
                public void onMoreClick() {

                }
            });
            adapter.setNoMore(R.layout.view_nomore, new RecyclerArrayAdapter.OnNoMoreListener() {
                @Override
                public void onNoMoreShow() {
                    adapter.resumeMore();
                }

                @Override
                public void onNoMoreClick() {
                    adapter.resumeMore();
                }
            });
        }
        if (isRefreshable()) {
            recyclerView.setRefreshListener(() -> loadData(true, false));
        }

        initHeaderAndFooterView();

        loadData(false, false);
    }

    protected abstract void createAdapter();

    protected void onListItemClick(int position, T data) {}

    protected void onListItemLongClick(int position, T data) {}

    protected boolean isLoadMore() {
        return true;
    }

    protected boolean isRefreshable() {
        return true;
    }

    protected void initHeaderAndFooterView() {

    }

    protected void loadData(boolean refresh, boolean loadMore) {
        if (refresh) {
            pageNumber = 1;
        }
    }

}
<commit_msg>add db service<commit_after>package com.idogfooding.backbone.ui;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.github.clans.fab.FloatingActionButton;
import com.idogfooding.backbone.R;
import com.idogfooding.backbone.utils.ViewUtils;
import com.jude.easyrecyclerview.EasyRecyclerView;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.jude.easyrecyclerview.decoration.DividerDecoration;

/**
 * ListFragment
 *
 * @author Charles
 */
public abstract class ListFragment<T, A extends RecyclerArrayAdapter<T>> extends BaseFragment {

    protected EasyRecyclerView recyclerView;
    protected FloatingActionButton btnTop;
    protected A adapter;

    protected int pageNumber = 1;

    @Override
    protected int getLayoutId() {
        return R.layout.view_list;
    }

    @Override
    protected void onSetupFragment(View view, Bundle savedInstanceState) {
        // find view
        btnTop = (FloatingActionButton) view.findViewById(R.id.btn_top);
        recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);

        btnTop.setOnClickListener(v -> recyclerView.scrollToPosition(0));

        // init recyclerView
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(layoutManager);
        DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, ViewUtils.dip2px(getContext(), 0.5f), ViewUtils.dip2px(getContext(), 72), 0);
        itemDecoration.setDrawLastItem(false);
        itemDecoration.setDrawHeaderFooter(true);
        recyclerView.addItemDecoration(itemDecoration);

        // init adapter
        createAdapter();
        recyclerView.setAdapterWithProgress(adapter);
        adapter.setOnItemClickListener(position -> onListItemClick(position, adapter.getItem(position)));
        adapter.setOnItemLongClickListener(position -> {
            onListItemLongClick(position, adapter.getItem(position));
            return true;
        });
        adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {
            @Override
            public void onErrorShow() {
                adapter.resumeMore();
            }

            @Override
            public void onErrorClick() {
                adapter.resumeMore();
            }
        });
        if (isLoadMore()) {
            adapter.setMore(R.layout.view_more, new RecyclerArrayAdapter.OnMoreListener() {
                @Override
                public void onMoreShow() {
                    loadData(false, true);
                }

                @Override
                public void onMoreClick() {

                }
            });
            adapter.setNoMore(R.layout.view_nomore, new RecyclerArrayAdapter.OnNoMoreListener() {
                @Override
                public void onNoMoreShow() {
                    adapter.resumeMore();
                }

                @Override
                public void onNoMoreClick() {
                    adapter.resumeMore();
                }
            });
        }
        if (isRefreshable()) {
            recyclerView.setRefreshListener(() -> loadData(true, false));
        }

        initHeaderAndFooterView();

        loadData(false, false);
    }

    protected abstract void createAdapter();

    protected void onListItemClick(int position, T data) {}

    protected void onListItemLongClick(int position, T data) {}

    protected boolean isLoadMore() {
        return true;
    }

    protected boolean isRefreshable() {
        return true;
    }

    protected void initHeaderAndFooterView() {

    }

    protected void loadData(boolean refresh, boolean loadMore) {
        if (refresh) {
            pageNumber = 1;
        }
    }

}

{'fraction_non_alphanumeric': 0.09070825211176088, 'fraction_numerical': 0.0028589993502274205, 'mean_word_length': 2.3680525164113786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '257134', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2006, 'n_words': 380}