Skip to content

Commit

Permalink
Corrected the message timestamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
zond committed Feb 1, 2017
1 parent f7e6188 commit 38c3bf8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
32 changes: 19 additions & 13 deletions app/src/main/java/se/oort/diplicity/apigen/Ticker.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
import java.util.*;

public class Ticker implements java.io.Serializable {
public Long nanos;
public Date unserializedAt;
public Ticker(Date unserializedAt, Long nanos) {
public Long nanos;
public Date unserializedAt;
public Ticker(Date unserializedAt, Long nanos) {
this.unserializedAt = unserializedAt;
this.nanos = nanos;
}
public Date deadlineAt() {
Calendar cal = Calendar.getInstance();
cal.setTime(unserializedAt);
cal.add(Calendar.MILLISECOND, (int) (nanos / (long) 1000000));
return cal.getTime();
}
public Long nanosLeft() {
return (long) (deadlineAt().getTime() - unserializedAt.getTime()) * (long) 1000000;
}
}
public Date createdAt() {
Calendar cal = Calendar.getInstance();
cal.setTime(unserializedAt);
cal.add(Calendar.MILLISECOND, (int) (nanos / (long) -1000000));
return cal.getTime();
}
public Date deadlineAt() {
Calendar cal = Calendar.getInstance();
cal.setTime(unserializedAt);
cal.add(Calendar.MILLISECOND, (int) (nanos / (long) 1000000));
return cal.getTime();
}
public Long nanosLeft() {
return (long) (deadlineAt().getTime() - unserializedAt.getTime()) * (long) 1000000;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void send(final MultiContainer<Message> messageMultiContainer) {
}

((TextView) row.findViewById(R.id.body)).setText(message.Body);
((TextView) row.findViewById(R.id.at)).setText(message.Age.deadlineAt().toString());
((TextView) row.findViewById(R.id.at)).setText(message.Age.createdAt().toString());
((TextView) row.findViewById(R.id.sender)).setText(getResources().getString(R.string.x_, message.Sender));
if (author != null) {
ImageView avatar = (ImageView) row.findViewById(R.id.avatar);
Expand Down

0 comments on commit 38c3bf8

Please sign in to comment.