소스 검색

[메뉴][Common] 메뉴 애니메이션 적용 중

Hasemi 6 년 전
부모
커밋
145e0b5bed

+ 3 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/event/EventDetailCoverHolder.java

@@ -2,6 +2,7 @@ package kr.co.zumo.app.lifeplus.view.screen.event;
 
 import android.graphics.Bitmap;
 import android.support.annotation.Nullable;
+import android.util.Log;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -97,6 +98,8 @@ public class EventDetailCoverHolder extends EventDetailView<EventEntryBean> {
       textViewEventDate.setText(builder.toString());
       textViewEventPresent.setText(bean.getSubTitleWithTrim());
       textViewEventTitle.setText(bean.getTwoLineTitle());
+      Log.e("APP#  EventDetailCoverHolder | initInternal", " bean.getTimeFrom() |" + bean.getTimeFrom());
+      Log.e("APP#  EventDetailCoverHolder | initInternal", " bean.getTimeTo() |" + bean.getTimeTo());
 
       if (null != bean.getTagList()) {
         TagBean tagBean;

+ 88 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/menu/AllMenuFragment.java

@@ -3,16 +3,27 @@
  */
 package kr.co.zumo.app.lifeplus.view.screen.menu;
 
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
 
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
 import kr.co.zumo.app.lifeplus.util.AppUtil;
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
 import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
 
@@ -27,6 +38,15 @@ import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
  * @since 2018. 10. 17.
  */
 public class AllMenuFragment extends FragmentBase<AllMenuPresenter> implements IAllMenuView {
+
+  private TextView textViewCategory0;
+  private TextView textViewCategory1;
+  private TextView textViewCategory2;
+  private TextView textViewCategory3;
+  private TextView textViewCategory4;
+  private List<TextView> categoryList;
+  private FrameLayout layoutFrame;
+
   @Nullable
   @Override
   protected View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -36,17 +56,33 @@ public class AllMenuFragment extends FragmentBase<AllMenuPresenter> implements I
   @Override
   protected void onAfterActivityCreated(Bundle savedInstanceState) {
 
-    findViewById(R.id.text_view_category_0).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FIRST_CATEGORY).build()));
-    findViewById(R.id.text_view_category_1).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.SECOND_CATEGORY).build()));
-    findViewById(R.id.text_view_category_2).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.THIRD_CATEGORY).build()));
-    findViewById(R.id.text_view_category_3).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FOURTH_CATEGORY).build()));
-    findViewById(R.id.text_view_category_4).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FIFTH_CATEGORY).build()));
+    textViewCategory0 = findViewById(R.id.text_view_category_0);
+    textViewCategory1 = findViewById(R.id.text_view_category_1);
+    textViewCategory2 = findViewById(R.id.text_view_category_2);
+    textViewCategory3 = findViewById(R.id.text_view_category_3);
+    textViewCategory4 = findViewById(R.id.text_view_category_4);
+
+    categoryList = new ArrayList<>();
+    categoryList.add(textViewCategory0);
+    categoryList.add(textViewCategory1);
+    categoryList.add(textViewCategory2);
+    categoryList.add(textViewCategory3);
+    categoryList.add(textViewCategory4);
+
+    textViewCategory0.setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FIRST_CATEGORY).build()));
+    textViewCategory1.setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.SECOND_CATEGORY).build()));
+    textViewCategory2.setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.THIRD_CATEGORY).build()));
+    textViewCategory3.setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FOURTH_CATEGORY).build()));
+    textViewCategory4.setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FIFTH_CATEGORY).build()));
+
 
     findViewById(R.id.text_my).setOnClickListener(v -> presenter.onEvent(new Event.Builder(Event.MY).build()));
     findViewById(R.id.text_view_faq).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.FAQ).build()));
     findViewById(R.id.text_event).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.EVENT).build()));
     findViewById(R.id.text_view_life_plus_guide).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.GUIDE).build()));
 
+    layoutFrame = findViewById(android.R.id.content);
+
     if (AppUtil.isDebug()) {
       findViewById(R.id.text_coupon).setVisibility(View.VISIBLE);
       findViewById(R.id.text_coupon).setOnClickListener(view -> presenter.onEvent(new Event.Builder(Event.COUPON_MALL).build()));
@@ -54,6 +90,28 @@ public class AllMenuFragment extends FragmentBase<AllMenuPresenter> implements I
     else {
       findViewById(R.id.text_coupon).setVisibility(View.GONE);
     }
+
+    setDefaultAnimationSetting();
+  }
+
+  @Override
+  public void setDefaultAnimationSetting() {
+    for (int i = 0; i < categoryList.size(); ++i) {
+      TextView categoryText = categoryList.get(i);
+      categoryText.setTranslationX(ResourceUtil.dpToPx(90));
+      categoryText.setAlpha(0f);
+    }
+  }
+
+  @Override
+  public void hideMenuAnimation() {
+    // <-------------------------------------
+//    ObjectAnimator translationX = ObjectAnimator.ofFloat(layoutFrame, View.TRANSLATION_X, layoutFrame.getWidth(), 0f);
+//    translationX.setDuration(500);
+//    translationX.start();
+    Log.w("APP# AllMenuFragment | hideMenuAnimation", "|" + "hide Menu A");
+    Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.activity_slide_in_enter);
+    layoutFrame.startAnimation(animation);
   }
 
   @Override
@@ -96,4 +154,29 @@ public class AllMenuFragment extends FragmentBase<AllMenuPresenter> implements I
   public void showNotiAnimation(boolean isNewNoti, boolean isAnim) {
     getHelper(ActionBarHelper.class).setNotiMarker(isNewNoti, isAnim);
   }
+
+  /**
+   * 메뉴 애니메이션 추가
+   */
+  @Override
+  public void showMenuAnimation() {
+
+    AnimatorSet animatorSet = new AnimatorSet();
+
+    for (int i = 0; i < categoryList.size(); ++i) {
+      TextView categoryText = categoryList.get(i);
+      ObjectAnimator translationX = ObjectAnimator.ofFloat(categoryText, View.TRANSLATION_X, categoryText.getTranslationX(), 0f);
+      ObjectAnimator alpha = ObjectAnimator.ofFloat(categoryText, View.ALPHA, 0.0f, 1f);
+
+      translationX.setDuration(700);
+      translationX.setStartDelay(100 * i + 1);
+
+      alpha.setDuration(700);
+      alpha.setStartDelay(100 * i + 1);
+
+      animatorSet.playTogether(translationX, alpha);
+    }
+
+    animatorSet.start();
+  }
 }

+ 7 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/menu/AllMenuPresenter.java

@@ -1,5 +1,7 @@
 package kr.co.zumo.app.lifeplus.view.screen.menu;
 
+import android.util.Log;
+
 import kr.co.zumo.app.lifeplus.helper.NavigationBar;
 import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
 import kr.co.zumo.app.lifeplus.view.Event;
@@ -30,11 +32,11 @@ public class AllMenuPresenter extends Presenter<AllMenuModel, IAllMenuView> {
 
   @Override
   protected void destroyInternal() {
-
   }
 
   @Override
   protected void destroyViewInternal() {
+
   }
 
   @Override
@@ -44,7 +46,8 @@ public class AllMenuPresenter extends Presenter<AllMenuModel, IAllMenuView> {
 
   @Override
   protected void startInternalOnce() {
-
+    Log.w("APP# AllMenuPresenter | startInternalOnce", "|" + "====> startInternalOnce");
+    view.setDefaultAnimationSetting();
   }
 
   @Override
@@ -134,6 +137,7 @@ public class AllMenuPresenter extends Presenter<AllMenuModel, IAllMenuView> {
 
   @Override
   public void onNavigationClickClose(NavigationBar navigationBar) {
+    view.hideMenuAnimation();
     onBackPressed();
   }
 
@@ -149,5 +153,6 @@ public class AllMenuPresenter extends Presenter<AllMenuModel, IAllMenuView> {
     // TODO: 알림 1개 이상일 경우 뱃지 노출
     // TODO: 애니메이션 이미지 추후 재요청 
     //view.showNotiAnimation(true, true);
+    view.showMenuAnimation();
   }
 }

+ 6 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/menu/IAllMenuView.java

@@ -18,4 +18,10 @@ import kr.co.zumo.app.lifeplus.view.IView;
 public interface IAllMenuView extends IView {
 
   void showNotiAnimation(boolean isNewNoti, boolean isAnim);
+
+  void showMenuAnimation();
+
+  void setDefaultAnimationSetting();
+
+  void hideMenuAnimation();
 }

+ 12 - 10
app/src/main/res/layout/fragment_all_menu.xml

@@ -3,19 +3,20 @@
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
+  android:id="@+id/container"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">
 
 
   <android.support.constraint.ConstraintLayout
-    android:layout_width="wrap_content"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:layout_marginTop="20dp"
+    android:layout_marginBottom="70dp"
     android:orientation="vertical"
     app:layout_constraintBottom_toBottomOf="@id/view4"
     app:layout_constraintEnd_toEndOf="parent"
-    android:layout_marginTop="20dp"
-    android:layout_marginBottom="70dp"
     app:layout_constraintStart_toStartOf="parent"
     app:layout_constraintTop_toTopOf="parent">
 
@@ -33,7 +34,8 @@
       app:layout_constraintBottom_toTopOf="@+id/text_view_category_1"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
-      app:layout_constraintTop_toTopOf="parent"/>
+      app:layout_constraintTop_toTopOf="parent"
+      app:layout_constraintVertical_chainStyle="spread_inside"/>
 
 
     <TextView
@@ -123,13 +125,13 @@
       android:id="@+id/text_my"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
+      android:layout_marginEnd="3dp"
       android:gravity="center"
       android:lineSpacingExtra="6sp"
+      android:padding="10dp"
       android:text="@string/menu_category1"
       android:textColor="@color/C000000"
       android:textSize="15sp"
-      android:layout_marginEnd="3dp"
-      android:padding="10dp"
       app:layout_constraintEnd_toStartOf="@+id/text_event"
       app:layout_constraintHorizontal_bias="0.5"
       app:layout_constraintStart_toStartOf="parent"/>
@@ -138,14 +140,14 @@
       android:id="@+id/text_event"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
-      android:gravity="center"
       android:layout_marginStart="3dp"
       android:layout_marginEnd="3dp"
+      android:gravity="center"
       android:lineSpacingExtra="6sp"
+      android:padding="10dp"
       android:text="@string/menu_category2"
       android:textColor="@color/C000000"
       android:textSize="15sp"
-      android:padding="10dp"
       app:layout_constraintEnd_toStartOf="@+id/text_coupon"
       app:layout_constraintHorizontal_bias="0.5"
       app:layout_constraintStart_toEndOf="@+id/text_my"/>
@@ -154,13 +156,13 @@
       android:id="@+id/text_coupon"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
+      android:layout_marginStart="3dp"
       android:gravity="center"
-      android:padding="10dp"
       android:lineSpacingExtra="6sp"
+      android:padding="10dp"
       android:text="@string/menu_category3"
       android:textColor="@color/C000000"
       android:textSize="15sp"
-      android:layout_marginStart="3dp"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.5"
       app:layout_constraintStart_toEndOf="@+id/text_event"/>