loopj / android-smart-image-view Goto Github PK
View Code? Open in Web Editor NEWAndroid ImageView replacement which allows image loading from URLs or contact address book, with caching
Home Page: http://loopj.com/android-smart-image-view/
Android ImageView replacement which allows image loading from URLs or contact address book, with caching
Home Page: http://loopj.com/android-smart-image-view/
Hello,
I have a simple ListView with some URL-loaded images on each row, with some text under it. When I scroll the list, the scrollbar is very weird (it grows or decreases when we approach an image) and each time we scroll up, the image is loaded suddenly so the scroll is very sudden and abrupt, and the image apprears suddenly at the middle of the screen..
I think the images are only displayed once they are onto the screen, but if we scroll quickly, its saccade because of the loading latency and sometimes gets on the top of the list by itself...
Is there a way to fix these issues ? My application can't be used, it's not convenient at all...
Thanks !
Great library. Is there currently a way to get a notification when the image has finished downloading so I can turn off a progress indicator? If not maybe you can add a getCurrentTask method in the SmartImageView and make the SmartImageTask class implement observable so an observer can get notified of the completed download.
Good, but need to add zoom capability.
How can i use this if i try to load from a URL that has basic authentication?
Have you tried it using inside an adapter for listview? It seems that your code is not optimized for loading a lot bitmaps. You may decode the result bitmap from the available Heap memory allocated for the app.
.XML
<com.loopj.android.image.SmartImageView
android:id="@+id/my_image"
android:layout_height="match_parent"
android:layout_width="match_parent" />
.JAVA
SmartImageView myImage = (SmartImageView) findViewById(R.id.my_image);
myImage.setImageUrl("http://www.awesomeimages.com/myawesomeimage.jpg");
Manifiest
error
FATAL EXCEPTION: main
Process:, PID: 14393
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.loopj.android.image.SmartImageView.setImageUrl(java.lang.String)' on a null object reference
setImageUrl(https://imgjam.com/albums/s55/55420/covers/1.100.jpg);
Why is android Smart Image View mixing images on scroll view before all images are loaded?
I am getting out of memory exception when I have long list of big images in a list view.
I was wondering if we can make the bitmap purge able then can we solve OOM errors.
I have been trying to optimize my ListView for a while now and am failing. When I only set a placeholder image and do not load remotely, the list is very fast.
Here is what I have tried (and still have all this):
What else can I try? I assumed the memory cache would be fast enough to make this a non-issue. To get an idea for performance, it is clearly dropping frames and a flick scroll can lock up the list for at least 500-1,000ms.
Thank you for an otherwise awesome library!
Use case:
I have a picture that should load an image from an url.
When the picture is clicked, it should allow the user to pick another image (from camera/gallery)
Initialy the image comes from an url, so it has to load for a second on start.
I only want to make the image clickable after the image is loaded from the url, so thats where the feature comes in.
perhaps you can pass a runnable?
f.e. image.setAfterImageIsSet(New Runnable(){ //Code here// }).
I dont know if this excample might even work, but its just a suggestion :p
how can I load image from different port num like this?
05-09 11:11:50.013: E/AndroidRuntime(8461): FATAL EXCEPTION: pool-2-thread-1
05-09 11:11:50.013: E/AndroidRuntime(8461): java.lang.OutOfMemoryError
05-09 11:11:50.013: E/AndroidRuntime(8461): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
05-09 11:11:50.013: E/AndroidRuntime(8461): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:546)
05-09 11:11:50.013: E/AndroidRuntime(8461): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:618)
05-09 11:11:50.013: E/AndroidRuntime(8461): at com.loopj.android.image.WebImage.getBitmapFromUrl(Unknown Source)
05-09 11:11:50.013: E/AndroidRuntime(8461): at com.loopj.android.image.WebImage.getBitmap(Unknown Source)
05-09 11:11:50.013: E/AndroidRuntime(8461): at com.loopj.android.image.SmartImageTask.run(Unknown Source)
05-09 11:11:50.013: E/AndroidRuntime(8461): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-09 11:11:50.013: E/AndroidRuntime(8461): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-09 11:11:50.013: E/AndroidRuntime(8461): at java.lang.Thread.run(Thread.java:838)
I am trying to load images using URL in Listview and I am able to show a progressbar widget while loading the images.
But the problem is, the image is not displayed for the first list item even if it gets loaded in Background. i.e onCompletionListener for that item gets executed properly, but the images is not displayed.
If I scroll the list down and comeback upwards the image is displayed.
Is there any other way to show progress while loading Images in ListView or any general view.
This is my layout
<com.loopj.android.image.SmartImageView
android:id="@+id/img_view
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:contentDescription="@string/description_img"
android:scaleType="centerCrop"
android:src="@drawable/room"
android:visibility="invisible" />
<ProgressBar
android:id="@+id/img_loader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
Permissions using the following suggestions to use the document to add a description.
Since commit 302339f all my Bitmaps (JPG and PNG) are extremely low quality and pixelated. I load the images from a webserver and have tested it with different images, servers and different locations in my App.
Seems that the new Bitmap decoding routing is not working for me.
get some features like to fetch facebook profile image using their id..
I am trying to download non-public images from amazon's s3.
To do this I have to generate a pre-signed url that includes a bunch of long parameters like the signature, and the library crashes because it wants to write a file whose name lenght exceeds the allowed limit.
I am now trying to hack the cache to use shorter version of the url as filename, but I think that would probably mess up the entire cache system for s3 pictures.
I would love a cache expiration control. I have to do it manually and it's sucks. Thank you!
SmartImageView doesn't handle HTTP 302 response code, which is the response for requests to drop box, for example, https://www.dropbox.com/s/rmnlnjj4ide9myo/picture.jpg
To explain with an example.
List View
Image 1
Image 2
Image 3
------- Beyond the visible area -----
Image 4
Image 5
All the image tags have default src attribute for empty images.
Now when I scroll down & if the connection is slow by default I will see Image1 and Image 2 in Image 4 and 5 place holders. Once the image is loaded it replaced it with correct images.
This is more visible when we scroll fast or use bigger images. It would be great if Image 4 and Image 5 could show the default drawable if the image is not loaded while scrolling.
We tried to play around with the code but I am no expert to fix it :)
EDIT : Fixed by assigning default drawable for this view
I just posted a sample project that uses SmartImageView
to display video thumbnails obtained from MediaStore
. The SmartImage
implementation is fairly straightforward:
private static class VideoThumbnailImage implements SmartImage {
private int videoId;
private int thumbnailKind;
VideoThumbnailImage(int videoId, int thumbnailKind) {
this.videoId=videoId;
this.thumbnailKind=thumbnailKind;
}
@Override
public Bitmap getBitmap(Context ctxt) {
return(MediaStore.Video.Thumbnails.getThumbnail(ctxt.getContentResolver(),
videoId,
thumbnailKind,
null));
}
}
My code is licensed Apache License 2.0, and I have no qualms if you want to add this code to your project.
need to have cache removal control. This can be done if the WebImageCache would be private and providing a getInstance method to the file would make this happen.
if url contains space image not converting.
I want using geographique card with levels of zoom and don't know from where I start
Hi,
I am using smartview to create an image search app. I need to share the images using Intent, so I load the image from Url. A few images are always loaded as ColorDrawable is I do imageView.getDrawable(). It is the same code loading all thumbnails in a grid, but a few pics are always loaded as ColorDrawable, and in that case my logic fails where I try to get bitmap from that file. Why does it happens this way?
Eg. from this json - https://ajax.googleapis.com/ajax/services/search/images?q=android&v=1.0&&rsz=8&imgsz=medium&start=2, the 4th object always loads as BitmapDrawable while 6th object always loads as ColorDrawable.
I have a list of contacts.
In listView's Adapter, i check if contact have image not null or empty.
But for the case when Image is empty or null, it display another image in the list. (Not the default one).
Here is the code :
if(image == null || image.isEmpty()) {
contactImage.setImageResource(R.drawable.nophoto);
} else {
contactImage.setImageUrl(image);
}
For example media/images/assets/staff/Denis_Roldán.jpg should be escaped like media/images/assets/staff/Denis_Rold%C3%A1n.jpg as a result, the call throws a FileNotFoundException
I am trying to display a image from a URL in a ImageView, and I tried this method based on your java class it doesn't seem to work... I've crash application...
pics.xml
<com.loopj.android.image.SmartImageView android:id="@+id/my_image" />
Pics.java
import com.loopj.android.image.SmartImageView;
import android.app.Activity;
import android.os.Bundle;
public class Pics extends Activity {
@OverRide
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pics);
SmartImageView myImage = (SmartImageView) this.findViewById(R.id.my_image);
myImage.setImageUrl("http://www.remoteServer.com/img/disconnect.png");
}
}
In AndroidManifest
<activity
android:name=".Pics"
android:label="test" >
</activity>
I like Smart ImageView and want to use it for a project, but I've moved my workflow over to using Gradle (part of using Android Studio).
I'm able to install the library just fine[1], but I was wondering if there was any chance we could have a Maven repository setup for this library?
Is there any possibility to have a feature like iOS's SDWebImageManager progressive download of image.
Hi, firstly thank you for your project, i think it works very well !
But, i still have outOfMemory issues when i try to download a .jpg from an URL on my server.
The logcat print that the bitmap exceed the VM budget, it's about 8.200.000 bytes it try to save. Is there any solution to reduce this bitmap ? Or is it from your code ?
Please reply.
hi,
this way suggest a simple class that extends from imageview but this does not work here since we don't know width until we fetch/download the image
any suggestion ?
If URL of image is broken, does it throw an exception that can be caught by me to do something about it? Great project, thanks :)
Could you make this includable as a gradle dependencie? Same as Android Asynchronous Http Client
I can run in Eclipse but I cannot run it in Android Studio. (the same code)
I think it's not import library problem because I can run "Asynchronous Http Client for Android" and others in Android Studio, of course I had opened internet permission. In LogCat, it seems xml problem but I don't know how to solve. Here are my xml code:
< com.loopj.android.image.SmartImageView
android:id="@+id/my_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Does anyone have this situation? Thanks~~
Would be good to be able to easily redownload the image and i.e. update the cache when 'called'
my code:
SmartImageView view = null;
if(convertView==null){
convertView = inflater.inflate(R.layout.image, null);
view = (SmartImageView)convertView.findViewById(R.id.image);
convertView.setTag(view);
}else{
view = (SmartImageView) convertView.getTag();
}
view.setImageUrl(imageUrls.get(position));
I see that on this library's Web page on loopj.com you state that it is licensed under the Apache License 2.0. However, your source code does not appear to have the copyright and license notice requested by the license terms. Based on the source code alone, it would appear that nobody has any rights to use the source. I suggest just adding the copyright-and-license boilerplate (tailored for you and the year) to the source files.
Also, you might consider mentioning the license in the repo's README
.
It handles caching and uses SPDY when possible.
Hello Sir,
Please Attach Apk File with Demo Zip if Possible Because of this We Can Check Apk File Before Use Code..
Hi!
I load more than 60 images from the internet using setImageUrl() and I receive an error:
Out of memory on a 270016-byte allocation.
What will advise?
Is there a way to scale the images, to make it similar to:
ImageView image;
image = (ImageView)findViewById(R.id.yourImageView1);
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
There is no provision that is similar.
I would like to scale images across many android devices.
Is this the right approach?
/* some code not shown; smartImageView is basically an instance of SmartImageView */
smartImageView.setImageUrl(data.picture);
smartImageView.setMaxHeight(10);
smartImageView.setMaxWidth(10);
What units are used as parameters for setMaxHeight()
and setMaxWidth()
or other methods for size setting?
Thanks.
When image in web-server changed,
Smart image view doesn't realize that changed.
I think, The reason is cache for super fast loading.
How can i disable using cache for super fast loading
or
realize changed-image.
My image url is "https://xxx.yyy.com/image.do?rid=hym921f2735e7df614f1982e2eaa88f720e92&a_t=RENDER_THUMBNAIL_IMAGE" . But it did not fetch the image. For security reasons I just put xxx.yyy in this issue.
But I gave "http://api.androidhive.info/images/sample.jpg" then its working fine. Have you only allow downloaded images that contain .extension like .png, , .jpg. ?
Add the cache size control.
Delete some old image when the cache size is large
And we can set the cache directory in the sdcard
Is smart image view still being updated/supported. It appears that is has not been updated in years and looking to see if it would handle images and mp4 and AndroidStudio.
hi ,
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(URL));
startActivity(Intent.createChooser(share, "Share Image"));
I want to position the image in the cache so I can share
where smart image view save image ?
i am making an app that load image form URL but in my scenario i am making dynamic layout i am not defining any view in xml.
here is my code.
SmartImageView lstimg=(SmartImageView) new ImageView(this);
lstimg.setImageUrl("http://www.pakistanimodels.pk/wp-content/uploads/2013/07/Ainy-Jaffri-Pakistani-Actress-Model-07.jpg");
img.addView(lstimg);
how can i use smart image view progmatically.?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.