Search in sources :

Example 1 with JsResizeListener

use of im.actor.core.js.images.JsResizeListener in project actor-platform by actorapp.

the class JsMessenger method sendAnimation.

public void sendAnimation(final Peer peer, final JsFile file) {
    Log.d(TAG, "Resizing animation");
    JsImageResize.resize(file, new JsResizeListener() {

        @Override
        public void onResized(String thumb, int thumbW, int thumbH, int fullW, int fullH) {
            Log.d(TAG, "Animation resized");
            int index = thumb.indexOf("base64,");
            if (index < 0) {
                Log.d(TAG, "Unable to find base64");
                return;
            }
            String rawData = thumb.substring(index + "base64,".length());
            byte[] thumbData = Base64Utils.fromBase64(rawData);
            String descriptor = fileSystemProvider.registerUploadFile(file);
            sendAnimation(peer, file.getName(), fullW, fullH, new FastThumb(thumbW, thumbH, thumbData), descriptor);
        }
    });
}
Also used : JsResizeListener(im.actor.core.js.images.JsResizeListener) FastThumb(im.actor.core.entity.content.FastThumb)

Example 2 with JsResizeListener

use of im.actor.core.js.images.JsResizeListener in project actor-platform by actorapp.

the class JsMessenger method sendPhoto.

public void sendPhoto(final Peer peer, final String fileName, final JsBlob blob) {
    Log.d(TAG, "Resizing photo");
    JsImageResize.resize(blob, new JsResizeListener() {

        @Override
        public void onResized(String thumb, int thumbW, int thumbH, int fullW, int fullH) {
            Log.d(TAG, "Photo resized");
            int index = thumb.indexOf("base64,");
            if (index < 0) {
                Log.d(TAG, "Unable to find base64");
                return;
            }
            String rawData = thumb.substring(index + "base64,".length());
            byte[] thumbData = Base64Utils.fromBase64(rawData);
            String descriptor = fileSystemProvider.registerUploadFile(blob);
            sendPhoto(peer, fileName, fullW, fullH, new FastThumb(thumbW, thumbH, thumbData), descriptor);
        }
    });
}
Also used : JsResizeListener(im.actor.core.js.images.JsResizeListener) FastThumb(im.actor.core.entity.content.FastThumb)

Aggregations

FastThumb (im.actor.core.entity.content.FastThumb)2 JsResizeListener (im.actor.core.js.images.JsResizeListener)2