Browse Source

Remove logs and Hungarian notations

Guy Carmeli 8 years ago
parent
commit
3a47aa8741
1 changed files with 34 additions and 44 deletions
  1. 34
    44
      android/app/src/main/java/com/reactnativenavigation/views/RctView.java

+ 34
- 44
android/app/src/main/java/com/reactnativenavigation/views/RctView.java View File

@@ -1,7 +1,6 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3 3
 import android.os.Bundle;
4
-import android.util.Log;
5 4
 import android.view.View;
6 5
 import android.view.ViewGroup;
7 6
 import android.view.ViewTreeObserver;
@@ -20,63 +19,54 @@ import com.reactnativenavigation.utils.ReflectionUtils;
20 19
  * Created by guyc on 10/03/16.
21 20
  */
22 21
 public class RctView extends FrameLayout {
23
-    private static final String TAG = "RctView";
24 22
 
25
-    private BottomTabActivity mContext;
26
-    private ReactRootView mReactRootView;
27
-    private ScrollView mScrollView;
28
-    private int mLastScrollY = -1;
29
-    private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
23
+    private BottomTabActivity context;
24
+    private ReactRootView reactRootView;
25
+    private ScrollView scrollView;
26
+    private int lastScrollY = -1;
27
+    private final ViewTreeObserver.OnScrollChangedListener scrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
30 28
         @Override
31 29
         public void onScrollChanged() {
32
-            if (!mScrollView.getViewTreeObserver().isAlive()) {
30
+            if (!scrollView.getViewTreeObserver().isAlive()) {
33 31
                 return;
34 32
             }
35 33
 
36
-            final int scrollY = mScrollView.getScrollY();
37
-            if (scrollY != mLastScrollY && // Scroll position changed
34
+            final int scrollY = scrollView.getScrollY();
35
+            if (scrollY != lastScrollY && // Scroll position changed
38 36
                 scrollY > 0 && // Ignore top overscroll
39
-                scrollY < (mScrollView.getChildAt(0).getHeight() - mScrollView.getHeight())) { // Ignore bottom overscroll
40
-                int direction = scrollY > mLastScrollY ?
37
+                scrollY < (scrollView.getChildAt(0).getHeight() - scrollView.getHeight())) { // Ignore bottom overscroll
38
+                int direction = scrollY > lastScrollY ?
41 39
                         BottomNavigation.SCROLL_DIRECTION_DOWN :
42 40
                         BottomNavigation.SCROLL_DIRECTION_UP;
43
-                mLastScrollY = scrollY;
44
-                mContext.onScrollChanged(direction);
41
+                lastScrollY = scrollY;
42
+                context.onScrollChanged(direction);
45 43
             }
46 44
         }
47 45
     };
48
-    private boolean mIsScrollEventListenerRegistered = false;
46
+    private boolean isScrollEventListenerRegistered = false;
49 47
 
50
-    private final View.OnAttachStateChangeListener mStateChangeListener =
48
+    private final View.OnAttachStateChangeListener stateChangeListener =
51 49
             new View.OnAttachStateChangeListener() {
52 50
                 @Override
53 51
                 public void onViewAttachedToWindow(View v) {
54
-                    Log.d(TAG, "onViewAttachedToWindow " + v.getClass());
55
-                    mScrollView = getScrollView((ViewGroup) getParent());
52
+                    scrollView = getScrollView((ViewGroup) getParent());
56 53
 
57
-                    if (mScrollView != null && !mIsScrollEventListenerRegistered) {
58
-                        Log.i(TAG, "setting scroll listener");
54
+                    if (scrollView != null && !isScrollEventListenerRegistered) {
59 55
                         addScrollListener();
60
-                    } else {
61
-                        Log.v(TAG, "doing nothing");
62 56
                     }
63 57
                 }
64 58
 
65 59
                 @Override
66 60
                 public void onViewDetachedFromWindow(final View detachedView) {
67
-                    Log.d(TAG, "onViewDetachedFromWindow. Removing scrollChangedListener");
68 61
                     removeScrollListener();
69 62
 
70 63
                     post(new Runnable() {
71 64
                         @Override
72 65
                         public void run() {
73
-                            mScrollView = getScrollView((ViewGroup) getParent());
74
-                            if (mScrollView != null && !mIsScrollEventListenerRegistered) {
75
-                                Log.i(TAG, "run: setting scroll listener");
76
-                                mIsScrollEventListenerRegistered = true;
66
+                            scrollView = getScrollView((ViewGroup) getParent());
67
+                            if (scrollView != null && !isScrollEventListenerRegistered) {
68
+                                isScrollEventListenerRegistered = true;
77 69
                                 addScrollListener();
78
-                            } else {
79
-                                Log.v(TAG, "doing nothing");
80 70
                             }
81 71
                         }
82 72
                     });
@@ -111,13 +101,13 @@ public class RctView extends FrameLayout {
111 101
                 }
112 102
             } : onDisplayedListener;
113 103
 
114
-        mReactRootView = new RnnReactRootView(ctx, onDisplayedListenerInternal);
115
-        mReactRootView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
104
+        reactRootView = new RnnReactRootView(ctx, onDisplayedListenerInternal);
105
+        reactRootView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
116 106
         Bundle passProps = createPassProps(screen);
117 107
         String componentName = screen.screenId;
118
-        mReactRootView.startReactApplication(rctInstanceManager, componentName, passProps);
108
+        reactRootView.startReactApplication(rctInstanceManager, componentName, passProps);
119 109
 
120
-        addView(mReactRootView);
110
+        addView(reactRootView);
121 111
     }
122 112
 
123 113
     private Bundle createPassProps(Screen screen) {
@@ -132,10 +122,10 @@ public class RctView extends FrameLayout {
132 122
     }
133 123
 
134 124
     private void setupScrollViewWithBottomTabs() {
135
-        mScrollView = getScrollView((ViewGroup) getParent());
136
-        if (mScrollView != null) {
137
-            mContext = (BottomTabActivity) getContext();
138
-            attachStateChangeListener(mScrollView);
125
+        scrollView = getScrollView((ViewGroup) getParent());
126
+        if (scrollView != null) {
127
+            context = (BottomTabActivity) getContext();
128
+            attachStateChangeListener(scrollView);
139 129
             addScrollListener();
140 130
         }
141 131
     }
@@ -157,15 +147,15 @@ public class RctView extends FrameLayout {
157 147
     }
158 148
 
159 149
     private void attachStateChangeListener(ScrollView scrollView) {
160
-        scrollView.addOnAttachStateChangeListener(mStateChangeListener);
150
+        scrollView.addOnAttachStateChangeListener(stateChangeListener);
161 151
     }
162 152
 
163 153
     private void addScrollListener() {
164
-        mScrollView.getViewTreeObserver().addOnScrollChangedListener(mScrollChangedListener);
154
+        scrollView.getViewTreeObserver().addOnScrollChangedListener(scrollChangedListener);
165 155
     }
166 156
 
167 157
     private void removeScrollListener() {
168
-        mScrollView.getViewTreeObserver().removeOnScrollChangedListener(mScrollChangedListener);
158
+        scrollView.getViewTreeObserver().removeOnScrollChangedListener(scrollChangedListener);
169 159
     }
170 160
 
171 161
     /**
@@ -175,7 +165,7 @@ public class RctView extends FrameLayout {
175 165
     public void onTemporallyRemovedFromScreen() {
176 166
         // Hack in order to prevent the react view from getting unmounted
177 167
 
178
-        ReflectionUtils.setField(mReactRootView, "mAttachScheduled", true);
168
+        ReflectionUtils.setField(reactRootView, "mAttachScheduled", true);
179 169
     }
180 170
 
181 171
     /**
@@ -183,7 +173,7 @@ public class RctView extends FrameLayout {
183 173
      * executed and componentWillUnmount is called
184 174
      */
185 175
     public void onRemoveFromScreen() {
186
-        ReflectionUtils.setField(mReactRootView, "mAttachScheduled", false);
176
+        ReflectionUtils.setField(reactRootView, "mAttachScheduled", false);
187 177
     }
188 178
 
189 179
     /**
@@ -191,11 +181,11 @@ public class RctView extends FrameLayout {
191 181
      * executed and componentWillUnmount is called
192 182
      */
193 183
     public void onReAddToScreen() {
194
-        ReflectionUtils.setField(mReactRootView, "mAttachScheduled", false);
184
+        ReflectionUtils.setField(reactRootView, "mAttachScheduled", false);
195 185
     }
196 186
 
197 187
     public void detachFromScreen() {
198
-        ReflectionUtils.invoke(mReactRootView, "onDetachedFromWindow");
188
+        ReflectionUtils.invoke(reactRootView, "onDetachedFromWindow");
199 189
     }
200 190
 }
201 191