@Override
public int getItemPosition(Object object) {
if(object != null && object instanceof FragmentPage2){
FragmentPage2 f = (FragmentPage2) object;
f.update();
}
return super.getItemPosition(object);
}
Similarly you can get object class and check if it is assignable from FragmentPage2.class
:
if(object.getClass().isAssignalbeFrom(FragmentPage2.class))
This happens because you have different classes that inherit Fragment
and getItemPosition()
does not care about the type of the object, but the casting you do does care about the type of the object.
Hope it helps.