-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathComponentPresenterBase.java
More file actions
27 lines (22 loc) · 959 Bytes
/
ComponentPresenterBase.java
File metadata and controls
27 lines (22 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.reactnativenavigation.viewcontrollers.component;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import androidx.annotation.NonNull;
public class ComponentPresenterBase {
public void applyTopInsets(@NonNull View view, int topInsets) {
if(!(view.getLayoutParams() instanceof MarginLayoutParams)) return;
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
if (lp != null && lp.topMargin != topInsets) {
lp.topMargin = topInsets;
view.requestLayout();
}
}
public void applyBottomInset(@NonNull View view, int bottomInset) {
if(!(view.getLayoutParams() instanceof MarginLayoutParams)) return;
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
if (lp != null && lp.bottomMargin!= bottomInset) {
lp.bottomMargin = bottomInset;
view.requestLayout();
}
}
}