You're using &
instead of &&
. The former is bitwise AND and will evaluate both sides always. The latter stands for logical AND and will do short-circuit conditional evaluation.
More info: Java Tutorials: Operators
Solution for your current problem: use logical AND &&
instead of bitwise AND &
. Similar for your bitwise OR |
.
if( !currentFragment.getTag().equals(PROFILE) ||
( currentFragment.getArguments() != null &&
currentFragment.getArguments().getInt("authorId") != userId) ) { }