示例#1
0
  @Override
  protected Pair<Integer, Dictionary> doInBackground(final DictionaryBean... params) {
    // Get properties from bean.
    final DictionaryBean bean = params[0];
    final int id = bean.getId();
    final String path = bean.getPath();
    final String type = bean.getType();

    try {
      // Create callables.
      Dictionary dictionary;
      if (type.equals(ChosenModel.LOCAL_DICTIONARY)) {
        // Create dict info.
        final DictionaryInformation info = DictionaryInformation.create(path);
        // Create necessary files.
        final IndexFile indexFile = IndexFile.makeFile(info.getIndexFile());
        final DictionaryFile dictionaryFile =
            DictionaryFile.makeRandomAccessFile(info.getDataFile());
        dictionary =
            new DICTDictionary.Builder(indexFile, dictionaryFile)
                .enableSplittingIndexFile()
                .build();
      } else {
        dictionary = new WikiDictionary(path);
      }
      return Pair.create(id, dictionary);
    } catch (final FileNotFoundException e) {
      Log.w(TAG, e.getMessage(), e);
      return null;
    }
  }