android.graphics.Movie Java Examples

The following examples show how to use android.graphics.Movie. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnimationView.java    From Wifi-Connect with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {

    /**
     * Starting from HONEYCOMB have to turn off HW acceleration to draw
     * Movie on Canvas.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifMoviewView, defStyle,
            R.style.Widget_GifMoviewView);

    mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

    array.recycle();

    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
    }
}
 
Example #2
Source File: GifView.java    From misound with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs,
                               int defStyle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    final TypedArray array = context.obtainStyledAttributes(attrs,
            R.styleable.GifView);
    mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
    mPaused = false;
    array.recycle();
    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(
                mMovieResourceId));
    }
}
 
Example #3
Source File: GifMovieView.java    From Simpler with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {

    /**
     * Starting from HONEYCOMB have to turn off HW acceleration to draw
     * Movie on Canvas.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifMoviewView, defStyle,
            R.style.Widget_GifMoviewView);

    mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

    array.recycle();

    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
    }
}
 
Example #4
Source File: GifMovieView.java    From gif-movie-view with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {

	/**
	 * Starting from HONEYCOMB have to turn off HW acceleration to draw
	 * Movie on Canvas.
	 */
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}

	final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifMoviewView, defStyle,
			R.style.Widget_GifMoviewView);

	mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif, -1);
	mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

	array.recycle();

	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
	}
}
 
Example #5
Source File: GifMovieView.java    From DialogUtil with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {

    /**
     * Starting from HONEYCOMB have to turn off HW acceleration to draw
     * Movie on Canvas.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifMoviewView, defStyle,
            R.style.Widget_GifMoviewView);

    mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

    array.recycle();

    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
    }
}
 
Example #6
Source File: GifView.java    From BlackLight with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs,
		int defStyle) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}
	final TypedArray array = context.obtainStyledAttributes(attrs,
			R.styleable.GifView, defStyle, R.style.Widget_GifView);
	mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
	mPaused = array.getBoolean(R.styleable.GifView_paused, false);
	array.recycle();
	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(
				mMovieResourceId));
	}
}
 
Example #7
Source File: GifMovieView.java    From DialogUtil with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {

    /**
     * Starting from HONEYCOMB have to turn off HW acceleration to draw
     * Movie on Canvas.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifMoviewView, defStyle,
            R.style.Widget_GifMoviewView);

    mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

    array.recycle();

    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
    }
}
 
Example #8
Source File: FFmpegUtil.java    From video-transcoder with GNU General Public License v3.0 6 votes vote down vote up
private static MediaInfo mediaInfoFixup(MediaInfo info)
{
    if(info.container != null && info.container == MediaContainer.GIF)
    {
        // ffprobe will not report the duration of GIF files. The duration will
        // need to be determined another way

        Movie gifMovie = Movie.decodeFile(info.file.getAbsolutePath());
        int durationMs = gifMovie.duration();

        info = new MediaInfo(info.file, durationMs, info.container, info.videoCodec, info.videoResolution,
                info.videoBitrateK, info.videoFramerate, info.audioCodec, info.audioSampleRate, info.audioBitrateK, info.audioChannels);
    }

    return info;
}
 
Example #9
Source File: GifView.java    From imsdk-android with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs,
                               int defStyle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    final TypedArray array = context.obtainStyledAttributes(attrs,
            R.styleable.GifView, defStyle, R.style.Widget_GifView);
    mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifView_paused, false);
    array.recycle();
    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(
                mMovieResourceId));
    }
}
 
Example #10
Source File: GifDrawable.java    From RichText with MIT License 6 votes vote down vote up
public GifDrawable(Movie movie, int height, int width) {
    this.movie = movie;
    this.height = height;
    this.width = width;
    setBounds(0, 0, width, height);
    scaleX = scaleY = 1.0f;
    paint = new Paint();
    handler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == what && running && textView != null) {
                textView.invalidate();
                sendEmptyMessageDelayed(what, 33);
            }
        }
    };
}
 
Example #11
Source File: Resources.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: GifMovieView.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
public void setMovieResource(InputStream inputStream) {

        //this.mMovieResourceId = movieResId;
        //  mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
        mMovie = Movie.decodeStream(inputStream);
        requestLayout();
    }
 
Example #13
Source File: ResourcesProxy.java    From GPT with Apache License 2.0 5 votes vote down vote up
@Override
public Movie getMovie(int id) throws NotFoundException {
    try {
        return super.getMovie(id);
    } catch (NotFoundException e) {
        return mHostResources.getMovie(id);
    }
}
 
Example #14
Source File: GIFView.java    From RedReader with GNU General Public License v3.0 5 votes vote down vote up
public GIFView(Context context, @NonNull final byte[] data) {
	super(context);

	setLayerType(View.LAYER_TYPE_SOFTWARE, null);

	mMovie = Movie.decodeByteArray(data, 0, data.length);

	if(mMovie.duration() < 1) {
		throw new RuntimeException("Invalid GIF");
	}

	paint.setAntiAlias(true);
	paint.setFilterBitmap(true);
}
 
Example #15
Source File: GifView.java    From Android with MIT License 5 votes vote down vote up
public void setGifResource(int movieResourceId) {
    /**
     * Starting from HONEYCOMB(Api Level:11) have to turn off HW acceleration to draw
     * Movie on Canvas.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    movie = Movie.decodeStream(getResources().openRawResource(movieResourceId));
    requestLayout();
}
 
Example #16
Source File: GifMovieView.java    From AnimeTaste with MIT License 5 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs,
		int defStyle) {

	/**
	 * Starting from HONEYCOMB have to turn off HW acceleration to draw
	 * Movie on Canvas.
	 */
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}

	final TypedArray array = context.obtainStyledAttributes(attrs,
			R.styleable.GifMoviewView, defStyle,
			R.style.Widget_GifMoviewView);

	mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif,
			-1);
	mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

	array.recycle();

	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(
				mMovieResourceId));
	}
}
 
