Fixes rare crashes when viewing accounts and favouriting. Also, fixes content warning characters not counting toward the character limit. Closes #32

This commit is contained in:
Vavassor 2017-03-19 22:38:39 -04:00
commit f2a400ab38
10 changed files with 88 additions and 31 deletions

View file

@ -306,25 +306,37 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
replyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onReply(getAdapterPosition());
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
listener.onReply(position);
}
}
});
reblogButton.setEventListener(new SparkEventListener() {
@Override
public void onEvent(ImageView button, boolean buttonState) {
listener.onReblog(!reblogged, getAdapterPosition());
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
listener.onReblog(!reblogged, position);
}
}
});
favouriteButton.setEventListener(new SparkEventListener() {
@Override
public void onEvent(ImageView button, boolean buttonState) {
listener.onFavourite(!favourited, getAdapterPosition());
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
listener.onFavourite(!favourited, position);
}
}
});
moreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onMore(v, getAdapterPosition());
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
listener.onMore(v, position);
}
}
});
/* Even though the content TextView is a child of the container, it won't respond to clicks
@ -334,7 +346,10 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
View.OnClickListener viewThreadListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onViewThread(getAdapterPosition());
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
listener.onViewThread(position);
}
}
};
content.setOnClickListener(viewThreadListener);