解决动画执行中偶现npe的问题

This commit is contained in:
wangcongtao
2020-12-02 17:11:59 +08:00
parent dc7c1eff4f
commit 88382b8b5a
3 changed files with 64 additions and 14 deletions

View File

@@ -581,7 +581,11 @@ public class AMapNaviViewWrapper implements IMogoMapView,
// mMyLocationMarker.startAnimation();
// }
// });
mMyLocationMarker.startAnimation();
try {
mMyLocationMarker.startAnimation();
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override

View File

@@ -342,10 +342,16 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
ScaleAnimation animationScale = new ScaleAnimation( fromX, toX, fromY, toY );
animationScale.setDuration( duration );
animationScale.setFillMode( Animation.FILL_MODE_FORWARDS );
animationScale.setInterpolator( interpolator );
if ( interpolator != null ) {
animationScale.setInterpolator( interpolator );
}
mMarker.setAnimation( animationScale );
mMarker.startAnimation();
try {
mMarker.startAnimation();
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
@@ -357,7 +363,9 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
ScaleAnimation animationScale = new ScaleAnimation( fromX, toX, fromY, toY );
animationScale.setDuration( duration );
animationScale.setFillMode( Animation.FILL_MODE_FORWARDS );
animationScale.setInterpolator( interpolator );
if ( interpolator != null ) {
animationScale.setInterpolator( interpolator );
}
animationScale.setAnimationListener( new Animation.AnimationListener() {
@Override
public void onAnimationStart() {
@@ -398,7 +406,9 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
AnimationSet animationSet = new AnimationSet( true );
animationSet.setDuration( duration );
animationSet.setInterpolator( interpolator );
if ( interpolator != null ) {
animationSet.setInterpolator( interpolator );
}
animationSet.setAnimationListener( new Animation.AnimationListener() {
@Override
public void onAnimationStart() {
@@ -422,7 +432,11 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
} );
mMarker.setAnimation( animationSet );
mMarker.startAnimation();
try {
mMarker.startAnimation();
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override

View File

@@ -48,7 +48,11 @@ public class TopViewManager implements IMogoTopViewManager {
public void addView(View view, ViewGroup.LayoutParams params,
IMogoTopViewStatusListener statusListener) {
parentParams = params;
TopViewAnimHelper.getInstance().startTopInAnim(view, params, statusListener);
try {
TopViewAnimHelper.getInstance().startTopInAnim(view, params, statusListener);
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
@@ -72,7 +76,11 @@ public class TopViewManager implements IMogoTopViewManager {
public void addViewNoLinkage(View view, ViewGroup.LayoutParams params,
IMogoTopViewStatusListener statusListener) {
parentParams = params;
TopViewNoLinkageAnimHelper.getInstance().startTopInAnim(view, params, statusListener);
try {
TopViewNoLinkageAnimHelper.getInstance().startTopInAnim(view, params, statusListener);
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
@@ -82,31 +90,55 @@ public class TopViewManager implements IMogoTopViewManager {
@Override
public void addSubView(View view, IMogoTopViewStatusListener statusListener) {
TopViewAnimHelper.getInstance().addSubView(view, parentParams, statusListener);
try {
TopViewAnimHelper.getInstance().addSubView(view, parentParams, statusListener);
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
public void removeView(View view) {
TopViewAnimHelper.getInstance().startTopOutAnim(view);
try {
TopViewAnimHelper.getInstance().startTopOutAnim(view);
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
public void removeViewNoLinkage(View view) {
TopViewNoLinkageAnimHelper.getInstance().startTopOutAnim(view);
try {
TopViewNoLinkageAnimHelper.getInstance().startTopOutAnim(view);
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
public void removeSubView(View view) {
TopViewAnimHelper.getInstance().removeSubView(view);
try {
TopViewAnimHelper.getInstance().removeSubView(view);
} catch ( Exception e ) {
e.printStackTrace();
}
}
@Override
public boolean isViewAdded(View view) {
return TopViewAnimHelper.getInstance().isViewAdded(view);
try {
return TopViewAnimHelper.getInstance().isViewAdded(view);
} catch ( Exception e ){
return false;
}
}
@Override
public boolean isViewNoLinkageAdded(View view) {
return TopViewNoLinkageAnimHelper.getInstance().isViewAdded(view);
try {
return TopViewNoLinkageAnimHelper.getInstance().isViewAdded(view);
} catch( Exception e ){
return false;
}
}
}