ActionBarSherlock
ActionBarSherlock copied to clipboard
Invalid ActionBar look after adjusting of indeterminate progress visibility and calling invalidateOptionsMenu and updating list model in onPostExecute
I've noticed this issue a long time ago but only now i was able to prepare demo which demonstrates it.
In application i have AsyncTask which may adjust visibility of actionbar indeterminate progress and reinit menu by calling invalidateOptionsMenu . This should hide refresh icon. This is working ok until i modify listView data model and call notifyDataSetChanged on adapter. After such action Actionbar may have broken view.
Expected view:

Broken view (Last item disappears or blank space added insted of in some cases):

The causing code is in onPostExecute
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
for (int i = 0; i < 10; i++)
{
adapter.items.add(i);
}
adapter.notifyDataSetChanged();
activity.stopLoading();
}
...
void stopLoading()
{
if (loaders.decrementAndGet() == 0)
{
setSupportProgressBarIndeterminateVisibility(false);
invalidateOptionsMenu();
}
}
Any idea why is this happening and in most cases because of updating listview adapter? If i remove line adapter.notifyDataSetChanged(); actionbar will not be broken.
Project demonstrating an issue: http://goo.gl/ZbMTU (Updated, previous url was wrong)
updated project url, previous was wrong
The demo may repeat the issue on android 2.1 emulator also. Original shots was from my ICS 4.0.3 device. The last menu item should not disappear and be unavailable even via menu button.
Keep digging on this issue. Seems that not exactly adapter.notifyDataSetChanged() causes invalid look, but the requestLayout call by the AdapterView.AdapterDataSetObserver which is listening for the data set changed event in the ListView. @JakeWharton any ideas?