Преглед изворни кода

Fix crash if titleView is null (#1025)

Rui Araújo пре 8 година
родитељ
комит
14f468f835
1 измењених фајлова са 6 додато и 6 уклоњено
  1. 6
    6
      android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java

+ 6
- 6
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Прегледај датотеку

84
 
84
 
85
     private void centerTitle(final StyleParams params) {
85
     private void centerTitle(final StyleParams params) {
86
         final View titleView = getTitleView();
86
         final View titleView = getTitleView();
87
+        if (titleView == null) {
88
+            return;
89
+        }
87
         ViewUtils.runOnPreDraw(titleView, new Runnable() {
90
         ViewUtils.runOnPreDraw(titleView, new Runnable() {
88
             @Override
91
             @Override
89
             public void run() {
92
             public void run() {
90
                 if (params.titleBarTitleTextCentered) {
93
                 if (params.titleBarTitleTextCentered) {
91
-                    if (titleView != null) {
92
-                        int[] location = new int[2];
93
-                        titleView.getLocationOnScreen(location);
94
-                        titleView.setTranslationX(titleView.getTranslationX() + (-location[0] + ViewUtils.getScreenWidth() / 2 - titleView.getWidth() / 2));
95
-                    }
96
-
94
+                    int[] location = new int[2];
95
+                    titleView.getLocationOnScreen(location);
96
+                    titleView.setTranslationX(titleView.getTranslationX() + (-location[0] + ViewUtils.getScreenWidth() / 2 - titleView.getWidth() / 2));
97
                 }
97
                 }
98
 
98
 
99
             }
99
             }