Android Open Source - book Translator






From Project

Back to project page book.

License

The source code is released under:

MIT License

If you think the Android project book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package translator;
//from   w w w . j av  a  2 s  .  co  m
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutionException;

import android.os.AsyncTask;
import book.Book;

import com.Db;

/*
 * 
 * 
 *   ZEN-ULTIMATE-BINGBING-TRANSLATORSHITE
 * translates almost any language into something awful which does not make any sense in any language.
 */

public class Translator{
  
  private Db db;

  public Translator(Db db){  
    this.db = db;
  }
  
  public Book translate(Book book){
    HashMap<String , List<String>> words = book.getWords();
    
    for (String word : words.keySet()){
      book.addTranslations(word, this.translate(word));
    }
    return book;
  }
  
  public List<String> translate(String word){    
    if (this.db.hasTranslations(word)){    
      return this.db.getTranslations(word);
    } else {
      AsyncTask translation = new TranslateWordTask().execute(word);
      try {
        String translated = (String) translation.get();
        List<String> result = new ArrayList<String>();
        result.add( translated );
        return result;
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return null;
    }        
  }
}




Java Source Code List

book.BookListAdapter.java
book.Book.java
book.ExpandableListAdapter.java
book.SelectableWordListAdapter.java
com.BookTable.java
com.Db.java
com.TranslationsTable.java
com.WordTable.java
fragments.BookListFragment.java
fragments.BookViewFragment.java
fragments.CameraFragment.java
fragments.EditBookFragment.java
fragments.PageAdapter.java
fragments.PagerActivity.java
translator.TranslateWordTask.java
translator.Translator.java