Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error trying to cast FABProgessCircle as FloatingActionButton #37

Open
dmfrey opened this issue Feb 4, 2017 · 3 comments
Open

Comments

@dmfrey
Copy link

dmfrey commented Feb 4, 2017

Here is the stacktrace:

02-04 10:24:40.942 8403-8403/org.mythtv.android E/AndroidRuntime: FATAL EXCEPTION: main
                                                              Process: org.mythtv.android, PID: 8403
                                                              java.lang.ClassCastException: com.github.jorgecastilloprz.FABProgressCircle cannot be cast to android.support.design.widget.FloatingActionButton
                                                                  at android.support.design.widget.FloatingActionButton$Behavior.onLayoutChild(FloatingActionButton.java:545)
                                                                  at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:849)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
                                                                  at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
                                                                  at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1367)
                                                                  at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:849)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1193)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                  at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                  at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                  at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                  at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
                                                                  at android.view.View.layout(View.java:16630)
                                                                  at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                  at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
                                                                  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
                                                                  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                                  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                                                                  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                                  at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                  at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

res/layout/phone_fab_view.xml (gets included in other layouts):

<com.github.jorgecastilloprz.FABProgressCircle xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fabProgressCircle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    android:layout_gravity="end|bottom"
    app:layout_behavior="org.mythtv.android.presentation.utils.ScrollAwareFABBehavior">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_autorenew_white_24dp"
        app:rippleColor="@color/white"
        app:elevation="6dp"
        app:borderWidth="0dp" />

</com.github.jorgecastilloprz.FABProgressCircle>

res/layout/activity_phone_main.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:title="@string/all_videos"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabGravity="fill"
                app:tabMode="fixed" />

        </android.support.design.widget.AppBarLayout>

        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <!--<include layout="@layout/phone_fab_view" />-->

    </android.support.design.widget.CoordinatorLayout>

    <include layout="@layout/mini_controller" />

</RelativeLayout>

<include layout="@layout/phone_navigation_view" />

</android.support.v4.widget.DrawerLayout>

res/layout/fragment_media_item_list.xml (includes the fab layout):

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv_mediaItems"
    android:scrollbars="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<include
    layout="@layout/phone_fab_view" />

</android.support.design.widget.CoordinatorLayout>

FABCircleProgress is loaded with ButterKnife

@BindView( R.id.fabProgressCircle )
FABProgressCircle fabProgressCircle;

Adapter is loading the RecyclerView, listener is starting/stopping/hiding the animations like described. For some reason, the FABCircleProgress is trying to be cast as a FloatingActionButton in the Coordinator layout.

Any ideas?

@arjunvekariyagithub
Copy link

arjunvekariyagithub commented Feb 7, 2017

I faced the same error today.

It's because of
app:layout_behavior="org.mythtv.android.presentation.utils.ScrollAwareFABBehavior"
attribute inside res/layout/phone_fab_view.xml. Place this behavior attribute into FloatingActionButton instead FABProgressCircle. This behavior is applicable to only FloatingActionButton and not for any other view so Android framework expects the view with this bahavior to be FloatingActionButton.

@dmfrey
Copy link
Author

dmfrey commented Feb 7, 2017

@arjunvekariyagithub thank you, I will give this a shot.

@dmfrey
Copy link
Author

dmfrey commented Feb 9, 2017

@arjunvekariyagithub thank you, that fixed the issue. I was still running into an NPE when trying to call .show(). However, I saw another issue that said to call .onMeasure(15,15). I don't believe that is a long-term fix, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants