Skip to content

Commit ebf535f

Browse files
committed
On 19+, assure that the view is attached to the window
1 parent b5a15ba commit ebf535f

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 23
5-
buildToolsVersion "23.0.3"
4+
compileSdkVersion 24
5+
buildToolsVersion "24.0.1"
66

77
defaultConfig {
88
applicationId "com.ovenbits.quickactionview.sample"
99
minSdkVersion 15
10-
targetSdkVersion 23
10+
targetSdkVersion 24
1111
versionCode 1
1212
versionName "1.0"
1313
vectorDrawables.useSupportLibrary = true
@@ -26,8 +26,8 @@ android {
2626
dependencies {
2727
compile fileTree(include: ['*.jar'], dir: 'libs')
2828
testCompile 'junit:junit:4.12'
29-
compile 'com.android.support:appcompat-v7:23.3.0'
30-
compile 'com.android.support:design:23.3.0'
31-
compile 'com.android.support:recyclerview-v7:23.3.0'
29+
compile 'com.android.support:appcompat-v7:24.1.1'
30+
compile 'com.android.support:design:24.1.1'
31+
compile 'com.android.support:recyclerview-v7:24.1.1'
3232
compile project(':quickactionview')
3333
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.1.0'
8+
classpath 'com.android.tools.build:gradle:2.1.2'
99
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
1010

1111
// NOTE: Do not place your application dependencies here; they belong

quickactionview/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 23
5-
buildToolsVersion "23.0.3"
4+
compileSdkVersion 24
5+
buildToolsVersion "24.0.1"
66

77
defaultConfig {
88
minSdkVersion 15
9-
targetSdkVersion 23
9+
targetSdkVersion 24
1010
versionCode 1
1111
versionName "1.0.0"
1212
}
@@ -24,7 +24,7 @@ android {
2424
dependencies {
2525
compile fileTree(dir: 'libs', include: ['*.jar'])
2626
testCompile 'junit:junit:4.12'
27-
compile 'com.android.support:appcompat-v7:23.4.0'
27+
compile 'com.android.support:appcompat-v7:24.1.1'
2828
}
2929

3030
apply from: 'https://raw.githubusercontent.com/Commit451/gradle-android-javadocs/1.0.0/gradle-android-javadocs.gradle'

quickactionview/src/main/java/com/ovenbits/quickactionview/QuickActionView.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ private void removeView() {
457457

458458
if (mQuickActionViewLayout != null) {
459459
WindowManager manager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
460-
manager.removeView(mQuickActionViewLayout);
460+
if (checkAttachedToWindow(mQuickActionViewLayout)) {
461+
manager.removeView(mQuickActionViewLayout);
462+
}
461463
mQuickActionViewLayout = null;
462464
mShown = false;
463465
}
@@ -470,6 +472,14 @@ private void removeView() {
470472
}
471473
}
472474

475+
private boolean checkAttachedToWindow(View view) {
476+
if (Build.VERSION.SDK_INT >= 19) {
477+
return view.isAttachedToWindow();
478+
}
479+
//Unfortunately, we have no way of truly knowing on versions less than 19
480+
return true;
481+
}
482+
473483
private void dismiss() {
474484
if (!mShown) {
475485
throw new RuntimeException("The QuickActionView must be visible to call dismiss()");

0 commit comments

Comments
 (0)