Skip to content

Commit

Permalink
Retrolambda dependency removed from materialintro library module.
Browse files Browse the repository at this point in the history
  • Loading branch information
iammert committed Jan 31, 2016
1 parent 20a9fd7 commit ce699e9
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 65 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions materialintro/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'

android {
compileSdkVersion 23
Expand All @@ -18,10 +17,6 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);

}

Expand All @@ -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);
}
});
}

Expand All @@ -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);
}
});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

0 comments on commit ce699e9

Please sign in to comment.