Browse Source

Merge branch 'develop' of https://github.com/swict/LifePlusAndroid into develop

hyodong.min 7 years ago
parent
commit
e08bd0146c

+ 13 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/Tutorial.java

@@ -5,6 +5,7 @@ import android.animation.ObjectAnimator;
 import android.content.Context;
 import android.support.constraint.ConstraintLayout;
 import android.support.v4.app.FragmentActivity;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.FrameLayout;
@@ -30,6 +31,7 @@ public class Tutorial {
   private FragmentActivity activity;
   private FrameLayout frameLayout;
   private LayoutInflater inflater;
+  private ObjectAnimator fadeOut;
 
   public final static int TUTORIAL_LISTICLE_COVER = 0;
   public final static int TUTORIAL_LISTICLE_DETAIL = 1;
@@ -60,6 +62,12 @@ public class Tutorial {
 
   }
 
+  public void cancel(){
+    if(fadeOut != null){
+      fadeOut.cancel();
+    }
+  }
+
   /**
    * 공통으로 사용되는 ObjectAnimator 객체 반환
    *
@@ -68,8 +76,7 @@ public class Tutorial {
    */
   private ObjectAnimator fadeOut(View target) {
     target.clearAnimation();
-    ObjectAnimator fadeOut;
-    fadeOut = ObjectAnimator.ofFloat(
+    this.fadeOut = ObjectAnimator.ofFloat(
       target,
       View.ALPHA,
       1.0f,
@@ -78,6 +85,7 @@ public class Tutorial {
     return fadeOut;
   }
 
+
   private void showTutorialListicleCover(IEventListener listener) {
     View view = inflater.inflate(R.layout.tutorial_listicle_cover, null);
     frameLayout.addView(view);
@@ -128,7 +136,9 @@ public class Tutorial {
       @Override
       public void onAnimationEnd(Animator animator) {
         frameLayout.removeView(view);
-        listener.onEvent(new Event.Builder(Event.NEXT).build());
+        if(null != listener){
+          listener.onEvent(new Event.Builder(Event.NEXT).build());
+        }
       }
 
       @Override

+ 36 - 13
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/ContentsFragment.java

@@ -52,6 +52,7 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
   private TextView textViewPageNumber;
   private String direction = null;
   private CustomPagerSnapHelper snapHelper;
+  private Tutorial tutorial;
 
   private RecyclerView.OnScrollListener scrollEventListener;
 
@@ -127,7 +128,23 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
 
   @Override
   protected void onAfterDestroy() {
+    if (null != tutorial) {
+      tutorial.cancel();
+    }
+  }
+
+  @Override
+  public void onStop() {
+    super.onStop();
+    if (null != tutorial) {
+      tutorial.cancel();
+    }
+  }
 
+  @Override
+  public void onStart() {
+    super.onStart();
+    tutorial = new Tutorial();
   }
 
   @Override
@@ -274,24 +291,30 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
 
   @Override
   public void showTutorialListicle() {
-    Tutorial tutorial = new Tutorial();
-    tutorial.showTutorial(getActivity(), Tutorial.TUTORIAL_LISTICLE_COVER, new IEventListener() {
-      @Override
-      public void onEvent(Event event) {
-        presenter.onEvent(event);
-      }
-    });
+    if (null != tutorial) {
+      tutorial.showTutorial(getActivity(), Tutorial.TUTORIAL_LISTICLE_COVER, new IEventListener() {
+        @Override
+        public void onEvent(Event event) {
+          if(null != event){
+            presenter.onEvent(event);
+          }
+        }
+      });
+    }
+
   }
 
   @Override
   public void showTutorialListicleDetail() {
-    Tutorial tutorial = new Tutorial();
-    tutorial.showTutorial(getActivity(), Tutorial.TUTORIAL_LISTICLE_DETAIL, new IEventListener() {
-      @Override
-      public void onEvent(Event event) {
+    if (null != tutorial) {
+      tutorial.showTutorial(getActivity(), Tutorial.TUTORIAL_LISTICLE_DETAIL, new IEventListener() {
+        @Override
+        public void onEvent(Event event) {
+
+        }
+      });
+    }
 
-      }
-    });
   }
 
 }