فهرست منبع

[회원가입][Common] 스피너 선택시 키보드 숨김 추가

Hasemi 7 سال پیش
والد
کامیت
66d1919515
1فایلهای تغییر یافته به همراه62 افزوده شده و 9 حذف شده
  1. 62 9
      app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/MobileAuthorizationDialog.java

+ 62 - 9
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/MobileAuthorizationDialog.java

@@ -11,6 +11,7 @@ import android.text.Editable;
 import android.text.TextWatcher;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowManager;
@@ -85,7 +86,7 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
   @Override
   public void onCreate(Bundle savedInstanceState) {
     setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
-     inputMethodManager = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
+    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
     presenter = new MobileAuthorizationPresenter(this);
     if (null != resultListener) {
       presenter.setResultListener(resultListener);
@@ -113,12 +114,10 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
   @Nullable
   @Override
   public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
-    WindowManager.LayoutParams lp = getDialog().getWindow().getAttributes();
-    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
     getDialog().setTitle(R.string.sign_up_mobile_identify_pop_up);
     addButtonToDialogTitle(getDialog());
     View view = inflater.inflate(R.layout.sign_up_phone_identify_dialog, container, false);
-
     initView(view);
 
     return view;
@@ -133,9 +132,48 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
 
     if (getDialog() != null) {
       getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+/*      int MIN_KEYBOARD_HEIGHT_PX = 150;
+      View decorView = getDialog().getWindow().getDecorView();
+
+      decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+        private final Rect windowVisibleDisplayFrame = new Rect();
+        private int lastVisibleDecorViewHeight;
+        @Override
+        public void onGlobalLayout() {
+          // Retrieve visible rectangle inside window.
+          decorView.getWindowVisibleDisplayFrame(windowVisibleDisplayFrame);
+          final int visibleDecorViewHeight = windowVisibleDisplayFrame.height();
+
+          // 현재화면 height
+          Log.e("APP#  MobileAuthorizationDialog | onGlobalLayout", "|" + visibleDecorViewHeight);
+          if (lastVisibleDecorViewHeight != 0) {
+            if (lastVisibleDecorViewHeight > visibleDecorViewHeight + MIN_KEYBOARD_HEIGHT_PX) {
+              // Calculate current keyboard height (this includes also navigation bar height when in fullscreen mode).
+              int currentKeyboardHeight = decorView.getHeight() - windowVisibleDisplayFrame.bottom;
+              // Notify listener about keyboard being shown.
+              onKeyboardShown(currentKeyboardHeight);
+            } else if (lastVisibleDecorViewHeight + MIN_KEYBOARD_HEIGHT_PX < visibleDecorViewHeight) {
+              // Notify listener about keyboard being hidden.
+              onKeyboardHidden();
+            }
+          }
+          // Save current decor view height for the next call.
+          lastVisibleDecorViewHeight = visibleDecorViewHeight;
+        }
+      });*/
     }
   }
 
+  public void onKeyboardShown(int currentKeyboardHeight) {
+    Log.e("APP#  MobileAuthorizationDialog | onKeyboardShown", "|" + currentKeyboardHeight);
+
+  }
+
+  public void onKeyboardHidden() {
+    Log.e("APP#  MobileAuthorizationDialog | onKeyboardHidden", "|" + "keyboardHidden");
+
+  }
+
   /**
    * 상단 바의 닫힘 버튼 구현 및 버튼 클릭 이벤트 발생
    *
@@ -248,20 +286,18 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
     editTextPhoneNumber.addTextChangedListener(new TextWatcher() {
       @Override
       public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
       }
 
       @Override
       public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-        Log.e("APP#  MobileAuthorizationDialog | onTextChanged", "|" +phoneIdentifyLayout.getMeasuredHeight() + ", " +  scrollView.getMeasuredHeight());
-        int offset = phoneIdentifyLayout.getMeasuredHeight() - ScrollViewLinearLayout.getMeasuredHeight();
-        scrollView.scrollTo(0 , offset);
+        Log.e("APP#  MobileAuthorizationDialog | onTextChanged", "|" + "onTextChanged");
+        scrollView.smoothScrollTo(0, 1012);
+        scrollView.setSmoothScrollingEnabled(false);
         presenter.onPhoneNumberTextChanged(charSequence.toString());
       }
 
       @Override
       public void afterTextChanged(Editable editable) {
-
       }
     });
 
@@ -310,6 +346,22 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
       }
     });
 
+    spinnerFirstPhoneNumber.setOnTouchListener(new View.OnTouchListener() {
+      @Override
+      public boolean onTouch(View view, MotionEvent motionEvent) {
+        presenter.doHideKeyBoard();
+        return false;
+      }
+    });
+
+    spinnerMobileCompany.setOnTouchListener(new View.OnTouchListener() {
+      @Override
+      public boolean onTouch(View view, MotionEvent motionEvent) {
+        presenter.doHideKeyBoard();
+        return false;
+      }
+    });
+
     spinnerMobileCompany.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
       @Override
       public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
@@ -317,6 +369,7 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
         presenter.doHideKeyBoard();
       }
 
+
       @Override
       public void onNothingSelected(AdapterView<?> adapterView) {