Skip to content

Commit d85fd6a

Browse files
Update README.md
1 parent 452fa46 commit d85fd6a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
11
# ImageLoaderJavaClass
22
Class that can be used to download an image and display into an ImageView or to save to a file.
3+
4+
There are 2 public functions and a Listener for callbacks
5+
6+
The first function downloadAndSaveFromUrl takes 2 parameters: a context and a url.
7+
The second function loadImageFromUrl takes 1 parameter: a url.
8+
9+
Implement the listener before calling either of these 2 functions.
10+
Example:
11+
12+
ImageLoader loader = new Loader();
13+
loader.setImageLoaderListener(new ImageLoader.ImageLoaderListener() {
14+
@Override
15+
public void onImageSaved(String filename, Bitmap bmp) {
16+
Toast.makeText(getContext(),"File Saved:" + filename,Toast.LENGTH_LONG).show();
17+
}
18+
19+
@Override
20+
public void onImageLoaded(Bitmap bmp) {
21+
22+
}
23+
24+
@Override
25+
public void onError(String error) {
26+
27+
}
28+
});
29+
loader.loadImageFromUrl(url);
30+
loader.downloadAndSaveFromUrl(getContext(), url);
31+
32+
The downloadAndSaveFromUrl will attempt to determine what the filetype is and automatically save using the appropiate compression format, otherwise, it will save the image as a PNG file.
33+
34+
ImageLoader.ImageLoaderListener is used for callbacks to notify the app that the download process has been completed. onImageSaved is fired when the Image has been successfully saved to the device storage. onImageLoaded is fired when the image is loaded into virtual memory into a bitmap object, which can then be set to be displayed in an ImageView or View of your choice. onError occurs if there was an error of any kind.

0 commit comments

Comments
 (0)