mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Merge "Fix Keyboard.getKey as thread safe"
This commit is contained in:
commit
7aeb7ef1ab
@ -185,19 +185,21 @@ public class Keyboard {
|
||||
if (code == CODE_UNSPECIFIED) {
|
||||
return null;
|
||||
}
|
||||
final int index = mKeyCache.indexOfKey(code);
|
||||
if (index >= 0) {
|
||||
return mKeyCache.valueAt(index);
|
||||
}
|
||||
|
||||
for (final Key key : mKeys) {
|
||||
if (key.mCode == code) {
|
||||
mKeyCache.put(code, key);
|
||||
return key;
|
||||
synchronized (mKeyCache) {
|
||||
final int index = mKeyCache.indexOfKey(code);
|
||||
if (index >= 0) {
|
||||
return mKeyCache.valueAt(index);
|
||||
}
|
||||
|
||||
for (final Key key : mKeys) {
|
||||
if (key.mCode == code) {
|
||||
mKeyCache.put(code, key);
|
||||
return key;
|
||||
}
|
||||
}
|
||||
mKeyCache.put(code, null);
|
||||
return null;
|
||||
}
|
||||
mKeyCache.put(code, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasKey(Key aKey) {
|
||||
|
Loading…
Reference in New Issue
Block a user