Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
0bcca238
Commit
0bcca238
authored
Nov 25, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix coding style
parent
41cd2147
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
17 deletions
+34
-17
DateTime.java
app/src/main/java/chat/rocket/android/helper/DateTime.java
+21
-17
MessageViewHolder.java
...cket/android/layouthelper/chatroom/MessageViewHolder.java
+7
-0
PairedMessage.java
...t/rocket/android/layouthelper/chatroom/PairedMessage.java
+6
-0
No files found.
app/src/main/java/chat/rocket/android/helper/DateTime.java
View file @
0bcca238
...
...
@@ -7,15 +7,17 @@ import java.util.GregorianCalendar;
import
java.util.TimeZone
;
import
timber.log.Timber
;
/**
* Utility class for converting epoch ms and date-time string.
*/
public
class
DateTime
{
private
static
final
String
TAG
=
DateTime
.
class
.
getName
();
private
static
final
SimpleDateFormat
sSimpleTimeFormat
=
new
SimpleDateFormat
(
"HH:mm"
);
private
static
final
SimpleDateFormat
sSimpleDateFormat
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
private
static
final
SimpleDateFormat
sSimpleDayFormat
=
new
SimpleDateFormat
(
"MM/dd"
);
private
static
final
SimpleDateFormat
sSimpleDayTimeFormat
=
new
SimpleDateFormat
(
"MM/dd HH:mm"
);
private
static
final
SimpleDateFormat
sSimpleDateTimeFormat
=
new
SimpleDateFormat
(
"yyyy/MM/dd HH:mm"
);
private
static
final
SimpleDateFormat
TIME_FORMAT
=
new
SimpleDateFormat
(
"HH:mm"
);
private
static
final
SimpleDateFormat
DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
private
static
final
SimpleDateFormat
DAY_FORMAT
=
new
SimpleDateFormat
(
"MM/dd"
);
private
static
final
SimpleDateFormat
DAY_TIME_FORMAT
=
new
SimpleDateFormat
(
"MM/dd HH:mm"
);
private
static
final
SimpleDateFormat
DATE_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyy/MM/dd HH:mm"
);
/**
* convert datetime ms to String.
...
...
@@ -26,26 +28,26 @@ public class DateTime {
switch
(
format
)
{
case
DAY:
return
sSimpleDayFormat
.
format
(
cal
.
getTime
());
return
DAY_FORMAT
.
format
(
cal
.
getTime
());
case
DATE:
return
sSimpleDateFormat
.
format
(
cal
.
getTime
());
return
DATE_FORMAT
.
format
(
cal
.
getTime
());
case
TIME:
return
sSimpleTimeFormat
.
format
(
cal
.
getTime
());
return
TIME_FORMAT
.
format
(
cal
.
getTime
());
case
DATE_TIME:
return
sSimpleDateTimeFormat
.
format
(
cal
.
getTime
());
return
DATE_TIME_FORMAT
.
format
(
cal
.
getTime
());
case
DAY_TIME:
return
sSimpleDayTimeFormat
.
format
(
cal
.
getTime
());
return
DAY_TIME_FORMAT
.
format
(
cal
.
getTime
());
case
AUTO_DAY_TIME:
{
final
long
curTimeMs
=
System
.
currentTimeMillis
();
Calendar
cal2
=
Calendar
.
getInstance
(
TimeZone
.
getTimeZone
(
"JST"
));
cal2
.
setTimeInMillis
(
curTimeMs
);
if
(
cal
.
get
(
Calendar
.
YEAR
)
==
cal2
.
get
(
Calendar
.
YEAR
)
&&
cal
.
get
(
Calendar
.
DAY_OF_YEAR
)
==
cal2
.
get
(
Calendar
.
DAY_OF_YEAR
))
{
if
(
cal
.
get
(
Calendar
.
YEAR
)
==
cal2
.
get
(
Calendar
.
YEAR
)
&&
cal
.
get
(
Calendar
.
DAY_OF_YEAR
)
==
cal2
.
get
(
Calendar
.
DAY_OF_YEAR
))
{
//same day.
return
sSimpleDayTimeFormat
.
format
(
cal
.
getTime
());
return
DAY_TIME_FORMAT
.
format
(
cal
.
getTime
());
}
else
{
return
sSimpleDayFormat
.
format
(
cal
.
getTime
());
return
DAY_FORMAT
.
format
(
cal
.
getTime
());
}
}
default
:
...
...
@@ -59,7 +61,7 @@ public class DateTime {
public
static
long
fromDateToEpocMs
(
String
dateString
)
{
try
{
Calendar
cal
=
new
GregorianCalendar
();
cal
.
setTime
(
sSimpleDateFormat
.
parse
(
dateString
));
cal
.
setTime
(
DATE_FORMAT
.
parse
(
dateString
));
return
cal
.
getTimeInMillis
();
}
catch
(
ParseException
exception
)
{
Timber
.
w
(
exception
,
"failed to parse date: %s"
,
dateString
);
...
...
@@ -67,8 +69,10 @@ public class DateTime {
return
0
;
}
/**
* format.
*/
public
enum
Format
{
DATE
,
DAY
,
TIME
,
DATE_TIME
,
DAY_TIME
,
AUTO_DAY_TIME
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageViewHolder.java
View file @
0bcca238
...
...
@@ -12,6 +12,7 @@ import chat.rocket.android.renderer.MessageRenderer;
import
chat.rocket.android.widget.message.RocketChatMessageLayout
;
/**
* View holder of NORMAL chat message.
*/
public
class
MessageViewHolder
extends
RealmModelViewHolder
<
PairedMessage
>
{
private
final
ImageView
avatar
;
...
...
@@ -23,6 +24,9 @@ public class MessageViewHolder extends RealmModelViewHolder<PairedMessage> {
private
final
View
newDayContainer
;
private
final
TextView
newDayText
;
/**
* constructor WITH hostname.
*/
public
MessageViewHolder
(
View
itemView
,
String
hostname
)
{
super
(
itemView
);
avatar
=
(
ImageView
)
itemView
.
findViewById
(
R
.
id
.
user_avatar
);
...
...
@@ -35,6 +39,9 @@ public class MessageViewHolder extends RealmModelViewHolder<PairedMessage> {
this
.
hostname
=
hostname
;
}
/**
* bind the view model.
*/
public
void
bind
(
PairedMessage
pairedMessage
)
{
new
MessageRenderer
(
itemView
.
getContext
(),
pairedMessage
.
target
)
.
avatarInto
(
avatar
,
hostname
)
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/PairedMessage.java
View file @
0bcca238
...
...
@@ -15,12 +15,18 @@ public class PairedMessage {
this
.
nextSibling
=
nextSibling
;
}
/**
* Returns true if target and nextSibling has the same date of timestamp.
*/
public
boolean
hasSameDate
()
{
return
nextSibling
!=
null
&&
DateTime
.
fromEpocMs
(
nextSibling
.
getTs
(),
DateTime
.
Format
.
DATE
)
.
equals
(
DateTime
.
fromEpocMs
(
target
.
getTs
(),
DateTime
.
Format
.
DATE
));
}
/**
* Returns true if target and nextSibling are sent by the same user.
*/
public
boolean
hasSameUser
()
{
return
nextSibling
!=
null
&&
nextSibling
.
getU
()
!=
null
&&
target
.
getU
()
!=
null
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment