Collapse message on click-again

This commit is contained in:
Mike Schwörer 2018-12-11 12:31:44 +01:00
parent e525221010
commit 1d983b9ac0
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 15 additions and 2 deletions

View File

@ -100,7 +100,6 @@ public class SCNApp extends Application implements LifecycleObserver
} }
} }
//TODO: Collapse on click again
//TODO: Share button on expand //TODO: Share button on expand
//TODO: Delete button on expand //TODO: Delete button on expand
//TODO: Config for collapsed line count //TODO: Config for collapsed line count

View File

@ -9,6 +9,8 @@ import java.util.TimeZone;
public class CMessage public class CMessage
{ {
public boolean IsExpandedInAdapter = false;
public final long SCN_ID; public final long SCN_ID;
public final long Timestamp; public final long Timestamp;
public final String Title; public final String Title;

View File

@ -136,6 +136,8 @@ public class MessageAdapter extends RecyclerView.Adapter
tvTitle.setText(msg.Title); tvTitle.setText(msg.Title);
tvMessage.setText(msg.Content); tvMessage.setText(msg.Content);
tvMessage.setMaxLines(msg.IsExpandedInAdapter ? 999 : 6);
switch (msg.Priority) switch (msg.Priority)
{ {
case LOW: case LOW:
@ -160,15 +162,25 @@ public class MessageAdapter extends RecyclerView.Adapter
@Override @Override
public void onClick(View v) public void onClick(View v)
{ {
if (data.IsExpandedInAdapter)
{
data.IsExpandedInAdapter=false;
tvMessage.setMaxLines(6);
return;
}
for (MessagePresenter holder : MessageAdapter.this.viewHolders.keySet()) for (MessagePresenter holder : MessageAdapter.this.viewHolders.keySet())
{ {
if (holder == null) continue; if (holder == null) continue;
if (holder == this) continue; if (holder == this) continue;
if (holder.tvMessage == null) continue; if (holder.tvMessage == null) continue;
if (holder.tvMessage.getMaxLines() == 6) continue; if (!holder.data.IsExpandedInAdapter) continue;
holder.data.IsExpandedInAdapter=false;
holder.tvMessage.setMaxLines(6); holder.tvMessage.setMaxLines(6);
} }
data.IsExpandedInAdapter=true;
tvMessage.setMaxLines(9999); tvMessage.setMaxLines(9999);
} }
} }