JakeWharton / ActionBarSherlock

[DEPRECATED] Action bar implementation which uses the native action bar on Android 4.0+ and a custom implementation on pre-4.0 through a single API and theme.
http://actionbarsherlock.com
Apache License 2.0
7.1k stars 3.53k forks source link

NPE when using collapsed AB with action modes on 2.x #388

Closed nelenkov closed 12 years ago

nelenkov commented 12 years ago

I am using tabs with a split action bar, and I collapse the action bar. To avoid the title and logo being displayed briefly before the tabs load, I use the following style (setting 'displayOptions' to none):

<style name="Widget.WwwjdicAbMain" parent="Widget.Sherlock.ActionBar">
        <item name="displayOptions"></item>
        <item name="android:displayOptions"></item>
        <item name="background">@null</item>
        <item name="android:background">@null</item>
        <item name="backgroundSplit">@drawable/action_bar_bg</item>
        <item name="android:backgroundSplit">@drawable/action_bar_bg</item>
        <item name="icon">@null</item>
        <item name="android:icon">@null</item>
        <item name="titleTextStyle">@style/action_bar_title</item>
        <item name="android:titleTextStyle">@style/action_bar_title</item>
    </style>

This works on ICS, but I get the following NPE on 2.x. It works if set any flag in displayOptions (e.g., 'showTitle'). But then the action mode bar is displayed below the tabs, which I'd like to avoid. (if displayOptions is empty/0, the action mode bar is displayed on top of the tabs. This is the behaviour I'd like to have on both 2.x and ICS)

D/dalvikvm(12133): GC_CONCURRENT freed 996K, 49% free 4217K/8263K, external 1625K/2137K, paused 2ms+3ms

E/PropertyValuesHolder(16049): Couldn't find setter property alpha for ScrollingTabContainerView with value type float

E/PropertyValuesHolder(16049): ScrollingTabContainerView - Couldn't find no-arg method for property alpha: java.lang.NoSuchMethodException: getAlpha

D/AndroidRuntime(16049): Shutting down VM

W/dalvikvm(16049): threadid=1: thread exiting with uncaught exception (group=0x40015560)

E/AndroidRuntime(16049): FATAL EXCEPTION: main

E/AndroidRuntime(16049): java.lang.NullPointerException

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.nineoldandroids.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:515)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:386)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:539)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:929)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:952)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator.start(ObjectAnimator.java:364)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.widget.ScrollingTabContainerView.animateToVisibility(ScrollingTabContainerView.java:237)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.app.ActionBarImpl.animateToMode(ActionBarImpl.java:632)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.app.ActionBarImpl.startActionMode(ActionBarImpl.java:407)

E/AndroidRuntime(16049):    at com.actionbarsherlock.internal.ActionBarSherlockCompat.startActionMode(ActionBarSherlockCompat.java:176)

E/AndroidRuntime(16049):    at com.actionbarsherlock.app.SherlockFragmentActivity.startActionMode(SherlockFragmentActivity.java:52)

E/AndroidRuntime(16049):    at org.nick.wwwjdic.history.HistoryFragmentBase.onItemLongClick(HistoryFragmentBase.java:470)

E/AndroidRuntime(16049):    at android.widget.AbsListView.performLongPress(AbsListView.java:1869)

E/AndroidRuntime(16049):    at android.widget.AbsListView.access$600(AbsListView.java:74)

E/AndroidRuntime(16049):    at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:1827)

E/AndroidRuntime(16049):    at android.os.Handler.handleCallback(Handler.java:587)

E/AndroidRuntime(16049):    at android.os.Handler.dispatchMessage(Handler.java:92)

E/AndroidRuntime(16049):    at android.os.Looper.loop(Looper.java:130)

E/AndroidRuntime(16049):    at android.app.ActivityThread.main(ActivityThread.java:3683)

E/AndroidRuntime(16049):    at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(16049):    at java.lang.reflect.Method.invoke(Method.java:507)

E/AndroidRuntime(16049):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

E/AndroidRuntime(16049):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

E/AndroidRuntime(16049):    at dalvik.system.NativeStart.main(Native Method)
JakeWharton commented 12 years ago

Should've been fixed with 3d7c57f6c7f0bd32b3f461a4ce5cf0e21cbc18e4. Download the dev branch and give it a try.

nelenkov commented 12 years ago

Thanks. I am actually using the dev branch, but it seems Eclipse hadn't picked up the updated files. Seems to be working fine. Sorry for the noise.

JakeWharton commented 12 years ago

Excellent!