@Override public void onError(final Exception e) { exec.invokeLater(new Runnable() { public void run () { listener.onError(e.getMessage()); } }); }
/** * Loads UTF-8 encoded text asynchronously. The returned state instance provides a means to * listen for the arrival of the text. * * @param path the path to the text asset. */ public RFuture<String> getText (final String path) { final RPromise<String> result = exec.deferredPromise(); exec.invokeAsync(new Runnable() { public void run () { try { result.succeed(getTextSync(path)); } catch (Throwable t) { result.fail(t); } } }); return result; }
/** Deletes this texture's GPU resources and renders it unusable. */ @Override public void close () { if (!disposed) { disposed = true; if (gfx.exec().isMainThread()) { gfx.gl.glDeleteTexture(id); } else { gfx.exec().invokeLater(new Runnable() { public void run () { gfx.gl.glDeleteTexture(id); } }); } } }
/** @deprecated Use {@link Exec#invokeAsync}. */ @Deprecated public void invokeAsync (Runnable action) { exec().invokeAsync(action); }
public SoundImpl (Exec exec) { super(exec.<Sound>deferredPromise()); this.exec = exec; }
/** @deprecated Use {@link Exec#isAsyncSupported}. */ @Deprecated public boolean isAsyncSupported () { return exec().isAsyncSupported(); } /** @deprecated Use {@link Exec#invokeAsync}. */
/** Deletes this texture's GPU resources and renders it unusable. */ @Override public void close () { if (!disposed) { disposed = true; if (gfx.exec().isMainThread()) { gfx.gl.glDeleteTexture(id); } else { gfx.exec().invokeLater(new Runnable() { public void run () { gfx.gl.glDeleteTexture(id); } }); } } }
/** @deprecated Use {@link Exec#invokeAsync}. */ @Deprecated public void invokeAsync (Runnable action) { exec().invokeAsync(action); }
public SoundImpl (Exec exec) { super(exec.<Sound>deferredPromise()); this.exec = exec; }
/** @deprecated Use {@link Exec#isAsyncSupported}. */ @Deprecated public boolean isAsyncSupported () { return exec().isAsyncSupported(); } /** @deprecated Use {@link Exec#invokeAsync}. */
@Override public void onClose(int code, String reason, boolean remote) { exec.invokeLater(new Runnable() { public void run () { listener.onClose(); } }); }
/** * Loads binary data asynchronously. The returned state instance provides a means to listen for * the arrival of the data. * * @param path the path to the binary asset. */ public RFuture<ByteBuffer> getBytes (final String path) { final RPromise<ByteBuffer> result = exec.deferredPromise(); exec.invokeAsync(new Runnable() { public void run () { try { result.succeed(getBytesSync(path)); } catch (Throwable t) { result.fail(t); } } }); return result; }
/** Deletes the framebuffer associated with this render target. */ @Override public void close () { if (!disposed) { disposed = true; if (gfx.exec().isMainThread()) { gfx.gl.glDeleteFramebuffer(id()); } else { gfx.exec().invokeLater(new Runnable() { public void run () { gfx.gl.glDeleteFramebuffer(id()); } }); } } }
/** * Asynchronously loads and returns an image. The calling thread will not block. The returned * image will not be immediately usable, will not report valid width and height, and cannot be * immediately rendered into a canvas or converted into a texture. Use {@link Image#state} to be * notified when loading succeeds or fails. * * @param path the path to the image asset. */ public Image getImage (final String path) { final ImageImpl image = createImage(true, 0, 0, path); exec.invokeAsync(new Runnable() { public void run () { try { image.succeed(load(path)); } catch (Throwable t) { image.fail(t); } } }); return image; }
protected ImageImpl (Platform plat, boolean async, Scale preScale, int preWidth, int preHeight, String source) { this(plat.graphics(), async ? plat.exec().<Image>deferredPromise() : RPromise.<Image>create(), preScale, preWidth, preHeight, source); }
@Override public void onMessage(final String msg) { exec.invokeLater(new Runnable() { public void run() { listener.onTextMessage(msg); }}); } @Override public void onError(final Exception e) {
/** * Loads UTF-8 encoded text asynchronously. The returned state instance provides a means to * listen for the arrival of the text. * * @param path the path to the text asset. */ public RFuture<String> getText (final String path) { final RPromise<String> result = exec.deferredPromise(); exec.invokeAsync(new Runnable() { public void run () { try { result.succeed(getTextSync(path)); } catch (Throwable t) { result.fail(t); } } }); return result; }
/** Deletes the framebuffer associated with this render target. */ @Override public void close () { if (!disposed) { disposed = true; if (gfx.exec().isMainThread()) { gfx.gl.glDeleteFramebuffer(id()); } else { gfx.exec().invokeLater(new Runnable() { public void run () { gfx.gl.glDeleteFramebuffer(id()); } }); } } }
/** * Asynchronously loads and returns an image. The calling thread will not block. The returned * image will not be immediately usable, will not report valid width and height, and cannot be * immediately rendered into a canvas or converted into a texture. Use {@link Image#state} to be * notified when loading succeeds or fails. * * @param path the path to the image asset. */ public Image getImage (final String path) { final ImageImpl image = createImage(true, 0, 0, path); exec.invokeAsync(new Runnable() { public void run () { try { image.succeed(load(path)); } catch (Throwable t) { image.fail(t); } } }); return image; }
@Override public RFuture<Boolean> sysDialog (final String title, final String text, final String ok, final String cancel) { final RPromise<Boolean> result = plat.exec().deferredPromise(); plat.activity.runOnUiThread(new Runnable() { public void run () { AlertDialog.Builder alert = new AlertDialog.Builder(plat.activity). setTitle(title).setMessage(text); alert.setPositiveButton(ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { result.succeed(true); } }); if (cancel != null) alert.setNegativeButton(cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { result.succeed(false); } }); alert.show(); } }); return result; }