|
@@ -4,17 +4,15 @@ import android.annotation.SuppressLint;
|
4
|
4
|
import android.app.Activity;
|
5
|
5
|
import android.content.Context;
|
6
|
6
|
import android.graphics.Typeface;
|
7
|
|
-import android.support.annotation.Nullable;
|
8
|
7
|
import android.support.v7.widget.Toolbar;
|
9
|
8
|
import android.util.Log;
|
10
|
9
|
import android.view.Gravity;
|
11
|
|
-import android.view.View;
|
12
|
|
-import android.view.ViewGroup;
|
13
|
10
|
import android.widget.TextView;
|
14
|
11
|
|
15
|
12
|
import com.reactnativenavigation.parse.Alignment;
|
16
|
13
|
import com.reactnativenavigation.parse.params.Button;
|
17
|
14
|
import com.reactnativenavigation.parse.params.Color;
|
|
15
|
+import com.reactnativenavigation.utils.ViewUtils;
|
18
|
16
|
import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
|
19
|
17
|
import com.reactnativenavigation.viewcontrollers.TitleBarReactViewController;
|
20
|
18
|
import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
|
|
@@ -80,7 +78,8 @@ public class TitleBar extends Toolbar {
|
80
|
78
|
}
|
81
|
79
|
|
82
|
80
|
public TextView getTitleTextView() {
|
83
|
|
- return findTextView(this);
|
|
81
|
+ List<TextView> children = ViewUtils.findChildrenByClass(this, TextView.class);
|
|
82
|
+ return children.isEmpty() ? null : children.get(0);
|
84
|
83
|
}
|
85
|
84
|
|
86
|
85
|
public void clear() {
|
|
@@ -152,20 +151,6 @@ public class TitleBar extends Toolbar {
|
152
|
151
|
return new TopBarButtonController((Activity) getContext(), button, buttonCreator, onClickListener);
|
153
|
152
|
}
|
154
|
153
|
|
155
|
|
- @Nullable
|
156
|
|
- private TextView findTextView(ViewGroup root) {
|
157
|
|
- for (int i = 0; i < root.getChildCount(); i++) {
|
158
|
|
- View view = root.getChildAt(i);
|
159
|
|
- if (view instanceof ViewGroup) {
|
160
|
|
- view = findTextView((ViewGroup) view);
|
161
|
|
- }
|
162
|
|
- if (view instanceof TextView) {
|
163
|
|
- return (TextView) view;
|
164
|
|
- }
|
165
|
|
- }
|
166
|
|
- return null;
|
167
|
|
- }
|
168
|
|
-
|
169
|
154
|
public Toolbar.LayoutParams getComponentLayoutParams(Alignment alignment) {
|
170
|
155
|
LayoutParams lp = new LayoutParams(MATCH_PARENT, getHeight());
|
171
|
156
|
if (alignment == Alignment.Center) {
|