use of android.graphics.drawable.Animatable in project remusic by aa112901.
the class RoundFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_roundimage, container, false);
((ViewGroup) rootView).setAnimationCacheEnabled(false);
if (getArguments() != null) {
albumPath = getArguments().getString("album");
}
// CircleImageView circleImageView = (CircleImageView) rootView.findViewById(R.id.circle);
sdv = (SimpleDraweeView) rootView.findViewById(R.id.sdv);
//初始化圆角圆形参数对象
RoundingParams rp = new RoundingParams();
//设置图像是否为圆形
rp.setRoundAsCircle(true);
//设置圆角半径
//rp.setCornersRadius(20);
//分别设置左上角、右上角、左下角、右下角的圆角半径
//rp.setCornersRadii(20,25,30,35);
//分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
//rp.setCornersRadii(new float[]{20,25,30,35,40,45,50,55});
//设置边框颜色及其宽度
rp.setBorder(Color.BLACK, 6);
//获取GenericDraweeHierarchy对象
GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setRoundingParams(rp).setFadeDuration(300).build();
//设置Hierarchy
sdv.setHierarchy(hierarchy);
//Log.e("music id",musicId + "");
// String uri = MusicUtils.getAlbumdata(getContext().getApplicationContext(), musicId);
//
// if (musicId != -1 && uri != null) {
// //circleImageView.setImageBitmap(bitmap);
// //circleImageView.setImageURI(Uri.parse(uri));
// Uri ur = MusicUtils.getAlbumUri(getContext().getApplicationContext(), musicId);
// sdv.setImageURI(ur);
// } else {
//
// // circleImageView.setImageResource(R.drawable.placeholder_disk_play_song);
// Uri urr = Uri.parse("res:/" + R.drawable.placeholder_disk_play_song);
// sdv.setImageURI(urr);
// }
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
//FLog.d("Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
sdv.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_play_song));
}
};
if (albumPath == null) {
sdv.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_play_song));
} else {
try {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(albumPath)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(sdv.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
sdv.setController(controller);
// sdv.setImageBitmap(BitmapFactory.decodeStream(HttpUtil.getFromCache(getActivity(),getAlbumPath())));
} catch (Exception e) {
e.printStackTrace();
}
}
return rootView;
}
use of android.graphics.drawable.Animatable in project remusic by aa112901.
the class LoodView method initUI.
/**
* 初始化UI
*
* @param context
*/
private void initUI(Context context) {
LayoutInflater.from(context).inflate(R.layout.load_view, this, true);
for (String imagesID : imageNet) {
final SimpleDraweeView mAlbumArt = new SimpleDraweeView(context);
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
//FLog.d("Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
};
Uri uri = null;
try {
uri = Uri.parse(imagesID);
} catch (Exception e) {
e.printStackTrace();
}
if (uri != null) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mAlbumArt.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
mAlbumArt.setController(controller);
} else {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
//view.setImageURI(Uri.parse(imagesID));
// view.setImageResource(imagesID);
// view.setImageResource(imagesID);
mAlbumArt.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageViewList.add(mAlbumArt);
}
dotViewList.add(findViewById(R.id.v_dot1));
dotViewList.add(findViewById(R.id.v_dot2));
dotViewList.add(findViewById(R.id.v_dot3));
dotViewList.add(findViewById(R.id.v_dot4));
dotViewList.add(findViewById(R.id.v_dot5));
dotViewList.add(findViewById(R.id.v_dot6));
dotViewList.add(findViewById(R.id.v_dot7));
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPager.setFocusable(true);
fPagerAdapter = new FPagerAdapter();
viewPager.setAdapter(fPagerAdapter);
viewPager.addOnPageChangeListener(new MyPageChangeListener());
}
use of android.graphics.drawable.Animatable in project HoloEverywhere by Prototik.
the class ProgressBar method startAnimation.
void startAnimation() {
if (getVisibility() != android.view.View.VISIBLE) {
return;
}
if (mIndeterminateDrawable instanceof Animatable) {
mShouldStartAnimationDrawable = true;
mHasAnimation = false;
} else {
mHasAnimation = true;
if (mInterpolator == null) {
mInterpolator = new LinearInterpolator();
}
if (mTransformation == null) {
mTransformation = new Transformation();
} else {
mTransformation.clear();
}
if (mAnimation == null) {
mAnimation = new AlphaAnimation(0.0f, 1.0f);
} else {
mAnimation.reset();
}
mAnimation.setRepeatMode(mBehavior);
mAnimation.setRepeatCount(Animation.INFINITE);
mAnimation.setDuration(mDuration);
mAnimation.setInterpolator(mInterpolator);
mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
}
postInvalidate();
}
use of android.graphics.drawable.Animatable in project HoloEverywhere by Prototik.
the class ProgressBar method onDraw.
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
Drawable d = mCurrentDrawable;
if (d != null) {
canvas.save();
canvas.translate(getPaddingLeft(), getPaddingTop());
long time = getDrawingTime();
if (mHasAnimation) {
mAnimation.getTransformation(time, mTransformation);
float scale = mTransformation.getAlpha();
try {
mInDrawing = true;
d.setLevel((int) (scale * ProgressBar.MAX_LEVEL));
} finally {
mInDrawing = false;
}
postInvalidate();
}
d.draw(canvas);
canvas.restore();
if (mShouldStartAnimationDrawable && d instanceof Animatable) {
((Animatable) d).start();
mShouldStartAnimationDrawable = false;
}
}
}
use of android.graphics.drawable.Animatable in project android_frameworks_base by ResurrectionRemix.
the class QSIconView method setIcon.
protected void setIcon(ImageView iv, QSTile.State state) {
if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
Drawable d = state.icon != null ? iv.isShown() && mAnimationEnabled ? state.icon.getDrawable(mContext) : state.icon.getInvisibleDrawable(mContext) : null;
int padding = state.icon != null ? state.icon.getPadding() : 0;
if (d != null && state.autoMirrorDrawable) {
d.setAutoMirrored(true);
}
iv.setImageDrawable(d);
iv.setTag(R.id.qs_icon_tag, state.icon);
iv.setPadding(0, padding, 0, padding);
if (d instanceof Animatable && iv.isShown()) {
Animatable a = (Animatable) d;
a.start();
if (!iv.isShown()) {
// skip directly to end state
a.stop();
}
}
}
if (state.disabledByPolicy) {
iv.setColorFilter(getContext().getColor(R.color.qs_tile_disabled_color));
} else {
iv.clearColorFilter();
}
}
Aggregations