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

AppBarLayout - Crashing when setExpand animate is true #3854

Open
ArcherEmiya05 opened this issue Nov 19, 2023 · 0 comments
Open

AppBarLayout - Crashing when setExpand animate is true #3854

ArcherEmiya05 opened this issue Nov 19, 2023 · 0 comments

Comments

@ArcherEmiya05
Copy link

Description:
Crashing after repeated call of appBarLayout.setExpanded(true, true)

Expected behavior:
Not crashing

Source code:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".presentation.MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            app:menu="@menu/activity_main_menu"
            app:title="@string/home"
            app:subtitle="@string/assets"
            app:titleCentered="true"
            app:subtitleCentered="true"/>

    </com.google.android.material.appbar.AppBarLayout>

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

</androidx.coordinatorlayout.widget.CoordinatorLayout>

When a back press is called, the RecyclerView inside content_main scrolls up after calling recyclerView.smoothScrollToPosition(0) then we also call appBarLayout.setExpanded(true, true). It works for a while but after repeatedly triggering both method and clicking some action menu or navigation icon while the list is scrolling the error below kicks in.

JNI DETECTED ERROR IN APPLICATION: can't call void com.google.android.material.appbar.AppBarLayout.setElevation(float) on null object

Minimal sample app repro: N/A

Android API version: 21

Material Library version: 1.10.0

Device: Pixel (emulator)

@ArcherEmiya05 ArcherEmiya05 changed the title AppBarLayout - Crashing when setExpand animation is true AppBarLayout - Crashing when setExpand animate is true Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants