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
56dc7727
Commit
56dc7727
authored
Aug 06, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change EmojiRepository#getRecents() logic
parent
e361544b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
16 deletions
+21
-16
EmojiDao.kt
emoji/src/main/java/chat/rocket/android/emoji/EmojiDao.kt
+1
-1
EmojiRepository.kt
...rc/main/java/chat/rocket/android/emoji/EmojiRepository.kt
+19
-14
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-1
No files found.
emoji/src/main/java/chat/rocket/android/emoji/EmojiDao.kt
View file @
56dc7727
...
@@ -20,7 +20,7 @@ interface EmojiDao {
...
@@ -20,7 +20,7 @@ interface EmojiDao {
fun
loadAllCustomEmojis
():
List
<
Emoji
>
fun
loadAllCustomEmojis
():
List
<
Emoji
>
@Query
(
"SELECT * FROM emoji WHERE shortname=:shortname"
)
@Query
(
"SELECT * FROM emoji WHERE shortname=:shortname"
)
fun
loadEmojiByShortname
(
shortname
:
String
):
Emoji
?
fun
loadEmojiByShortname
(
shortname
:
String
):
List
<
Emoji
>
@Query
(
"SELECT * FROM emoji WHERE UPPER(category)=UPPER(:category)"
)
@Query
(
"SELECT * FROM emoji WHERE UPPER(category)=UPPER(:category)"
)
fun
loadEmojisByCategory
(
category
:
String
):
List
<
Emoji
>
fun
loadEmojisByCategory
(
category
:
String
):
List
<
Emoji
>
...
...
emoji/src/main/java/chat/rocket/android/emoji/EmojiRepository.kt
View file @
56dc7727
...
@@ -149,7 +149,7 @@ object EmojiRepository {
...
@@ -149,7 +149,7 @@ object EmojiRepository {
* @return Emoji given by shortname or null
* @return Emoji given by shortname or null
*/
*/
private
suspend
fun
getEmojiByShortname
(
shortname
:
String
):
Emoji
?
=
withContext
(
CommonPool
)
{
private
suspend
fun
getEmojiByShortname
(
shortname
:
String
):
Emoji
?
=
withContext
(
CommonPool
)
{
return
@withContext
db
.
emojiDao
().
load
EmojiByShortname
(
shortname
)
return
@withContext
db
.
emojiDao
().
load
AllCustomEmojis
().
firstOrNull
(
)
}
}
/**
/**
...
@@ -158,12 +158,14 @@ object EmojiRepository {
...
@@ -158,12 +158,14 @@ object EmojiRepository {
internal
fun
addToRecents
(
emoji
:
Emoji
)
{
internal
fun
addToRecents
(
emoji
:
Emoji
)
{
val
emojiShortname
=
emoji
.
shortname
val
emojiShortname
=
emoji
.
shortname
val
recentsJson
=
JSONObject
(
preferences
.
getString
(
PREF_EMOJI_RECENTS
,
"{}"
))
val
recentsJson
=
JSONObject
(
preferences
.
getString
(
PREF_EMOJI_RECENTS
,
"{}"
))
if
(
recentsJson
.
has
(
emojiShortname
))
{
if
(
recentsJson
.
has
(
emojiShortname
))
{
val
useCount
=
recentsJson
.
getInt
(
emojiShortname
)
val
useCount
=
recentsJson
.
getInt
(
emojiShortname
)
recentsJson
.
put
(
emojiShortname
,
useCount
+
1
)
recentsJson
.
put
(
emojiShortname
,
useCount
+
1
)
}
else
{
}
else
{
recentsJson
.
put
(
emojiShortname
,
1
)
recentsJson
.
put
(
emojiShortname
,
1
)
}
}
preferences
.
edit
().
putString
(
PREF_EMOJI_RECENTS
,
recentsJson
.
toString
()).
apply
()
preferences
.
edit
().
putString
(
PREF_EMOJI_RECENTS
,
recentsJson
.
toString
()).
apply
()
}
}
...
@@ -182,23 +184,26 @@ object EmojiRepository {
...
@@ -182,23 +184,26 @@ object EmojiRepository {
*
*
* @return All recent emojis ordered by usage.
* @return All recent emojis ordered by usage.
*/
*/
internal
suspend
fun
getRecents
():
List
<
Emoji
>
{
internal
suspend
fun
getRecents
():
List
<
Emoji
>
=
withContext
(
CommonPool
)
{
val
list
=
mutableListOf
<
Emoji
>()
val
list
=
mutableListOf
<
Emoji
>()
val
recentsJson
=
JSONObject
(
preferences
.
getString
(
PREF_EMOJI_RECENTS
,
"{}"
))
val
recentsJson
=
JSONObject
(
preferences
.
getString
(
PREF_EMOJI_RECENTS
,
"{}"
))
// for (shortname in recentsJson.keys()) {
val
allEmojis
=
db
.
emojiDao
().
loadAllEmojis
()
// val emoji = getEmojiByShortname(shortname)
val
len
=
recentsJson
.
length
()
// emoji?.let {
val
recentShortnames
=
recentsJson
.
keys
()
// val useCount = recentsJson.getInt(it.shortname)
for
(
i
in
0
until
len
)
{
// list.add(it.copy(count = useCount))
val
shortname
=
recentShortnames
.
next
()
// }
allEmojis
.
firstOrNull
{
it
.
shortname
==
shortname
}
?.
let
{
// }
val
useCount
=
recentsJson
.
getInt
(
it
.
shortname
)
//
list
.
add
(
it
.
copy
(
count
=
useCount
))
// list.sortWith(Comparator { o1, o2 ->
}
// o2.count - o1.count
}
// })
list
.
sortWith
(
Comparator
{
o1
,
o2
->
o2
.
count
-
o1
.
count
})
return
list
return
@withContext
list
}
}
/**
/**
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
56dc7727
...
@@ -4,4 +4,4 @@ distributionPath=wrapper/dists
...
@@ -4,4 +4,4 @@ distributionPath=wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.9-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.9-all.zip
distributionSha256Sum
=
9bc16f929e5920a9a27fef22c65a8ab8140d705e418de0159ca6eb7f08a74200
distributionSha256Sum
=
39e2d5803bbd5eaf6c8efe07067b0e5a00235e8c71318642b2ed262920b27721
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