示例#1
0
  @Override
  protected Void doInBackground(Post... params) {
    final Post post = params[0];
    if (post.getBlogName().equals(client.user().getName())) {
      AlertDialog.Builder builder = new AlertDialog.Builder(activity);
      builder.setTitle("Delete post");
      builder.setIcon(R.drawable.menu);
      builder.setMessage("Are you sure you want to delete this post?");

      builder.setPositiveButton(
          "Delete",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              post.delete();
            }
          });

      builder.setNegativeButton(
          "Cancel",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              // Sluit de popup weer af
              dialog.dismiss();
            }
          });

      // Laat de popup zien als de gebruiker op de knop klinkt
      AlertDialog add = builder.show();
      add.show();
    }
    return null;
  }
示例#2
0
 /** Met behulp van Jumblr wordt een lijst met post die bij de meegegeven blognaam opgehaald. */
 @Override
 protected List<Post> doInBackground(String... params) {
   return client.blogPosts(blogname, options);
 }
示例#3
0
    @Override
    protected Bitmap doInBackground(String... params) {
      // Authenticate via OAuth
      JumblrClient client =
          new JumblrClient(
              "LfbunCVV9nOklMzFaoSGgmYG7jU4Jzt1kMjchWDXxXjEabhNtT",
              "Aeftb6z3MpR9Nxj9wUFXMYyrcKTIMeCaJnFJ1gdvNH8oczDfMF");
      client.setToken(
          "LsvYhkMInXLtIvU5JffQSMesYzEvbyxwl0nksaGdi9TZmRgLUy",
          "UILbtYeCzHyXQ6ATHh3vG4wcqV8p1hncGoLImSvX8jy8EpGDNf");

      // First query (gets 20 photos with tag cockerspaniel)
      Map<String, Long> options = new HashMap<>();
      options.put("limit", 20l);
      Long timeStamp = 0l;

      PhotoPost photoPost;
      for (Post post : client.tagged("cockerspaniel", options)) {

        if (post instanceof PhotoPost) {
          photoPost = (PhotoPost) post;
          for (Photo photo : photoPost.getPhotos()) {

            if (!(photo.getSizes().get(0).getUrl()).contains(".gif") && urls.size() < 20) {
              timeStamp = post.getTimestamp();
              urls.add(photo.getSizes().get(0).getUrl());
              // Adding the photos and their notecounts in hashmap
              note_counts.put(photo.getSizes().get(0).getUrl(), post.getNoteCount());
              // Adding the photo's URLS and their timestamps in a hashmap
              timestamps.put(photo.getSizes().get(0).getUrl(), post.getTimestamp());
            } else {
              break;
            }
          }
        }
      }

      // Second query (gets 20 photos with tag cockerspaniel)
      Map<String, Long> options2 = new HashMap<>();
      options2.put("limit", 20l);
      options2.put("before", timeStamp);

      for (Post post : client.tagged("cockerspaniel", options2)) {
        if (post instanceof PhotoPost) {
          photoPost = (PhotoPost) post;
          for (Photo photo : photoPost.getPhotos()) {

            if (!(photo.getSizes().get(0).getUrl()).contains(".gif") && urls.size() < 40) {
              timeStamp = post.getTimestamp();
              urls.add(photo.getSizes().get(0).getUrl());
              // Adding the photos and their notecounts in hashmap
              note_counts.put(photo.getSizes().get(0).getUrl(), post.getNoteCount());
              // Adding the photo's URLS and their timestamps in a hashmap
              timestamps.put(photo.getSizes().get(0).getUrl(), post.getTimestamp());
            } else {
              break;
            }
          }
        }
      }

      // Third query (gets 10 photos with tag cockerspaniel)
      Map<String, Long> options3 = new HashMap<>();
      options3.put("limit", 20l);
      options3.put("before", timeStamp);

      for (Post post : client.tagged("cockerspaniel", options3)) {
        if (post instanceof PhotoPost) {
          photoPost = (PhotoPost) post;
          for (Photo photo : photoPost.getPhotos()) {
            if (!(photo.getSizes().get(0).getUrl()).contains(".gif") && urls.size() < 50) {
              urls.add(photo.getSizes().get(0).getUrl());
              // Adding the photos and their notecounts in hashmap
              note_counts.put(photo.getSizes().get(0).getUrl(), post.getNoteCount());
              // Adding the photo's URLS and their timestamps in a hashmap
              timestamps.put(photo.getSizes().get(0).getUrl(), post.getTimestamp());
            } else {
              break;
            }
          }
        }
      }

      // Map for sorting by Most Popular
      TreeMap<String, Long> desc = new TreeMap<>(note_counts.descendingMap());
      mostPopular.addAll(desc.keySet());
      // Map for sorting by Most Recent
      Map<String, Long> asc = sortByComparator(timestamps);
      mostRecent.addAll(asc.keySet());
      return null;
    }