Example #17
Source File: GifView.java    From Android with MIT License 5 votes vote down vote up
public void setGifResource(String filepath) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    InputStream inputStream = ResourceUtil.getAssetsStream(filepath);
    if (inputStream != null) {
        movie = Movie.decodeStream(inputStream);
        requestLayout();
    }
}
 
Example #18
Source File: ResourcesProxy.java    From Neptune with Apache License 2.0 5 votes vote down vote up
@Override
public Movie getMovie(int id) throws NotFoundException {
    try {
        return super.getMovie(id);
    } catch (NotFoundException e) {
        return mHostResources.getMovie(id);
    }
}
 
Example #19
Source File: GifImageView.java    From VoIpUSSD with Apache License 2.0 5 votes vote down vote up
private void init() {
    setFocusable(true);
    mMovie = Movie.decodeStream(mInputStream);
    mWidth = mMovie.width();
    mHeight = mMovie.height();

    requestLayout();
}
 
Example #20
Source File: GifView.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    // 从描述文件中读出gif的值,创建出Movie实例
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView, defStyle, R.style.AppBaseTheme);
    mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifView_paused, false);
    array.recycle();
    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
    }
}
 
Example #21
Source File: GifView.java    From GOpenSource_AppKit_Android_AS with MIT License 5 votes vote down vote up
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}
	// 从描述文件中读出gif的值,创建出Movie实例
	final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView, defStyle,
			R.style.Widget_GifView);
	mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
	mPaused = array.getBoolean(R.styleable.GifView_paused, false);
	array.recycle();
	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
	}
}
 
Example #22
Source File: GifMovieView.java    From zen4android with MIT License 5 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs,
		int defStyle) {

	/**
	 * Starting from HONEYCOMB have to turn off HW acceleration to draw
	 * Movie on Canvas.
	 */
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}

	final TypedArray array = context.obtainStyledAttributes(attrs,
			R.styleable.GifMoviewView, defStyle,
			R.style.Widget_GifMoviewView);

	mMovieResourceId = array.getResourceId(R.styleable.GifMoviewView_gif,
			-1);
	mPaused = array.getBoolean(R.styleable.GifMoviewView_paused, false);

	array.recycle();

	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(
				mMovieResourceId));
	}
}
 
Example #23
Source File: ImageActivity.java    From BlackLight with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onPostExecute(Object[] result) {
	super.onPostExecute(result);
	ViewGroup v = (ViewGroup) result[0];
	Object img = result[1];
	
	if (img != null) {
		v.removeAllViews();
		if (img instanceof Bitmap) {
			PhotoView p = new PhotoView(ImageActivity.this);
			
			// Disable hardware acceleration if too large
			Bitmap image = (Bitmap) img;
			int maxSize = Utility.getSupportedMaxPictureSize();
			if (image.getWidth() > maxSize || image.getHeight() > maxSize) {
				p.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
				
				if (DEBUG) {
					Log.d(TAG, "Image too large, hardware acceleration disabled. max size: " + maxSize);
				}
			}
			
			p.setImageBitmap(image);
			p.setOnPhotoTapListener(ImageActivity.this);
			v.addView(p, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
		} else if (img instanceof Movie) {
			GifView g = new GifView(ImageActivity.this);
			g.setMovie((Movie) img);
			v.addView(g, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
		}
	}
}
 
Example #24
Source File: GifView.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}
	// 从描述文件中读出gif的值,创建出Movie实例
	final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView, defStyle,
			R.style.Widget_GifView);
	mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
	mPaused = array.getBoolean(R.styleable.GifView_paused, false);
	array.recycle();
	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
	}
}
 
Example #25
Source File: GifView.java    From gokit-android with MIT License 5 votes vote down vote up
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}
	// 从描述文件中读出gif的值,创建出Movie实例
	final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView, defStyle,
			R.style.Widget_GifView);
	mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
	mPaused = array.getBoolean(R.styleable.GifView_paused, false);
	array.recycle();
	if (mMovieResourceId != -1) {
		mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
	}
}
 
Example #26
Source File: XResources.java    From xposed-art with Apache License 2.0 5 votes vote down vote up
@Override
public Movie getMovie(int id) throws NotFoundException {
	Object replacement = getReplacement(id);
	if (replacement instanceof XResForwarder) {
		Resources repRes = ((XResForwarder) replacement).getResources();
		int repId = ((XResForwarder) replacement).getId();
		return repRes.getMovie(repId);
	}
	return super.getMovie(id);
}
 
Example #27
Source File: GifView.java    From gokit-android with MIT License 4 votes vote down vote up
/**
 * 设置gif图资源
 * 
 * @param movieResId
 */
public void setMovieResource(int movieResId) {
	this.mMovieResourceId = movieResId;
	mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
	requestLayout();
}
 
Example #28
Source File: GifMovieView.java    From AnimeTaste with MIT License 4 votes vote down vote up
public Movie getMovie() {
	return mMovie;
}
 
Example #29
Source File: GifView.java    From gokit-android with MIT License 4 votes vote down vote up
public Movie getMovie() {
	return mMovie;
}
 
Example #30
Source File: GifView.java    From gokit-android with MIT License 4 votes vote down vote up
public void setMovie(Movie movie) {
	this.mMovie = movie;
	requestLayout();
}