Search in sources :

Example 11 with SwipeRefreshLayout

use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project IITB-App by wncc.

the class NewsFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
    toolbar.setTitle("News");
    Utils.setSelectedMenuItem(getActivity(), R.id.nav_news);
    setHasOptionsMenu(true);
    updateData();
    postType = NewsArticle.class;
    adapterType = NewsAdapter.class;
    recyclerView = getActivity().findViewById(R.id.news_recycler_view);
    swipeRefreshLayout = getActivity().findViewById(R.id.news_swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            updateData();
        }
    });
}
Also used : SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 12 with SwipeRefreshLayout

use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project IITB-App by wncc.

the class PlacementBlogFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
    toolbar.setTitle("Placement Blog");
    Utils.setSelectedMenuItem(getActivity(), R.id.nav_placement_blog);
    setHasOptionsMenu(true);
    updateData();
    postType = PlacementBlogPost.class;
    adapterType = PlacementBlogAdapter.class;
    recyclerView = getActivity().findViewById(R.id.placement_feed_recycler_view);
    swipeRefreshLayout = getActivity().findViewById(R.id.placement_feed_swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            updateData();
        }
    });
}
Also used : SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 13 with SwipeRefreshLayout

use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project IITB-App by wncc.

the class TrainingBlogFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
    toolbar.setTitle("Internship Blog");
    Utils.setSelectedMenuItem(getActivity(), R.id.nav_training_blog);
    setHasOptionsMenu(true);
    updateData();
    postType = TrainingBlogPost.class;
    adapterType = TrainingBlogAdapter.class;
    recyclerView = getActivity().findViewById(R.id.training_feed_recycler_view);
    swipeRefreshLayout = getActivity().findViewById(R.id.training_feed_swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            updateData();
        }
    });
}
Also used : SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 14 with SwipeRefreshLayout

use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project SherlockAdapter by EvilBT.

the class MultiItemActivity method initView.

private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mGridLayoutManager = new GridLayoutManager(this, 3);
    mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
    mRecyclerView = (RecyclerView) findViewById(R.id.list);
    mRecyclerView.setLayoutManager(mGridLayoutManager);
    mIsGrid = true;
    mAdapter = new MyMultiAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(@NonNull View view, final int adapterPosition) {
            new AlertDialog.Builder(MultiItemActivity.this).setTitle("是否删除第" + adapterPosition + "项").setPositiveButton("确定", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mAdapter.removeData(adapterPosition);
                }
            }).setNegativeButton("取消", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).create().show();
            return true;
        }
    });
    mData = new ArrayList<>();
    initGridData();
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            refreshLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mAdapter.setData(mData);
                    refreshLayout.setRefreshing(false);
                }
            }, 500);
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) OnItemLongClickListener(xyz.zpayh.adapter.OnItemLongClickListener) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) MyMultiAdapter(xyz.zpayh.myadapter.adapter.MyMultiAdapter) Toolbar(androidx.appcompat.widget.Toolbar)

Example 15 with SwipeRefreshLayout

use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project SherlockAdapter by EvilBT.

the class AutoLoadMoreActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_auto_load_more);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new AutoLoadAdapter(this);
    recyclerView.setAdapter(mAdapter);
    final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
    mAdapter.setAlwaysShowHead(true);
    mAdapter.setAlwaysShowFoot(true);
    mAdapter.addHeadLayout(R.layout.item_head);
    mAdapter.addFootLayout(R.layout.item_foot2);
    // 模拟数据
    data = new ArrayList<>();
    for (int i = 0; i < mTitles.length; i++) {
        ImageCard card = new ImageCard(mImageResId[i], mTitles[i]);
        data.add(card);
    }
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            // 模拟刷新
            recyclerView.postDelayed(new Runnable() {

                @Override
                public void run() {
                    refreshLayout.setRefreshing(false);
                    mAdapter.setData(data);
                }
            }, 500);
        }
    });
    // 必须设置事件监听与开启auto
    mAdapter.openAutoLoadMore(true);
    mAdapter.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            Log.d("Sherlock", "加载更多");
            // 模拟加载更多
            recyclerView.postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mState == LOAD_ADD) {
                        mAdapter.addData(data);
                    } else if (mState == LOAD_COMPLETED) {
                        mAdapter.loadCompleted();
                    } else if (mState == LOAD_FAILED) {
                        mAdapter.loadFailed();
                    }
                }
            }, 800);
        }
    });
    findViewById(R.id.action_add).setOnClickListener(this);
    findViewById(R.id.action_failed).setOnClickListener(this);
    findViewById(R.id.action_completed).setOnClickListener(this);
    findViewById(R.id.action_empty).setOnClickListener(this);
    findViewById(R.id.action_close).setOnClickListener(this);
    mShowHead = (CheckBox) findViewById(R.id.cb_show_head);
    mShowFoot = (CheckBox) findViewById(R.id.cb_show_foot);
    mShowHead.setChecked(true);
    mShowFoot.setChecked(true);
    mShowHead.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mAdapter.setAlwaysShowHead(isChecked);
        }
    });
    mShowFoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mAdapter.setAlwaysShowFoot(isChecked);
        }
    });
}
Also used : OnLoadMoreListener(xyz.zpayh.adapter.OnLoadMoreListener) AutoLoadAdapter(xyz.zpayh.myadapter.adapter.AutoLoadAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) ImageCard(xyz.zpayh.myadapter.data.ImageCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) CompoundButton(android.widget.CompoundButton)

Aggregations

SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)41 RecyclerView (androidx.recyclerview.widget.RecyclerView)20 View (android.view.View)19 ToolbarScrollHideHandler (me.ccrama.redditslide.handler.ToolbarScrollHideHandler)10 Toolbar (androidx.appcompat.widget.Toolbar)9 FastScroller (eu.davidea.fastscroller.FastScroller)8 FlexibleItemDecoration (eu.davidea.flexibleadapter.common.FlexibleItemDecoration)8 CatchStaggeredGridLayoutManager (me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager)8 PreCachingLayoutManager (me.ccrama.redditslide.Views.PreCachingLayoutManager)8 DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)7 ExampleAdapter (eu.davidea.samples.flexibleadapter.ExampleAdapter)7 ScrollableUseCaseItem (eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem)7 Bundle (android.os.Bundle)6 Intent (android.content.Intent)5 Handler (android.os.Handler)5 TextView (android.widget.TextView)5 ContributionAdapter (me.ccrama.redditslide.Adapters.ContributionAdapter)5 Context (android.content.Context)4 NonNull (androidx.annotation.NonNull)4 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)4