Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class aLagarta {
- ArrayList<PImage> thumbs = new ArrayList<PImage>();
- //ArrayList<PImage> editionPages = new ArrayList<PImage>();
- PImage readingPage;
- final int OK = 0;
- final int noEditionFound = 1;
- int numberOfEditions = 1;
- boolean loadMag = true;
- boolean loadEdition = true;
- int update() {
- background = loadImage("http://alagarta.com/edicoes/"+mag.thumbs.size()+"/bg.jpg");
- topLogo = loadImage("topLogo.png");
- println("Passei - update\n");
- while (numberOfEditions < 15) {
- println("Passei - While\n");
- try {
- PImage cover;
- if (numberOfEditions == 1 || numberOfEditions > 11)
- cover = requestImage("http://www.alagarta.com/edicoes/"+numberOfEditions+"/1.png");
- else
- cover = requestImage("http://www.alagarta.com/edicoes/"+numberOfEditions+"/1.jpg");
- if (cover.width == -1) {
- break;
- }
- else if (cover.width == 0) {
- println("loading cover - "+numberOfEditions);
- /*while (cover.width == 0) {
- int n = 1
- PImage loading = loadImage("loadingscreen"+n+". imageMode(CENTER);
- image(loading, 394, 260);
- delay(100);
- n++;
- }*/
- thumbs.add(cover);
- numberOfEditions++;
- }
- }
- catch(NullPointerException npe) {
- loadMag = false;
- println("erro\n");
- break;
- }
- }
- if (thumbs.size() == 0)
- return(noEditionFound);
- isDone = true;
- return(OK);
- }
- int getPage(int editionNumber, int pageNumber) {
- println("Passei getEdition\n");
- try {
- //PImage page;
- if (editionNumber == 1 || editionNumber > 11)
- readingPage = requestImage("http://alagarta.com/edicoes/"+editionNumber+"/"+pageNumber+".png");
- else
- readingPage = requestImage("http://alagarta.com/edicoes/"+editionNumber+"/"+pageNumber+".jpg");
- if (readingPage.width == -1) {
- println("error");
- }
- else if (readingPage.width == 0) {
- println("loading page - "+pageNumber);
- }
- println("add page - "+pageNumber);
- }
- catch(NullPointerException npe) {
- println("erro - getEdition\n");
- }
- return(OK);
- }
- }
- class SimpleThread extends Thread {
- boolean running;
- int wait;
- String id;
- PImage loading;
- SimpleThread(int w, String s) {
- wait = w;
- running = false;
- id = s;
- }
- void start() {
- running = true;
- super.start();
- }
- void run() {
- int n =1;
- while (running) {
- imageMode(CENTER);
- loading = loadImage("loadingscreen"+n+".png");
- image(loading, 394, 260);
- //println("estou vivo");
- delay(100);
- if (n < 4)
- n++;
- else
- n = 1;
- try {
- sleep((long)(wait));
- }
- catch(Exception e) {
- }
- }
- }
- public void draw() {
- image(loading, 394, 260);
- }
- void quit() {
- running = false;
- interrupt();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement