Ver código fonte

[공통][Common] 좋아요, 북마크 애니메이션 일괄적용

Hasemi 6 anos atrás
pai
commit
60ecf3865e

+ 35 - 9
app/src/main/java/kr/co/zumo/app/lifeplus/helper/NavigationBar.java

@@ -416,7 +416,6 @@ public class NavigationBar {
    * public
    ***********************************/
   /**
-   * show
    */
   public void show() {
     navigationView.setVisibility(View.VISIBLE);
@@ -491,18 +490,31 @@ public class NavigationBar {
   public void setLiked(boolean isChecked, boolean isAnim) {
     BlackWhite blackWhite = getBlackWhite(buttonLike);
     blackWhite.setChecked(isChecked);
+    LikeAnimation likeAnimation = new LikeAnimation();
+    int drawableRes;
+    if (isWhite) {
+      drawableRes = R.drawable.icon_header_like_wh_off;
+    }
+    else {
+      drawableRes = R.drawable.icon_header_like_bk_off;
+    }
+
     if (isChecked) {
       if (isAnim) {
-        LikeAnimation likeAnimation = new LikeAnimation();
-        likeAnimation.show(buttonLike);
+        likeAnimation.onAnimationShow(buttonLike);
       }
       else {
         buttonLike.setImageResource(R.drawable.icon_header_like_wh_on);
       }
     }
     else {
-      buttonLike.setImageResource(R.drawable.icon_header_like_wh_off);
-      blackWhite.change(isWhite);
+      if (isAnim) {
+        likeAnimation.offAnimationShow(buttonLike, drawableRes);
+      }
+      else {
+        buttonLike.setImageResource(R.drawable.icon_header_like_wh_off);
+        blackWhite.change(isWhite);
+      }
     }
   }
 
@@ -518,18 +530,32 @@ public class NavigationBar {
   public void setBookmarked(boolean isChecked, boolean isAnim) {
     BlackWhite blackWhite = getBlackWhite(buttonBookmark);
     blackWhite.setChecked(isChecked);
+    BookmarkAnimation bookmarkAnimation = new BookmarkAnimation();
+    int drawableRes;
+    if (isWhite) {
+      drawableRes = R.drawable.icon_header_bookmark_wh_off;
+    }
+    else {
+      drawableRes = R.drawable.icon_header_bookmark_bk_off;
+    }
+
     if (isChecked) {
       if (isAnim) {
-        BookmarkAnimation bookmarkAnimation = new BookmarkAnimation();
-        bookmarkAnimation.show(buttonBookmark);
+        bookmarkAnimation.onAnimationShow(buttonBookmark);
       }
       else {
+        bookmarkAnimation.offAnimationShow(buttonBookmark, drawableRes);
         buttonBookmark.setImageResource(R.drawable.icon_header_bookmark_wh_on);
       }
     }
     else {
-      buttonBookmark.setImageResource(R.drawable.icon_header_bookmark_wh_off);
-      blackWhite.change(isWhite);
+      if (isAnim) {
+        bookmarkAnimation.offAnimationShow(buttonBookmark, drawableRes);
+      }
+      else {
+        buttonBookmark.setImageResource(R.drawable.icon_header_bookmark_wh_off);
+        blackWhite.change(isWhite);
+      }
     }
   }
 

+ 12 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/animation/BookmarkAnimation.java

@@ -4,6 +4,8 @@
 package kr.co.zumo.app.lifeplus.view.animation;
 
 import android.graphics.drawable.AnimationDrawable;
+import android.support.annotation.DrawableRes;
+import android.support.v4.content.ContextCompat;
 import android.widget.ImageView;
 
 import kr.co.zumo.app.R;
@@ -22,11 +24,19 @@ public class BookmarkAnimation {
 
   private AnimationDrawable animationDrawable;
 
-  public void show(ImageView target){
+  public void onAnimationShow(ImageView target) {
     target.setImageResource(R.drawable.bookmark_on_animation);
-    animationDrawable = (AnimationDrawable)target.getDrawable();
+    animationDrawable = (AnimationDrawable) target.getDrawable();
     animationDrawable.setOneShot(true);
     animationDrawable.start();
   }
 
+  public void offAnimationShow(ImageView target, @DrawableRes int drawableRes) {
+    target.setImageResource(R.drawable.bookmark_off_animation);
+    animationDrawable = (AnimationDrawable) target.getDrawable();
+    animationDrawable.setOneShot(true);
+    animationDrawable.addFrame(ContextCompat.getDrawable(target.getContext(), drawableRes), 40);
+    animationDrawable.start();
+  }
+
 }

+ 12 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/animation/LikeAnimation.java

@@ -4,6 +4,9 @@
 package kr.co.zumo.app.lifeplus.view.animation;
 
 import android.graphics.drawable.AnimationDrawable;
+import android.support.annotation.DrawableRes;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.content.res.AppCompatResources;
 import android.widget.ImageView;
 
 import kr.co.zumo.app.R;
@@ -22,12 +25,18 @@ public class LikeAnimation {
 
   private AnimationDrawable animationDrawable;
 
-  public void show(ImageView target){
+  public void onAnimationShow(ImageView target) {
     target.setImageResource(R.drawable.like_on_animation);
-    animationDrawable = (AnimationDrawable)target.getDrawable();
+    animationDrawable = (AnimationDrawable) target.getDrawable();
     animationDrawable.setOneShot(true);
     animationDrawable.start();
   }
 
-
+  public void offAnimationShow(ImageView target, @DrawableRes int drawableRes) {
+    target.setImageDrawable(AppCompatResources.getDrawable(target.getContext(), R.drawable.like_off_animation));
+    animationDrawable = (AnimationDrawable) target.getDrawable();
+    animationDrawable.setOneShot(true);
+    animationDrawable.addFrame(ContextCompat.getDrawable(target.getContext(), drawableRes), 40);
+    animationDrawable.start();
+  }
 }

+ 9 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/BookmarkCheckbox.java

@@ -42,17 +42,23 @@ public class BookmarkCheckbox extends AbstractCheckbox {
 
   public void setChecked(boolean isChecked, boolean isAnim) {
     this.isChecked = isChecked;
+    BookmarkAnimation bookmarkAnimation = new BookmarkAnimation();
     if (isChecked) {
       if (isAnim) {
-        BookmarkAnimation bookmarkAnimation = new BookmarkAnimation();
-        bookmarkAnimation.show(checkImage);
+        bookmarkAnimation.onAnimationShow(checkImage);
       }
       else {
         checkImage.setImageResource(R.drawable.icon_bookmark_on);
       }
     }
     else {
-      checkImage.setImageResource(R.drawable.icon_bookmark_off);
+      if (isAnim) {
+        bookmarkAnimation.offAnimationShow(checkImage, R.drawable.icon_bookmark_off);
+      }
+      else {
+        checkImage.setImageResource(R.drawable.icon_bookmark_off);
+      }
+
     }
 
   }

+ 8 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/LikeCheckbox.java

@@ -43,18 +43,23 @@ public class LikeCheckbox extends AbstractCheckbox {
   @Override
   protected void setChecked(boolean isChecked, boolean isAnim) {
     this.isChecked = isChecked;
+    LikeAnimation likeAnimation = new LikeAnimation();
 
     if (isChecked) {
       if (isAnim) {
-        LikeAnimation likeAnimation = new LikeAnimation();
-        likeAnimation.show(checkImage);
+        likeAnimation.onAnimationShow(checkImage);
       }
       else {
         checkImage.setImageResource(R.drawable.icon_like_on);
       }
     }
     else {
-      checkImage.setImageResource(R.drawable.icon_like_off);
+      if (isAnim) {
+        likeAnimation.offAnimationShow(checkImage, R.drawable.icon_like_off);
+      }
+      else {
+        checkImage.setImageResource(R.drawable.icon_like_off);
+      }
     }
 
   }

+ 23 - 8
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/ContentsOverviewFragment.java

@@ -148,10 +148,11 @@ public class ContentsOverviewFragment extends FragmentBase<ContentsOverviewPrese
 
   @Override
   public void setLiked(boolean isChecked, boolean isAnim) {
+    LikeAnimation likeAnimation = new LikeAnimation();
+
     if (isChecked) {
-      if (isAnim == false) {
-        LikeAnimation likeAnimation = new LikeAnimation();
-        likeAnimation.show(imageLiked);
+      if (isAnim) {
+        likeAnimation.onAnimationShow(imageLiked);
       }
       else {
         imageLiked.setImageResource(R.drawable.icon_header_like_wh_on);
@@ -159,7 +160,12 @@ public class ContentsOverviewFragment extends FragmentBase<ContentsOverviewPrese
 
     }
     else {
-      imageLiked.setImageResource(R.drawable.icon_header_like_off_over_view);
+      if (isAnim) {
+        likeAnimation.offAnimationShow(imageLiked, R.drawable.icon_header_like_off_over_view);
+      }
+      else {
+        imageLiked.setImageResource(R.drawable.icon_header_like_off_over_view);
+      }
     }
   }
 
@@ -169,6 +175,7 @@ public class ContentsOverviewFragment extends FragmentBase<ContentsOverviewPrese
       imageBookmark.setImageResource(R.drawable.icon_header_bookmark_wh_on);
     }
     else {
+
       imageBookmark.setImageResource(R.drawable.icon_header_bookmark_off_over_view);
     }
 
@@ -176,10 +183,11 @@ public class ContentsOverviewFragment extends FragmentBase<ContentsOverviewPrese
 
   @Override
   public void setBookmarked(boolean isChecked, boolean isAnim) {
+    BookmarkAnimation bookmarkAnimation = new BookmarkAnimation();
+
     if (isChecked) {
-      if (isAnim == false) {
-        BookmarkAnimation bookmarkAnimation= new BookmarkAnimation();
-        bookmarkAnimation.show(imageBookmark);
+      if (isAnim) {
+        bookmarkAnimation.onAnimationShow(imageBookmark);
       }
       else {
         imageBookmark.setImageResource(R.drawable.icon_header_bookmark_wh_on);
@@ -187,7 +195,14 @@ public class ContentsOverviewFragment extends FragmentBase<ContentsOverviewPrese
 
     }
     else {
-      imageBookmark.setImageResource(R.drawable.icon_header_bookmark_off_over_view);
+
+      if (isAnim) {
+        bookmarkAnimation.offAnimationShow(imageBookmark, R.drawable.icon_header_bookmark_off_over_view);
+      }
+      else {
+        imageBookmark.setImageResource(R.drawable.icon_header_bookmark_off_over_view);
+      }
+
     }
   }
 

+ 44 - 16
app/src/main/res/drawable/bookmark_off_animation.xml

@@ -1,18 +1,46 @@
 <?xml version="1.0" encoding="utf-8"?>
-<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
-  <item android:drawable="@drawable/bookmark_00000_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00001_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00002_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00003_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00004_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00005_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00006_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00007_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00008_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00009_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00010_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00011_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00012_off" android:duration="40"/>
-  <item android:drawable="@drawable/bookmark_00013_off" android:duration="40"/>
-  <item android:drawable="@drawable/icon_header_bookmark_wh_off" android:duration="40"/>
+<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
+                android:oneshot="true">
+  <item
+    android:drawable="@drawable/bookmark_00000_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00001_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00002_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00003_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00004_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00005_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00006_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00007_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00008_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00009_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00010_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00011_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00012_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/bookmark_00013_off"
+    android:duration="40"/>
 </animation-list>

+ 20 - 0
app/src/main/res/drawable/icon_header_bookmark_bk_off.xml

@@ -0,0 +1,20 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="18dp"
+        android:height="18dp"
+        android:viewportWidth="70"
+        android:viewportHeight="70">
+  <group
+    android:pivotX="35"
+    android:pivotY="35"
+    android:scaleX="0.86"
+    android:scaleY="0.86">
+
+    <path
+      android:fillColor="#00000000"
+      android:fillType="evenOdd"
+      android:pathData="M11,8h49v54L36,44 11,62z"
+      android:strokeWidth="6"
+      android:strokeColor="#000"
+      android:strokeLineCap="square"/>
+  </group>
+</vector>

+ 19 - 0
app/src/main/res/drawable/icon_header_like_bk_off.xml

@@ -0,0 +1,19 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="18dp"
+        android:height="18dp"
+        android:viewportWidth="70"
+        android:viewportHeight="70">
+
+  <group
+    android:pivotX="35"
+    android:pivotY="35"
+    android:scaleX="0.86"
+    android:scaleY="0.86">
+    <path
+      android:fillType="evenOdd"
+      android:pathData="M35,61c-0.738,0 -1.476,-0.234 -2,-1 -5.896,-4.034 -21.937,-16.426 -26,-24 -4.396,-8.311 -1.632,-19.5 6,-25 3.091,-1.212 5.986,-2 9,-2 4.848,0 9.737,2.425 13,7 3.264,-4.576 8.152,-7 13,-7 3.013,0 5.907,0.788 9,2 7.631,5.5 10.395,16.689 6,25 -4.063,7.574 -20.106,19.966 -26,24 -0.526,0.766 -1.263,1 -2,1z"
+      android:strokeWidth="6"
+      android:strokeColor="@color/C000000"
+      android:strokeLineCap="square"/>
+  </group>
+</vector>

+ 47 - 17
app/src/main/res/drawable/like_off_animation.xml

@@ -1,19 +1,49 @@
 <?xml version="1.0" encoding="utf-8"?>
-<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
-  <item android:drawable="@drawable/like_00000_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00001_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00002_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00003_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00004_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00005_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00006_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00007_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00008_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00009_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00010_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00011_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00012_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00013_off" android:duration="40"/>
-  <item android:drawable="@drawable/like_00014_off" android:duration="40"/>
-  <item android:drawable="@drawable/icon_header_like_wh_off" android:duration="40"/>
+<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
+                android:oneshot="true">
+  <item
+    android:drawable="@drawable/like_00000_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00001_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00002_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00003_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00004_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00005_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00006_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00007_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00008_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00009_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00010_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00011_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00012_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00013_off"
+    android:duration="40"/>
+  <item
+    android:drawable="@drawable/like_00014_off"
+    android:duration="40"/>
 </animation-list>