Exemplo n.º 1
0
 @Override
 protected void onHandleIntent(Intent intent) {
   DatabaseManager databaseManager = new DatabaseManager(this);
   Gson gson = new Gson();
   Request request = new Request.Builder().url("http://xkcd.com/info.0.json").build();
   try {
     Response response = BlipApplication.getInstance().client.newCall(request).execute();
     if (!response.isSuccessful()) throw new IOException();
     Comic comic = gson.fromJson(response.body().string(), Comic.class);
     if (!databaseManager.comicExists(comic)) {
       databaseManager.addComic(comic);
       Intent notifIntent = new Intent(NEW_COMIC);
       notifIntent.putExtra(EXTRA_NUM, comic.getNum());
       sendBroadcast(notifIntent);
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 2
0
 @Override
 public void onTextChanged(CharSequence s, int start, int before, int count) {
   if (!s.toString().equals("")) {
     adapter.updateList(
         databaseManager.search(
             s.toString(), SharedPrefs.getInstance().transcriptSearchEnabled()));
   } else {
     adapter.updateList(Collections.<Comic>emptyList());
   }
 }