Hello I want to implement only one circular progress animation until the images are loaded from the glide but after implementing animation in placeholder it gives the animation to each individual image and also the image changes to the placeholder image size which I don't want
I want that there should be only one circular progress animation in the center of the layout until the images are loaded in the recycler view
Post_Item_Container.xml
<com.google.android.material.imageview.ShapeableImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="11dp"
android:layout_marginEnd="6dp"
android:contentDescription="@string/todo"
app:shapeAppearanceOverlay="@style/RoundedCorner" />
Fragment_Search.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/search_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
<androidx.appcompat.widget.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
android:background="@color/grey"
android:overScrollMode="never" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/search_view"
android:overScrollMode="never">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/listText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:paddingStart="40dp"
android:paddingEnd="0dp"
android:text="@string/today_s_most_liked_posts"
android:textColor="@color/white"
android:textSize="25sp"
android:textStyle="italic" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawable="@drawable/hu3fv"
android:layout_marginTop="240dp"
android:gravity="center_vertical|center_horizontal"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/postRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:overScrollMode="never"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
Search_Fragment.java
public class Search_Fragment extends Fragment {
private final DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("uploads");
public List<Upload> mUploads;
PostAdapter_Search postsAdapter;
RecyclerView postRecyclerView;
ProgressBar progressBar;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search, container, false);
requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
postRecyclerView = view.findViewById(R.id.postRecyclerView);
progressBar = view.findViewById(R.id.progressBar);
postRecyclerView.setLayoutManager(
new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
);
getData();
progressBar.setVisibility(View.VISIBLE);
mUploads = new ArrayList<>();
postsAdapter = new PostAdapter_Search(getContext(), mUploads);
postRecyclerView.setAdapter(postsAdapter);
return view;
}
private void getData() {
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.exists()) {
mUploads.clear();
for (DataSnapshot dataSnapshot : snapshot.getChildren()) {
progressBar.setVisibility(View.GONE);
postRecyclerView.setVisibility(View.VISIBLE);
Upload upload = dataSnapshot.getValue(Upload.class);
upload.setmKey(dataSnapshot.getKey());
mUploads.add(upload);
}
}
//notify the adapter
postsAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}