Ver código fonte

[공통][New] 로딩 시작 시 보이지 않는 블라인드로 터치 이벤트 차단

hyodong.min 6 anos atrás
pai
commit
1cfb998390

+ 14 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/animation/Loading.java

@@ -53,6 +53,8 @@ public class Loading {
    * @return
    */
   public Loading show() {
+    create();
+
     if (delayMs > 0) {
       disposable = Completable.timer(delayMs, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
         .subscribe(this::showInternal);
@@ -63,17 +65,22 @@ public class Loading {
     return this;
   }
 
-  private void showInternal() {
+  private void create() {
     if (null == view) {
       FrameLayout frameLayout = activity.findViewById(android.R.id.content);
       LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       view = inflater.inflate(R.layout.dialog_loading, null);
       view.setClickable(true);
+      view.setAlpha(0f);
+      frameLayout.addView(view);
+    }
+  }
 
+  private void showInternal() {
+    if (null != view) {
+      view.setAlpha(1f);
       ImageView imageView = view.findViewById(R.id.image_loading);
       animation = new FrameAnimation.Builder(imageView, R.array.loading_animation, 50).repeat(true).build();
-
-      frameLayout.addView(view);
     }
   }
 
@@ -86,11 +93,14 @@ public class Loading {
       disposable = null;
     }
     if (null != view) {
-      animation.stopAnimation();
       FrameLayout frameLayout = activity.findViewById(android.R.id.content);
       frameLayout.removeView(view);
       view = null;
       activity = null;
     }
+    if (null != animation) {
+      animation.stopAnimation();
+      animation = null;
+    }
   }
 }

+ 16 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/animation/LoadingDriver.java

@@ -24,17 +24,19 @@ public class LoadingDriver {
   private int loadingCount = 0;
   private Loading waiter = null;
 
+
   /**
    * 로딩 표시
    * 호출 될 때마다 카운트를 증가시켜 닫기를 대비한다.
    *
    * @param activity
+   * @param delayMs
    * @return
    */
-  public LoadingDriver create(Activity activity) {
+  public LoadingDriver create(Activity activity, int delayMs) {
     ++loadingCount;
     if (null == waiter) {
-      waiter = new Loading(activity, 300);
+      waiter = new Loading(activity, delayMs);
       waiter.show();
       Log.d("APP# LoadingDriver | remove", "|" + " ----------- create!! " + loadingCount);
     }
@@ -42,6 +44,18 @@ public class LoadingDriver {
     return this;
   }
 
+  /**
+   * 로딩 표시
+   * 호출 될 때마다 카운트를 증가시켜 닫기를 대비한다.
+   *
+   * @param activity
+   * @return
+   */
+  public LoadingDriver create(Activity activity) {
+    create(activity, 300);
+    return this;
+  }
+
   /**
    * 로딩 제거
    * 호출 된 카운트를 역산하여 0일 경우 제거 가능하다.

+ 2 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainFragment.java

@@ -62,6 +62,7 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.util.StringUtil;
 import kr.co.zumo.app.lifeplus.util.ViewUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
+import kr.co.zumo.app.lifeplus.view.animation.LoadingDriver;
 import kr.co.zumo.app.lifeplus.view.command.ExitCommand;
 import kr.co.zumo.app.lifeplus.view.command.ScreenCommand;
 import kr.co.zumo.app.lifeplus.view.presenter.CommandInvoker;
@@ -420,7 +421,7 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
 
       button = findViewById(R.id.button_0000);
       button.setOnClickListener(v -> {
-        presenter.showWaiter();
+        new LoadingDriver().create(getActivity(), 5000);
         setDefaultPin();
         renderDebug();
       });