public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
if (!resource.isAnimated()) {
float viewRatio = view.getWidth() / (float) view.getHeight();
float drawableRatio = resource.getIntrinsicWidth() / (float) resource.getIntrinsicHeight();
if (Math.abs(viewRatio - 1f) <= SQUARE_RATIO_MARGIN
&& Math.abs(drawableRatio - 1f) <= SQUARE_RATIO_MARGIN) {
resource = new SquaringDrawable(resource, view.getWidth());
}
}
super.onResourceReady(resource, animation);
this.resource = resource;
// 这里调用了 GifDrawable 的 start 方法
resource.setLoopCount(maxLoopCount);
resource.start();
}
// GlideDrawable
public void start() {
// 状态置换跳过不看
isStarted = true;
resetLoopCount();
if (isVisible) {
// 真正的使能代码
startRunning();
}
}