diff --git a/build.gradle b/build.gradle index 65ca22d..2271121 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha5' - classpath 'me.tatarka:gradle-retrolambda:3.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/materialintro/build.gradle b/materialintro/build.gradle index faf2f3a..123d435 100644 --- a/materialintro/build.gradle +++ b/materialintro/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.library' -apply plugin: 'me.tatarka.retrolambda' android { compileSdkVersion 23 @@ -18,10 +17,6 @@ android { } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } } dependencies { diff --git a/materialintro/src/main/java/co/mobiwise/materialintro/animation/AnimationFactory.java b/materialintro/src/main/java/co/mobiwise/materialintro/animation/AnimationFactory.java index 62ee6bd..8b250b5 100644 --- a/materialintro/src/main/java/co/mobiwise/materialintro/animation/AnimationFactory.java +++ b/materialintro/src/main/java/co/mobiwise/materialintro/animation/AnimationFactory.java @@ -20,7 +20,7 @@ public class AnimationFactory { * @param duration * @param onAnimationStartListener */ - public static void animateFadeIn(View view, long duration, AnimationListener.OnAnimationStartListener onAnimationStartListener) { + public static void animateFadeIn(View view, long duration, final AnimationListener.OnAnimationStartListener onAnimationStartListener) { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); objectAnimator.setDuration(duration); objectAnimator.addListener(new Animator.AnimatorListener() { @@ -57,7 +57,7 @@ public void onAnimationRepeat(Animator animation) { * @param duration * @param onAnimationEndListener */ - public static void animateFadeOut(View view, long duration, AnimationListener.OnAnimationEndListener onAnimationEndListener) { + public static void animateFadeOut(View view, long duration, final AnimationListener.OnAnimationEndListener onAnimationEndListener) { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha", 1, 0); objectAnimator.setDuration(duration); objectAnimator.addListener(new Animator.AnimatorListener() { diff --git a/materialintro/src/main/java/co/mobiwise/materialintro/view/MaterialIntroView.java b/materialintro/src/main/java/co/mobiwise/materialintro/view/MaterialIntroView.java index 77b00c2..e415686 100644 --- a/materialintro/src/main/java/co/mobiwise/materialintro/view/MaterialIntroView.java +++ b/materialintro/src/main/java/co/mobiwise/materialintro/view/MaterialIntroView.java @@ -23,6 +23,7 @@ import android.widget.TextView; import co.mobiwise.materialintro.animation.AnimationFactory; +import co.mobiwise.materialintro.animation.AnimationListener; import co.mobiwise.materialintro.animation.MaterialIntroListener; import co.mobiwise.materialintro.prefs.PreferencesManager; import co.mobiwise.materialintro.utils.Constants; @@ -259,9 +260,9 @@ public void onGlobalLayout() { circleShape.reCalculateAll(); if (circleShape != null && circleShape.getPoint().y != 0 && !isLayoutCompleted) { if (isInfoEnabled) - handler.post(() -> setInfoLayout(height, circleShape)); + setInfoLayout(); if(isDotViewEnabled) - handler.post(() -> setDotViewLayout()); + setDotViewLayout(); getViewTreeObserver().removeOnGlobalLayoutListener(this); } } @@ -372,13 +373,20 @@ private void show(Activity activity) { setReady(true); - handler.postDelayed(() -> { - if (isFadeAnimationEnabled) - AnimationFactory.animateFadeIn(this, fadeAnimationDuration, () -> setVisibility(VISIBLE)); - else - setVisibility(VISIBLE); - - }, delayMillis); + handler.postDelayed(new Runnable() { + @Override + public void run() { + if (isFadeAnimationEnabled) + AnimationFactory.animateFadeIn(MaterialIntroView.this, fadeAnimationDuration, new AnimationListener.OnAnimationStartListener() { + @Override + public void onAnimationStart() { + setVisibility(VISIBLE); + } + }); + else + setVisibility(VISIBLE); + } + },delayMillis); } @@ -387,12 +395,14 @@ private void show(Activity activity) { */ private void dismiss() { preferencesManager.setDisplayed(materialIntroViewId); - AnimationFactory.animateFadeOut(this, fadeAnimationDuration, () -> { - setVisibility(INVISIBLE); - - if (materialIntroListener != null) - materialIntroListener.onUserClicked(materialIntroViewId); + AnimationFactory.animateFadeOut(this, fadeAnimationDuration, new AnimationListener.OnAnimationEndListener() { + @Override + public void onAnimationEnd() { + setVisibility(INVISIBLE); + if (materialIntroListener != null) + materialIntroListener.onUserClicked(materialIntroViewId); + } }); } @@ -401,57 +411,73 @@ private void dismiss() { * circle. If circle's Y coordiante is bigger than * Y coordinate of root view, then locate cardview * above the circle. Otherwise locate below. - * - * @param viewPositionY - * @param circle */ - private void setInfoLayout(int viewPositionY, Circle circle) { - - isLayoutCompleted = true; - - if (infoView.getParent() != null) - ((ViewGroup) infoView.getParent()).removeView(infoView); + private void setInfoLayout() { - RelativeLayout.LayoutParams infoDialogParams = new RelativeLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.FILL_PARENT); - - if (circle.getPoint().y < viewPositionY / 2) { - ((RelativeLayout) infoView).setGravity(Gravity.TOP); - infoDialogParams.setMargins(0, circle.getPoint().y + circle.getRadius(), 0, 0); - } else { - ((RelativeLayout) infoView).setGravity(Gravity.BOTTOM); - infoDialogParams.setMargins(0, 0, 0, height - (circle.getPoint().y + circle.getRadius()) + 2 * circle.getRadius()); - } + handler.post(new Runnable() { + @Override + public void run() { + isLayoutCompleted = true; + + if (infoView.getParent() != null) + ((ViewGroup) infoView.getParent()).removeView(infoView); + + RelativeLayout.LayoutParams infoDialogParams = new RelativeLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.FILL_PARENT); + + if (circleShape.getPoint().y < height / 2) { + ((RelativeLayout) infoView).setGravity(Gravity.TOP); + infoDialogParams.setMargins( + 0, + circleShape.getPoint().y + circleShape.getRadius(), + 0, + 0); + } else { + ((RelativeLayout) infoView).setGravity(Gravity.BOTTOM); + infoDialogParams.setMargins( + 0, + 0, + 0, + height - (circleShape.getPoint().y + circleShape.getRadius()) + 2 * circleShape.getRadius()); + } - infoView.setLayoutParams(infoDialogParams); - infoView.postInvalidate(); + infoView.setLayoutParams(infoDialogParams); + infoView.postInvalidate(); - addView(infoView); + addView(infoView); - infoView.setVisibility(VISIBLE); + infoView.setVisibility(VISIBLE); + } + }); } private void setDotViewLayout() { - if (dotView.getParent() != null) - ((ViewGroup) dotView.getParent()).removeView(dotView); - - RelativeLayout.LayoutParams dotViewLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - dotViewLayoutParams.height = Utils.dpToPx(Constants.DEFAULT_DOT_SIZE); - dotViewLayoutParams.width = Utils.dpToPx(Constants.DEFAULT_DOT_SIZE); - dotViewLayoutParams.setMargins( - circleShape.getPoint().x - (dotViewLayoutParams.width / 2), - circleShape.getPoint().y - (dotViewLayoutParams.height / 2), - 0, - 0); - dotView.setLayoutParams(dotViewLayoutParams); - dotView.postInvalidate(); - addView(dotView); - - dotView.setVisibility(VISIBLE); - AnimationFactory.performAnimation(dotView); + handler.post(new Runnable() { + @Override + public void run() { + + if (dotView.getParent() != null) + ((ViewGroup) dotView.getParent()).removeView(dotView); + + RelativeLayout.LayoutParams dotViewLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + dotViewLayoutParams.height = Utils.dpToPx(Constants.DEFAULT_DOT_SIZE); + dotViewLayoutParams.width = Utils.dpToPx(Constants.DEFAULT_DOT_SIZE); + dotViewLayoutParams.setMargins( + circleShape.getPoint().x - (dotViewLayoutParams.width / 2), + circleShape.getPoint().y - (dotViewLayoutParams.height / 2), + 0, + 0); + dotView.setLayoutParams(dotViewLayoutParams); + dotView.postInvalidate(); + addView(dotView); + + dotView.setVisibility(VISIBLE); + AnimationFactory.performAnimation(dotView); + } + }); } /** diff --git a/sample/build.gradle b/sample/build.gradle index 7d7abd1..7de59ae 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -24,6 +24,6 @@ dependencies { testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' - compile 'com.github.iammert:MaterialIntroView:1.0' - //compile project(':materialintro') + //compile 'com.github.iammert:MaterialIntroView:1.0' + compile project(':materialintro') }