YoungBill / Android-FloatWindow

Android custom FloatWindow, can be suspended in any app, any desktop
377 stars 103 forks source link

DraggableFlowWindow.dismiss() StackOverflow. #2

Open lhr2528 opened 6 years ago

lhr2528 commented 6 years ago

The singleton class DraggableFloatWindow 's dismiss() method is recursive. Suggest to replace DraggableFloatWindow.java line 63 mWindowManager.dismiss(); with "mWindowManager.removeView(mDraggableFloatView); to hide the floating window.

Let me know if we can have a pull request to fix this.

Thank you.

YoungBill commented 6 years ago

So sorry, I just saw this issue, thank you for your reminder, I found the dismiss method, forgot to implement, I think it can be implemented according to what you said, I will add the dismiss button in GetFloatWindowFreePositionActivity, then you can implement it in Submit, thank you

happyHou commented 6 years ago
/**
 * attach floatView to window
 */
private  void attachFloatViewToWindow() {
    showState =true;
    if (mDraggableFloatView == null)
        throw new IllegalStateException("DraggableFloatView can not be null");
    if (mParams == null)
        throw new IllegalStateException("WindowManager.LayoutParams can not be null");
    try {
        mWindowManager.updateViewLayout(mDraggableFloatView, mParams);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, e.getMessage());
        //if floatView not attached to window,addView
        mWindowManager.addView(mDraggableFloatView, mParams);
    }
}

/**
 * detach floatView from window
 */
private  void detachFloatViewFromWindow() {
    // TODO: 18-7-30 @lhr2528 you can fix issue 2 here
    if (showState) {
        mWindowManager.removeView(mDraggableFloatView);
        showState =false;
    }
}

public boolean isShowing(){
    return showState;
}