From 35e3a479cd070c9c652770650164698b45fedc54 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 29 Sep 2016 02:05:53 +0800 Subject: [PATCH] Remove unnecessary expand list that causes crashes --- .../java/com/topjohnwu/magisk/ReposAdapter.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java index 381227a17..5e4257c60 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java @@ -9,6 +9,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,16 +37,11 @@ import butterknife.ButterKnife; public class ReposAdapter extends RecyclerView.Adapter { private final List mList; - private List mExpandedList; private View mView; private Context context; public ReposAdapter(List list) { mList = list; - mExpandedList = new ArrayList<>(mList.size()); - for (int i = 0; i < mList.size(); i++) { - mExpandedList.add(false); - } } @Override @@ -59,10 +55,6 @@ public class ReposAdapter extends RecyclerView.Adapter @Override public void onBindViewHolder(final ViewHolder holder, int position) { final Repo repo = mList.get(position); - mExpandedList = new ArrayList<>(mList.size()); - for (int i = 0; i < mList.size(); i++) { - mExpandedList.add(false); - } if (repo.isCache()) { holder.title.setText("[Cache] " + repo.getName()); } else { @@ -152,6 +144,8 @@ public class ReposAdapter extends RecyclerView.Adapter private ObjectAnimator animY2; private ViewHolder holder; + private boolean expanded = false; + public ViewHolder(View itemView) { super(itemView); WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); @@ -179,13 +173,12 @@ public class ReposAdapter extends RecyclerView.Adapter }); mView.setOnClickListener(view -> { - int position = getAdapterPosition(); - if (mExpandedList.get(position)) { + if (expanded) { collapse(holder.expandLayout); } else { expand(holder.expandLayout); } - mExpandedList.set(position, !mExpandedList.get(position)); + expanded = !expanded; }); }