Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

NullPointerException in onTouch, due to .getState() #98

Open
geecko86 opened this issue Oct 29, 2018 · 3 comments
Open

NullPointerException in onTouch, due to .getState() #98

geecko86 opened this issue Oct 29, 2018 · 3 comments
Labels

Comments

@geecko86
Copy link
Contributor

geecko86 commented Oct 29, 2018

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int jp.co.recruit_lifestyle.android.floatingview.FloatingView.getState()' on a null object reference
       at jp.co.recruit_lifestyle.android.floatingview.FloatingViewManager.onTouch(SourceFile:349)
       at com.geecko.QuickLyric.services.LyricsOverlayService.onTouch(SourceFile:969)
       at jp.co.recruit_lifestyle.android.floatingview.FloatingViewManager.dispatchTouchEvent(SourceFile:906)

This is the piece of code from FloatingViewManager.onTouch that triggers the exception:

        final int state = mTargetFloatingView.getState();
        mTargetFloatingView = (FloatingView) v;

It seems like mTargetFloatingView can sometimes be null when the first line is executed.

@YoshihideSogawa
Copy link
Contributor

@geecko86
I've never seen this crash log before.
Is there the latest code of LyricsOverlayService?

@geecko86
Copy link
Contributor Author

I'm not sure I understand the question.

Here's the LyricsOverlayService.onTouch method:

@Override
public boolean onTouch(View view, MotionEvent event) {
    if (mFloatingViewManager == null || view.getAlpha() != 1f || mFloatingViewManager.getTargetFloatingView() == null)
        return false;
    boolean output = mFloatingViewManager.onTouch(view, event);
    if (isInOverlay()) {
        if (event.getAction() == MotionEvent.ACTION_MOVE && !mDoPullBack) {
            exitOverlay(false, false);
            mDoPullBack = true;
            mFloatingViewManager.getTargetFloatingView().setBlockMoveToEdge(true);
        }
    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        if (event.getEventTime() - event.getDownTime() < 200)
            view.performClick();
    }

    return output;
}

The if mFloatingViewManager.getTargetFloatingView() == null part was just added by me, and should (in theory) prevent this from happening.

It's still odd, though.

@geecko86
Copy link
Contributor Author

This might very well be an issue on our end. Don't hesitate to close if you think it's too weird.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants