Open meness opened 9 years ago
You need to extend UltimateAdapter or you can achieve the feature in your adapter
@cymcsg I'm extending that but I couldn't find how to add a progressbar. Can you please give me an example of adding a progressbar? thanks.
@cymcsg Please help me with adding a progressbar to the recyclerview when the load more option is enabled.
In fact SimpleAdapter is an Adapter which extends UltimateAdapter.The loading more view has been defined as customLoadMoreView.
I wrote following codes in my adapter which extends the UltimateViewAdapter
but the ProgressBar
not showing. Please give me a clear example.
@Override
public View getCustomLoadMoreView() {
super.getCustomLoadMoreView();
View view = View.inflate(context, R.layout.progress_item, null);
return view;
}
And the ProgressBar
layout content is
<?xml version="1.0" encoding="utf-8"?>
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.Holo.ProgressBar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:indeterminate="true"/>
I had read that! I really don't know why you don't give me an clear example! In than simple example, the ProgressBar
has defined, but has no usage. So that progress bar will not be used by default. This is my idea. If I'm wrong, please guide me or the best idea is, write about adding progress bar in the documentation clearly. Thanks. I'm waiting for a good answer from you since 4 days ago! Please help me! Thanks.
Because I do not know about your code.Have you used enableloadmore
method in your demo?
I'm really thankful for your time. I give you my adapter and its usage. Please take a look at them and let me know how to add progress bar on load more.
UltimateRecyclerView recyclerView = (UltimateRecyclerView) rootView.findViewById(R.id.urv);
PersonTimelineAdapter mAdapter = new PersonTimelineAdapter(getActivity(), myItems);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.enableLoadmore();
recyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
// load more data
}
});
public class PersonTimelineAdapter extends UltimateViewAdapter < CellFeedViewHolder > {
public PersonTimelineAdapter(Context context,
List < CompactPostPerson > postList) {
this.context = context;
mPosts = postList;
}
@Override
public CellFeedViewHolder getViewHolder(View view) {
return new CellFeedViewHolder(view,
false);
}
@Override
public CellFeedViewHolder onCreateViewHolder(ViewGroup viewGroup) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.fppt,
viewGroup,
false);
CellFeedViewHolder cellFeedViewHolder = new CellFeedViewHolder(view,
true);
return cellFeedViewHolder;
}
@Override
public void onBindViewHolder(CellFeedViewHolder viewHolder,
int position) {
// ...
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup viewGroup) {
return null;
}
@Override
public int getItemCount() {
super.getItemCount();
return mPosts.size();
}
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
}
@Override
public int getAdapterItemCount() {
return mPosts.size();
}
@Override
public long generateHeaderId(int i) {
return 0;
}
public static class CellFeedViewHolder extends UltimateRecyclerviewViewHolder {
@Bind(R.id.image_view_post_picture)
NetworkImageView postPicture;
public CellFeedViewHolder(View view, boolean isItem) {
super(view);
if (isItem) {
ButterKnife.bind(this, view);
}
}
}
}
public class Test extends Activity {
TestAdapter simpleRecyclerViewAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final List<String> stringList = new ArrayList<>();
stringList.add("111");
stringList.add("aaa");
stringList.add("222");
stringList.add("33");
stringList.add("44");
stringList.add("55");
simpleRecyclerViewAdapter = new TestAdapter(stringList);
UltimateRecyclerView ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
ultimateRecyclerView.setHasFixedSize(false);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
ultimateRecyclerView.setLayoutManager(linearLayoutManager);
ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
ultimateRecyclerView.enableLoadmore();
simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this)
.inflate(R.layout.custom_bottom_progressbar, null));
ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
}
}, 1000);
}
});
}
}
ublic class TestAdapter extends UltimateViewAdapter<TestAdapter.SimpleAdapterViewHolder> {
private List<String> stringList;
public TestAdapter(List<String> stringList) {
this.stringList = stringList;
}
@Override
public SimpleAdapterViewHolder getViewHolder(View view) {
return new SimpleAdapterViewHolder(view, false);
}
@Override
public SimpleAdapterViewHolder onCreateViewHolder(ViewGroup parent) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_view_adapter, parent, false);
SimpleAdapterViewHolder vh = new SimpleAdapterViewHolder(v, true);
return vh;
}
@Override
public int getAdapterItemCount() {
return stringList.size();
}
@Override
public long generateHeaderId(int position) {
return 0;
}
@Override
public void onBindViewHolder(SimpleAdapterViewHolder holder, int position) {
if (position < getItemCount() && (customHeaderView != null ? position <= stringList.size() : position < stringList.size()) && (customHeaderView != null ? position > 0 : true)) {
((SimpleAdapterViewHolder) holder).textViewSample.setText(stringList.get(customHeaderView != null ? position - 1 : position));
}
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
return null;
}
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int position) {
}
public class SimpleAdapterViewHolder extends UltimateRecyclerviewViewHolder {
TextView textViewSample;
ImageView imageViewSample;
public SimpleAdapterViewHolder(View itemView, boolean isItem) {
super(itemView);
if (isItem) {
textViewSample = (TextView) itemView.findViewById(
R.id.textview);
imageViewSample = (ImageView) itemView.findViewById(R.id.imageview);
}
}
@Override
public void onItemSelected() {
}
@Override
public void onItemClear() {
}
}
}
I have written a sample for just this.I think it'll help you.
Can you check this, UltimateViewAdapter.setCustomLoadMoreView()
works with UltimateViewAdapter
but not with MultiViewTypesRecyclerViewAdapter
. When I scroll down, recycler view still loads more but there's not custom footer view.
@kientux MultiViewTypesRecyclerViewAdapter
do not have full feature of UltimateViewAdapter
in current version.It's need some time to improve it.
Hi,
I'm using this library for the endless list but I don't know how to add the progressbar to the list. How can I add a progressbar?