I am facing a problem to hide RecyclerView. From Last 2 night's I am looking for the solution but I have failed to find it.
I am using firebase recycleradapter to show value in recyclerview. When ever someone click the viewholderitem i save his Uid under the datasnapshot key.
So to show the value if datasnapshot don't have the uid key show the value in recyclerview. If the datasnapshot have the uid key don't show his data . everything works fine . But i want to hide the recyclerview and show a textview when every datasnapshot have the uid key and there is nothing to show in the recyclerview. My problem is in the last line . I can't hide the recyclerview and how the textview.
FirebaseRecyclerOptions options = new FirebaseRecyclerOptions.Builder<ViewsAdapter>()
.setQuery(ViewsRef,ViewsAdapter.class)
.build();
adapter = new FirebaseRecyclerAdapter<ViewsAdapter, ViewsAdapterHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull final ViewsAdapterHolder holder, int position, @NonNull ViewsAdapter model) {
String userIds = getRef(position).getKey();
assert userIds != null;
ViewsRef.child(userIds).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.hasChild(Uid)){
Long date = dataSnapshot.child(Uid).getValue(Long.class);
assert date != null;
int dat = date.intValue();
if (dat!=Date){
recyclerView.removeAllViews();
dataSnapshot.child(Uid).getRef().setValue(null);
adapter.startListening();
}
ViewGroup.LayoutParams layoutParams =holder.itemView.getLayoutParams();
layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.height= 0;
holder.itemView.setLayoutParams(layoutParams);
}else {
//get the data from child and show in recyclerview
holder.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
@NonNull
@Override
public ViewsAdapterHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.viewsview,viewGroup,false);
return new ViewsAdapterHolder(view);
}
};
recyclerView.setAdapter(adapter);