|
|
@@ -4,12 +4,14 @@ import android.app.Activity;
|
|
|
import android.support.annotation.StringRes;
|
|
|
import android.support.design.widget.AppBarLayout;
|
|
|
import android.support.design.widget.CoordinatorLayout;
|
|
|
+import android.support.v4.graphics.drawable.DrawableCompat;
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
@@ -40,10 +42,10 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
private ViewGroup container;
|
|
|
private Toolbar toolbar;
|
|
|
private TextView actionBarTitle;
|
|
|
- private View imageBi;
|
|
|
- private View buttonBack;
|
|
|
- private View buttonSearch;
|
|
|
- private View buttonMenu;
|
|
|
+ private ImageView imageBi;
|
|
|
+ private ImageView buttonBack;
|
|
|
+ private ImageView buttonSearch;
|
|
|
+ private ImageView buttonMenu;
|
|
|
private ProgressBar progressBar;
|
|
|
|
|
|
private Builder builder;
|
|
|
@@ -148,7 +150,7 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
/**
|
|
|
* actionbar hide
|
|
|
*/
|
|
|
- public void hide() {
|
|
|
+ private void hide() {
|
|
|
Log.i("APP# ActionBarManager | hide", "|" + "~~~~~~~~~~~~~~~~~~~~~~`");
|
|
|
actionBar.hide();
|
|
|
// appBarLayout.setExpanded(false, false);
|
|
|
@@ -157,7 +159,7 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
/**
|
|
|
* show
|
|
|
*/
|
|
|
- public void show() {
|
|
|
+ private void show() {
|
|
|
Log.i("APP# ActionBarManager | show", "|" + "~~~~~~~~~~~~~~~~~~~~~~`");
|
|
|
actionBar.show();
|
|
|
|
|
|
@@ -183,27 +185,17 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
*/
|
|
|
private void setScrollable(boolean isEnabled) {
|
|
|
// custom appbar scroll behavior
|
|
|
- CoordinatorLayout.LayoutParams containerLayoutParams = (CoordinatorLayout.LayoutParams) container.getLayoutParams();
|
|
|
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
|
|
|
CoordinatorLayout.LayoutParams appBarLayoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
|
|
|
if (isEnabled) {
|
|
|
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
|
|
|
appBarLayoutParams.setBehavior(new AppBarLayout.Behavior());
|
|
|
appBarLayout.setLayoutParams(appBarLayoutParams);
|
|
|
-
|
|
|
- containerLayoutParams.topMargin = 0;
|
|
|
- containerLayoutParams.setBehavior(new CustomScrollingViewBehavior());
|
|
|
- container.setLayoutParams(containerLayoutParams);
|
|
|
}
|
|
|
else {
|
|
|
params.setScrollFlags(0);
|
|
|
appBarLayoutParams.setBehavior(null);
|
|
|
appBarLayout.setLayoutParams(appBarLayoutParams);
|
|
|
-
|
|
|
- containerLayoutParams.setBehavior(null);
|
|
|
- containerLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
- containerLayoutParams.topMargin = ResourceUtil.getDimension(R.dimen.action_bar_height);
|
|
|
- container.setLayoutParams(containerLayoutParams);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -274,6 +266,10 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void setBackgroundTransparent(boolean isTransparent) {
|
|
|
+ toolbar.setBackgroundResource(isTransparent ? android.R.color.transparent : R.color.CFFFFFF);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* progress bar 보이기/안보이기
|
|
|
*
|
|
|
@@ -293,7 +289,7 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
setMenuVisible(false);
|
|
|
setProgressVisible(false);
|
|
|
setScrollable(false);
|
|
|
-
|
|
|
+ setBackgroundTransparent(false);
|
|
|
}
|
|
|
|
|
|
if (builder.isScrollable != newBuilder.isScrollable) {
|
|
|
@@ -318,8 +314,79 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
setTitleVisible(newBuilder.isVisibleTitle);
|
|
|
setTitle(newBuilder.title);
|
|
|
}
|
|
|
+ if (builder.isTransparentBackground != newBuilder.isTransparentBackground) {
|
|
|
+ setBackgroundTransparent(newBuilder.isTransparentBackground);
|
|
|
+ }
|
|
|
+ if (builder.isWhite != newBuilder.isWhite) {
|
|
|
+ setWhiteUi(newBuilder.isWhite);
|
|
|
+ }
|
|
|
|
|
|
builder = newBuilder;
|
|
|
+
|
|
|
+ setContentsLayout(builder.isHidden, builder.isScrollable, builder.isTransparentBackground);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setWhiteUi(boolean isWhite) {
|
|
|
+ if (isWhite) {
|
|
|
+ actionBarTitle.setTextColor(ResourceUtil.getColor(R.color.CFFFFFF));
|
|
|
+ DrawableCompat.setTint(buttonBack.getDrawable(), ResourceUtil.getColor(R.color.CFFFFFF));
|
|
|
+ DrawableCompat.setTint(imageBi.getDrawable(), ResourceUtil.getColor(R.color.CFFFFFF));
|
|
|
+ DrawableCompat.setTint(buttonBack.getDrawable(), ResourceUtil.getColor(R.color.CFFFFFF));
|
|
|
+ DrawableCompat.setTint(buttonSearch.getDrawable(), ResourceUtil.getColor(R.color.CFFFFFF));
|
|
|
+ DrawableCompat.setTint(buttonMenu.getDrawable(), ResourceUtil.getColor(R.color.CFFFFFF));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ actionBarTitle.setTextColor(ResourceUtil.getColor(R.color.C000000));
|
|
|
+ DrawableCompat.setTint(buttonBack.getDrawable(), ResourceUtil.getColor(R.color.C000000));
|
|
|
+ DrawableCompat.setTint(imageBi.getDrawable(), ResourceUtil.getColor(R.color.C000000));
|
|
|
+ DrawableCompat.setTint(buttonBack.getDrawable(), ResourceUtil.getColor(R.color.C000000));
|
|
|
+ DrawableCompat.setTint(buttonSearch.getDrawable(), ResourceUtil.getColor(R.color.C000000));
|
|
|
+ DrawableCompat.setTint(buttonMenu.getDrawable(), ResourceUtil.getColor(R.color.C000000));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setContentsLayout(boolean isHidden, boolean isScrollable, boolean isTransparentBackground) {
|
|
|
+ /**
|
|
|
+ * 1 툴바 배경 있음, 스크롤/논스크롤
|
|
|
+ * 2 툴바 배경 없음, 스크롤/논스크롤
|
|
|
+ */
|
|
|
+
|
|
|
+ CoordinatorLayout.LayoutParams containerLayoutParams = (CoordinatorLayout.LayoutParams) container.getLayoutParams();
|
|
|
+ if (isHidden) {
|
|
|
+ containerLayoutParams.setBehavior(null);
|
|
|
+ containerLayoutParams.topMargin = 0;
|
|
|
+ containerLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
+ container.setLayoutParams(containerLayoutParams);
|
|
|
+ }
|
|
|
+ else if (isTransparentBackground) {
|
|
|
+ if (isScrollable) {
|
|
|
+ // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
|
|
|
+ containerLayoutParams.setBehavior(null);
|
|
|
+ containerLayoutParams.topMargin = 0;
|
|
|
+ containerLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
+ container.setLayoutParams(containerLayoutParams);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ containerLayoutParams.setBehavior(null);
|
|
|
+ containerLayoutParams.topMargin = 0;
|
|
|
+ containerLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
+ container.setLayoutParams(containerLayoutParams);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (isScrollable) {
|
|
|
+ containerLayoutParams.topMargin = 0;
|
|
|
+ containerLayoutParams.setBehavior(new CustomScrollingViewBehavior());
|
|
|
+ container.setLayoutParams(containerLayoutParams);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ containerLayoutParams.setBehavior(null);
|
|
|
+ containerLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
+ containerLayoutParams.topMargin = ResourceUtil.getDimension(R.dimen.action_bar_height);
|
|
|
+ container.setLayoutParams(containerLayoutParams);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -424,6 +491,9 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
private boolean isVisibleProgress = false;
|
|
|
private boolean isScrollable = false;
|
|
|
private int title = R.string.empty_string;
|
|
|
+ private boolean isTransparentBackground = false;
|
|
|
+ private boolean isHidden = false;
|
|
|
+ private boolean isWhite = false;
|
|
|
|
|
|
public Builder() {
|
|
|
}
|
|
|
@@ -501,9 +571,21 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 설정 세팅
|
|
|
+ * 배경 투명하게
|
|
|
+ *
|
|
|
+ * @return Builder
|
|
|
*/
|
|
|
- public void set() {
|
|
|
+ public Builder transparent() {
|
|
|
+ isTransparentBackground = true;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder white() {
|
|
|
+ isWhite = true;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void set() {
|
|
|
ourInstance.set(this);
|
|
|
}
|
|
|
|
|
|
@@ -511,6 +593,7 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
* show
|
|
|
*/
|
|
|
public void show() {
|
|
|
+ isHidden = false;
|
|
|
set();
|
|
|
ourInstance.show();
|
|
|
}
|
|
|
@@ -519,6 +602,7 @@ public class ActionBarManager implements IActionBarListener {
|
|
|
* hide
|
|
|
*/
|
|
|
public void hide() {
|
|
|
+ isHidden = true;
|
|
|
set();
|
|
|
ourInstance.hide();
|
|
|
}
|