Merge branch 'fix-back-animation' into 'master'
fix activity transitions by limiting view rebinding Closes #1636 See merge request fdroid/fdroidclient!781
This commit is contained in:
commit
251391f051
@ -5,6 +5,7 @@ import android.database.Cursor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
|
||||
@ -36,6 +37,10 @@ class AppPreviewAdapter extends RecyclerView.Adapter<AppCardController> {
|
||||
}
|
||||
|
||||
public void setAppCursor(Cursor cursor) {
|
||||
if (this.cursor == cursor) {
|
||||
//don't notify when the cursor did not change
|
||||
return;
|
||||
}
|
||||
this.cursor = cursor;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
@ -3,22 +3,32 @@ package org.fdroid.fdroid.views.categories;
|
||||
import android.app.Activity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.recyclerview.extensions.ListAdapter;
|
||||
import android.support.v7.util.DiffUtil;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CategoryAdapter extends RecyclerView.Adapter<CategoryController> {
|
||||
|
||||
@NonNull
|
||||
private List<String> unlocalizedCategoryNames = Collections.<String>emptyList();
|
||||
public class CategoryAdapter extends ListAdapter<String, CategoryController> {
|
||||
|
||||
private final Activity activity;
|
||||
private final LoaderManager loaderManager;
|
||||
|
||||
public CategoryAdapter(Activity activity, LoaderManager loaderManager) {
|
||||
super(new DiffUtil.ItemCallback<String>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(String oldItem, String newItem) {
|
||||
return oldItem.equals(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(String oldItem, String newItem) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
this.activity = activity;
|
||||
this.loaderManager = loaderManager;
|
||||
}
|
||||
@ -32,17 +42,11 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryController> {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CategoryController holder, int position) {
|
||||
holder.bindModel(unlocalizedCategoryNames.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return unlocalizedCategoryNames.size();
|
||||
holder.bindModel(getItem(position));
|
||||
}
|
||||
|
||||
public void setCategories(@NonNull List<String> unlocalizedCategoryNames) {
|
||||
this.unlocalizedCategoryNames = unlocalizedCategoryNames;
|
||||
notifyDataSetChanged();
|
||||
submitList(unlocalizedCategoryNames);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.fdroid.fdroid.BuildConfig;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
@ -102,6 +103,10 @@ public class WhatsNewAdapter extends RecyclerView.Adapter<AppCardController> {
|
||||
}
|
||||
|
||||
public void setAppsCursor(Cursor cursor) {
|
||||
if (this.cursor == cursor) {
|
||||
//don't notify when the cursor did not change
|
||||
return;
|
||||
}
|
||||
this.cursor = cursor;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user