From adf35cab26eed32502cf185cd93ae3c146bdb7df Mon Sep 17 00:00:00 2001 From: Eduard Bosch Bertran Date: Thu, 19 Oct 2017 12:57:11 +0200 Subject: [PATCH 1/4] chore: Update gradle plugin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a641feb5..22015de1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0-beta2' + classpath 'com.android.tools.build:gradle:2.3.2' } } From 3510d407f65e022d964821606d97387e21a654e0 Mon Sep 17 00:00:00 2001 From: Eduard Bosch Bertran Date: Thu, 19 Oct 2017 13:06:16 +0200 Subject: [PATCH 2/4] chore: Update libraries and move constants --- app/build.gradle | 14 +++++++------- build.gradle | 10 ++++++++++ gradle.properties | 4 ---- library/build.gradle | 12 ++++++------ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7aa8daa4..62cd3024 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion ANDROID_BUILD_SDK_VERSION as int - buildToolsVersion ANDROID_BUILD_TOOLS_VERSION + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { - minSdkVersion 14 - targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName VERSION_NAME @@ -40,9 +40,9 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':library') - compile 'com.android.support:appcompat-v7:24.1.1' - compile 'com.android.support:design:24.1.1' - compile 'com.android.support:recyclerview-v7:24.1.1' + compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibVersion" + compile "com.android.support:design:$rootProject.ext.supportLibVersion" + compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibVersion" debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' diff --git a/build.gradle b/build.gradle index 22015de1..6e14fb94 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,16 @@ allprojects { repositories { jcenter() mavenCentral() + maven { url "https://maven.google.com" } } } + +ext { + minSdkVersion = 14 + targetSdkVersion = 26 + compileSdkVersion = 26 + buildToolsVersion = '26.0.2' + + supportLibVersion = '26.1.0' +} diff --git a/gradle.properties b/gradle.properties index d615c99c..0a58ae92 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,8 +16,4 @@ POM_DEVELOPER_EMAIL=alessandro.crugnola@gmail.com POM_DEVELOPER_URL=http://blog.sephiroth.it POM_DEVELOPER_ROLE=author -ANDROID_BUILD_TARGET_SDK_VERSION=25 -ANDROID_BUILD_TOOLS_VERSION=25.0.2 -ANDROID_BUILD_SDK_VERSION=25 - org.gradle.daemon=true diff --git a/library/build.gradle b/library/build.gradle index 91532538..84431c43 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -4,12 +4,12 @@ group GROUP version VERSION_NAME android { - compileSdkVersion ANDROID_BUILD_SDK_VERSION as int - buildToolsVersion ANDROID_BUILD_TOOLS_VERSION + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { - minSdkVersion 14 - targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName VERSION_NAME consumerProguardFiles 'proguard-rules.txt' @@ -43,8 +43,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - provided 'com.android.support:support-annotations:24.1.1' - compile 'com.android.support:appcompat-v7:24.1.1' + provided "com.android.support:support-annotations:$rootProject.ext.supportLibVersion" + compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibVersion" } From e3a667c7af6e4d421ed618db8f9a07a7d883e83d Mon Sep 17 00:00:00 2001 From: Eduard Bosch Bertran Date: Thu, 19 Oct 2017 13:11:15 +0200 Subject: [PATCH 3/4] fix: Do not delete tooltips while requesting layout --- .../android/library/tooltip/Tooltip.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java b/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java index e28d644b..26892b2e 100644 --- a/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java +++ b/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java @@ -572,10 +572,14 @@ void removeFromParent() { removeCallbacks(); if (null != parent) { - ((ViewGroup) parent).removeView(TooltipViewImpl.this); + ViewGroup parentViewGroup = (ViewGroup) parent; - if (null != mShowAnimation && mShowAnimation.isStarted()) { - mShowAnimation.cancel(); + // If layout is requested we should delay removing the view to avoid parent + // onLayout crash + if (parentViewGroup.isLayoutRequested()) { + postRemoveFromParentNow(parentViewGroup); + } else { + removeFromParentNow(parentViewGroup); } } } @@ -585,6 +589,23 @@ private void removeCallbacks() { mHandler.removeCallbacks(activateRunnable); } + private void postRemoveFromParentNow(final ViewGroup parent) { + post(new Runnable() { + @Override + public void run() { + removeFromParentNow(parent); + } + }); + } + + private void removeFromParentNow(ViewGroup parent) { + parent.removeView(TooltipViewImpl.this); + + if (null != mShowAnimation && mShowAnimation.isStarted()) { + mShowAnimation.cancel(); + } + } + @Override public void remove() { log(TAG, INFO, "[%d] remove()", mToolTipId); From 8855dc345771772c8a0f1dcac6461d6cac3c6b6a Mon Sep 17 00:00:00 2001 From: Eduard Bosch Bertran Date: Thu, 19 Oct 2017 13:45:07 +0200 Subject: [PATCH 4/4] refactor: Do not post animation cancel --- .../it/sephiroth/android/library/tooltip/Tooltip.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java b/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java index 26892b2e..ae4c28c2 100644 --- a/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java +++ b/library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java @@ -581,6 +581,10 @@ void removeFromParent() { } else { removeFromParentNow(parentViewGroup); } + + if (null != mShowAnimation && mShowAnimation.isStarted()) { + mShowAnimation.cancel(); + } } } @@ -600,10 +604,6 @@ public void run() { private void removeFromParentNow(ViewGroup parent) { parent.removeView(TooltipViewImpl.this); - - if (null != mShowAnimation && mShowAnimation.isStarted()) { - mShowAnimation.cancel(); - } } @Override