am 3c67f6a2: Merge "Add a way to know externally if we\'re installing a new dict"
# Via Android (Google) Code Review (1) and Jean Chalard (1) * commit '3c67f6a2d020a6e1d85abc32e1d1477439f917f4': Add a way to know externally if we're installing a new dictmain
commit
899b32fe2d
|
@ -57,6 +57,8 @@ public final class Suggest {
|
||||||
private ContactsBinaryDictionary mContactsDict;
|
private ContactsBinaryDictionary mContactsDict;
|
||||||
private final ConcurrentHashMap<String, Dictionary> mDictionaries =
|
private final ConcurrentHashMap<String, Dictionary> mDictionaries =
|
||||||
CollectionUtils.newConcurrentHashMap();
|
CollectionUtils.newConcurrentHashMap();
|
||||||
|
@UsedForTesting
|
||||||
|
private boolean mIsCurrentlyWaitingForMainDictionary = false;
|
||||||
|
|
||||||
public static final int MAX_SUGGESTIONS = 18;
|
public static final int MAX_SUGGESTIONS = 18;
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ public final class Suggest {
|
||||||
|
|
||||||
public void resetMainDict(final Context context, final Locale locale,
|
public void resetMainDict(final Context context, final Locale locale,
|
||||||
final SuggestInitializationListener listener) {
|
final SuggestInitializationListener listener) {
|
||||||
|
mIsCurrentlyWaitingForMainDictionary = true;
|
||||||
mMainDictionary = null;
|
mMainDictionary = null;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
|
listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
|
||||||
|
@ -112,6 +115,7 @@ public final class Suggest {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
|
listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
|
||||||
}
|
}
|
||||||
|
mIsCurrentlyWaitingForMainDictionary = false;
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
@ -122,6 +126,11 @@ public final class Suggest {
|
||||||
return null != mMainDictionary && mMainDictionary.isInitialized();
|
return null != mMainDictionary && mMainDictionary.isInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UsedForTesting
|
||||||
|
public boolean isCurrentlyWaitingForMainDictionary() {
|
||||||
|
return mIsCurrentlyWaitingForMainDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
public Dictionary getMainDictionary() {
|
public Dictionary getMainDictionary() {
|
||||||
return mMainDictionary;
|
return mMainDictionary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,8 +231,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForDictionaryToBeLoaded() {
|
protected void waitForDictionaryToBeLoaded() {
|
||||||
int remainingAttempts = 10;
|
int remainingAttempts = 300;
|
||||||
while (remainingAttempts > 0 && !mLatinIME.mSuggest.hasMainDictionary()) {
|
while (remainingAttempts > 0 && mLatinIME.mSuggest.isCurrentlyWaitingForMainDictionary()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
Loading…
Reference in New Issue