ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

Invalid ActionBar look after adjusting of indeterminate progress visibility and calling invalidateOptionsMenu and updating list model in onPostExecute

Open httpdispatch opened this issue 12 years ago • 3 comments

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: image

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

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)

httpdispatch avatar Apr 03 '13 08:04 httpdispatch

updated project url, previous was wrong

httpdispatch avatar Apr 03 '13 09:04 httpdispatch

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.

httpdispatch avatar Apr 05 '13 09:04 httpdispatch

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?

httpdispatch avatar Apr 12 '13 08:04 httpdispatch