From 4b11a1316fd4ee9a6b1c3e744b65e86c4e04d9f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20Kwiecie=C5=84?= Date: Thu, 26 Nov 2015 22:22:37 +0100 Subject: [PATCH] fixes --- build.gradle | 4 ++-- .../java/pl/aprilapps/switcher/Animations.java | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 688fde5..f555cf0 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.1.3' + classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.github.dcendents:android-maven-plugin:1.2' } } @@ -20,5 +20,5 @@ ext { buildToolsVersion = "23.0.1" minSdkVersion = 14 versionCode = 16 - versionName = "2.0.3" + versionName = "git --git-dir=${rootDir}/.git --work-tree=${rootDir} describe --tags --abbrev=0".execute().text.trim() } \ No newline at end of file diff --git a/switcher-library/src/main/java/pl/aprilapps/switcher/Animations.java b/switcher-library/src/main/java/pl/aprilapps/switcher/Animations.java index 897da14..38db099 100644 --- a/switcher-library/src/main/java/pl/aprilapps/switcher/Animations.java +++ b/switcher-library/src/main/java/pl/aprilapps/switcher/Animations.java @@ -2,6 +2,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.content.Context; import android.util.Log; import android.view.View; @@ -11,11 +12,20 @@ public class Animations { public static CrossfadeListeners crossfadeViews(final View viewToHide, final View viewToShow) { - return crossfadeViews(viewToHide, viewToShow); + Context context; + if (viewToHide != null) { + context = viewToHide.getContext(); + } else if (viewToShow != null) { + context = viewToShow.getContext(); + } else { + return null; + } + int animDuration = context.getResources().getInteger(android.R.integer.config_shortAnimTime); + return crossfadeViews(viewToHide, viewToShow, animDuration); } public static CrossfadeListeners crossfadeViews(final View viewToHide, final View viewToShow, int animDuration) { - if (viewToShow == null) return null; + if (viewToShow == null || viewToHide == null) return null; FadeInListener fadeInListener = fadeIn(viewToShow, animDuration); FadeOutListener fadeOutListener = fadeOut(viewToHide, animDuration); return new CrossfadeListeners(fadeOutListener, fadeInListener);