I have a problem with this code:
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
getDefaultIntent();
}
});
I want to convert this code to use a lambda expression like this:
view.getViewTreeObserver().addOnGlobalLayoutListener(()->{
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
getDefaultIntent();
});
But it wont work because now this
doesn't refer to the inner class.