Java 带swipelayout的动画冻结
添加2个新功能(swipelayout+动画)后,我的ui冻结 我有一个包含电影对象的recyclerview。如果我添加/删除/修改一部电影,我会调用我的电影管理器,因为有一个通知概念(所有想要使用数据的视图都必须在这个管理器上注册)。 在我添加新功能之前,所有这些都很好 我使用这种泳衣布局: 目前,这些项目如下所示: 刷卡后: 如果我有4个项目,冻结总是可以复制的。我在第二个项目上滑动并删除它。然后它会像我想的那样消失。在我刷完“新”的第二个物品后,会冻结10-15秒 项目的布局xml:Java 带swipelayout的动画冻结,java,android,animation,swipe,Java,Android,Animation,Swipe,添加2个新功能(swipelayout+动画)后,我的ui冻结 我有一个包含电影对象的recyclerview。如果我添加/删除/修改一部电影,我会调用我的电影管理器,因为有一个通知概念(所有想要使用数据的视图都必须在这个管理器上注册)。 在我添加新功能之前,所有这些都很好 我使用这种泳衣布局: 目前,这些项目如下所示: 刷卡后: 如果我有4个项目,冻结总是可以复制的。我在第二个项目上滑动并删除它。然后它会像我想的那样消失。在我刷完“新”的第二个物品后,会冻结10-15秒 项目的布局xml
<com.daimajia.swipe.SwipeLayout
android:id="@+id/item_movie_swipe_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/item_movie_swipe_bottom_wrapper"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#ff0000">
<TextView
android:id="@+id/item_movie_bottom_delete_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_delete_white_24dp"
android:text="@string/delete"
android:textColor="#fff"
android:layout_gravity="center"
android:padding="10dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="@+id/item_movie_list_poster"
style="@style/image_border_style"
android:layout_width="68dp"
android:layout_height="100dp"
android:layout_marginRight="3dp"
android:background="@android:color/black"/>
<TextView
android:id="@+id/item_movie_list_name_year"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="3dp"
android:layout_toEndOf="@+id/item_movie_list_poster"
android:layout_toRightOf="@+id/item_movie_list_poster"
android:gravity="center|left"
android:padding="3dp" android:text="name"/>
<TextView
android:id="@+id/item_movie_list_genre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/item_movie_list_name_year"
android:layout_marginBottom="3dp"
android:layout_toEndOf="@+id/item_movie_list_poster"
android:layout_toRightOf="@+id/item_movie_list_poster"
android:padding="3dp"
android:text="Drama - Komödie - Action" android:textColor="@color/item_textyear"
android:textSize="12dp"/>
<TextView
android:id="@+id/item_movie_list_viewed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/item_movie_list_poster"
android:layout_toRightOf="@+id/item_movie_list_poster"
android:paddingLeft="3dp" android:text="Gesehen: "
android:textColor="@color/accept"
android:textSize="12dp"/>
</RelativeLayout>
</com.daimajia.swipe.SwipeLayout>
在CDMMovieManager.getInstance().removeMovieID(m_List,m_MovieIDs.get(p_iPosition))代码>电影将被删除,并通知所有已注册的视图。在这种情况下,此适配器的片段将调用m_adapter.notifyDataSetChanged()代码>
动画文件:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:fromXDelta="0%"
android:toXDelta="-100%"/>
</set>
我尝试了View.clearAnimation()
或Animation.setAnimationListener(null)
之类的方法,但我总是遇到这个问题。
请询问您是否需要更多信息
更新:
只有在我尝试刷下一个项目时才会出现问题。(例如,删除第二项。然后尝试滑动第三项,即新的第二项->冻结我尝试滑动的项)。只有在刷其他物品时才能解除冻结。我解决了我的问题。这个答案帮助了我:
我已将此代码添加到适配器:
@Override
public void onViewDetachedFromWindow(IC_ViewHolder p_Holder) {
p_Holder.m_View.clearAnimation();
}
有什么建议吗?我认为问题在于动画及其animationlistener的初始化。来自管理器的onAnimationEnd()
和适配器.notifyDataSetChanged()
调用可能存在同步问题。我不知道如何修理它。请帮忙。
@Override
public void onViewDetachedFromWindow(IC_ViewHolder p_Holder) {
p_Holder.m_View.clearAnimation();
}