I have this code in my Android app:
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if(viewType == POST_VIEW_TYPE){
View view = LayoutInflater.from(App.instance).inflate(R.layout.item_post, parent, false);
return new PostViewHolder(view);
}else{
View view = LayoutInflater.from(App.instance).inflate(R.layout.item_user, parent, false);
return new UserViewHolder(view);
}
}
The code basically gets a constant named viewType
, and inflates the correct view accordingly. My constant POST_VIEW_TYPE
is equal to 1
:
So far so good. I am passing viewType
as 1
to my handler, but the code is somehow evaluating the else
branch even though the (extremely simple) expression in if
evaluates to true
(obviously):
How is this even possible?
UPDATE: I've cleaned the project and rebuilt, but nothing has changed. I've put a breakpoint on the if statement. Here is a GIF demonstrating as I step through the debugger: