Advertisement
Guest User

alagartaClasses

a guest
Jan 15th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.01 KB | None | 0 0
  1. class aLagarta {
  2.   ArrayList<PImage> thumbs = new ArrayList<PImage>();
  3.   //ArrayList<PImage> editionPages = new ArrayList<PImage>();
  4.   PImage readingPage;
  5.   final int OK = 0;
  6.   final int noEditionFound = 1;
  7.   int numberOfEditions = 1;
  8.   boolean loadMag = true;
  9.   boolean loadEdition = true;
  10.  
  11.   int update() {
  12.  
  13.     background = loadImage("http://alagarta.com/edicoes/"+mag.thumbs.size()+"/bg.jpg");
  14.     topLogo = loadImage("topLogo.png");
  15.  
  16.     println("Passei - update\n");
  17.     while (numberOfEditions < 15) {
  18.       println("Passei - While\n");
  19.       try {
  20.         PImage cover;
  21.         if (numberOfEditions == 1 || numberOfEditions > 11)
  22.           cover = requestImage("http://www.alagarta.com/edicoes/"+numberOfEditions+"/1.png");
  23.         else
  24.           cover = requestImage("http://www.alagarta.com/edicoes/"+numberOfEditions+"/1.jpg");
  25.         if (cover.width == -1) {
  26.           break;
  27.         }
  28.         else if (cover.width == 0) {
  29.           println("loading cover - "+numberOfEditions);
  30.           /*while (cover.width == 0) {
  31.            int n = 1
  32.            PImage loading = loadImage("loadingscreen"+n+".        imageMode(CENTER);
  33.            image(loading, 394, 260);
  34.            delay(100);
  35.            n++;
  36.            }*/
  37.           thumbs.add(cover);
  38.           numberOfEditions++;
  39.         }
  40.       }
  41.       catch(NullPointerException npe) {
  42.         loadMag = false;
  43.         println("erro\n");
  44.         break;
  45.       }
  46.     }
  47.     if (thumbs.size() == 0)
  48.       return(noEditionFound);
  49.     isDone = true;
  50.     return(OK);
  51.   }
  52.  
  53.   int getPage(int editionNumber, int pageNumber) {
  54.     println("Passei getEdition\n");
  55.     try {
  56.       //PImage page;
  57.       if (editionNumber == 1 || editionNumber > 11)
  58.         readingPage = requestImage("http://alagarta.com/edicoes/"+editionNumber+"/"+pageNumber+".png");
  59.       else
  60.         readingPage = requestImage("http://alagarta.com/edicoes/"+editionNumber+"/"+pageNumber+".jpg");
  61.       if (readingPage.width == -1) {
  62.         println("error");
  63.       }
  64.       else if (readingPage.width == 0) {
  65.         println("loading page - "+pageNumber);
  66.       }
  67.       println("add page - "+pageNumber);
  68.     }
  69.     catch(NullPointerException npe) {
  70.       println("erro - getEdition\n");
  71.     }
  72.     return(OK);
  73.   }
  74. }
  75.  
  76. class SimpleThread extends Thread {
  77.   boolean running;
  78.   int wait;
  79.   String id;
  80.   PImage loading;
  81.  
  82.   SimpleThread(int w, String s) {
  83.     wait = w;
  84.     running = false;
  85.     id = s;
  86.   }
  87.  
  88.   void start() {
  89.     running = true;
  90.     super.start();
  91.   }
  92.  
  93.   void run() {
  94.     int n =1;
  95.     while (running) {
  96.       imageMode(CENTER);
  97.       loading = loadImage("loadingscreen"+n+".png");
  98.       image(loading, 394, 260);
  99.       //println("estou vivo");
  100.       delay(100);
  101.       if (n < 4)
  102.         n++;
  103.       else
  104.         n = 1;
  105.       try {
  106.         sleep((long)(wait));
  107.       }
  108.       catch(Exception e) {
  109.       }
  110.     }
  111.   }
  112.  
  113.   public void draw() {
  114.     image(loading, 394, 260);
  115.   }
  116.  
  117.   void quit() {
  118.     running = false;
  119.     interrupt();
  120.   }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement