Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AsyncExecutor executor;
- AsyncResult<Pixmap> pending;
- public MerchScreen(MainClass gam ) {
- executor = new AsyncExecutor(1);
- render()
- if (pending != null) {
- if (pending.isDone()) {
- if (imageSelected1 != null) {
- imageSelected1.dispose();
- }
- if(file.exists()) {
- imageSelected1 = new Texture(file);
- selected1 = new TextureRegionDrawable(new TextureRegion(imageSelected1));
- style2.up = skin.newDrawable(skin.newDrawable(selected1));
- style2.down = skin.newDrawable(skin.newDrawable(selected1));
- }
- }
- ___________
- public void pickingImage() {
- if (gallery != null) {
- gallery.pickImage(new GalleryOpener.Callback() {
- public void onImagePicked(final InputStream stream) {
- loading = "Loading";
- pending = executor.submit(new AsyncTask<Pixmap>() {
- @Override
- public Pixmap call() throws Exception {
- StreamUtils.copyStream(stream, file.write(false));
- final byte[] bytes = file.readBytes();
- final Pixmap pix = new Pixmap(bytes, 0, bytes.length);
- return pix;
- }
- });
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement