示例#1
0
 public SearchListAdapter() {
   simpleDateFormat = new SimpleDateFormat("MMMM dd, yyyy (EEEE)", Locale.getDefault());
   OkHttpClient picassoClient = BlipApplication.getInstance().client.clone();
   picassoClient.interceptors().add(BlipUtils.REWRITE_CACHE_CONTROL_INTERCEPTOR);
   new Picasso.Builder(SearchActivity.this)
       .downloader(new OkHttpDownloader(picassoClient))
       .build();
 }
示例#2
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();
   }
 }