|
|
@@ -8,7 +8,6 @@ import android.support.design.widget.AppBarLayout;
|
|
|
import android.support.design.widget.CoordinatorLayout;
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
-import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ProgressBar;
|
|
|
@@ -40,18 +39,12 @@ public class ActionBarHelper extends Helper {
|
|
|
private Context context;
|
|
|
private ActionBar actionBar;
|
|
|
private AppBarLayout appBarLayout;
|
|
|
- private ViewGroup container;
|
|
|
+ private ConstraintLayout container;
|
|
|
private Toolbar toolbar;
|
|
|
private ProgressBar progressBar;
|
|
|
private ConstraintLayout layoutCategoryTab;
|
|
|
private ConstraintLayout categoryMainTab;
|
|
|
|
|
|
- private RadioButton radioButtonCategory1;
|
|
|
- private RadioButton radioButtonCategory2;
|
|
|
- private RadioButton radioButtonCategory3;
|
|
|
- private RadioButton radioButtonCategory4;
|
|
|
- private RadioButton radioButtonCategory5;
|
|
|
-
|
|
|
private ArrayList<RadioButton> radioButtons;
|
|
|
|
|
|
private Builder builder;
|
|
|
@@ -77,7 +70,7 @@ public class ActionBarHelper extends Helper {
|
|
|
*
|
|
|
* @param actionBar
|
|
|
*/
|
|
|
- public void init(Activity activity, ActionBar actionBar, AppBarLayout appBarLayout, ViewGroup container) {
|
|
|
+ public void init(Activity activity, ActionBar actionBar, AppBarLayout appBarLayout, ConstraintLayout container) {
|
|
|
this.actionBar = actionBar;
|
|
|
this.appBarLayout = appBarLayout;
|
|
|
this.container = container;
|
|
|
@@ -90,20 +83,14 @@ public class ActionBarHelper extends Helper {
|
|
|
progressBar = appBarLayout.findViewById(R.id.progress_bar);
|
|
|
layoutCategoryTab = appBarLayout.findViewById(R.id.layout_category_main_tab);
|
|
|
categoryMainTab = appBarLayout.findViewById(R.id.category_main_tab);
|
|
|
- radioButtonCategory1 = appBarLayout.findViewById(R.id.tab_first_category);
|
|
|
- radioButtonCategory2 = appBarLayout.findViewById(R.id.tab_second_category);
|
|
|
- radioButtonCategory3 = appBarLayout.findViewById(R.id.tab_third_category);
|
|
|
- radioButtonCategory4 = appBarLayout.findViewById(R.id.tab_fourth_category);
|
|
|
- radioButtonCategory5 = appBarLayout.findViewById(R.id.tab_fifth_category);
|
|
|
|
|
|
radioButtons = new ArrayList<>();
|
|
|
- radioButtons.add(radioButtonCategory1);
|
|
|
- radioButtons.add(radioButtonCategory2);
|
|
|
- radioButtons.add(radioButtonCategory3);
|
|
|
- radioButtons.add(radioButtonCategory4);
|
|
|
- radioButtons.add(radioButtonCategory5);
|
|
|
+ radioButtons.add(appBarLayout.findViewById(R.id.tab_first_category));
|
|
|
+ radioButtons.add(appBarLayout.findViewById(R.id.tab_second_category));
|
|
|
+ radioButtons.add(appBarLayout.findViewById(R.id.tab_third_category));
|
|
|
+ radioButtons.add(appBarLayout.findViewById(R.id.tab_fourth_category));
|
|
|
+ radioButtons.add(appBarLayout.findViewById(R.id.tab_fifth_category));
|
|
|
|
|
|
- Log.i("APP# ActionBarHelper | init", "|" + "progressBar: " + progressBar);
|
|
|
}
|
|
|
|
|
|
/***********************************
|
|
|
@@ -227,28 +214,10 @@ public class ActionBarHelper extends Helper {
|
|
|
public void setVisibleBookmark(boolean isVisible) {
|
|
|
navigationBar.setVisibleBookmark(isVisible);
|
|
|
}
|
|
|
+
|
|
|
/***********************************
|
|
|
* private
|
|
|
***********************************/
|
|
|
- /**
|
|
|
- * 액션바 영역이 스크롤 설정
|
|
|
- *
|
|
|
- * @param isEnabled
|
|
|
- */
|
|
|
- private void setScrollable(boolean isEnabled) {
|
|
|
- // custom appbar scroll behavior
|
|
|
-// AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
|
|
|
-// CoordinatorLayout.LayoutParams appBarLayoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
|
|
|
-// if (isEnabled) {
|
|
|
-// params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
|
|
|
-// appBarLayoutParams.setBehavior(new AppBarLayout.Behavior());
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// params.setScrollFlags(0);
|
|
|
-// appBarLayoutParams.setBehavior(null);
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
private void setContentsLayout(boolean isHidden, boolean isScrollable, boolean isTransparentBackground) {
|
|
|
/**
|
|
|
* 1 툴바 배경 있음, 스크롤/논스크롤
|
|
|
@@ -258,40 +227,27 @@ public class ActionBarHelper extends Helper {
|
|
|
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
|
|
|
CoordinatorLayout.LayoutParams appBarLayoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
|
|
|
CoordinatorLayout.LayoutParams containerLayoutParams = (CoordinatorLayout.LayoutParams) container.getLayoutParams();
|
|
|
+
|
|
|
if (isHidden) {
|
|
|
containerLayoutParams.setBehavior(null);
|
|
|
}
|
|
|
- else if (isTransparentBackground) {
|
|
|
- if (isScrollable) {
|
|
|
- // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
|
|
|
- params.setScrollFlags(APP_BAR_LAYOUT_SCROLL_PARAM);
|
|
|
- params.height = ResourceUtil.getDimension(R.dimen.action_bar_height_with_status_bar_height);
|
|
|
- appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
|
|
|
+ else if (isScrollable) {
|
|
|
+ // 스크롤 플래그 설정
|
|
|
+ params.setScrollFlags(APP_BAR_LAYOUT_SCROLL_PARAM);
|
|
|
+ // 스테이터스 바 위로 스크롤 시키기위해서 높이 조절
|
|
|
+ params.height = ResourceUtil.getDimension(R.dimen.action_bar_height_with_status_bar_height);
|
|
|
|
|
|
- // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
|
|
|
- containerLayoutParams.setBehavior(null);
|
|
|
- }
|
|
|
- else {
|
|
|
- params.setScrollFlags(0);
|
|
|
- params.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
|
|
|
- appBarLayoutParams.setBehavior(null);
|
|
|
- containerLayoutParams.setBehavior(null);
|
|
|
- }
|
|
|
+ appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
|
|
|
+ containerLayoutParams.setBehavior(null);
|
|
|
}
|
|
|
else {
|
|
|
- if (isScrollable) {
|
|
|
- params.setScrollFlags(APP_BAR_LAYOUT_SCROLL_PARAM);
|
|
|
- params.height = ResourceUtil.getDimension(R.dimen.action_bar_height_with_status_bar_height);
|
|
|
- appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
|
|
|
+ params.setScrollFlags(0);
|
|
|
+ params.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
|
|
|
|
|
|
- containerLayoutParams.setBehavior(null);
|
|
|
- }
|
|
|
- else {
|
|
|
- params.setScrollFlags(0);
|
|
|
- params.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
|
|
|
- appBarLayoutParams.setBehavior(null);
|
|
|
- containerLayoutParams.setBehavior(null);
|
|
|
+ appBarLayoutParams.setBehavior(null);
|
|
|
+ containerLayoutParams.setBehavior(null);
|
|
|
|
|
|
+ if (false == isTransparentBackground) {
|
|
|
/**
|
|
|
* 스크롤이 아닌 뷰에게는 액션바 만큼의 탑 마진을 설정해 준다.
|
|
|
*/
|
|
|
@@ -306,9 +262,9 @@ public class ActionBarHelper extends Helper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void setViewVisible(View view, boolean isVisible, int visibility) {
|
|
|
+ private void setViewVisible(View view, boolean isVisible) {
|
|
|
if (null != view) {
|
|
|
- view.setVisibility(isVisible ? View.VISIBLE : visibility);
|
|
|
+ view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -318,24 +274,19 @@ public class ActionBarHelper extends Helper {
|
|
|
* @param isVisible
|
|
|
*/
|
|
|
private void setProgressVisible(boolean isVisible) {
|
|
|
- setViewVisible(progressBar, isVisible, View.GONE);
|
|
|
+ setViewVisible(progressBar, isVisible);
|
|
|
}
|
|
|
|
|
|
private void set(Builder newBuilder) {
|
|
|
-
|
|
|
if (null == builder) {
|
|
|
builder = new Builder(this);
|
|
|
setProgressVisible(false);
|
|
|
- setScrollable(false);
|
|
|
}
|
|
|
// navigation bar setting
|
|
|
navigationBar = new NavigationBar.Builder(context).build(newBuilder.getNavigationBarBuilder());
|
|
|
View view = navigationBar.getView();
|
|
|
setCustomView(view);
|
|
|
|
|
|
- if (builder.isScrollable != newBuilder.isScrollable) {
|
|
|
- setScrollable(newBuilder.isScrollable);
|
|
|
- }
|
|
|
if (builder.isVisibleProgress != newBuilder.isVisibleProgress) {
|
|
|
setProgressVisible(newBuilder.isVisibleProgress);
|
|
|
}
|
|
|
@@ -376,7 +327,6 @@ public class ActionBarHelper extends Helper {
|
|
|
|
|
|
setContentsLayout(builder.isHidden, builder.isScrollable, builder.isTransparentBackground);
|
|
|
|
|
|
-
|
|
|
if (newBuilder.isHidden) {
|
|
|
actionBar.hide();
|
|
|
navigationBar.hide();
|
|
|
@@ -405,11 +355,7 @@ public class ActionBarHelper extends Helper {
|
|
|
|
|
|
private void setCustomView(View view) {
|
|
|
|
|
|
- // Custom Actionbar 를 사용하기 위해 CustomEnabled 을 true 시키고 필요 없는 것은 false 시킨다
|
|
|
actionBar.setDisplayShowCustomEnabled(true);
|
|
|
-// actionBar.setDisplayHomeAsUpEnabled(false); //액션바 아이콘을 업 네비게이션 형태로 표시합니다.
|
|
|
-// actionBar.setDisplayShowTitleEnabled(false); //액션바에 표시되는 제목의 표시유무를 설정합니다.
|
|
|
-// actionBar.setDisplayShowHomeEnabled(false); //홈 아이콘을 숨김처리합니다.
|
|
|
/**
|
|
|
* 툴바를 gravity top 으로 설정하려면 LayoutParams.MATCH_PARENT 를 설정한다.
|
|
|
*/
|
|
|
@@ -456,8 +402,8 @@ public class ActionBarHelper extends Helper {
|
|
|
|
|
|
private NavigationBar.Builder navigationBarBuilder;
|
|
|
|
|
|
- protected INavigationBarListener arrowListener = null;
|
|
|
- protected INavigationBarListener titleListener = null;
|
|
|
+ private INavigationBarListener arrowListener = null;
|
|
|
+ private INavigationBarListener titleListener = null;
|
|
|
private ActionBarHelper actionBarHelper;
|
|
|
|
|
|
public Builder(ActionBarHelper actionBarHelper) {
|