mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[android] throw clear IllegalStateException when controller is missing
This commit is contained in:
parent
9babc86c59
commit
9d488a4f65
@ -358,11 +358,19 @@ public class SpineView extends View implements Choreographer.FrameCallback {
|
|||||||
* {@link SpineView#loadFromDrawable(AndroidSkeletonDrawable)} or
|
* {@link SpineView#loadFromDrawable(AndroidSkeletonDrawable)} or
|
||||||
* {@link SpineView#setSkeletonDrawable(AndroidSkeletonDrawable)}. */
|
* {@link SpineView#setSkeletonDrawable(AndroidSkeletonDrawable)}. */
|
||||||
public void loadFrom (AndroidSkeletonDrawableLoader loader) {
|
public void loadFrom (AndroidSkeletonDrawableLoader loader) {
|
||||||
|
if (controller == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"SpineController is not set. When using SpineView from XML, call setController(...) before loadFromAsset/loadFromFile/loadFromHttp/loadFromDrawable.");
|
||||||
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Thread backgroundThread = new Thread( () -> {
|
Thread backgroundThread = new Thread( () -> {
|
||||||
try {
|
try {
|
||||||
final AndroidSkeletonDrawable skeletonDrawable = loader.load();
|
final AndroidSkeletonDrawable skeletonDrawable = loader.load();
|
||||||
mainHandler.post( () -> {
|
mainHandler.post( () -> {
|
||||||
|
if (controller == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"SpineController became null before initialization. Ensure setController(...) is called and not cleared until loading completes.");
|
||||||
|
}
|
||||||
setSkeletonDrawable(skeletonDrawable);
|
setSkeletonDrawable(skeletonDrawable);
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -375,6 +383,10 @@ public class SpineView extends View implements Choreographer.FrameCallback {
|
|||||||
/** Set the skeleton drawable. Must be called from the main thread. */
|
/** Set the skeleton drawable. Must be called from the main thread. */
|
||||||
@MainThread
|
@MainThread
|
||||||
public final void setSkeletonDrawable (@NonNull AndroidSkeletonDrawable skeletonDrawable) {
|
public final void setSkeletonDrawable (@NonNull AndroidSkeletonDrawable skeletonDrawable) {
|
||||||
|
if (controller == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"SpineController is not set. When using SpineView from XML, call setController(...) before setSkeletonDrawable/loadFromAsset/loadFromFile/loadFromHttp/loadFromDrawable.");
|
||||||
|
}
|
||||||
computedBounds = boundsProvider.computeBounds(skeletonDrawable);
|
computedBounds = boundsProvider.computeBounds(skeletonDrawable);
|
||||||
updateCanvasTransform();
|
updateCanvasTransform();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user