|
@@ -181,6 +181,8 @@ public class SpineView extends View implements Choreographer.FrameCallback {
|
|
|
private Alignment alignment = Alignment.CENTER;
|
|
|
private ContentMode contentMode = ContentMode.FIT;
|
|
|
|
|
|
+ private boolean isAttached = false;
|
|
|
+
|
|
|
/** Constructs a new {@link SpineView}.
|
|
|
*
|
|
|
* After initialization is complete, the provided {@code SpineController} is invoked as per the {@link SpineController}
|
|
@@ -208,6 +210,18 @@ public class SpineView extends View implements Choreographer.FrameCallback {
|
|
|
// Set properties by view id
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onAttachedToWindow () {
|
|
|
+ super.onAttachedToWindow();
|
|
|
+ isAttached = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDetachedFromWindow () {
|
|
|
+ super.onDetachedFromWindow();
|
|
|
+ isAttached = false;
|
|
|
+ }
|
|
|
+
|
|
|
/** Constructs a new {@link SpineView} from files in your app assets. The {@code atlasFileName} specifies the `.atlas` file to
|
|
|
* be loaded for the images used to render the skeleton. The {@code skeletonFileName} specifies either a Skeleton `.json` or
|
|
|
* `.skel` file containing the skeleton data.
|
|
@@ -407,10 +421,9 @@ public class SpineView extends View implements Choreographer.FrameCallback {
|
|
|
controller.setCoordinateTransform(x + offsetX / scaleX, y + offsetY / scaleY, scaleX, scaleY);
|
|
|
}
|
|
|
|
|
|
- // Choreographer.FrameCallback
|
|
|
-
|
|
|
@Override
|
|
|
public void doFrame (long frameTimeNanos) {
|
|
|
+ if (!isAttached) return;
|
|
|
if (lastTime != 0) delta = (frameTimeNanos - lastTime) / 1e9f;
|
|
|
lastTime = frameTimeNanos;
|
|
|
invalidate();
|