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

Commit

Permalink
Merge pull request #93 from recruit-lifestyle/feature/issue_89
Browse files Browse the repository at this point in the history
Fix IllegalArgumentException
  • Loading branch information
YoshihideSogawa authored Oct 2, 2018
2 parents b95b5d5 + efca8e9 commit 96447e0
Showing 1 changed file with 18 additions and 5 deletions.
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

0 comments on commit 96447e0

Please sign in to comment.