2

I'm trying to override getItemViewType and return a different view type for my footer, but integer comparison is failing within the function:

enter image description here

This image shows a debug session where the input position is 21 and the the private List mValues has a size of 21, however when I pushed "step over" the conditional code is skipped.

If both integers are equal, why does position == mValues.size() return false?

I cleaned and rebuilt my project before running.

UPDATE:

It works when the integers are hardcoded:

enter image description here

but not when I use the input parameter:

enter image description here

UPDATE

I added a Log statement as the first line of the function

Log.e("MYAPP", "position: " + position + ", evaluates: " + (position == 21));

and in my monitor I see: position: 21, evaluates: true

However, my breakpoint at return FOOTER_VIEW; is never called and none of the functions related to the footer view are ever called.

UPDATE:

Heres the full Adaptor: https://gist.github.com/fergusom/79c6d5d9b1fd5e8348949d114a0159d5

Note that I updated the code to compute a boolean first, but it still fails even though the boolean prints out true in the logs

Cbas
  • 6,003
  • 11
  • 56
  • 87

2 Answers2

1

Give the jvm no chance:

if(new Integer(position).equals(new Integer(mValues.size()))

If the Integer constructor fails you'll know what the values were in the exception

David Kühner
  • 793
  • 1
  • 7
  • 19
  • I tried going one step further and creating a `boolean` to use in the conditional and it still failed even when the `boolean` prints out `true` in a log. check out the full gist in the last update – Cbas Sep 02 '16 at 16:54
  • Wait what? You printed a boolean variable, gives you true and it doesn't goes in the if statement? – David Kühner Sep 02 '16 at 17:13
  • yes. seems to have been a glitch on my device. I restarted my phone and its working now – Cbas Sep 02 '16 at 17:14
1

I restarted my phone and it started working...

Cbas
  • 6,003
  • 11
  • 56
  • 87