[fix] crash

This commit is contained in:
liujing
2020-09-17 09:57:11 +08:00
parent c6e28801e7
commit cbfe597f7c
2 changed files with 20 additions and 14 deletions

View File

@@ -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() {

View File

@@ -34,8 +34,8 @@ public class V2XNetworkLoadingView extends RelativeLayout {
LayoutInflater.from(context).inflate(R.layout.v2x_network_loading_item, this);
initView();
/*
添加动画图片资源
*/
添加动画图片资源
* */
setLoadingImage(AnimationResources.loadingRes);
}