Forráskód Böngészése

[튜토리얼][Common] 오브젝트애니메이터로 변경

Hasemi 7 éve
szülő
commit
a6298a8063

+ 84 - 42
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/Tutorial.java

@@ -3,13 +3,10 @@ package kr.co.zumo.app.lifeplus.view.custom;
 import android.animation.Animator;
 import android.animation.ObjectAnimator;
 import android.content.Context;
-import android.os.Handler;
 import android.support.constraint.ConstraintLayout;
 import android.support.v4.app.FragmentActivity;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
 import android.widget.FrameLayout;
 
 import kr.co.zumo.app.R;
@@ -69,7 +66,9 @@ public class Tutorial {
    * @return
    */
   private ObjectAnimator fadeOut(View target) {
-    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(
+    target.clearAnimation();
+    ObjectAnimator fadeOut;
+    fadeOut = ObjectAnimator.ofFloat(
       target,
       View.ALPHA,
       1.0f,
@@ -87,6 +86,12 @@ public class Tutorial {
     ObjectAnimator firstTutorial = fadeOut(bubble1);
     firstTutorial.setStartDelay(1000);
     firstTutorial.setDuration(1000);
+    firstTutorial.start();
+
+    ObjectAnimator secondTutorial = fadeOut(bubble2);
+    secondTutorial.setStartDelay(2000);
+    secondTutorial.setDuration(1000);
+
     firstTutorial.addListener(new Animator.AnimatorListener() {
       @Override
       public void onAnimationStart(Animator animator) {
@@ -96,6 +101,8 @@ public class Tutorial {
       @Override
       public void onAnimationEnd(Animator animator) {
         bubble2.setVisibility(View.VISIBLE);
+        secondTutorial.start();
+
       }
 
       @Override
@@ -108,12 +115,8 @@ public class Tutorial {
 
       }
     });
-    firstTutorial.start();
 
 
-    ObjectAnimator secondTutorial = fadeOut(bubble2);
-    secondTutorial.setStartDelay(2000);
-    secondTutorial.setDuration(1000);
     secondTutorial.addListener(new Animator.AnimatorListener() {
       @Override
       public void onAnimationStart(Animator animator) {
@@ -136,9 +139,6 @@ public class Tutorial {
 
       }
     });
-
-    secondTutorial.start();
-
   }
 
   private void showTutorialListicleDetail(IEventListener listener) {
@@ -151,6 +151,12 @@ public class Tutorial {
     ObjectAnimator firstTutorial = fadeOut(bubble1);
     firstTutorial.setStartDelay(1000);
     firstTutorial.setDuration(1000);
+    firstTutorial.start();
+
+    ObjectAnimator secondTutorial = fadeOut(bubble2);
+    secondTutorial.setStartDelay(2000);
+    secondTutorial.setDuration(1000);
+
     firstTutorial.addListener(new Animator.AnimatorListener() {
       @Override
       public void onAnimationStart(Animator animator) {
@@ -160,6 +166,7 @@ public class Tutorial {
       @Override
       public void onAnimationEnd(Animator animator) {
         bubble2.setVisibility(View.VISIBLE);
+        secondTutorial.start();
       }
 
       @Override
@@ -172,11 +179,8 @@ public class Tutorial {
 
       }
     });
-    firstTutorial.start();
 
-    ObjectAnimator secondTutorial = fadeOut(bubble2);
-    secondTutorial.setStartDelay(2000);
-    secondTutorial.setDuration(1000);
+
     secondTutorial.addListener(new Animator.AnimatorListener() {
       @Override
       public void onAnimationStart(Animator animator) {
@@ -198,65 +202,103 @@ public class Tutorial {
 
       }
     });
-    secondTutorial.start();
+
   }
 
   private void showTutorialBucketTag(IEventListener listener) {
-    Animation fadeOut = AnimationUtils.loadAnimation(activity, R.anim.fade_out);
     View firstView = inflater.inflate(R.layout.tutorial_bucket_list_tag, null);
+    ConstraintLayout bubble1 = firstView.findViewById(R.id.tutorial_bucket_list_tag1);
+    ConstraintLayout bubble2 = firstView.findViewById(R.id.tutorial_bucket_list_tag2);
+
     View secondView = inflater.inflate(R.layout.tutorial_bucket_list_update, null);
+    ConstraintLayout bubble3 = secondView.findViewById(R.id.tutorial_bucket_list_success);
 
     frameLayout.addView(firstView);
     firstView.setClickable(true);
+    ObjectAnimator first = fadeOut(bubble1);
+    first.setDuration(1000);
+    first.setStartDelay(1000);
+    first.start();
+
+    ObjectAnimator second = fadeOut(bubble2);
+    second.setDuration(1000);
+    second.setStartDelay(1000);
 
-    new Handler().postDelayed(new Runnable() {
+    ObjectAnimator third = fadeOut(bubble3);
+    third.setDuration(1000);
+    third.setStartDelay(1000);
+
+    first.addListener(new Animator.AnimatorListener() {
       @Override
-      public void run() {
+      public void onAnimationStart(Animator animator) {
 
-        firstView.findViewById(R.id.tutorial_bucket_list_tag1).startAnimation(fadeOut);
-        firstView.findViewById(R.id.tutorial_bucket_list_tag1).setVisibility(View.GONE);
       }
-    }, 2000);
 
-    new Handler().postDelayed(new Runnable() {
       @Override
-      public void run() {
+      public void onAnimationEnd(Animator animator) {
+        bubble2.setVisibility(View.VISIBLE);
+        second.start();
+      }
+
+      @Override
+      public void onAnimationCancel(Animator animator) {
 
-        firstView.findViewById(R.id.tutorial_bucket_list_tag2).setVisibility(View.VISIBLE);
       }
-    }, 3000);
 
-    new Handler().postDelayed(new Runnable() {
       @Override
-      public void run() {
+      public void onAnimationRepeat(Animator animator) {
 
-        firstView.findViewById(R.id.tutorial_bucket_list_tag2).startAnimation(fadeOut);
-        firstView.findViewById(R.id.tutorial_bucket_list_tag2).setVisibility(View.GONE);
       }
-    }, 4000);
+    });
+
 
-    new Handler().postDelayed(new Runnable() {
+    second.addListener(new Animator.AnimatorListener() {
       @Override
-      public void run() {
+      public void onAnimationStart(Animator animator) {
+
+      }
+
+      @Override
+      public void onAnimationEnd(Animator animator) {
         frameLayout.removeView(firstView);
         frameLayout.addView(secondView);
+        third.start();
+      }
+
+      @Override
+      public void onAnimationCancel(Animator animator) {
+
       }
-    }, 6000);
 
-    new Handler().postDelayed(new Runnable() {
       @Override
-      public void run() {
-        secondView.findViewById(R.id.tutorial_bucket_list_success).startAnimation(fadeOut);
-        secondView.findViewById(R.id.tutorial_bucket_list_success).setVisibility(View.GONE);
+      public void onAnimationRepeat(Animator animator) {
 
       }
-    }, 7000);
+    });
+
 
-    new Handler().postDelayed(new Runnable() {
+    third.addListener(new Animator.AnimatorListener() {
       @Override
-      public void run() {
+      public void onAnimationStart(Animator animator) {
+
+      }
+
+      @Override
+      public void onAnimationEnd(Animator animator) {
         frameLayout.removeView(secondView);
       }
-    }, 9000);
+
+      @Override
+      public void onAnimationCancel(Animator animator) {
+
+      }
+
+      @Override
+      public void onAnimationRepeat(Animator animator) {
+
+      }
+    });
+
+
   }
 }