Browse Source

Cleanup TitleBar class a bit

Guy Carmeli 7 years ago
parent
commit
6db371beac

+ 2
- 17
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java View File

@@ -4,7 +4,6 @@ import android.animation.Animator;
4 4
 import android.animation.AnimatorListenerAdapter;
5 5
 import android.app.Activity;
6 6
 import android.content.Context;
7
-import android.content.ContextWrapper;
8 7
 import android.graphics.drawable.Drawable;
9 8
 import android.support.annotation.Nullable;
10 9
 import android.support.v7.widget.ActionMenuView;
@@ -14,6 +13,7 @@ import android.view.View;
14 13
 import android.view.animation.AccelerateDecelerateInterpolator;
15 14
 import android.view.animation.AccelerateInterpolator;
16 15
 import android.widget.TextView;
16
+
17 17
 import com.reactnativenavigation.params.BaseScreenParams;
18 18
 import com.reactnativenavigation.params.BaseTitleBarButtonParams;
19 19
 import com.reactnativenavigation.params.StyleParams;
@@ -51,10 +51,6 @@ public class TitleBar extends Toolbar {
51 51
         addButtonsToTitleBar(navigatorEventId, menu);
52 52
     }
53 53
 
54
-    public int getRightButtonsWidth() {
55
-        return actionMenuView.getWidth();
56
-    }
57
-
58 54
     public void setLeftButton(TitleBarLeftButtonParams leftButtonParams,
59 55
                               LeftButtonOnClickListener leftButtonOnClickListener,
60 56
                               String navigatorEventId,
@@ -95,17 +91,6 @@ public class TitleBar extends Toolbar {
95 91
         centerTitle(styleParams);
96 92
     }
97 93
 
98
-    private Activity getActivity() {
99
-        Context context = getContext();
100
-        while (context instanceof ContextWrapper) {
101
-            if (context instanceof Activity) {
102
-                return (Activity)context;
103
-            }
104
-            context = ((ContextWrapper)context).getBaseContext();
105
-        }
106
-        return null;
107
-    }
108
-
109 94
     private void centerTitle(final StyleParams params) {
110 95
         final View titleView = getTitleView();
111 96
         if (titleView == null) {
@@ -115,7 +100,7 @@ public class TitleBar extends Toolbar {
115 100
             @Override
116 101
             public void run() {
117 102
                 if (params.titleBarTitleTextCentered) {
118
-                    titleView.setX(ViewUtils.getWindowWidth(getActivity()) / 2 - titleView.getWidth() / 2);
103
+                    titleView.setX(ViewUtils.getWindowWidth((Activity) getContext()) / 2 - titleView.getWidth() / 2);
119 104
                 }
120 105
             }
121 106
         });