GithubHelp home page GithubHelp logo

loopj / android-smart-image-view Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 510.0 18 KB

Android ImageView replacement which allows image loading from URLs or contact address book, with caching

Home Page: http://loopj.com/android-smart-image-view/

Java 100.00%

android-smart-image-view's People

Contributors

aisipos avatar loopj avatar rutvijkumarshah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-smart-image-view's Issues

Weird and sharp behavior

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 !

Progress Indicator?

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.

Out of Memory Error

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.

Crash Aplicattion

.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

Out of memory when loading in big list view

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.

Very choppy scrolling in a ListView with SmartImageView

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):

  • ViewHolder for all views
  • ViewHolder stores reference to current URL, so as long as URL didn't change, it won't refresh (this helps if the list refreshes with new data, but the same order of rows)
  • Loading thumbnail images (256x256), so minimal resizing or cropping

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!

Request: A way to run code when downloading from url is finished

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

I build a HTTP server in local,then use SmartImageView.setImageUrl(String url)

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)

How to set a progressloader for Images in ListView

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>

a suggestion for docs

Permissions using the following suggestions to use the document to add a description.

Bitmaps are extremely low quality

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.

Error when saving cache file for very long URL: ENAMETOOLONG (File name too long)

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.

While scrolling images in list view is disturbed.

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

VideoThumbnailImage

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.

Cache removal control

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.

geographique card

I want using geographique card with levels of zoom and don't know from where I start

Some images are loaded as ColorDrawable while some as BitmapDrawable

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.

Display wrong image

I have a list of contacts.
In listView's Adapter, i check if contact have image not null or empty.

  • If yes -> display default image with : contactImage.setImageResource(R.drawable.nophoto);
  • If no -> display image with contact's image : contactImage.setImageUrl(image);

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);
}

Can you help me this ? Thanks a lots.


Untitled

Does not escape urls, FileNotFoundException

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

Crash application

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>

Still OutOfMemory issues

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.

Gradle dependencie

Could you make this includable as a gradle dependencie? Same as Android Asynchronous Http Client

Cannot run in Android Studio?

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~~

android_debug_monitor

Update cached image

Would be good to be able to easily redownload the image and i.e. update the cache when 'called'

sway in gallery when move it

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));

Add license information to source, GitHub repo

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.

Use OkHttp

It handles caching and uses SPDY when possible.

Regard to APK File

Hello Sir,
Please Attach Apk File with Demo Zip if Possible Because of this We Can Check Apk File Before Use Code..

Out of memory

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?

Scaling of images

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.

How can i disable using cache for super fast loading

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.

cache size control

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

Still supported

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.

share (not working) mms

hi ,

when i try share image

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.