Closed Guimareshh closed 7 years ago
@Guimareshh is your animation in the recyclerview?
@gpeal no the animation is inside the ConstraintLayout, same level as the recyclerView. That's why I find this issue very strange
@Guimareshh Can you attach a sample project that repros this?
@gpeal I tried in a sample project to repro the same bug, but it was impossible. After trying few things in my main project I have found that it doesn't come from the notifyDataSetChanged();
It seems to be the Realm insertion that freeze the animation. Indeed the freeze is when I start to save my objects inside Realm :
DiscoverRest discoverRest = ServiceGenerator.createService(DiscoverRest.class, true);
discoverRest
.getCategories()
.enqueue(new Callback<CategoryListResponse>() {
@Override
public void onResponse(Call<CategoryListResponse> call, Response<CategoryListResponse> response) {
if (response.isSuccessful()) {
Realm realm = Realm.getDefaultInstance();
for (final Category category : response.body().getCategories()) {
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.copyToRealmOrUpdate(category);
}
});
if (category.getSubCategories() != null) {
for (final SubCategory subCategory : category.getSubCategories()) {
subCategory.setIdCategory(category.getId());
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.copyToRealmOrUpdate(subCategory);
}
});
}
}
}
loadFromRealm();
} else {
APIError error = ErrorUtils.parseError(response);
Toast.makeText(getActivity(), error.message(), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<CategoryListResponse> call, Throwable t) {
Toast.makeText(getActivity(), getString(R.string.api_failed), Toast.LENGTH_LONG).show();
}
});
}
If I remove the Realm part and add the following code :
categories.addAll(response.body().getCategories());
categoryAdapter.notifyDataSetChanged();
binding.animationView.animate().alpha(0f).setDuration(250).start();
The Lottie animation doesn't freeze. For now, the solution will be to save objects with Realm after the animation has "gone".
@Guimareshh This doesn't seem like a Lottie issue then. You may be able to use systrace or something to figure out why it's not working though.
I've met the question as you too.do nothing but notifyDataSetChanged,the animation freeze. lottie version is 6.2.0
Hi there !
I'm using Lottie since months now and I found a strange issue today. In my fragment I have the Lottie animation already set, and using the animation to make the user wait during the call of API nor loading data from Realm. When it's done I animate the Lottie file to set the Alpha to 0 and call notifyDataSetChanged() for two recyclerView.
Here is the video
And here is my code :
One of the RecyclerView has a lot of items (±50) and the other only 5.
And how the Lottie XML looks like :
Any idea why this is happening ? Thanks for your help !