Search in sources :

Example 6 with Movie

use of android.graphics.Movie in project android_frameworks_base by crdroidandroid.

the class Resources method getMovie.

/**
     * Return a movie object associated with the particular resource ID.
     * @param id The desired resource identifier, as generated by the aapt
     *           tool. This integer encodes the package, type, and resource
     *           entry. The value 0 is an invalid identifier.
     * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
     * 
     */
public Movie getMovie(@RawRes int id) throws NotFoundException {
    final InputStream is = openRawResource(id);
    final Movie movie = Movie.decodeStream(is);
    try {
        is.close();
    } catch (IOException e) {
    // No one cares.
    }
    return movie;
}
Also used : Movie(android.graphics.Movie) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 7 with Movie

use of android.graphics.Movie in project platform_frameworks_base by android.

the class Resources method getMovie.

/**
     * Return a movie object associated with the particular resource ID.
     * @param id The desired resource identifier, as generated by the aapt
     *           tool. This integer encodes the package, type, and resource
     *           entry. The value 0 is an invalid identifier.
     * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
     * 
     */
public Movie getMovie(@RawRes int id) throws NotFoundException {
    final InputStream is = openRawResource(id);
    final Movie movie = Movie.decodeStream(is);
    try {
        is.close();
    } catch (IOException e) {
    // No one cares.
    }
    return movie;
}
Also used : Movie(android.graphics.Movie) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 8 with Movie

use of android.graphics.Movie in project android_frameworks_base by AOSPA.

the class Resources method getMovie.

/**
     * Return a movie object associated with the particular resource ID.
     * @param id The desired resource identifier, as generated by the aapt
     *           tool. This integer encodes the package, type, and resource
     *           entry. The value 0 is an invalid identifier.
     * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
     * 
     */
public Movie getMovie(@RawRes int id) throws NotFoundException {
    final InputStream is = openRawResource(id);
    final Movie movie = Movie.decodeStream(is);
    try {
        is.close();
    } catch (IOException e) {
    // No one cares.
    }
    return movie;
}
Also used : Movie(android.graphics.Movie) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 9 with Movie

use of android.graphics.Movie in project 9GAG by Mixiaoxiao.

the class ImageViewEx method setSourceBlocking.

/**
 * Sets the image from a byte array in a blocking, CPU-consuming way.
 * Will handle itself referring back to the UI thread when needed.
 *
 * @param src The byte array containing the image to set into the ImageViewEx.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setSourceBlocking(final byte[] src) {
    if (src == null) {
        try {
            stop();
            mGif = null;
            setTag(null);
        } catch (Throwable ignored) {
        }
        return;
    }
    Movie gif = null;
    // decoding into a Movie is pointless (read: expensive)
    if (internalCanAnimate()) {
        gif = Movie.decodeByteArray(src, 0, src.length);
    }
    // If gif is null, it's probably not a gif
    if (gif == null || !internalCanAnimate()) {
        // If not a gif and if on Android 3+, enable HW acceleration
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
        // Sets the image as a regular Drawable
        setTag(null);
        final Drawable d = Converters.byteArrayToDrawable(src, mOptions, getContext());
        // We need to run this on the UI thread
        stopLoading();
        mSetDrawableRunnable.setDrawable(d);
        mHandler.post(mSetDrawableRunnable);
    } else {
        // Disables the HW acceleration when viewing a GIF on Android 3+
        if (Build.VERSION.SDK_INT >= 11) {
            setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        // We need to run this on the UI thread
        stopLoading();
        mSetGifRunnable.setGif(gif);
        mHandler.post(mSetGifRunnable);
    }
}
Also used : Movie(android.graphics.Movie) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) TargetApi(android.annotation.TargetApi)

Aggregations

Movie (android.graphics.Movie)9 IOException (java.io.IOException)8 InputStream (java.io.InputStream)8 TargetApi (android.annotation.TargetApi)1 Paint (android.graphics.Paint)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1