Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
dbdc81a3
Commit
dbdc81a3
authored
10 years ago
by
Tadashi G. Takaoka
Committed by
Android (Google) Code Review
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Cleanup InputMethodInfoCache"
parents
4077a7e5
afd52dfc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/RichInputMethodManager.java
+32
-22
32 additions, 22 deletions
...com/android/inputmethod/latin/RichInputMethodManager.java
with
32 additions
and
22 deletions
java/src/com/android/inputmethod/latin/RichInputMethodManager.java
+
32
−
22
View file @
dbdc81a3
...
...
@@ -70,10 +70,6 @@ public class RichInputMethodManager {
private
RichInputMethodSubtype
mCurrentRichInputMethodSubtype
;
private
InputMethodInfo
mShortcutInputMethodInfo
;
private
InputMethodSubtype
mShortcutSubtype
;
final
HashMap
<
InputMethodInfo
,
List
<
InputMethodSubtype
>>
mSubtypeListCacheWithImplicitlySelectedSubtypes
=
new
HashMap
<>();
final
HashMap
<
InputMethodInfo
,
List
<
InputMethodSubtype
>>
mSubtypeListCacheWithoutImplicitlySelectedSubtypes
=
new
HashMap
<>();
private
static
final
int
INDEX_NOT_FOUND
=
-
1
;
...
...
@@ -235,33 +231,57 @@ public class RichInputMethodManager {
private
final
InputMethodManager
mImm
;
private
final
String
mImePackageName
;
private
InputMethodInfo
mCachedValue
;
private
InputMethodInfo
mCachedThisImeInfo
;
private
final
HashMap
<
InputMethodInfo
,
List
<
InputMethodSubtype
>>
mCachedSubtypeListWithImplicitlySelected
;
private
final
HashMap
<
InputMethodInfo
,
List
<
InputMethodSubtype
>>
mCachedSubtypeListOnlyExplicitlySelected
;
public
InputMethodInfoCache
(
final
InputMethodManager
imm
,
final
String
imePackageName
)
{
mImm
=
imm
;
mImePackageName
=
imePackageName
;
mCachedSubtypeListWithImplicitlySelected
=
new
HashMap
<>();
mCachedSubtypeListOnlyExplicitlySelected
=
new
HashMap
<>();
}
public
synchronized
InputMethodInfo
get
()
{
if
(
mCached
Value
!=
null
)
{
return
mCached
Value
;
public
synchronized
InputMethodInfo
get
InputMethodOfThisIme
()
{
if
(
mCached
ThisImeInfo
!=
null
)
{
return
mCached
ThisImeInfo
;
}
for
(
final
InputMethodInfo
imi
:
mImm
.
getInputMethodList
())
{
if
(
imi
.
getPackageName
().
equals
(
mImePackageName
))
{
mCached
Value
=
imi
;
mCached
ThisImeInfo
=
imi
;
return
imi
;
}
}
throw
new
RuntimeException
(
"Input method id for "
+
mImePackageName
+
" not found."
);
}
public
synchronized
List
<
InputMethodSubtype
>
getEnabledInputMethodSubtypeList
(
final
InputMethodInfo
imi
,
final
boolean
allowsImplicitlySelectedSubtypes
)
{
final
HashMap
<
InputMethodInfo
,
List
<
InputMethodSubtype
>>
cache
=
allowsImplicitlySelectedSubtypes
?
mCachedSubtypeListWithImplicitlySelected
:
mCachedSubtypeListOnlyExplicitlySelected
;
final
List
<
InputMethodSubtype
>
cachedList
=
cache
.
get
(
imi
);
if
(
cachedList
!=
null
)
{
return
cachedList
;
}
final
List
<
InputMethodSubtype
>
result
=
mImm
.
getEnabledInputMethodSubtypeList
(
imi
,
allowsImplicitlySelectedSubtypes
);
cache
.
put
(
imi
,
result
);
return
result
;
}
public
synchronized
void
clear
()
{
mCachedValue
=
null
;
mCachedThisImeInfo
=
null
;
mCachedSubtypeListWithImplicitlySelected
.
clear
();
mCachedSubtypeListOnlyExplicitlySelected
.
clear
();
}
}
public
InputMethodInfo
getInputMethodInfoOfThisIme
()
{
return
mInputMethodInfoCache
.
get
();
return
mInputMethodInfoCache
.
get
InputMethodOfThisIme
();
}
public
String
getInputMethodIdOfThisIme
()
{
...
...
@@ -446,21 +466,11 @@ public class RichInputMethodManager {
private
List
<
InputMethodSubtype
>
getEnabledInputMethodSubtypeList
(
final
InputMethodInfo
imi
,
final
boolean
allowsImplicitlySelectedSubtypes
)
{
final
HashMap
<
InputMethodInfo
,
List
<
InputMethodSubtype
>>
cache
=
allowsImplicitlySelectedSubtypes
?
mSubtypeListCacheWithImplicitlySelectedSubtypes
:
mSubtypeListCacheWithoutImplicitlySelectedSubtypes
;
final
List
<
InputMethodSubtype
>
cachedList
=
cache
.
get
(
imi
);
if
(
null
!=
cachedList
)
return
cachedList
;
final
List
<
InputMethodSubtype
>
result
=
mImmWrapper
.
mImm
.
getEnabledInputMethodSubtypeList
(
return
mInputMethodInfoCache
.
getEnabledInputMethodSubtypeList
(
imi
,
allowsImplicitlySelectedSubtypes
);
cache
.
put
(
imi
,
result
);
return
result
;
}
public
void
refreshSubtypeCaches
()
{
mSubtypeListCacheWithImplicitlySelectedSubtypes
.
clear
();
mSubtypeListCacheWithoutImplicitlySelectedSubtypes
.
clear
();
mInputMethodInfoCache
.
clear
();
updateCurrentSubtype
(
mImmWrapper
.
mImm
.
getCurrentInputMethodSubtype
());
updateShortcutIme
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment