Bladeren bron

[마이][Bug] 버킷리스트 등록 화면 레이아웃 및 UI 작동 로직 수정

hyodong.min 7 jaren geleden
bovenliggende
commit
14eb7d0e55

+ 14 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/IMyBucketListView.java

@@ -1,7 +1,5 @@
 package kr.co.zumo.app.lifeplus.view;
 
-import android.widget.RelativeLayout;
-
 /**
  * IMyBucketListView
  * <pre>
@@ -12,8 +10,19 @@ import android.widget.RelativeLayout;
  * @history 하세미   [2018-10-18]   [최초 작성]
  * @since 2018-10-18
  */
-public interface IMyBucketListView extends  IView {
+public interface IMyBucketListView extends IView {
+
+  /**
+   * 등록 버튼 보이기 안보이기
+   *
+   * @param isVisible
+   */
+  void setVisibleRegisterButton(boolean isVisible);
 
-  void onTextChanged(String inputText);
-  void onLayoutChange(int visible, RelativeLayout.LayoutParams layoutParams, int margin);
+  /**
+   * 키보드 표시 유무에 따라서 레이아웃 설정
+   *
+   * @param isBig
+   */
+  void setLayoutSize(boolean isBig);
 }

+ 37 - 27
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/my/bucketlist/AddMyBucketListFragment.java

@@ -7,14 +7,12 @@ import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.text.Editable;
 import android.text.TextWatcher;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ImageView;
-import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import java.util.ArrayList;
@@ -24,7 +22,6 @@ import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.TextImageBean;
 import kr.co.zumo.app.lifeplus.manager.ActionBarManager;
 import kr.co.zumo.app.lifeplus.model.MyBucketListModel;
-import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
 import kr.co.zumo.app.lifeplus.view.IMyBucketListView;
 import kr.co.zumo.app.lifeplus.view.fragment.FragmentBase;
@@ -67,7 +64,6 @@ public class AddMyBucketListFragment extends FragmentBase<MyBucketListPresenter>
     editTextMyBucketTitle.addTextChangedListener(new TextWatcher() {
       @Override
       public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
       }
 
       @Override
@@ -76,8 +72,23 @@ public class AddMyBucketListFragment extends FragmentBase<MyBucketListPresenter>
       }
 
       @Override
-      public void afterTextChanged(Editable editable) {
-
+      public void afterTextChanged(Editable s) {
+        /*
+         * The loop is in reverse for a purpose,
+         * each replace or delete call on the Editable will cause
+         * the afterTextChanged method to be called again.
+         * Hence the return statement after the first removal.
+         * http://developer.android.com/reference/android/text/TextWatcher.html#afterTextChanged(android.text.Editable)
+         */
+        /*
+          엔터는 제거해준다.
+         */
+        for (int i = s.length() - 1; i >= 0; --i) {
+          if (s.charAt(i) == '\n') {
+            s.delete(i, i + 1);
+            return;
+          }
+        }
       }
     });
 
@@ -86,27 +97,15 @@ public class AddMyBucketListFragment extends FragmentBase<MyBucketListPresenter>
     recyclerViewImageList = findViewById(R.id.recycler_view_image_list);
 
     doDummyData();
+
     AddMyBucketListAdapter addMyBucketListAdapter = new AddMyBucketListAdapter(getActivity(), addMyBucketListData);
     recyclerViewImageList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
     recyclerViewImageList.setAdapter(addMyBucketListAdapter);
-    RelativeLayout.LayoutParams layoutParams =  (RelativeLayout.LayoutParams) recyclerViewImageList.getLayoutParams();
 
-    recyclerViewImageList.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
-      @Override
-      public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
-        if(bottom < oldBottom){
-          //parameter 설명:
-          // 1. textViewMyBucketDetail visibility 설정
-          // 2. recyclerViewImageList layoutPrams 세팅
-          // 3. recyclerViewImageList marginBottom  조정
-          presenter.onLayoutChange(View.INVISIBLE, layoutParams , 35);
-        }else{
-          presenter.onLayoutChange(View.VISIBLE, layoutParams , 20);
-        }
-      }
+    recyclerViewImageList.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
+      presenter.onLayoutChange(view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom);
     });
 
-
   }
 
   @Override
@@ -135,15 +134,26 @@ public class AddMyBucketListFragment extends FragmentBase<MyBucketListPresenter>
     addMyBucketListData.add(new TextImageBean(R.drawable.img_select_bg_10, R.string.bucket_select_text5));
   }
 
+  /**
+   * 등록 버튼 보이기 안보이기
+   *
+   * @param isVisible
+   */
   @Override
