Basically, I have an AnimationDrawable
that I generated with a helper method:
public static AnimationDrawable requestLoadingDrawable(Context originContext) {
if(panoramaLoadingLoopDrawable == null) {
panoramaLoadingLoopDrawable = new AnimationDrawable();
Bitmap src = BitmapFactory.decodeResource(originContext.getResources(), R.drawable.load360_3lines);
BitmapDrawable frameInDrawable;
//int squareInstDim = (int)(200*adapterCtx.getResources().getDisplayMetrics().density);
int horiDim = (int)(src.getWidth() / 10);
int vertDim = (int)(src.getHeight() / 3);
Bitmap frame;
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 10; j++) {
frame = Bitmap.createBitmap(src, j * horiDim, i*vertDim, horiDim, vertDim);
frameInDrawable = new BitmapDrawable(originContext.getResources(), frame);
panoramaLoadingLoopDrawable.addFrame(frameInDrawable, (1000/30));
}
}
src.recycle();
}
panoramaLoadingLoopDrawable.setOneShot(false);
return panoramaLoadingLoopDrawable;
}
The panoramaLoadingLoopDrawable
is private static
in this helper class.
When I put it in the RecyclerView, when there's 2 items that use this AnimationDrawable
in the ViewHolder
, both would stop animating.
Should I make the panoramaLoadingLoopDrawable
non-static or something?