Search in sources :

Example 6 with MaterialRefreshListener

use of com.cjj.MaterialRefreshListener in project Android-MaterialRefreshLayout by android-cjj.

the class AutoRefreshActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview);
    String[] array = new String[50];
    for (int i = 0; i < array.length; i++) {
        array[i] = "啊哈哈哈哈哈,啊哈哈 " + i;
    }
    final ListView listView = (ListView) findViewById(R.id.lv);
    listView.setAdapter(new android.widget.ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, array));
    materialRefreshLayout = (MaterialRefreshLayout) findViewById(R.id.refresh);
    materialRefreshLayout.setLoadMore(true);
    materialRefreshLayout.finishRefreshLoadMore();
    materialRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() {

        @Override
        public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {
            materialRefreshLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    materialRefreshLayout.finishRefresh();
                }
            }, 3000);
        }

        @Override
        public void onfinish() {
            Toast.makeText(AutoRefreshActivity.this, "finish", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {
            Toast.makeText(AutoRefreshActivity.this, "load more", Toast.LENGTH_LONG).show();
        }
    });
    materialRefreshLayout.autoRefresh();
}
Also used : ListView(android.widget.ListView) MaterialRefreshListener(com.cjj.MaterialRefreshListener) MaterialRefreshLayout(com.cjj.MaterialRefreshLayout)

Example 7 with MaterialRefreshListener

use of com.cjj.MaterialRefreshListener in project Android-MaterialRefreshLayout by android-cjj.

the class LoadMoreActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_list);
    initsToolbar();
    materialRefreshLayout = (MaterialRefreshLayout) findViewById(R.id.refresh);
    materialRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() {

        @Override
        public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {
            materialRefreshLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    materialRefreshLayout.finishRefresh();
                }
            }, 3000);
        }

        @Override
        public void onfinish() {
            Toast.makeText(LoadMoreActivity.this, "finish", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onRefreshLoadMore(final MaterialRefreshLayout materialRefreshLayout) {
            Toast.makeText(LoadMoreActivity.this, "load more", Toast.LENGTH_LONG).show();
            materialRefreshLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    materialRefreshLayout.finishRefreshLoadMore();
                }
            }, 3000);
        }
    });
    RecyclerView rv = (RecyclerView) findViewById(R.id.recyclerview);
    setupRecyclerView(rv);
}
Also used : MaterialRefreshListener(com.cjj.MaterialRefreshListener) MaterialRefreshLayout(com.cjj.MaterialRefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

MaterialRefreshLayout (com.cjj.MaterialRefreshLayout)7 MaterialRefreshListener (com.cjj.MaterialRefreshListener)7 RecyclerView (android.support.v7.widget.RecyclerView)3 ListView (android.widget.ListView)3