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
         collapsedFab = null;
99
         collapsedFab = null;
100
         expendedFab = null;
100
         expendedFab = null;
101
         for (FloatingActionButton action : actions) {
101
         for (FloatingActionButton action : actions) {
102
+            ((CoordinatorLayout.LayoutParams) action.getLayoutParams()).setBehavior(null);
102
             parent.removeView(action);
103
             parent.removeView(action);
103
         }
104
         }
104
         actions.clear();
105
         actions.clear();
214
 
215
 
215
         @Override
216
         @Override
216
         public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
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
             final float dependentValue = dependency.getRotation();
222
             final float dependentValue = dependency.getRotation();
218
             float fraction = calculateTransitionFraction(dependentValue);
223
             float fraction = calculateTransitionFraction(dependentValue);
219
-            child.setY(calculateY(parent, fraction));
224
+            child.setY(calculateY(dependentView, fraction));
220
             child.setAlpha(calculateAlpha(fraction));
225
             child.setAlpha(calculateAlpha(fraction));
221
             setVisibility(child);
226
             setVisibility(child);
222
             return true;
227
             return true;
230
             return 1 * fraction;
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
         @FloatRange(from=0.0, to=1.0)
242
         @FloatRange(from=0.0, to=1.0)