use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project SmartRefreshLayout by scwang90.
the class BottomSheetExampleFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState);
final Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
}
});
RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(new ClassicsHeader(getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind).setPrimaryColorId(R.color.colorPrimary).setAccentColorId(android.R.color.white));
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull final RefreshLayout refreshLayout) {
refreshLayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.loadMore(initData());
refreshLayout.finishLoadMore();
}
}, 2000);
}
});
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<Void>(initData(), 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);
}
});
((ViewGroup) refreshLayout.getLayout().getParent()).removeView(refreshLayout.getLayout());
BottomSheetDialog dialog = new BottomSheetDialog(getContext());
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
getActivity().finish();
}
});
dialog.setContentView(refreshLayout.getLayout());
dialog.show();
}
use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project SmartRefreshLayout by scwang90.
the class NestedScrollExampleFragment 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();
}
});
final BaseRecyclerAdapter<Item> adapter;
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(adapter = new BaseRecyclerAdapter<Item>(Arrays.asList(Item.values()), simple_list_item_2, NestedScrollExampleFragment.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);
}
});
if (mNestedPager) {
final Runnable loadMore = new Runnable() {
@Override
public void run() {
adapter.loadMore(Arrays.asList(Item.values()));
adapter.loadMore(Arrays.asList(Item.values()));
adapter.loadMore(Arrays.asList(Item.values()));
adapter.loadMore(Arrays.asList(Item.values()));
adapter.loadMore(Arrays.asList(Item.values()));
adapter.loadMore(Arrays.asList(Item.values()));
adapter.loadMore(Arrays.asList(Item.values()));
}
};
final RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
refreshLayout.setEnableFooterFollowWhenLoadFinished(true);
refreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
if (adapter.getItemCount() < 20) {
loadMore.run();
refreshLayout.finishLoadMore(2000);
} else {
refreshLayout.finishLoadMoreWithNoMoreData();
}
}
});
loadMore.run();
}
/*
* 监听 AppBarLayout 的关闭和开启 ActionButton 设置关闭隐藏动画
*/
AppBarLayout appBarLayout = (AppBarLayout) root.findViewById(R.id.appbar);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
boolean misAppbarExpand = true;
View fab = root.findViewById(R.id.fab);
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
int scrollRange = appBarLayout.getTotalScrollRange();
float fraction = 1f * (scrollRange + verticalOffset) / scrollRange;
if (fraction < 0.1 && misAppbarExpand) {
misAppbarExpand = false;
fab.animate().scaleX(0).scaleY(0);
}
if (fraction > 0.8 && !misAppbarExpand) {
misAppbarExpand = true;
fab.animate().scaleX(1).scaleY(1);
}
}
});
}
use of com.scwang.smartrefresh.layout.listener.OnLoadmoreListener in project SmartRefreshLayout by scwang90.
the class BannerPracticeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_practice_banner);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
mAdapter = new QuickAdapter();
recyclerView.addItemDecoration(new DividerItemDecoration(this, VERTICAL));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(mAdapter);
final List<Movie> movies = new Gson().fromJson(JSON_MOVIES, new TypeToken<ArrayList<Movie>>() {
}.getType());
mAdapter.replaceData(movies);
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull final RefreshLayout refreshLayout) {
refreshLayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
if (mAdapter.getItemCount() < 2) {
List<Movie> movies = new Gson().fromJson(JSON_MOVIES, new TypeToken<ArrayList<Movie>>() {
}.getType());
mAdapter.replaceData(movies);
}
refreshLayout.finishRefresh();
}
}, 2000);
}
});
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
mAdapter.addData(movies);
refreshLayout.finishLoadMoreWithNoMoreData();
}
});
// 添加Header
View header = LayoutInflater.from(this).inflate(R.layout.listitem_movie_header, recyclerView, false);
Banner banner = (Banner) header;
banner.setImageLoader(new GlideImageLoader());
banner.setImages(BANNER_ITEMS);
banner.start();
mAdapter.addHeaderView(banner);
mAdapter.openLoadAnimation();
// 状态栏透明和间距处理
StatusBarUtil.immersive(this);
StatusBarUtil.setPaddingSmart(this, toolbar);
StatusBarUtil.setPaddingSmart(this, recyclerView);
StatusBarUtil.setMargin(this, findViewById(R.id.header));
StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurView));
}
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();
}
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();
}
Aggregations