-  public void onTextChanged(String inputText) {
-    buttonAddMyBucket.setVisibility(inputText.length() == 0 ? View.INVISIBLE : View.VISIBLE);
+  public void setVisibleRegisterButton(boolean isVisible) {
+    buttonAddMyBucket.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
   }
 
+  /**
+   * 키보드 표시 유무에 따라서 레이아웃 설정
+   *
+   * @param isBig
+   */
   @Override
-  public void onLayoutChange(int visible, RelativeLayout.LayoutParams layoutParams, int margin) {
-    textViewMyBucketDetail.setVisibility(visible);
-    layoutParams.setMargins(0, 0 ,0 , ResourceUtil.dpToPx(margin));
-    recyclerViewImageList.setLayoutParams(layoutParams);
+  public void setLayoutSize(boolean isBig) {
+    // setVisibility 를 직접 실행하면 누락되는 경우가 있어서 post 로 실행
+    textViewMyBucketDetail.post(() -> {
+      textViewMyBucketDetail.setVisibility(isBig ? View.VISIBLE : View.GONE);
+    });
   }
 }

+ 33 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/presenter/MyBucketListPresenter.java

@@ -1,6 +1,7 @@
 package kr.co.zumo.app.lifeplus.view.presenter;
 
-import android.widget.RelativeLayout;
+import android.util.Log;
+import android.view.View;
 
 import kr.co.zumo.app.lifeplus.model.MyBucketListModel;
 import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
@@ -67,14 +68,41 @@ public class MyBucketListPresenter extends Presenter<MyBucketListModel, IMyBucke
     }
   }
 
+  /**
+   * 텍스트 입력 시 실행
+   *
+   * @param inputText
+   */
   public void onTextChanged(String inputText) {
-    view.onTextChanged(inputText);
+    view.setVisibleRegisterButton(inputText.length() != 0);
   }
 
-  public void onLayoutChange(int visible, RelativeLayout.LayoutParams layoutParams, int margin){
-    view.onLayoutChange(visible, layoutParams, margin);
-
+  /**
+   * 레이아웃 변경시 실행
+   *
+   * @param view
+   * @param left
+   * @param top
+   * @param right
+   * @param bottom
+   * @param oldLeft
+   * @param oldTop
+   * @param oldRight
+   * @param oldBottom
+   */
+  public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+    Log.i("APP# MyBucketListPresenter | onLayoutChange", "|" + "bottom: " + bottom + ", oldBottom: " + oldBottom);
+    if (Math.abs(oldBottom - bottom) > 100) {
+      if (bottom < oldBottom) {
+        this.view.setLayoutSize(false);
+      }
+      else {
+        this.view.setLayoutSize(true);
+      }
+    }
   }
+
+
   @Override
   public void onResult(Event event) {
 

+ 26 - 23
app/src/main/res/layout/fragment_add_my_bucket_list.xml

@@ -1,38 +1,38 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
+<android.support.constraint.ConstraintLayout
   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:layout_width="match_parent"
   android:layout_height="match_parent"
-
   >
 
   <ImageView
+    android:id="@+id/imageView2"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:scaleType="centerCrop"
-    android:src="@drawable/img_bestbucket_1"
-    />
-
+    android:src="@drawable/img_bestbucket_1"/>
 
   <EditText
     android:id="@+id/edit_text_my_bucket"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_alignParentStart="true"
-    android:layout_centerVertical="true"
+    android:layout_marginStart="40dp"
+    android:layout_marginEnd="40dp"
     android:background="@null"
     android:hint="@string/make_my_bucket_list"
-    android:lineSpacingExtra="11sp"
-    android:maxLines="1"
     android:imeOptions="normal"
+    android:lineSpacingExtra="11sp"
+    android:maxLines="2"
     android:textAlignment="center"
-    android:gravity="top"
     android:textColor="@color/CFFFFFF"
     android:textColorHint="#80FFFFFF"
     android:textCursorDrawable="@drawable/white_cursor"
-    android:textSize="28sp"/>
+    android:textSize="28sp"
+    app:layout_constraintBottom_toTopOf="@+id/button_add_my_bucket"
+    app:layout_constraintTop_toTopOf="parent"
+    app:layout_constraintVertical_chainStyle="packed"/>
 
   <Button
     android:id="@+id/button_add_my_bucket"
@@ -40,33 +40,36 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_below="@+id/edit_text_my_bucket"
-    android:layout_centerHorizontal="true"
     android:layout_marginTop="25dp"
+    android:layout_marginBottom="8dp"
+    android:text="@string/registration"
     android:visibility="invisible"
-    tools:visibility="visible"
-    android:text="@string/registration"/>
+    app:layout_constraintBottom_toTopOf="@+id/recycler_view_image_list"
+    app:layout_constraintEnd_toEndOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    app:layout_constraintTop_toBottomOf="@+id/edit_text_my_bucket"
+    app:layout_constraintVertical_chainStyle="packed"
+    tools:visibility="invisible"/>
 
   <android.support.v7.widget.RecyclerView
     android:id="@+id/recycler_view_image_list"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:layout_above="@+id/text_view_my_bucket_detail"
-    android:layout_alignParentBottom="true"
-    android:layout_marginBottom="35dp"/>
+    android:layout_height="53dp"
+    android:layout_marginBottom="9dp"
+    app:layout_constraintBottom_toTopOf="@+id/text_view_my_bucket_detail"
+    app:layout_goneMarginBottom="20dp"/>
 
   <TextView
     android:id="@+id/text_view_my_bucket_detail"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:layout_alignParentRight="true"
-    android:layout_alignParentBottom="true"
     android:layout_marginEnd="9dp"
     android:layout_marginBottom="9dp"
-    android:gravity="end"
-    android:lineSpacingExtra="4sp"
     android:text="@string/bucket_select_text1"
     android:textColor="@color/CFFFFFF"
     android:textSize="12sp"
     android:visibility="visible"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"
     />
-</RelativeLayout>
+</android.support.constraint.ConstraintLayout>