I use Glide to load my ImageView from Firebase.
When I am running my application, my ImageView will delay(like the tooth in my video), https://www.youtube.com/watch?v=6Mj0Xq3M8n0
so I want to know why is this so,and this is my code:
private void setTooth() {
for(int j=0;j<tooth.length;j++) {
final int finalJ = j;
toothRef.child(j+1+"").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
if(dataSnapshot.getValue().toString().trim().equals("b"))
{
imageRef.child("tooth_dirty").child(finalJ%16+1+"").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Glide.with(Home_Activity.this)
.load(Uri.parse(dataSnapshot.getValue().toString()))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(tooth[finalJ]);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
else
{
imageRef.child("tooth_clean").child(finalJ%16+1+"").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Glide.with(Home_Activity.this)
.load(Uri.parse(dataSnapshot.getValue().toString()))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(tooth[finalJ]);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}
else
{
for(int i=0;i<tooth.length;i++)
toothRef.child(i+1+"").setValue("g");
setTooth();
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}
How can I solve my problem:(
try using the inbuilt FirebaseLoader image loader
try this use
placeholder()
to display a temparay image whole loading image using glideTry the following to add placeholder
or use apply instead of setDefaultRequestOptions