I am using a ProgressBar library with Glide to animate dots indicators while each item in GridView is loading, this works fine but I cannot hide the ProgressBar for each item that completed the download.
Strange behavior is that whichever item completes, its loading will result in the progressbar hiding only for the last item, the progressbar will continue to animate endlessly for all other completed items.
In summary I would like the progressbar to have the same behavior as a Gilde placeholder.
XML Code:
<com.wang.avi.AVLoadingIndicatorView
android:id="@+id/avi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:indicatorColor="@color/skyblue"
app:indicatorName="BallPulseIndicator"
style="@style/AVLoadingIndicatorView.Small"
/>
public CustomAdapter_GridViewMainFile(ActivityVideo_Cloud contextActivity, String[] stringArr_File, String[] stringArr_Date) {
// TODO Auto-generated constructor stub
context = contextActivity;
strArr_File = stringArr_File;
strArr_Date = stringArr_Date;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
if (strArr_File != null) {
return strArr_File.length;
} else {
return 0;
}
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public class Holder {
AVLoadingIndicatorView avi;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
holder = new Holder();
if (convertView == null)
{
convertView = inflater.inflate(R.layout.activity_video_gridview_single_checkbox, null);
}
holder.avi = convertView.findViewById(R.id.avi);
Glide.with(getBaseContext())
.load(strArr_File[position])
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
holder.avi.hide();
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
holder.avi.hide();
return false;
}
})
.into(holder.ivImage);
...