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
f5c8aa45
Unverified
Commit
f5c8aa45
authored
Dec 15, 2018
by
Rafael Kellermann Streit
Committed by
GitHub
Dec 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into nullfix
parents
73235eb1
04c07f98
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
21 deletions
+39
-21
build.gradle
app/build.gradle
+1
-1
strings.xml
app/src/main/res/values-ru-rRU/strings.xml
+2
-2
SuggestionsAdapter.kt
.../chat/rocket/android/suggestions/ui/SuggestionsAdapter.kt
+9
-3
SuggestionsView.kt
...ava/chat/rocket/android/suggestions/ui/SuggestionsView.kt
+27
-15
No files found.
app/build.gradle
View file @
f5c8aa45
...
@@ -16,7 +16,7 @@ android {
...
@@ -16,7 +16,7 @@ android {
applicationId
"chat.rocket.android"
applicationId
"chat.rocket.android"
minSdkVersion
versions
.
minSdk
minSdkVersion
versions
.
minSdk
targetSdkVersion
versions
.
targetSdk
targetSdkVersion
versions
.
targetSdk
versionCode
205
3
versionCode
205
4
versionName
"3.2.0"
versionName
"3.2.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
multiDexEnabled
true
...
...
app/src/main/res/values-ru-rRU/strings.xml
View file @
f5c8aa45
...
@@ -169,8 +169,8 @@
...
@@ -169,8 +169,8 @@
<string
name=
"msg_send_email"
>
Отправить e-mail
</string>
<string
name=
"msg_send_email"
>
Отправить e-mail
</string>
<string
name=
"msg_android_app_support"
>
Поддержка Android-приложения
</string>
<string
name=
"msg_android_app_support"
>
Поддержка Android-приложения
</string>
<string
name=
"msg_muted_on_this_channel"
>
Вы лишены дара речи на этом канале
</string>
<string
name=
"msg_muted_on_this_channel"
>
Вы лишены дара речи на этом канале
</string>
<string
name=
"msg_unable_to_update_password"
>
Unable to update password. Error message: %1$s
</string>
<!-- TODO - Add proper translation --
>
<string
name=
"msg_unable_to_update_password"
>
Невозможно обновить пароль. Ошибка: %1$s
</string
>
<string
name=
"msg_password_updated_successfully"
>
Password updated successfully
</string>
<!-- TODO - Add proper translation --
>
<string
name=
"msg_password_updated_successfully"
>
Пароль успешно обновлен
</string
>
<plurals
name=
"msg_reacted_with_"
>
<plurals
name=
"msg_reacted_with_"
>
<item
quantity=
"one"
>
%1$s реагирует с %2$s
</item>
<item
quantity=
"one"
>
%1$s реагирует с %2$s
</item>
<item
quantity=
"few"
>
%1$s реагируют с %2$s
</item>
<item
quantity=
"few"
>
%1$s реагируют с %2$s
</item>
...
...
suggestions/src/main/java/chat/rocket/android/suggestions/ui/SuggestionsAdapter.kt
View file @
f5c8aa45
...
@@ -29,6 +29,9 @@ abstract class SuggestionsAdapter<VH : BaseSuggestionViewHolder>(
...
@@ -29,6 +29,9 @@ abstract class SuggestionsAdapter<VH : BaseSuggestionViewHolder>(
notifyDataSetChanged
()
notifyDataSetChanged
()
}
}
private
var
currentCount
=
0
;
private
var
currentItems
=
listOf
<
SuggestionModel
>()
init
{
init
{
setHasStableIds
(
true
)
setHasStableIds
(
true
)
}
}
...
@@ -41,10 +44,10 @@ abstract class SuggestionsAdapter<VH : BaseSuggestionViewHolder>(
...
@@ -41,10 +44,10 @@ abstract class SuggestionsAdapter<VH : BaseSuggestionViewHolder>(
holder
.
bind
(
getItem
(
position
),
itemClickListener
)
holder
.
bind
(
getItem
(
position
),
itemClickListener
)
}
}
override
fun
getItemCount
()
=
strategy
.
autocompleteItems
(
currentTerm
).
size
override
fun
getItemCount
()
=
currentCount
private
fun
getItem
(
position
:
Int
):
SuggestionModel
{
private
fun
getItem
(
position
:
Int
):
SuggestionModel
{
return
strategy
.
autocompleteItems
(
currentTerm
)
[
position
]
return
currentItems
[
position
]
}
}
/**
/**
...
@@ -58,12 +61,15 @@ abstract class SuggestionsAdapter<VH : BaseSuggestionViewHolder>(
...
@@ -58,12 +61,15 @@ abstract class SuggestionsAdapter<VH : BaseSuggestionViewHolder>(
fun
autocomplete
(
newTerm
:
String
)
{
fun
autocomplete
(
newTerm
:
String
)
{
this
.
currentTerm
=
newTerm
.
toLowerCase
().
trim
()
this
.
currentTerm
=
newTerm
.
toLowerCase
().
trim
()
currentItems
=
strategy
.
autocompleteItems
(
currentTerm
)
currentCount
=
currentItems
.
size
}
}
fun
addItems
(
list
:
List
<
SuggestionModel
>)
{
fun
addItems
(
list
:
List
<
SuggestionModel
>)
{
strategy
.
addAll
(
list
)
strategy
.
addAll
(
list
)
// Since we've just added new items we should check for possible new completion suggestions.
// Since we've just added new items we should check for possible new completion suggestions.
strategy
.
autocompleteItems
(
currentTerm
)
//strategy.autocompleteItems(currentTerm)
autocomplete
(
currentTerm
)
notifyDataSetChanged
()
notifyDataSetChanged
()
}
}
...
...
suggestions/src/main/java/chat/rocket/android/suggestions/ui/SuggestionsView.kt
View file @
f5c8aa45
...
@@ -10,6 +10,7 @@ import android.text.TextWatcher
...
@@ -10,6 +10,7 @@ import android.text.TextWatcher
import
android.transition.Slide
import
android.transition.Slide
import
android.transition.TransitionManager
import
android.transition.TransitionManager
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.util.Log
import
android.view.Gravity
import
android.view.Gravity
import
android.view.View
import
android.view.View
import
android.widget.EditText
import
android.widget.EditText
...
@@ -24,6 +25,7 @@ import chat.rocket.android.suggestions.model.SuggestionModel
...
@@ -24,6 +25,7 @@ import chat.rocket.android.suggestions.model.SuggestionModel
import
chat.rocket.android.suggestions.ui.SuggestionsAdapter.Companion.CONSTRAINT_BOUND_TO_START
import
chat.rocket.android.suggestions.ui.SuggestionsAdapter.Companion.CONSTRAINT_BOUND_TO_START
import
java.lang.ref.WeakReference
import
java.lang.ref.WeakReference
import
java.util.concurrent.atomic.AtomicInteger
import
java.util.concurrent.atomic.AtomicInteger
import
kotlin.system.measureTimeMillis
// This is a special index that means we're not at an autocompleting state.
// This is a special index that means we're not at an autocompleting state.
private
const
val
NO_STATE_INDEX
=
0
private
const
val
NO_STATE_INDEX
=
0
...
@@ -101,22 +103,32 @@ class SuggestionsView : FrameLayout, TextWatcher {
...
@@ -101,22 +103,32 @@ class SuggestionsView : FrameLayout, TextWatcher {
return
return
}
}
val
prefixEndIndex
=
this
.
editor
?.
get
()
?.
selectionStart
?:
NO_STATE_INDEX
if
(
completionOffset
.
get
()
==
NO_STATE_INDEX
)
{
if
(
prefixEndIndex
==
NO_STATE_INDEX
||
prefixEndIndex
<
completionOffset
.
get
())
return
return
val
prefix
=
s
.
subSequence
(
completionOffset
.
get
(),
this
.
editor
?.
get
()
?.
selectionStart
?:
completionOffset
.
get
()).
toString
()
recyclerView
.
adapter
?.
let
{
it
as
SuggestionsAdapter
// we need to look up only after the '@'
it
.
autocomplete
(
prefix
)
val
cacheMap
=
localProvidersByToken
[
it
.
token
]
if
(
cacheMap
!=
null
&&
cacheMap
[
prefix
]
!=
null
)
{
it
.
addItems
(
cacheMap
[
prefix
]
!!
)
}
else
{
// fetch more suggestions from an external source if any
externalProvidersByToken
[
it
.
token
]
?.
invoke
(
prefix
)
}
}
}
measureTimeMillis
{
val
prefixEndIndex
=
this
.
editor
?.
get
()
?.
selectionStart
?:
NO_STATE_INDEX
if
(
prefixEndIndex
==
NO_STATE_INDEX
||
prefixEndIndex
<
completionOffset
.
get
())
return
val
prefix
=
s
.
subSequence
(
completionOffset
.
get
(),
this
.
editor
?.
get
()
?.
selectionStart
?:
completionOffset
.
get
()).
toString
()
recyclerView
.
adapter
?.
also
{
it
as
SuggestionsAdapter
// we need to look up only after the '@'
measureTimeMillis
{
it
.
autocomplete
(
prefix
)
}.
let
{
time
->
Log
.
d
(
"SuggestionsView"
,
"autocomplete($prefix) in $time ms"
)
}
val
cacheMap
=
localProvidersByToken
[
it
.
token
]
if
(
cacheMap
!=
null
&&
cacheMap
[
prefix
]
!=
null
)
{
if
(
it
.
itemCount
==
0
)
{
it
.
addItems
(
cacheMap
[
prefix
]
!!
)
}
}
else
{
// fetch more suggestions from an external source if any
externalProvidersByToken
[
it
.
token
]
?.
invoke
(
prefix
)
}
}
}.
let
{
Log
.
d
(
"SuggestionsView"
,
"whole prefix in $it ms"
)
}
}
}
override
fun
onMeasure
(
widthMeasureSpec
:
Int
,
heightMeasureSpec
:
Int
)
{
override
fun
onMeasure
(
widthMeasureSpec
:
Int
,
heightMeasureSpec
:
Int
)
{
...
...
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