Search in sources :

Example 6 with OnLoadmoreListener

use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project weibo by dingdangmao123.

the class WeicoFG method CreateView.

@Override
public void CreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, View v) {
    target.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            msg.hide(false);
            Intent i = new Intent(getActivity(), Message.class);
            startActivity(i);
        }
    });
    title.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final EasyPopup mCirclePop;
            mCirclePop = new EasyPopup(getActivity()).setContentView(R.layout.popmenu).setFocusAndOutsideEnable(true).createPopup();
            TextView t1 = mCirclePop.getView(R.id.t1);
            TextView t2 = mCirclePop.getView(R.id.t2);
            TextView t3 = mCirclePop.getView(R.id.t3);
            t1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "new";
                    if (current != 1) {
                        reset = true;
                        current = 1;
                    } else {
                        reset = false;
                    }
                    title.setText("最新微博");
                    Refresh(1);
                }
            });
            t2.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "hot";
                    if (current != 2) {
                        reset = true;
                        current = 2;
                    } else {
                        reset = false;
                    }
                    title.setText("热门微博");
                    Refresh(1);
                }
            });
            t3.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "care";
                    if (current != 3) {
                        reset = true;
                        current = 3;
                    } else {
                        reset = false;
                    }
                    title.setText("我关注的");
                    Refresh(1);
                }
            });
            mCirclePop.showAtAnchorView(v, VerticalGravity.BELOW, HorizontalGravity.ALIGN_LEFT, 0, 0);
        }
    });
    adapter = new WeicoAdapter(data, getActivity());
    tl.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh(1);
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            Refresh(0);
        }
    });
    msg = new QBadgeView(getActivity());
    msg.bindTarget(target).setBadgeGravity(Gravity.END | Gravity.TOP);
    getMessage();
    rf.autoRefresh();
}
Also used : Message(com.gapcoder.weico.Message.Message) Intent(android.content.Intent) QBadgeView(q.rorbin.badgeview.QBadgeView) EasyPopup(com.zyyoona7.lib.EasyPopup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) QBadgeView(q.rorbin.badgeview.QBadgeView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) TextView(android.widget.TextView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) WeicoAdapter(com.gapcoder.weico.Index.Adapter.WeicoAdapter)

Example 7 with OnLoadmoreListener

use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project weibo by dingdangmao123.

the class UserList method init.

@Override
public void init() {
    if ((uid = getIntent().getIntExtra("uid", 0)) == 0)
        return;
    type = getIntent().getStringExtra("type");
    if (type.equals("fans"))
        title.setText("粉丝");
    else
        title.setText("关注");
    adapter = new UserListAdapter(data, this);
    tl.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh(1);
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            Refresh(0);
        }
    });
    rf.autoRefresh();
}
Also used : SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Example 8 with OnLoadmoreListener

use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project yoo_home_Android by culturer.

the class RecommendFragment method initRefresh.

private void initRefresh() {
    final RefreshLayout refreshLayout = contentView.findViewById(R.id.mrefreshLayout);
    refreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            // 传入false表示刷新失败
            refreshlayout.finishRefresh(2000);
            refresh(refreshlayout);
        }
    });
    refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            loadMore(refreshlayout);
            // 传入false表示加载失败
            refreshlayout.finishLoadmore(2000);
        }
    });
}
Also used : RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Example 9 with OnLoadmoreListener

use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project SmartRefreshLayout by scwang90.

