YoungBill / Android-FloatWindow

Android custom FloatWindow, can be suspended in any app, any desktop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DraggableFlowWindow.dismiss() StackOverflow.

lhr2528 opened this issue · comments

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.

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

/**
 * 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;
}