2. public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
3. public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
4. public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
5. public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
6. public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
7. public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
8. public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
ChatForm
9. public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
ChatForm
10. this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
tb.addCommandToOverflowMenu("Media", null, e -> {});
tb.addCommandToOverflowMenu("Search", null, e -> {});
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
ChatForm
11. tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
tb.addCommandToOverflowMenu("Media", null, e -> {});
tb.addCommandToOverflowMenu("Search", null, e -> {});
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
ChatForm
12. tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
tb.addCommandToOverflowMenu("Media", null, e -> {});
tb.addCommandToOverflowMenu("Search", null, e -> {});
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
ChatForm
13. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
14. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
15. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
16. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
17. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
18. addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
removeShowListener(this);
getContentPane().scrollComponentToVisible(cc);
}
});
}
private void addDay(Date d, long currentDay) {
ChatForm
19. addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
removeShowListener(this);
getContentPane().scrollComponentToVisible(cc);
}
});
}
private void addDay(Date d, long currentDay) {
ChatForm
20. addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
removeShowListener(this);
getContentPane().scrollComponentToVisible(cc);
}
});
}
private void addDay(Date d, long currentDay) {
ChatForm
21. }
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
22. }
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
23. }
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
24. }
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
25. }
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
26. }
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm