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

Multiple Sliding Views Per Page
(Android) better to store a single table of data in sqlite or as a text file? [closed]
Error while running 'ionic run android'
Bring the another App in the front when receiving the broadcast
How to compute the rotation matrix as this result in Android opengl es?
How to use android camera2 api to record 60 fps video with fixed exposure time
After enabling webcam to emulator, my projects crash
Smack library warning
android - how to get the IP address of a BLE beacon device
after get an accesstoken ?in oauth
Show options spinner in action bar
Can't change target SDK in Android Studio
How to set font size in Android webView fixed , even if font size changed in Settings->Display->Font?
Azure Oauth authentication on embeded web browesers will be blocked on 20 April, 2017 warning came
Retrofit - Base URL is changed when request process is being executed
how to blur image in android and set it to relative layout

Categories

HOME
service-worker
google-cloud-platform
hyperlink
paraview
linkedin
string
fpga
interface
pascal
yahoo-finance
database-normalization
xbee
mips
tvos
iis-6
banner
lanczos
project-intu
google-form
gource
symbol
entitymanager
null-pointer
vuejs
asp.net-mvc-viewmodel
foreign-keys
nim
boost-icl
googlebot
babel
cgbitmapcontext
visual-studio-extensions
imageresizer
php-mysqlidb
froala
datastax-enterprise-graph
browser-sync
winpe
cart
kodi
quickfixj
playstation-portable
autolisp
processwire
openproject
connection-pool
protein-database
sim-card
odroid
ods
health-monitoring
demo
c9.io
setup.py
portforwarding
escpos
wmp
congestion-control
bindingnavigator
rfc3339
phpdbg
gitlist
netbeans6.8
facebook-pixel
wpas
opengl-4
ngmaterial
check-mk
oozie-coordinator
javafx-css
smartfoxserver
builtins
parfor
envi
file-uri
nikeplus-api
qiime
omniauth-facebook
createprocess
opl
ms-access-2000
android-broadcast
cocos3d
unix-socket
dct
memset
radiant
renderer
gtm-oauth2
printdialog
process-explorer
route-provider
node-blade
insert-id
wcf-configuration
appjs
stress
node-redis
automationelement
google-ajax-api
http-daemon
django-paypal
appledoc
mtu
ie-compatibility-mode
interop-domino

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