Browse Source

Discord fab action behavior when action is removed

Guy Carmeli 7 years ago
parent
commit
b942353949

+ 8
- 3
android/app/src/main/java/com/reactnativenavigation/views/FloatingActionButtonCoordinator.java View File

@@ -99,6 +99,7 @@ class FloatingActionButtonCoordinator {
99 99
         collapsedFab = null;
100 100
         expendedFab = null;
101 101
         for (FloatingActionButton action : actions) {
102
+            ((CoordinatorLayout.LayoutParams) action.getLayoutParams()).setBehavior(null);
102 103
             parent.removeView(action);
103 104
         }
104 105
         actions.clear();
@@ -214,9 +215,13 @@ class FloatingActionButtonCoordinator {
214 215
 
215 216
         @Override
216 217
         public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
218
+            final View dependentView = parent.findViewById(dependencyId);
219
+            if (dependentView == null) {
220
+                return false;
221
+            }
217 222
             final float dependentValue = dependency.getRotation();
218 223
             float fraction = calculateTransitionFraction(dependentValue);
219
-            child.setY(calculateY(parent, fraction));
224
+            child.setY(calculateY(dependentView, fraction));
220 225
             child.setAlpha(calculateAlpha(fraction));
221 226
             setVisibility(child);
222 227
             return true;
@@ -230,8 +235,8 @@ class FloatingActionButtonCoordinator {
230 235
             return 1 * fraction;
231 236
         }
232 237
 
233
-        private float calculateY(CoordinatorLayout parent, float fraction) {
234
-            return parent.findViewById(dependencyId).getY() - yStep * fraction;
238
+        private float calculateY(View dependentView, float fraction) {
239
+            return dependentView.getY() - yStep * fraction;
235 240
         }
236 241
 
237 242
         @FloatRange(from=0.0, to=1.0)