Advertisement
progrmor

Untitled

Jun 30th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. AsyncExecutor executor;
  2.     AsyncResult<Pixmap> pending;
  3.  
  4. public MerchScreen(MainClass gam ) {
  5. executor = new AsyncExecutor(1);
  6.  
  7. render()
  8.  
  9. if (pending != null) {
  10.             if (pending.isDone()) {
  11.                 if (imageSelected1 != null) {
  12.                     imageSelected1.dispose();
  13.                 }
  14.  
  15.                 if(file.exists()) {
  16.                     imageSelected1 = new Texture(file);
  17.                     selected1 = new TextureRegionDrawable(new TextureRegion(imageSelected1));
  18.                     style2.up = skin.newDrawable(skin.newDrawable(selected1));
  19.                     style2.down = skin.newDrawable(skin.newDrawable(selected1));
  20.  
  21.                 }
  22.  
  23. }
  24.  
  25. ___________
  26. public void pickingImage() {
  27.         if (gallery != null) {
  28.             gallery.pickImage(new GalleryOpener.Callback() {
  29.                 public void onImagePicked(final InputStream stream) {
  30.                     loading = "Loading";
  31.                     pending = executor.submit(new AsyncTask<Pixmap>() {
  32.                         @Override
  33.                         public Pixmap call() throws Exception {
  34.                             StreamUtils.copyStream(stream, file.write(false));
  35.                             final byte[] bytes = file.readBytes();
  36.                             final Pixmap pix = new Pixmap(bytes, 0, bytes.length);
  37.                             return pix;
  38.                         }
  39.                     });
  40.                 }
  41.             });
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement