diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java index 67c87bea4d..94a760dd65 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java @@ -18,15 +18,15 @@ public class V2XAnimationManager implements Animation { private final static int MSG_LOOP = 3004; private long INTERVAL = 100L; - private Handler mHandler = new Handler( Looper.getMainLooper() ) { + private Handler mHandler = new Handler(Looper.getMainLooper()) { @Override - public void handleMessage( Message msg ) { - super.handleMessage( msg ); - switch ( msg.what ) { + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { case MSG_LOOP: - if ( isStarted ) { + if (isStarted) { // targetImageView.setImageResource( AnimationResources.loadingRes[mStartIndex++ % AnimationResources.loadingRes.length] ); - mHandler.sendEmptyMessageDelayed( MSG_LOOP, INTERVAL ); + mHandler.sendEmptyMessageDelayed(MSG_LOOP, INTERVAL); } break; } @@ -43,20 +43,26 @@ public class V2XAnimationManager implements Animation { @Override synchronized public void start() { isStarted = true; - mHandler.sendEmptyMessage( MSG_LOOP ); - targetImageView.setVisibility(View.VISIBLE); + mHandler.sendEmptyMessage(MSG_LOOP); + if (targetImageView != null) { + targetImageView.setVisibility(View.VISIBLE); + } } @Override synchronized public void stop() { isStarted = false; - mHandler.removeMessages( MSG_LOOP ); - targetImageView.setVisibility(View.INVISIBLE); + mHandler.removeMessages(MSG_LOOP); + if (targetImageView != null) { + targetImageView.setVisibility(View.INVISIBLE); + } } - public void soptWithError(){ + public void soptWithError() { stop(); - targetImageView.setVisibility(View.VISIBLE); + if (targetImageView != null) { + targetImageView.setVisibility(View.VISIBLE); + } } public void release() { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java index c3f59a81fb..99a6cbbad7 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java @@ -34,8 +34,8 @@ public class V2XNetworkLoadingView extends RelativeLayout { LayoutInflater.from(context).inflate(R.layout.v2x_network_loading_item, this); initView(); /* - 添加动画图片资源 - */ + 添加动画图片资源 + * */ setLoadingImage(AnimationResources.loadingRes); }