android


Universal Image Loader: Get Original height and width onClick


I use Universal Image Loader to load images in a Jsoup parsed html. The <img> tags doesn't have a static position, they can appear anywhere in the Html element. And since I want them to appear in the positions where the <img> are, I can't give them an image view.
This is the class that I'm using to load the images
public class UILImageGetter implements Html.ImageGetter, View.OnClickListener{
Context c;
TextView conatiner;
UrlImageDownloader urlDrawable;
public UILImageGetter(View textView, Context context) {
this.c = context;
this.conatiner = (TextView) textView;
}
#Override
public Drawable getDrawable(String source) {
urlDrawable = new UrlImageDownloader(c.getResources(), source);
if (Build.VERSION.SDK_INT >= 21) {
urlDrawable.mDrawable = c.getResources().getDrawable(R.drawable.default_thumb,null);
} else {
urlDrawable.mDrawable = c.getResources().getDrawable(R.drawable.default_thumb);
}
ImageLoader.getInstance().loadImage(source, new SimpleListener(urlDrawable));
return urlDrawable;
}
#Override
public void onClick(View v) {
}
private class SimpleListener extends SimpleImageLoadingListener {
UrlImageDownloader mUrlImageDownloader;
public SimpleListener(UrlImageDownloader downloader) {
super();
mUrlImageDownloader= downloader;
}
#Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
int width = loadedImage.getWidth();
int height = loadedImage.getHeight();
int newWidth = width;
int newHeight = height;
if (width > conatiner.getWidth()) {
newWidth = conatiner.getWidth();
newHeight = (newWidth * height) / width;
}
if (view != null) {
view.getLayoutParams().width = newWidth;
view.getLayoutParams().height = newHeight;
}
Drawable result = new BitmapDrawable(c.getResources(), loadedImage);
result.setBounds(0, 0, newWidth, newHeight);
mUrlImageDownloader.setBounds(0, 0, newWidth, newHeight);
mUrlImageDownloader.mDrawable = result;
conatiner.setHeight((conatiner.getHeight() + result.getIntrinsicHeight()));
//conatiner.invalidate();
}
}
private class UrlImageDownloader extends BitmapDrawable {
public Drawable mDrawable;
public UrlImageDownloader(Resources resources, String filepath) {
super(resources, filepath);
mDrawable = new BitmapDrawable(resources, filepath);
}
#Override
public void draw(Canvas canvas) {
if (mDrawable != null) {
mDrawable.draw(canvas);
}
}
}
}
My problem is how to set OnclickListener on the images and get them to display (in a dialog) the original height and width when clicked.

Related Links

Sound MediaPlayer under Android Crashed
How to listen to dev/binder?
Dynamically Load javascript files inside file:/// in android Webkit
Losing reference to Android service when returning to Activity after screen orientation change
Android Save images to SQLite or SDCard or memory
Android Listview - pointToPosition returning invalid_position
Attaching file in email
Add delay during adding of view in android
Service not available in geoCoder
Clear Edittext onclick issues
Dynamically change the text of TextView from Spinner
Android - How to do if customer wants to specify his key for exporting project to .apk?
How to measure or estimate bitmap size in Android Versions that do not support bitmap.getByteCount()
illegal instruction while running iperf
Putting included layout at top and bottom of main layout
Android TextView `ifAtLineStart` method?

Categories

HOME
hyperlink
design-patterns
gdb
developer-tools
codenvy
github-for-windows
nunit
pyqt
themes
hessian
obfuscation
oracle-apex-5
soa
mips
ado.net
tvos
bing-maps
sendgrid-api-v3
okhttp
enthought
heap
distribution
windows-ce
project-intu
redis-sentinel
ycsb
jsonpath
flash-player
flatpak
http-post
keytool
firefox-addon
foreign-keys
boost-icl
dynamically-generated
siri
opentk
jackson-modules
outliers
inversion-of-control
android-things
browser-sync
mockjax
utorrent
papaparse
hreflang
android-maps-extensions
hibernate-search
parse-tree
openproject
google-earth-engine
flatmap
claims
avcapturedevice
dynamic-linq
jboss-4.2.x
google-cse
payara-micro
reshape
offline.js
meteor-packages
builtins
seek
project-organization
lz77
nupic
jaunt-api
apache-commons-daemon
jquery-forms-plugin
java-security
mass-assignment
pseudo-class
verold
vbe
cfcache
notorm
embedded-fonts
mbunit
jeromq
printdialog
bjyauthorize
booksleeve
intersect
curb
midlet
sentestingkit
qtconcurrent
boost-msm
multiplexing
window-decoration
virtualpathprovider
workflow-services
lr
mbeans
jqueryform
addchild
duplex
pbcopy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App