Progress Bar Set Visiblity Using Grid View Images Gallery
Hello everyone i have an issue with the progress bar. I tried to make a gallery view, all the images shown in grid view.but the issue is that, when all the images is loaded the pr
Solution 1:
update your xml file
<com.victor.loading.rotate.RotateLoading
android:id="@+id/rotateloading"
android:layout_width="80dp"
android:layout_height="80dp"
app:loading_width="5dp"
app:loading_color="#ffffff"
android:layout_centerInParent="true"
android:visibility="invisible"/>
and in your getView() method,
rotateLoading.start();
rotateLoading.setVisibility(View.VISIBLE);
Glide.with(mContext)
.load(url)
.thumbnail(0.5f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.fitCenter()
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
rotateLoading.setVisibility(View.INVISIBLE);
rotateLoading.stop();
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
rotateLoading.setVisibility(View.INVISIBLE);
rotateLoading.stop();
return false;
}
})
.crossFade()
.into(imageView);
Solution 2:
I created a library that shows a progress over an imageview: PowerfulImageView.
Import it, adding to gradle this line
compile 'com.stefanosiano:powerlessimageview:0.3.1'
Then change your xml with this:
<com.stefanosiano.powerfulimageview.PowerfulImageView
android:layout_width="380dp"
android:layout_height="380dp"
android:id="@+id/imageView2"
app:piv_progress_mode="circular" />
Then change your getView method to:
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
PowerfulImageView imageView;
if (convertView == null) {
convertView= LayoutInflater.from(mContext).inflate(R.layout.image_gallery,parent,false);
imageView=(PowerfulImageView)convertView.findViewById(R.id.imageView2);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(380,480));
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
} else {
imageView = (PowerfulImageView) convertView.findViewById(R.id.imageView2);
}
imageView.changeProgressMode(PivProgressMode.CIRCULAR);
String url = null;
url=getItem(position);
Glide.with(mContext)
.load(url)
.thumbnail(0.5f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(android.R.drawable.progress_indeterminate_horizontal)
.centerCrop()
.crossFade()
.into(imageView);
return convertView;
}
Let me know if everything works fine :)
Post a Comment for "Progress Bar Set Visiblity Using Grid View Images Gallery"