the class BasicExampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_example_basic);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    AbsListView listView = (AbsListView) findViewById(R.id.listView);
    listView.setAdapter(mAdapter = new BaseRecyclerAdapter<Void>(simple_list_item_2) {

        @Override
        protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) {
            holder.text(android.R.id.text1, getString(R.string.item_example_number_title, position));
            holder.text(android.R.id.text2, getString(R.string.item_example_number_abstract, position));
            holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
        }
    });
    mAdapter.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            BottomSheetDialog dialog = new BottomSheetDialog(BasicExampleActivity.this);
            View dialogView = View.inflate(BasicExampleActivity.this, R.layout.activity_example_basic, null);
            dialog.setContentView(dialogView);
            AbsListView listView = (AbsListView) dialogView.findViewById(R.id.listView);
            listView.setAdapter(mAdapter);
            ViewGroup parentGroup = (ViewGroup) listView.getParent();
            parentGroup.removeView(listView);
            // ViewGroup parentRoot = (ViewGroup) parentGroup.getParent();
            // parentRoot.removeView(parentGroup);
            RecyclerView recyclerView = new RecyclerView(BasicExampleActivity.this);
            recyclerView.setLayoutManager(new LinearLayoutManager(BasicExampleActivity.this));
            recyclerView.setAdapter(mAdapter);
            ((SmartRefreshLayout) parentGroup).setEnableRefresh(false);
            // ((SmartRefreshLayout) parentGroup).startNestedScroll(0);
            // ((SmartRefreshLayout) parentGroup).setEnableOverScrollDrag(false);
            ((SmartRefreshLayout) parentGroup).setRefreshContent(recyclerView);
            // parentRoot.addView(recyclerView, -1, -1);
            dialog.show();
        }
    });
    final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
    // 开启自动加载功能(非必须)
    refreshLayout.setEnableAutoLoadMore(true);
    refreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(@NonNull final RefreshLayout refreshLayout) {
            refreshLayout.getLayout().postDelayed(new Runnable() {

                @Override
                public void run() {
                    mAdapter.refresh(initData());
                    refreshLayout.finishRefresh();
                    refreshLayout.setNoMoreData(false);
                }
            }, 2000);
        }
    });
    refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull final RefreshLayout refreshLayout) {
            refreshLayout.getLayout().postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mAdapter.getItemCount() > 30) {
                        Toast.makeText(getApplication(), "数据全部加载完毕", Toast.LENGTH_SHORT).show();
                        // 将不会再次触发加载更多事件
                        refreshLayout.finishLoadMoreWithNoMoreData();
                    } else {
                        mAdapter.loadMore(initData());
                        refreshLayout.finishLoadMore();
                    }
                }
            }, 2000);
        }
    });
    // 触发自动刷新
    refreshLayout.autoRefresh();
}
Also used : OnLoadMoreListener(com.scwang.smartrefresh.layout.listener.OnLoadMoreListener) SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) BaseRecyclerAdapter(com.scwang.refreshlayout.adapter.BaseRecyclerAdapter) BottomSheetDialog(android.support.design.widget.BottomSheetDialog) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) Toolbar(android.support.v7.widget.Toolbar)

Example 10 with OnLoadmoreListener

use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project SmartRefreshLayout by scwang90.

the class NestedScrollExampleFragmentIntegral method onViewCreated.

@Override
public void onViewCreated(@NonNull final View root, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(root, savedInstanceState);
    Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    Banner banner = (Banner) root.findViewById(R.id.banner);
    banner.setImageLoader(new BannerImageLoader());
    banner.setImages(Arrays.asList(image_weibo_home_2, gif_header_repast));
    banner.start();
    RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recyclerView);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
    recyclerView.setAdapter(mAdapter = new BaseRecyclerAdapter<Item>(buildItems(), simple_list_item_2, NestedScrollExampleFragmentIntegral.this) {

        @Override
        protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
            holder.text(android.R.id.text1, model.name());
            holder.text(android.R.id.text2, model.name);
            holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
        }
    });
    RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
    refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull final RefreshLayout refreshLayout) {
            refreshLayout.getLayout().postDelayed(new Runnable() {

                @Override
                public void run() {
                    mAdapter.loadMore(buildItems());
                    refreshLayout.finishLoadMore();
                }
            }, 2000);
        }
    });
}
Also used : OnLoadMoreListener(com.scwang.smartrefresh.layout.listener.OnLoadMoreListener) SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) Banner(com.youth.banner.Banner) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) BaseRecyclerAdapter(com.scwang.refreshlayout.adapter.BaseRecyclerAdapter) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Item(com.scwang.refreshlayout.fragment.example.NestedScrollExampleFragment.Item) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)14 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)13 OnLoadmoreListener (com.scwang.smartrefresh.layout.listener.OnLoadmoreListener)12 OnRefreshListener (com.scwang.smartrefresh.layout.listener.OnRefreshListener)12 RecyclerView (android.support.v7.widget.RecyclerView)6 View (android.view.View)6 Toolbar (android.support.v7.widget.Toolbar)5 OnLoadMoreListener (com.scwang.smartrefresh.layout.listener.OnLoadMoreListener)5 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)4 AdapterView (android.widget.AdapterView)4 BaseRecyclerAdapter (com.scwang.refreshlayout.adapter.BaseRecyclerAdapter)4 SmartViewHolder (com.scwang.refreshlayout.adapter.SmartViewHolder)4 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3 WeicoAdapter (com.gapcoder.weico.Index.Adapter.WeicoAdapter)3 Intent (android.content.Intent)2 BottomSheetDialog (android.support.design.widget.BottomSheetDialog)2 ViewGroup (android.view.ViewGroup)2 AbsListView (android.widget.AbsListView)2 ImageView (android.widget.ImageView)2