From 670dfa75ebbed6d05618166447bad359fac7a918 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 2 Aug 2019 15:41:19 +0200 Subject: [PATCH] proper view type switch Signed-off-by: Andy Scherzinger --- .../ui/adapter/AccountListAdapter.java | 129 ++++++++++-------- 1 file changed, 69 insertions(+), 60 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java index 04dc753939..c81478f027 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/AccountListAdapter.java @@ -40,7 +40,6 @@ import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.BaseActivity; import com.owncloud.android.ui.activity.UserInfoActivity; import com.owncloud.android.utils.DisplayUtils; -import com.owncloud.android.utils.ThemeUtils; import org.parceler.Parcels; @@ -53,14 +52,14 @@ import androidx.recyclerview.widget.RecyclerView; /** * This Adapter populates a RecyclerView with all accounts within the app. */ -public class AccountListAdapter extends RecyclerView.Adapter +public class AccountListAdapter extends RecyclerView.Adapter implements DisplayUtils.AvatarGenerationListener { private static final String TAG = AccountListAdapter.class.getSimpleName(); - private float mAccountAvatarRadiusDimension; - private final BaseActivity mContext; - private List mValues; - private AccountListAdapterListener mListener; - private Drawable mTintedCheck; + private float accountAvatarRadiusDimension; + private final BaseActivity context; + private List values; + private AccountListAdapterListener accountListAdapterListener; + private Drawable tintedCheck; private RecyclerView mRecyclerView; private UserAccountManager accountManager; @@ -68,14 +67,14 @@ public class AccountListAdapter extends RecyclerView.Adapter values, Drawable tintedCheck) { - this.mContext = context; + this.context = context; this.accountManager = accountManager; - this.mValues = values; + this.values = values; if (context instanceof AccountListAdapterListener) { - this.mListener = (AccountListAdapterListener) context; + this.accountListAdapterListener = (AccountListAdapterListener) context; } - this.mAccountAvatarRadiusDimension = context.getResources().getDimension(R.dimen.list_item_avatar_icon_radius); - this.mTintedCheck = tintedCheck; + this.accountAvatarRadiusDimension = context.getResources().getDimension(R.dimen.list_item_avatar_icon_radius); + this.tintedCheck = tintedCheck; } @Override @@ -84,35 +83,49 @@ public class AccountListAdapter extends RecyclerView.Adapter { - final Intent intent = new Intent(mContext, UserInfoActivity.class); + final Intent intent = new Intent(context, UserInfoActivity.class); if (accountListItem.isEnabled()) { intent.putExtra(UserInfoActivity.KEY_ACCOUNT, Parcels.wrap(account)); try { @@ -121,7 +134,7 @@ public class AccountListAdapter extends RecyclerView.Adapter mListener.showFirstRunActivity()); + actionView.setOnClickListener(v -> accountListAdapterListener.showFirstRunActivity()); } else { - actionView.setOnClickListener(v -> mListener.createAccount()); + actionView.setOnClickListener(v -> accountListAdapterListener.createAccount()); } } @@ -205,8 +207,8 @@ public class AccountListAdapter extends RecyclerView.Adapter items){ - if(mValues == null){ - mValues = new ArrayList<>(); + if(values == null){ + values = new ArrayList<>(); } - mValues.addAll(items); + values.addAll(items); notifyDataSetChanged(); } @@ -310,7 +312,14 @@ public class AccountListAdapter extends RecyclerView.Adapter