Quellcode durchsuchen

[공통][New] 프로그래스 바 위치 이동: toolbar -> AppBarLayout

hyodong.min vor 7 Jahren
Ursprung
Commit
82496d6521

+ 24 - 53
app/src/main/java/kr/co/zumo/app/lifeplus/manager/ActionBarManager.java

@@ -96,11 +96,11 @@ public class ActionBarManager implements IActionBarListener {
     LayoutInflater inflater = LayoutInflater.from(activity);
     View view = inflater.inflate(R.layout.action_bar, null);
 
+    progressBar = appBarLayout.findViewById(R.id.progress_bar);
     actionBarTitle = view.findViewById(R.id.action_bar_title);
     imageBi = view.findViewById(R.id.image_bi);
     buttonSearch = view.findViewById(R.id.button_search);
     buttonMenu = view.findViewById(R.id.button_menu);
-    progressBar = view.findViewById(R.id.progress_bar);
 
     buttonBack = view.findViewById(R.id.button_back);
     buttonBack.setOnClickListener(v -> {
@@ -114,6 +114,12 @@ public class ActionBarManager implements IActionBarListener {
     });
 
     setCustomView(view);
+
+    toolbar = (Toolbar) view.getParent();
+    toolbar.setPadding(0, 0, 0, 0);//for tab otherwise give space in tab
+    toolbar.setContentInsetsAbsolute(0, 0);
+
+    Log.i("APP# ActionBarManager | init", "|" + "progressBar: " + progressBar);
   }
 
   /**
@@ -188,7 +194,20 @@ public class ActionBarManager implements IActionBarListener {
    * @param isVisible
    */
   public void setProgressVisible(boolean isVisible) {
-    setViewVisible(progressBar, isVisible);
+    setViewVisible(progressBar, isVisible, View.GONE);
+  }
+
+  /**
+   * Progress bar 의 진행율 설정
+   *
+   * @param percent 0~100
+   */
+  public void setProgress(int percent) {
+    Log.i("APP# ActionBarManager | setProgress", "|" + progressBar);
+    if (null != progressBar) {
+      Log.i("APP# ActionBarManager | setProgress", "|" + "percent: " + percent);
+      progressBar.setProgress(percent);
+    }
   }
 
   private void setViewVisible(View view, boolean isVisible) {
@@ -248,56 +267,8 @@ public class ActionBarManager implements IActionBarListener {
     actionBar.setDisplayShowHomeEnabled(false);      //홈 아이콘을 숨김처리합니다.
     actionBar.setCustomView(view);
 
-    toolbar = (Toolbar) view.getParent();
-    toolbar.setPadding(0, 0, 0, 0);//for tab otherwise give space in tab
-    toolbar.setContentInsetsAbsolute(0, 0);
-//    toolbar.setLayoutParams(new AppBarLayout.LayoutParams(AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.MATCH_PARENT));
-
-    setDisplayOptions(android.app.ActionBar.DISPLAY_SHOW_CUSTOM);
-    setElevation(0);
-  }
-
-  /**
-   * Progress bar 의 진행율 설정
-   *
-   * @param percent 0~100
-   */
-  public void setProgress(int percent) {
-    View customView = actionBar.getCustomView();
-    if (null != customView) {
-      progressBar.setProgress(percent);
-    }
-  }
-
-//  private void disableShowHideAnimation(ActionBar actionBar) {
-//    try
-//    {
-//      actionBar.getClass().getDeclaredMethod("setShowHideAnimationEnabled", boolean.class).invoke(actionBar, false);
-//    }
-//    catch (Exception exception)
-//    {
-//      try {
-//        Field mActionBarField = actionBar.getClass().getSuperclass().getDeclaredField("mActionBar");
-//        mActionBarField.setAccessible(true);
-//        Object icsActionBar = mActionBarField.get(actionBar);
-//        Field mShowHideAnimationEnabledField = icsActionBar.getClass().getDeclaredField("mShowHideAnimationEnabled");
-//        mShowHideAnimationEnabledField.setAccessible(true);
-//        mShowHideAnimationEnabledField.set(icsActionBar,false);
-//        Field mCurrentShowAnimField = icsActionBar.getClass().getDeclaredField("mCurrentShowAnim");
-//        mCurrentShowAnimField.setAccessible(true);
-//        mCurrentShowAnimField.set(icsActionBar,null);
-//      }catch (Exception e){
-//        //....
-//      }
-//    }
-//  }
-
-  private void setDisplayOptions(int displayOptions) {
-    actionBar.setDisplayOptions(displayOptions);
-  }
-
-  private void setElevation(int elevation) {
-    actionBar.setElevation(elevation);
+    actionBar.setDisplayOptions(android.app.ActionBar.DISPLAY_SHOW_CUSTOM);
+    actionBar.setElevation(0);
   }
 
   @Override
@@ -357,7 +328,7 @@ public class ActionBarManager implements IActionBarListener {
     if (null != appBarLayout) {
       appBarLayout = null;
       if (null != scrollListener) {
-        appBarLayout.addOnOffsetChangedListener(onOffsetChangedListener);
+        appBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
       }
     }
 

+ 3 - 26
app/src/main/res/layout/action_bar.xml

@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<RelativeLayout
   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"
+  android:layout_gravity="fill_horizontal"
   android:background="@color/CFFFFFF"
   android:gravity="top"
   android:orientation="vertical"
@@ -97,28 +98,4 @@
       app:srcCompat="@drawable/ic_icon_header_menu"/>
   </LinearLayout>
 
-  <RelativeLayout
-    android:layout_width="match_parent"
-    android:layout_height="4dp"
-    android:layout_gravity="bottom"
-    android:gravity="start">
-
-    <!--<LinearLayout-->
-    <!--android:id="@+id/layout_for_max_width"-->
-    <!--android:layout_width="match_parent"-->
-    <!--android:layout_height="match_parent"-->
-    <!--android:background="@color/CF8F8F8"-->
-    <!--android:orientation="horizontal"/>-->
-
-    <ProgressBar
-      android:id="@+id/progress_bar"
-      style="?android:attr/progressBarStyleHorizontal"
-      android:layout_width="match_parent"
-      android:layout_height="match_parent"
-      android:layout_centerInParent="false"
-      android:progressDrawable="@drawable/sign_up_progress"
-      tools:progress="50"
-      />
-  </RelativeLayout>
-
-</LinearLayout>
+</RelativeLayout>

+ 21 - 1
app/src/main/res/layout/activity_main.xml

@@ -2,6 +2,7 @@
 <android.support.design.widget.CoordinatorLayout
   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"
   android:background="@color/CFFFFFF"
@@ -20,6 +21,7 @@
     android:id="@+id/layout_app_bar"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:background="@color/C999999"
     app:elevation="0dp"
     >
 
@@ -30,8 +32,26 @@
       android:background="@color/CFFFFFF"
       android:minHeight="0dp"
       >
-
     </android.support.v7.widget.Toolbar>
+
+    <RelativeLayout
+      android:id="@+id/layout_app_bar_contents"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_gravity="bottom"
+      android:background="@color/CFFFFFF"
+      android:gravity="start">
+
+      <ProgressBar
+        android:id="@+id/progress_bar"
+        style="?android:attr/progressBarStyleHorizontal"
+        android:layout_width="match_parent"
+        android:layout_height="4dp"
+        android:layout_centerInParent="false"
+        android:progressDrawable="@drawable/sign_up_progress"
+        tools:progress="50"
+        />
+    </RelativeLayout>
   </android.support.design.widget.AppBarLayout>
 
   <!--<android.support.design.widget.FloatingActionButton-->