It seems that not all .equals() methods are created equal.
I've been testing backwards compatibility on an android app and noticed something peculiar. When I tested my app under Froyo (2.2), RectF.equals() fails when used to compare two identical objects. Rect.equals() works as expected on all versions, but RectF seems to have overhauled in between Froyo and Jelly Bean. Stepping through the source code, it seems that RectF never overrode .equals and just used the Object implementation. Not so with Rect.equals, however.
Rect r1 = new Rect(0,0,1,1);
Rect r2 = new Rect(r1);
RectF rf1 = new RectF(0,0,1,1);
RectF rf2 = new RectF(rf1);
if (r1.equals(r2))
Log.d(Build.VERSION.RELEASE,"r1 and r2 are equal");
else
Log.d(Build.VERSION.RELEASE,"r1 and r2 are NOT equal");
if (rf1.equals(rf2))
Log.d(Build.VERSION.RELEASE,"rf1 and rf2 are equal");
else
Log.d(Build.VERSION.RELEASE,"rf1 and rf2 are NOT equal");
Looking at the code above, one would expect both .equals() to return true. Not so. the Rect comparison always returns true, while the RectF comparison returns true on my Nexus 7 and false on every other device. Arrgh!
It took me a while to find this problem as I've used Rect objects extensively and never had a problem. I never considered that RectF would be so inconsistent.
My question is: How can I easily find reference to changes to Android source objects between versions? The API Reference makes mention of new methods and deprecation but doesn't mention when the behaviour of methods is dramatically altered. I also scanned the bug list on code.google.com but found nothing about it. Is their another online resource that I can use when I'm suspicious of an inconsistency? I don't want to have to traipse through the android source every time I have a problem, when I have a hard enough time dealing with my own bugs/inconsistencies. For instance, is there an easy way for me to find the entire change history for RectF?
thanks,