Exemplo n.º 1
0
  @Override
  public void setUp() throws Exception {
    super.setUp();
    SearchEngine engine =
        ServiceList.getService("Youtube").getSearchEngineInstance(new Downloader());

    result = engine.search("this is something boring", 0, "de", new Downloader()).getSearchResult();
    suggestionReply = engine.suggestionList("hello", "de", new Downloader());
  }
 @Override
 public void run() {
   try {
     SearchEngine engine =
         ServiceList.getService(serviceId).getSearchEngineInstance(new Downloader());
     SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
     String searchLanguageKey = context.getString(R.string.search_language_key);
     String searchLanguage =
         sp.getString(searchLanguageKey, getString(R.string.default_language_value));
     ArrayList<String> suggestions =
         engine.suggestionList(query, searchLanguage, new Downloader());
     h.post(new SuggestionResultRunnable(suggestions));
   } catch (ExtractionException e) {
     ErrorActivity.reportError(
         h,
         VideoItemListActivity.this,
         e,
         null,
         findViewById(R.id.videoitem_list),
         ErrorActivity.ErrorInfo.make(
             ErrorActivity.SEARCHED,
             ServiceList.getNameOfService(serviceId),
             query,
             R.string.parsing_error));
     e.printStackTrace();
   } catch (IOException e) {
     postNewErrorToast(h, R.string.network_error);
     e.printStackTrace();
   } catch (Exception e) {
     ErrorActivity.reportError(
         h,
         VideoItemListActivity.this,
         e,
         null,
         findViewById(R.id.videoitem_list),
         ErrorActivity.ErrorInfo.make(
             ErrorActivity.SEARCHED,
             ServiceList.getNameOfService(serviceId),
             query,
             R.string.general_error));
   }
 }