Comments (10)
There is already support for setImageResource
, but it's not very efficient and effectively sets the drawable twice: https://github.com/vinc3m1/RoundedImageView/blob/master/roundedimageview/src/com/makeramen/RoundedImageView.java#L262
Actually, holding the resource id isn't that bad, I'm not sure why I didn't do that in the first place... I think I got it confused with setImageURI
from roundedimageview.
maybe that's because i've done a checkout a long time ago that i couldn't see this function and added my "patch" to it.
maybe you should look at the android code of imageView and get other ideas? even though their code is quite large, it could help you with possible optimizations...
from roundedimageview.
I think my code suggestion is flawed. Not sure what's the reason.
from roundedimageview.
I think this could be the correct changes:
@OverRide
public void setImageDrawable(final Drawable drawable) {
mResId = 0;
if (drawable != null) {
mDrawable = RoundedDrawable.fromDrawable(drawable);
updateDrawableAttrs();
} else {
mDrawable = null;
}
super.setImageDrawable(mDrawable);
}
@OverRide
public void setImageBitmap(final Bitmap bm) {
mResId = 0;
if (bm != null) {
mDrawable = new RoundedDrawable(bm);
updateDrawableAttrs();
} else {
mDrawable = null;
}
super.setImageDrawable(mDrawable);
}
@OverRide
public void setImageResource(final int resId) {
if (mResId == resId && resId != 0)
return;
if (resId == 0)
setImageDrawable(null);
else
setImageDrawable(getResources().getDrawable(resId));
mResId = resId;
}
from roundedimageview.
see 97b04ea
Should theoretically be faster, but might not be complete if getResources()
is ever null for some reason...
from roundedimageview.
on which cases getResources returns null?
i don't think it's possible...
from roundedimageview.
Not sure, but there's a null check in resolveUri
in ImageView.java
source.
from roundedimageview.
weird.
anyway, so now the code on this library is better, and uses the resources' drawable in a better way?
from roundedimageview.
it should, but the way it was working before was fine too
from roundedimageview.
thanks.
from roundedimageview.
Related Issues (20)
- convert drawble image to bitmap HOT 1
- How can I display a gif??? HOT 2
- Fatal Exception: java.lang.OutOfMemoryError HOT 2
- TransitionDrawable support
- Out of Memory Error in resolveBackgroundResource HOT 1
- ImageView on top of roundedimageview HOT 1
- Losing Fade-in Animation when used with Picasso HOT 1
- <com.makeramen.roundedimageview.RoundedImageView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/imageView1" android:src="@drawable/photo1" android:scaleType="fitCenter" app:riv_corner_radius="30dip" app:riv_border_width="2dip" app:riv_border_color="#333333" app:riv_mutate_background="true" app:riv_tile_mode="repeat" app:riv_oval="true" /> HOT 1
- Could not resolve com.makeramen:roundedimageview:2.3.0.
- RoundedImageView设置ScaleType=ScaleType.FIT_XY时,图片显示不出的效果,没有进行拉伸。用ImageView是正常的。
- RoundedImageView not working Glide transition animation and rounded corner broken! HOT 1
- LinearLayout使用layout_weight属性的bug HOT 1
- Display error when layout change caused by screen rotation
- android:scaleType Not working in new version HOT 3
- cannot show gif HOT 1
- Conflict with Glide .transition(DrawableTransitionOptions.withCrossFade) HOT 2
- Fatal Exception: java.lang.OutOfMemoryError HOT 1
- 控件设置android:tint 属性对图片着色没有效果
- cannot show gif. How can I fix that? HOT 3
- Will your library supprot OpenHarmony platform by JavaScript language? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roundedimageview.