So I'm using the library Swipe by Pwittchen and the code being used is this section:
CoreActivity.java
@Override
public void onSwipedDown(final MotionEvent event) {
if(m_Toolbar.getVisibility() == View.VISIBLE ){
WebShrink.cancel();
}
//WebView Animation (Shrink)
// if(m_WebView.getAnimation().hasStarted() || m_WebView.getAnimation().hasEnded()){
if(WebEnlarge.hasStarted()){
WebShrink = AnimationUtils.loadAnimation(CoreActivity.this,R.anim.m_webview_shrink);
m_WebView.startAnimation(WebShrink);
m_Preference_Toolbar.setVisibility(View.GONE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
m_Toolbar.setVisibility(View.VISIBLE);
}
}, 350);//3 seconds
}
}
Currently I crashes if you swipe down in the moment it is created. Im trying to find a way around it with:
if(m_Toolbar.getVisibility() == View.VISIBLE ){
WebShrink.cancel();
}
but this is not working and am wondering if anyone could help me with this. the ideal situation is that if the toolbar is visible or if WebShrink is already in place then do nothing but I can't find away around it
LogCat
01-18 20:57:23.652 29764-29764/com.equiware.mickeyt.fire E/InputEventReceiver: Exception dispatching input event.
01-18 20:57:23.653 29764-29764/com.equiware.mickeyt.fire D/AndroidRuntime: Shutting down VM
01-18 20:57:23.654 29764-29764/com.equiware.mickeyt.fire E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.equiware.mickeyt.fire, PID: 29764
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.animation.Animation.cancel()' on a null object reference
at com.equiware.mickeyt.fire.CoreActivity$2.onSwipedDown(CoreActivity.java:161)
at com.github.pwittchen.swipe.library.rx2.Swipe.onActionUp(Swipe.java:138)
at com.github.pwittchen.swipe.library.rx2.Swipe.dispatchTouchEvent(Swipe.java:101)
at com.equiware.mickeyt.fire.CoreActivity.dispatchTouchEvent(CoreActivity.java:216)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:374)
at android.view.View.dispatchPointerEvent(View.java:10177)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4628)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4496)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3947)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4000)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3966)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3974)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3947)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4000)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3966)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4095)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3974)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4152)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3947)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4000)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3966)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3974)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3947)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6437)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6411)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6372)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6571)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6519)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6594)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:613)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)