コード例 #1
0
ファイル: Main.java プロジェクト: damacode/MyTumblr
 public static void run(int start_page, int end_page) {
   if (start_page < 1 || end_page < 1) {
     Main.status("start_page and end_page must be integers >= 1");
     return;
   }
   int progress = 0;
   if (gui != null) {
     gui.setProgress(progress);
   }
   if (end_page >= start_page) {
     if (gui != null) {
       gui.setMaxProgress(end_page - start_page);
     }
     for (int i = start_page; i <= end_page; i++) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   } else {
     if (gui != null) {
       gui.setMaxProgress(start_page - end_page);
     }
     for (int i = start_page; i >= end_page; i--) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
   }
   Main.writeDuplicates();
 }