|
@@ -4,6 +4,7 @@ import android.content.Context;
|
4
|
4
|
import android.content.res.AssetManager;
|
5
|
5
|
import android.graphics.Color;
|
6
|
6
|
import android.graphics.Typeface;
|
|
7
|
+import android.text.TextUtils;
|
7
|
8
|
|
8
|
9
|
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
|
9
|
10
|
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
|
|
@@ -28,6 +29,7 @@ public class BottomTabs extends AHBottomNavigation {
|
28
|
29
|
createVisibilityAnimator();
|
29
|
30
|
setStyle();
|
30
|
31
|
setFontFamily(context);
|
|
32
|
+ setTitlesDisplayState();
|
31
|
33
|
}
|
32
|
34
|
|
33
|
35
|
public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
|
|
@@ -50,11 +52,27 @@ public class BottomTabs extends AHBottomNavigation {
|
50
|
52
|
setAccentColor(params.selectedBottomTabsButtonColor.getColor());
|
51
|
53
|
}
|
52
|
54
|
|
53
|
|
- setForceTitlesDisplay(params.forceTitlesDisplay);
|
54
|
|
-
|
55
|
55
|
setVisibility(params.bottomTabsHidden, true);
|
56
|
56
|
}
|
57
|
57
|
|
|
58
|
+ private void setTitlesDisplayState() {
|
|
59
|
+ if (AppStyle.appStyle.forceTitlesDisplay) {
|
|
60
|
+ setTitleState(TitleState.ALWAYS_SHOW);
|
|
61
|
+ } else {
|
|
62
|
+ centerIconsIfNeeded();
|
|
63
|
+ }
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ private void centerIconsIfNeeded() {
|
|
67
|
+ for (int i = 0; i < getItemsCount(); i++) {
|
|
68
|
+ String title = getItem(0).getTitle(getContext());
|
|
69
|
+ if (!TextUtils.isEmpty(title)) {
|
|
70
|
+ return;
|
|
71
|
+ }
|
|
72
|
+ }
|
|
73
|
+ setTitleState(TitleState.ALWAYS_HIDE);
|
|
74
|
+ }
|
|
75
|
+
|
58
|
76
|
public void setVisibility(boolean hidden, boolean animated) {
|
59
|
77
|
if (visibilityAnimator != null) {
|
60
|
78
|
visibilityAnimator.setVisible(!hidden, animated);
|