square / mortar

A simple library that makes it easy to pair thin views with dedicated controllers, isolated from most of the vagaries of the Activity life cycle.
Apache License 2.0
2.16k stars 156 forks source link

ClassCastException in sample #170

Open MichaelEvans opened 9 years ago

MichaelEvans commented 9 years ago

I'm new to mortar, so perhaps this is an easy fix (in which case I'd be glad to send a PR)

Navigating to the a Friend screen and hitting back/up/"friend" in the Actionbar yields a ClassCastException with the stack trace attached. I'm guessing that the answer lies in the fact that FramePathContainerView expects all it's children to be ViewGroups, rather than just views?

 java.lang.ClassCastException: com.example.mortar.view.FriendView cannot be cast to android.view.ViewGroup
            at com.example.mortar.screen.FramePathContainerView.getCurrentChild(FramePathContainerView.java:78)
            at flow.path.PathContainer.executeTraversal(PathContainer.java:71)
            at com.example.mortar.screen.FramePathContainerView.dispatch(FramePathContainerView.java:65)
            at com.example.mortar.core.MortarDemoActivity.dispatch(MortarDemoActivity.java:78)
            at flow.Flow$PendingTraversal.dispatch(Flow.java:315)
            at flow.Flow$2.doExecute(Flow.java:197)
            at flow.Flow$PendingTraversal.execute(Flow.java:323)
            at flow.Flow.move(Flow.java:232)
            at flow.Flow.set(Flow.java:162)
            at com.example.mortar.core.MortarDemoActivity$1.call(MortarDemoActivity.java:72)
            at com.example.mortar.core.MortarDemoActivity$2.onMenuItemClick(MortarDemoActivity.java:166)
            at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147)
            at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
            at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:546)
            at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:115)
            at android.view.View.performClick(View.java:4438)
            at android.view.View$PerformClick.run(View.java:18422)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
ghost commented 9 years ago

I can confirm the issue. Correction to recreate steps: "Friends" -> Alex or Chris -> Back/up