ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
148 stars 60 forks source link

App crash after adding dropdown #89

Closed X-Tender closed 9 years ago

X-Tender commented 9 years ago

I try to add the dropdownmenu to the ActionBar

var dropdown = Alloy.Globals.abx.createDropdown({
    titles: [ 'Downloads', 'Optionen' ]
});

After that the App Crashes. Adding buttons to the menu works perfectly.

Android 5 TI SDK: Tryed 4.1.1.GA and 5.0.2.GA

manumaticx commented 9 years ago

Hi. Can you post the log of the exception? Thanks

X-Tender commented 9 years ago

No Exception. Just "App Quit" Dialog. :/

manumaticx commented 9 years ago

You can use the monitor or ddms of the android sdk tools to see the native logs.

X-Tender commented 9 years ago
10-10 11:13:25.292: E/AndroidRuntime(3362): FATAL EXCEPTION: main
10-10 11:13:25.292: E/AndroidRuntime(3362): Process: de.lpip.de, PID: 3362
10-10 11:13:25.292: E/AndroidRuntime(3362): java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 3, found: 2 Pager id: android:id/tabcontent Pager class: class ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTabGroup$1 Problematic adapter: class ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTabGroup$TabGroupFragmentPagerAdapter
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.support.v4.view.ViewPager.populate(ViewPager.java:966)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.support.v4.view.ViewPager.populate(ViewPager.java:918)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1440)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:398)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:278)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:124)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:444)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2618)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.View.measure(View.java:17637)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2019)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1177)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1383)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1065)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5901)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.Choreographer.doCallbacks(Choreographer.java:580)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.Choreographer.doFrame(Choreographer.java:550)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.os.Handler.handleCallback(Handler.java:739)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.os.Handler.dispatchMessage(Handler.java:95)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.os.Looper.loop(Looper.java:211)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at android.app.ActivityThread.main(ActivityThread.java:5373)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at java.lang.reflect.Method.invoke(Native Method)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at java.lang.reflect.Method.invoke(Method.java:372)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
10-10 11:13:25.292: E/AndroidRuntime(3362):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
manumaticx commented 9 years ago

I've never used a dropdown on a Tabgroup which seems to be the problem. I'm going to test this soon but from the logs it does not appear to be a bug in the abx module. I'm not able to tell you the exact reason for this ecxeption before I've tested this but I can think of a possible reason. Both, the dropdown and the tabgroup, uses the actionbars navigation listener but they are using different navigation modes. So when you add the dropdown to your actionbar the navigation mode gets changed and this probably breaks the navigation listener in the tabgroup. I'll test and let you know soon.

X-Tender commented 9 years ago

Thanks for investigating this.

manumaticx commented 9 years ago

I'm afraid that we'll have to deprecate the dropdown since Actionbar.setNavigationMode() is deprecated but the dropdown proxy in this module is based on the old technique.

The way to solve it would be using a Spinner within the Toolbar (see here) but this requires Toolbar support on Titanium side.

manumaticx commented 9 years ago

If you think of the idea again that the dropdown as a navigation mode actually is meant to be a replacement for the Tabs, then the reason for the error that occured in your example is that you have 3 Tabs but only 2 Dropdown items. It won't crash if you pass an array of 3 dropdown items but this probably also breaks your logic.

I'll close this and suggest: do not use TabGroup and Dropdown together. (This will be resolved when Toolbar is supported)

X-Tender commented 9 years ago

OK. No problem, Thanks for checking the issue out (Maybe add it to the module description :) )