Set transient state on expand only

pull/147/head
M66B 6 years ago
parent deab962e8a
commit 8979eab674

@ -247,8 +247,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvBody.setMovementMethod(new UrlHandler()); tvBody.setMovementMethod(new UrlHandler());
if (viewType == ViewType.THREAD)
itemView.setHasTransientState(true);
} }
private void wire() { private void wire() {
@ -313,6 +311,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean show_addresses = properties.showAddresses(message.id); boolean show_addresses = properties.showAddresses(message.id);
boolean show_headers = properties.showHeaders(message.id); boolean show_headers = properties.showHeaders(message.id);
if (viewType == ViewType.THREAD) {
if (show_expanded) {
if (!properties.isFrozen(message.id)) {
itemView.setHasTransientState(true);
properties.setFrozen(message.id, true);
}
} else {
if (properties.isFrozen(message.id)) {
itemView.setHasTransientState(false);
properties.setFrozen(message.id, false);
}
}
}
pbLoading.setVisibility(View.GONE); pbLoading.setVisibility(View.GONE);
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
@ -1664,6 +1676,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
interface IProperties { interface IProperties {
void setExpanded(long id, boolean expand); void setExpanded(long id, boolean expand);
void setFrozen(long id, boolean freeze);
void setAddresses(long id, boolean show); void setAddresses(long id, boolean show);
void setHeaders(long id, boolean show); void setHeaders(long id, boolean show);
@ -1672,6 +1686,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean isExpanded(long id); boolean isExpanded(long id);
boolean isFrozen(long id);
boolean showAddresses(long id); boolean showAddresses(long id);
boolean showHeaders(long id); boolean showHeaders(long id);

@ -117,6 +117,7 @@ public class FragmentMessages extends FragmentEx {
private int autoCloseCount = 0; private int autoCloseCount = 0;
private boolean autoExpand = true; private boolean autoExpand = true;
private List<Long> expanded = new ArrayList<>(); private List<Long> expanded = new ArrayList<>();
private List<Long> frozen = new ArrayList<>();
private List<Long> addresses = new ArrayList<>(); private List<Long> addresses = new ArrayList<>();
private List<Long> headers = new ArrayList<>(); private List<Long> headers = new ArrayList<>();
private List<Long> images = new ArrayList<>(); private List<Long> images = new ArrayList<>();
@ -310,6 +311,15 @@ public class FragmentMessages extends FragmentEx {
expanded.remove(id); expanded.remove(id);
} }
@Override
public void setFrozen(long id, boolean freeze) {
Log.i(Helper.TAG, "Freeze=" + freeze + " id=" + id);
if (freeze)
frozen.add(id);
else
frozen.remove(id);
}
@Override @Override
public void setAddresses(long id, boolean show) { public void setAddresses(long id, boolean show) {
if (show) if (show)
@ -339,6 +349,11 @@ public class FragmentMessages extends FragmentEx {
return expanded.contains(id); return expanded.contains(id);
} }
@Override
public boolean isFrozen(long id) {
return frozen.contains(id);
}
@Override @Override
public boolean showAddresses(long id) { public boolean showAddresses(long id) {
return !addresses.contains(id); return !addresses.contains(id);

Loading…
Cancel
Save