Refactored adapters to use bindTo method

This commit is contained in:
M66B
2018-08-07 06:51:49 +00:00
parent 9b148eefb9
commit 048660d24f
4 changed files with 65 additions and 51 deletions

View File

@@ -73,6 +73,14 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
itemView.setOnClickListener(null);
}
private void bindTo(EntityAccount account) {
ivPrimary.setVisibility(account.primary ? View.VISIBLE : View.GONE);
tvName.setText(account.name);
ivSync.setVisibility(account.synchronize ? View.VISIBLE : View.INVISIBLE);
tvHost.setText(String.format("%s:%d", account.host, account.port));
tvUser.setText(account.user);
}
@Override
public void onClick(View view) {
int pos = getAdapterPosition();
@@ -192,12 +200,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
holder.unwire();
EntityAccount account = filtered.get(position);
holder.ivPrimary.setVisibility(account.primary ? View.VISIBLE : View.GONE);
holder.tvName.setText(account.name);
holder.ivSync.setVisibility(account.synchronize ? View.VISIBLE : View.INVISIBLE);
holder.tvHost.setText(String.format("%s:%d", account.host, account.port));
holder.tvUser.setText(account.user);
holder.bindTo(account);
holder.wire();
}