RecyclerView перекрывается при вызове notifyItemInserted и notifyItemRangeChanged - PullRequest
0 голосов
/ 20 октября 2018

У меня есть RecyclerView с динамическим контентом, таким как добавление и удаление, пока он не был в порядке, но однажды он становится глючным и странным, как это.

enter image description here

Использование notifyItemInserted (), за которым следует notifyItemRangeChanged (), для обновления списка в прошлом месяце работало нормально.Я также пытался обновить свои зависимости до 28.0.0 и не работает.Это просто действие с RecyclerView.Тем не менее я не могу понять это, потому что тогда это не происходит.

Вот мой XML

<RelativeLayout 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"
android:background="@color/colorPrimaryDarker"
tools:context=".common.AnnouncementComments"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/commentLinear"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:minHeight="?android:attr/actionBarSize"
        android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        tools:targetApi="lollipop">


        <TextView
            android:id="@+id/titleBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/comment_section"
            android:textColor="@color/icon_selected"
            android:textSize="24sp"
            android:textStyle="bold"
            android:typeface="normal" />

    </android.support.v7.widget.Toolbar>


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

        <com.yalantis.phoenix.PullToRefreshView
            android:id="@+id/comment_refresh"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="2dp">

            <com.bitwise.rotaractclubapp.system.AutoPlayVideoRecyclerView
                android:id="@+id/commentRecycler"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="3dp" />

            </com.yalantis.phoenix.PullToRefreshView>

        <TextView
            android:id="@+id/noComments"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/be_the_first_in_this_comment_section"
            android:textColor="@color/not_selected"
            android:layout_centerInParent="true"
            android:textSize="18sp" />
    </RelativeLayout>

</LinearLayout>

<LinearLayout
    android:id="@+id/commentLinear"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@color/colorPrimaryDark"
        android:padding="5dp"
        android:weightSum="10">

        <com.sackcentury.shinebuttonlib.ShineButton
            android:id="@+id/videoBtn"
            android:layout_width="30dp"
            android:layout_height="35dp"
            android:layout_gravity="center"
            android:layout_marginEnd="5dp"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:contentDescription="@string/help"
            app:allow_random_color="true"
            app:big_shine_color="@color/highlighted"
            app:click_animation_duration="350"
            app:enable_flashing="true"
            app:shine_animation_duration="5000"
            app:shine_count="15"
            app:shine_turn_angle="20"
            app:siShape="@drawable/ic_movie_creation_black_24dp"
            app:small_shine_offset_angle="40"
            app:srcCompat="@drawable/ic_movie_creation_black_24dp"
            app:tint="@color/highlighted" />


        <com.sackcentury.shinebuttonlib.ShineButton
            android:id="@+id/imageBtn"
            android:layout_width="30dp"
            android:layout_height="35dp"
            android:layout_gravity="center"
            android:layout_marginEnd="5dp"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:contentDescription="@string/help"
            app:allow_random_color="true"
            app:big_shine_color="@color/highlighted"
            app:click_animation_duration="350"
            app:enable_flashing="true"
            app:shine_animation_duration="5000"
            app:shine_count="15"
            app:shine_turn_angle="20"
            app:siShape="@drawable/ic_image_black_24dp"
            app:small_shine_offset_angle="40"
            app:srcCompat="@drawable/ic_image_black_24dp"
            app:tint="@color/highlighted" />

        <EditText
            android:id="@+id/comment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="7"
            android:background="@drawable/edit_text_background"
            android:ems="10"
            android:hint="@string/your_comment"
            android:inputType="text|textCapSentences|textMultiLine"
            android:padding="10dp"
            android:textColor="@color/icon_selected"
            android:textColorHint="@color/icon_not_selected"
            tools:targetApi="lollipop"
            tools:ignore="Autofill" />

        <com.sackcentury.shinebuttonlib.ShineButton
            android:id="@+id/sendingBtn"
            android:layout_width="30dp"
            android:layout_height="35dp"
            android:layout_gravity="center"
            android:layout_marginStart="5dp"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:contentDescription="@string/help"
            app:allow_random_color="true"
            app:big_shine_color="@color/highlighted"
            app:click_animation_duration="350"
            app:enable_flashing="true"
            app:shine_animation_duration="5000"
            app:shine_count="15"
            app:shine_turn_angle="20"
            app:siShape="@drawable/ic_send_white_24dp"
            app:small_shine_offset_angle="40"
            app:srcCompat="@drawable/ic_send_white_24dp"
            app:tint="@color/highlighted" />

    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/filesRecycler"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="2dp"
        android:layout_marginStart="2dp"
        android:visibility="gone" />

</LinearLayout>

1 Ответ

0 голосов
/ 21 октября 2018

Я решил проблему, это была глупая ошибка, и мне потребовались недели, чтобы понять.Причиной проблемы является то, что некоторые предметы не подлежат переработке setIsRecyclable(false).

...