I know what setFlags does is replacing the old flags with the new ones. And addFlags is appending more flag. I'm just confused why are the arguments in setFlags method that I've seen usually the same? For example:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//or
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
After taking a look at android.view.Window class, I'm not clear that why they must do many binary operators (NOT, AND, OR). What is the purpose of this?
public void setFlags(int flags, int mask) {
final WindowManager.LayoutParams attrs = getAttributes();
attrs.flags = (attrs.flags & ~mask) | (flags & mask);
mForcedWindowFlags |= mask;
dispatchWindowAttributesChanged(attrs);
}
One more question, what is the difference between
//argument is a flag
getWindow().addFlags(flag1);
and
//argument is the result of OR operator of 2 identical flags
getWindow().addFlags(flag1 | flag1);
and
//argument is the result of OR operator of 2 different flags
getWindow().addFlags(flag1 | flag2);
and
//argument is the result of AND operator of 2 identical flags
getWindow().addFlags(flag1 & flag1);
and
//argument is the result of AND operator of 2 different flags
getWindow().addFlags(flag1 & flag2);
Any help would be appreciated.