Skip to content

Instantly share code, notes, and snippets.

@suwhs
Last active January 7, 2017 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suwhs/fd046416544fee5180a723f338ac4454 to your computer and use it in GitHub Desktop.
Save suwhs/fd046416544fee5180a723f338ac4454 to your computer and use it in GitHub Desktop.
Preload hyphenation patterns
new AsyncTask<Void,Void,Void>() {
@Override
protected void onPreExecute() {
// set application state 'rules loading', if nesessary (or do something else)
}
@Override
protected Void doInBackground(Void... params) {
/** loading patterns from assets **/
HyphenPattern pat = PatternsLoader
.getInstance(getBaseContext())
.getHyphenPatternAssets("en_us.hyphen.dat"); // en_us.hyphen.dat from assets folder
if (pat!=null) {
/* initialize instance with loaded pattern ) */
LineBreaker hlb = HyphenLineBreker.getInstance(pat);
hyphenatorReady = true;
}
return null;
}
@Override
protected void onPostExecute(Void params) {
// set 'rules ready' flag, if nesessary, or do something else
}
}.execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment