Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-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
xabber-android
Commits
a43c0b71
Commit
a43c0b71
authored
Feb 24, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ChatMessageAdapter: system date and time format used.
parent
d1949f1c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
18 deletions
+7
-18
ChatMessageAdapter.java
...ava/com/xabber/android/ui/adapter/ChatMessageAdapter.java
+2
-2
StringUtils.java
app/src/main/java/com/xabber/android/utils/StringUtils.java
+5
-16
No files found.
app/src/main/java/com/xabber/android/ui/adapter/ChatMessageAdapter.java
View file @
a43c0b71
...
...
@@ -199,7 +199,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
if
(
timeStamp
!=
null
)
{
String
delay
=
activity
.
getString
(
incoming
?
R
.
string
.
chat_delay
:
R
.
string
.
chat_typed
,
StringUtils
.
getSmartTimeText
(
timeStamp
));
StringUtils
.
getSmartTimeText
(
activity
,
timeStamp
));
append
(
builder
,
delay
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
}
...
...
@@ -226,7 +226,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
textView
.
setText
(
builder
);
textView
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
String
time
=
StringUtils
.
getSmartTimeText
(
messageItem
.
getTimestamp
());
String
time
=
StringUtils
.
getSmartTimeText
(
activity
,
messageItem
.
getTimestamp
());
((
TextView
)
view
.
findViewById
(
R
.
id
.
message_time
)).
setText
(
time
);
...
...
app/src/main/java/com/xabber/android/utils/StringUtils.java
View file @
a43c0b71
...
...
@@ -14,13 +14,12 @@
*/
package
com
.
xabber
.
android
.
utils
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
* Helper class to get plural forms.
...
...
@@ -123,25 +122,15 @@ public class StringUtils {
* @param timeStamp
* @return String with time or with date and time depend on current time.
*/
public
static
String
getSmartTimeText
(
Date
timeStamp
)
{
public
static
String
getSmartTimeText
(
Context
context
,
Date
timeStamp
)
{
if
(
timeStamp
==
null
)
{
return
""
;
}
// today
Calendar
midnight
=
new
GregorianCalendar
();
// reset hour, minutes, seconds and millis
midnight
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
midnight
.
set
(
Calendar
.
MINUTE
,
0
);
midnight
.
set
(
Calendar
.
SECOND
,
0
);
midnight
.
set
(
Calendar
.
MILLISECOND
,
0
);
DateFormat
timeFormat
=
android
.
text
.
format
.
DateFormat
.
getTimeFormat
(
context
);
DateFormat
dateFormat
=
android
.
text
.
format
.
DateFormat
.
getDateFormat
(
context
);
if
(
timeStamp
.
getTime
()
>
midnight
.
getTimeInMillis
())
synchronized
(
TIME
)
{
return
TIME
.
format
(
timeStamp
);
}
else
return
getDateTimeText
(
timeStamp
);
return
dateFormat
.
format
(
timeStamp
)
+
" "
+
timeFormat
.
format
(
timeStamp
);
}
}
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