Search in sources :

Example 1 with Movie

use of android.graphics.Movie in project xUtils3 by wyouflf.

the class ImageDecoder method decodeGif.

/**
     * 转换文件为Movie, 可用于创建GifDrawable.
     *
     * @param file
     * @param options
     * @param cancelable
     * @return
     * @throws IOException
     */
public static Movie decodeGif(File file, ImageOptions options, Callback.Cancelable cancelable) throws IOException {
    {
        // check params
        if (file == null || !file.exists() || file.length() < 1)
            return null;
    /*if (options == null) {
                options = ImageOptions.DEFAULT; // not use
            }
            if (options.getMaxWidth() <= 0 || options.getMaxHeight() <= 0) {
                options.optimizeMaxSize(null);
            }*/
    }
    InputStream in = null;
    try {
        if (cancelable != null && cancelable.isCancelled()) {
            throw new Callback.CancelledException("cancelled during decode image");
        }
        int buffSize = 1024 * 16;
        in = new BufferedInputStream(new FileInputStream(file), buffSize);
        in.mark(buffSize);
        Movie movie = Movie.decodeStream(in);
        if (movie == null) {
            throw new IOException("decode image error");
        }
        return movie;
    } catch (IOException ex) {
        throw ex;
    } catch (Throwable ex) {
        LogUtil.e(ex.getMessage(), ex);
        return null;
    } finally {
        IOUtil.closeQuietly(in);
    }
}
Also used : Movie(android.graphics.Movie) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Paint(android.graphics.Paint) FileInputStream(java.io.FileInputStream)

Example 2 with Movie

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

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(int id) throws NotFoundException {
    InputStream is = openRawResource(id);
    Movie movie = Movie.decodeStream(is);
    try {
        is.close();
    } catch (java.io.IOException e) {
    // don't care, since the return value is valid
    }
    return movie;
}
Also used : Movie(android.graphics.Movie) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 3 with Movie

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

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 4 with Movie

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

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 5 with Movie

use of android.graphics.Movie in project XobotOS by xamarin.

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(int id) throws NotFoundException {
    InputStream is = openRawResource(id);
    Movie movie = Movie.decodeStream(is);
    try {
        is.close();
    } catch (java.io.IOException e) {
    // don't care, since the return value is valid
    }
    return movie;
}
Also used : Movie(android.graphics.Movie) InputStream(java.io.InputStream) IOException(java.io.IOException)

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