fix activity transitions by limiting view rebinding
This commit is contained in:
parent
c0123eb01b
commit
074f72f58a
@ -5,6 +5,7 @@ import android.database.Cursor;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.data.App;
|
import org.fdroid.fdroid.data.App;
|
||||||
|
|
||||||
@ -36,6 +37,10 @@ class AppPreviewAdapter extends RecyclerView.Adapter<AppCardController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAppCursor(Cursor cursor) {
|
public void setAppCursor(Cursor cursor) {
|
||||||
|
if (this.cursor == cursor) {
|
||||||
|
//don't notify when the cursor did not change
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.cursor = cursor;
|
this.cursor = cursor;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,32 @@ package org.fdroid.fdroid.views.categories;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.LoaderManager;
|
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 android.view.ViewGroup;
|
||||||
|
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CategoryAdapter extends RecyclerView.Adapter<CategoryController> {
|
public class CategoryAdapter extends ListAdapter<String, CategoryController> {
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private List<String> unlocalizedCategoryNames = Collections.<String>emptyList();
|
|
||||||
|
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
private final LoaderManager loaderManager;
|
private final LoaderManager loaderManager;
|
||||||
|
|
||||||
public CategoryAdapter(Activity activity, 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.activity = activity;
|
||||||
this.loaderManager = loaderManager;
|
this.loaderManager = loaderManager;
|
||||||
}
|
}
|
||||||
@ -32,17 +42,11 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryController> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull CategoryController holder, int position) {
|
public void onBindViewHolder(@NonNull CategoryController holder, int position) {
|
||||||
holder.bindModel(unlocalizedCategoryNames.get(position));
|
holder.bindModel(getItem(position));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return unlocalizedCategoryNames.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategories(@NonNull List<String> unlocalizedCategoryNames) {
|
public void setCategories(@NonNull List<String> unlocalizedCategoryNames) {
|
||||||
this.unlocalizedCategoryNames = unlocalizedCategoryNames;
|
submitList(unlocalizedCategoryNames);
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import android.support.v7.widget.GridLayoutManager;
|
|||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.fdroid.fdroid.BuildConfig;
|
import org.fdroid.fdroid.BuildConfig;
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.data.App;
|
import org.fdroid.fdroid.data.App;
|
||||||
@ -102,6 +103,10 @@ public class WhatsNewAdapter extends RecyclerView.Adapter<AppCardController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAppsCursor(Cursor cursor) {
|
public void setAppsCursor(Cursor cursor) {
|
||||||
|
if (this.cursor == cursor) {
|
||||||
|
//don't notify when the cursor did not change
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.cursor = cursor;
|
this.cursor = cursor;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user