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

Fix IllegalArgumentException #93

Merged
merged 1 commit into from
Oct 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.util.DisplayMetrics;
import android.view.DisplayCutout;
import android.view.HapticFeedbackConstants;
Expand Down Expand Up @@ -544,7 +545,7 @@ public void addViewToWindow(View view, Options options) {
mWindowManager.addView(mFullscreenObserverView, mFullscreenObserverView.getWindowLayoutParams());
mTargetFloatingView = floatingView;
} else {
mWindowManager.removeViewImmediate(mTrashView);
removeViewImmediate(mTrashView);
}
// 必ずトップに来て欲しいので毎回貼り付け
mWindowManager.addView(mTrashView, mTrashView.getWindowLayoutParams());
Expand All @@ -559,7 +560,7 @@ private void removeViewToWindow(FloatingView floatingView) {
final int matchIndex = mFloatingViewList.indexOf(floatingView);
// 見つかった場合は表示とリストから削除
if (matchIndex != -1) {
mWindowManager.removeViewImmediate(floatingView);
removeViewImmediate(floatingView);
mFloatingViewList.remove(matchIndex);
}

Expand All @@ -576,17 +577,29 @@ private void removeViewToWindow(FloatingView floatingView) {
* ViewをWindowから全て取り外します。
*/
public void removeAllViewToWindow() {
mWindowManager.removeViewImmediate(mFullscreenObserverView);
mWindowManager.removeViewImmediate(mTrashView);
removeViewImmediate(mFullscreenObserverView);
removeViewImmediate(mTrashView);
// FloatingViewの削除
final int size = mFloatingViewList.size();
for (int i = 0; i < size; i++) {
final FloatingView floatingView = mFloatingViewList.get(i);
mWindowManager.removeViewImmediate(floatingView);
removeViewImmediate(floatingView);
}
mFloatingViewList.clear();
}

/**
* Safely remove the View (issue #89)
*
* @param view {@link View}
*/
private void removeViewImmediate(View view) {
if (!ViewCompat.isAttachedToWindow(view)) {
return;
}
mWindowManager.removeViewImmediate(view);
}

/**
* Find the safe area of DisplayCutout.
*
Expand Down