本文整理匯總了Java中android.graphics.Movie.decodeStream方法的典型用法代碼示例。如果您正苦於以下問題:Java Movie.decodeStream方法的具體用法?Java Movie.decodeStream怎麽用?Java Movie.decodeStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Movie
的用法示例。
在下文中一共展示了Movie.decodeStream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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));
}
}
示例2: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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, 0);
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));
}
}
示例3: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
/**
* 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);
}
final TypedArray array = context.obtainStyledAttributes(attrs,
R.styleable.GifView, defStyle, R.style.Widget_GifView);
//-1 is default value
mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
mPaused = array.getBoolean(R.styleable.GifView_paused, false);
array.recycle();
if (mMovieResourceId != -1) {
movie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
}
}
示例4: fetchFromUrl
import android.graphics.Movie; //導入方法依賴的package包/類
@Override
public Movie fetchFromUrl(@NonNull String url, @NonNull DecodeSpec decodeSpec,
@Nullable ProgressListener<Movie> progressListener,
@Nullable ErrorListener errorListener) throws Exception {
super.fetchFromUrl(url, decodeSpec, progressListener, errorListener);
Resources resources = this.mContext.getResources();
int resId = resources.getIdentifier(mSplitter.getRealPath(url),
"drawable",
this.mContext.getPackageName());
if (resId <= 0) {
callOnError(errorListener, new Cause(new Resources.NotFoundException(String.format("Res of id-%s not found.", resId))));
return null;
}
callOnStart(progressListener);
@Cleanup
InputStream inputStream = resources.openRawResource(0);
Movie movie = Movie.decodeStream(inputStream);
callOnComplete(progressListener, movie);
return movie;
}
示例5: PowerImageView
import android.graphics.Movie; //導入方法依賴的package包/類
/**
* PowerImageView構造函數,在這裏完成所有必要的初始化操作。
*
* @param context
*/
public PowerImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PowerImageView);
int resourceId = getResourceId(a, context, attrs);
if (resourceId != 0) {
// 當資源id不等於0時,就去獲取該資源的流
InputStream is = getResources().openRawResource(resourceId);
// 使用Movie類對流進行解碼
mMovie = Movie.decodeStream(is);
if (mMovie != null) {
// 如果返回值不等於null,就說明這是一個GIF圖片,下麵獲取是否自動播放的屬性
isAutoPlay = a.getBoolean(R.styleable.PowerImageView_auto_play, false);
Bitmap bitmap = BitmapFactory.decodeStream(is);
mImageWidth = bitmap.getWidth();
mImageHeight = bitmap.getHeight();
bitmap.recycle();
if (!isAutoPlay) {
// 當不允許自動播放的時候,得到開始播放按鈕的圖片,並注冊點擊事件
mStartButton = BitmapFactory.decodeResource(getResources(),
R.mipmap.ic_launcher);
setOnClickListener(this);
}
}
}
}
示例6: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
/**
* 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);
}
final TypedArray array = context.obtainStyledAttributes(attrs,
R.styleable.GifView, defStyle, R.style.Widget_GifView);
//-1 is default value
mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
mPaused = array.getBoolean(R.styleable.GifView_paused, false);
mScaleToFillWidth = array.getBoolean(R.styleable.GifView_scaleToFillWidth, false);
array.recycle();
if (mMovieResourceId != -1) {
movie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
}
}
示例7: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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.PullToRefresh, defStyle, R.style.Widget_GifView);
mMovieResourceId = array.getResourceId(R.styleable.PullToRefresh_ptrGifResource, -1);
mPaused = array.getBoolean(R.styleable.PullToRefresh_ptrGifPaused, false);
array.recycle();
if (mMovieResourceId != -1) {
mMovie = Movie.decodeStream(getResources().openRawResource(
mMovieResourceId));
}
}
示例8: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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.GifView, defStyle,
R.style.Widget_GifMoviewView);
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));
}
}
示例9: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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));
}
}
示例10: setAnimatedGif
import android.graphics.Movie; //導入方法依賴的package包/類
public void setAnimatedGif(int rawResourceId, TYPE streachType) {
setImageBitmap(null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
mType = streachType;
animatedGifImage = true;
is = getContext().getResources().openRawResource(rawResourceId);
try {
mMovie = Movie.decodeStream(is);
} catch (Exception e) {
e.printStackTrace();
byte[] array = streamToBytes(is);
mMovie = Movie.decodeByteArray(array, 0, array.length);
}
p = new Paint();
}
示例11: PowerImageView
import android.graphics.Movie; //導入方法依賴的package包/類
/**
* PowerImageView構造函數,在這裏完成所有必要的初始化操作。
*
* @param context
*/
public PowerImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PowerImageView);
int resourceId = getResourceId(a, context, attrs);
if (resourceId != 0) {
// 當資源id不等於0時,就去獲取該資源的流
InputStream is = getResources().openRawResource(resourceId);
// 使用Movie類對流進行解碼
mMovie = Movie.decodeStream(is);
if (mMovie != null) {
// 如果返回值不等於null,就說明這是一個GIF圖片,下麵獲取是否自動播放的屬性
isAutoPlay = a.getBoolean(R.styleable.PowerImageView_auto_play, false);
Bitmap bitmap = BitmapFactory.decodeStream(is);
mImageWidth = bitmap.getWidth();
mImageHeight = bitmap.getHeight();
bitmap.recycle();
if (!isAutoPlay) {
// 當不允許自動播放的時候,得到開始播放按鈕的圖片,並注冊點擊事件
mStartButton = BitmapFactory.decodeResource(getResources(),
R.drawable.start_play);
setOnClickListener(this);
}
}
}
}
示例12: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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));
}
}
示例13: setViewAttributes
import android.graphics.Movie; //導入方法依賴的package包/類
@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));
}
}
示例14: setGifResource
import android.graphics.Movie; //導入方法依賴的package包/類
public void setGifResource(int movieResourceId) {
this.mMovieResourceId = movieResourceId;
movie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
mDuration = movie.duration();
if (mDuration == 0) mDuration = DEFAULT_MOVIE_VIEW_DURATION;
requestLayout();
}
示例15: setMovieResource
import android.graphics.Movie; //導入方法依賴的package包/類
/**
* 設置gif圖資源
*
* @param movieResId
*/
public void setMovieResource(int movieResId) {
this.mMovieResourceId = movieResId;
mMovie = Movie.decodeStream(getResources().openRawResource(
mMovieResourceId));
requestLayout();
}