-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
Hi there,
Gradle build indicates this:
warning: [deprecation] removeGlobalOnLayoutListener(OnGlobalLayoutListener) in ViewTreeObserver has been deprecated
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
After some research i came across this solution:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
mView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
Another one I found later is:
MyView.setBackgroundDrawable(viewAlphaOverlay,gd);
Should be turned into:
SetBackground(viewAlphaOverlay,gd);
@SuppressWarnings("deprecation")
private void SetBackground(View MyView, GradientDrawable gd) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN){
MyView.setBackgroundDrawable(gd);
} else {
MyView.setBackground(gd);
}
}
Thanks!
Metadata
Metadata
Assignees
Labels
No labels