Some refactoring of the EntryViewHolder
This commit is contained in:
parent
661f388992
commit
145c4b6105
2 changed files with 17 additions and 19 deletions
|
@ -233,7 +233,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTap(final int position) {
|
public void onCardClicked(final int position) {
|
||||||
if (settings.getTapToReveal()) {
|
if (settings.getTapToReveal()) {
|
||||||
final Entry entry = displayedEntries.get(position);
|
final Entry entry = displayedEntries.get(position);
|
||||||
final int realIndex = entries.indexOf(entry);
|
final int realIndex = entries.indexOf(entry);
|
||||||
|
@ -256,7 +256,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCounterTapped(int position) {
|
public void onCounterClicked(int position) {
|
||||||
Entry entry = displayedEntries.get(position);
|
Entry entry = displayedEntries.get(position);
|
||||||
Entry realEntry = entries.get(getRealIndex(position));
|
Entry realEntry = entries.get(getRealIndex(position));
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
super(v);
|
super(v);
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.tapToReveal = tapToReveal;
|
|
||||||
|
|
||||||
card = v.findViewById(R.id.card_view);
|
card = v.findViewById(R.id.card_view);
|
||||||
value = v.findViewById(R.id.valueText);
|
value = v.findViewById(R.id.valueText);
|
||||||
|
@ -117,7 +116,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.onCounterTapped(getAdapterPosition());
|
callback.onCounterClicked(getAdapterPosition());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -146,28 +145,23 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
|
|
||||||
final String tokenFormatted = Tools.formatToken(entry.getCurrentOTP(), settings.getTokenSplitGroupSize());
|
final String tokenFormatted = Tools.formatToken(entry.getCurrentOTP(), settings.getTokenSplitGroupSize());
|
||||||
|
|
||||||
this.label.setText(entry.getLabel());
|
label.setText(entry.getLabel());
|
||||||
value.setText(tokenFormatted);
|
value.setText(tokenFormatted);
|
||||||
// save the unformatted token to the tag of this TextView for copy/paste
|
// save the unformatted token to the tag of this TextView for copy/paste
|
||||||
value.setTag(entry.getCurrentOTP());
|
value.setTag(entry.getCurrentOTP());
|
||||||
|
|
||||||
List<String> tags = entry.getTags();
|
List<String> entryTags = entry.getTags();
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for(int i = 0; i < tags.size(); i++) {
|
for(int i = 0; i < entryTags.size(); i++) {
|
||||||
stringBuilder.append(tags.get(i));
|
stringBuilder.append(entryTags.get(i));
|
||||||
if(i < tags.size() - 1) {
|
if(i < entryTags.size() - 1) {
|
||||||
stringBuilder.append(", ");
|
stringBuilder.append(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.tags.setText(stringBuilder.toString());
|
tags.setText(stringBuilder.toString());
|
||||||
|
|
||||||
if (! tags.isEmpty()) {
|
|
||||||
this.tags.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
this.tags.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
tags.setVisibility(entryTags.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
thumbnailFrame.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE);
|
thumbnailFrame.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
int thumbnailSize = settings.getThumbnailSize();
|
int thumbnailSize = settings.getThumbnailSize();
|
||||||
|
@ -221,6 +215,8 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTapToReveal(boolean enabled) {
|
private void setTapToReveal(boolean enabled) {
|
||||||
|
tapToReveal = enabled;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
valueLayout.setVisibility(View.GONE);
|
valueLayout.setVisibility(View.GONE);
|
||||||
coverLayout.setVisibility(View.VISIBLE);
|
coverLayout.setVisibility(View.VISIBLE);
|
||||||
|
@ -229,7 +225,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
card.setOnClickListener(new View.OnClickListener() {
|
card.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
callback.onTap(getAdapterPosition());
|
callback.onCardClicked(getAdapterPosition());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,8 +259,10 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
|
|
||||||
void onMenuButtonClicked(View parentView, int position);
|
void onMenuButtonClicked(View parentView, int position);
|
||||||
void onCopyButtonClicked(String text, int position);
|
void onCopyButtonClicked(String text, int position);
|
||||||
void onTap(int position);
|
|
||||||
void onCounterTapped(int position);
|
void onCardClicked(int position);
|
||||||
|
|
||||||
|
void onCounterClicked(int position);
|
||||||
void onCounterLongPressed(int position);
|
void onCounterLongPressed(int position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue