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();
}
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);
}
});
}
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();
}
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);
}
});
}
Aggregations