I have a list of animated gifs in drawable resource folder in my android project. I need these gifs played one by one, wait for seconds, and then play the next gif. but when I run the app, all gifs load very very fast so I can just see the last gif. I used Glide for playing gifs and this is my code
Handler handler1 = new Handler();
for (int a = 1; a<=lines.size() ;a++) {
handler1.postDelayed(new Runnable() {
@Override
public void run() {
String resName = "";
int duration = 0;
resName = "wo_" + (lines.get(slideIndex).split(",")[0]).toLowerCase().trim().replace(".gif", "");
duration = Integer.parseInt(lines.get(slideIndex++).split(",")[2].trim());
int resourceId = getResId(resName, R.drawable.class);//this.getResources().getIdentifier(resName, "drawable", this.getPackageName());
Glide.with(WorkoutActivity.this).asGif().load(resourceId).into(imageView);
}
}, 5000);
}