WearImageLoader is an image downloading and caching library for Android Wear
Use WearImageLoader from your SmartWatch app
Loader.with(context).load("/image/0").into(imageView);
Loader.with(context).load("http://i.imgur.com/o3ELrbX.jpg").into(imageView);
Into an imageview
Loader.with(context).load("/image/0").into(imageView);
Into a FragmentGridPagerAdapter
@Override
public Drawable getBackgroundForRow(final int row) {
return Loader.with(context).load("/image/" + row).into(this, row);
}
Into a CallBack
Loader.with(context).load("http://i.imgur.com/o3ELrbX.jpg").into(new WearImageLoader.Callback() {
@Override
public void onBitmapLoaded(String path, Bitmap bitmap) {
}
});
By default, the asset name used for the bitmap is "image", you can modify this
Loader.with(context).load("/image/0").setImageAssetName("myImage").into(imageView);
In your smartphone service
@Override
public void onMessageReceived(MessageEvent messageEvent) {
super.onMessageReceived(messageEvent);
Daemon.with(getApplicationContext()).handleMessage(messageEvent);
...
}
Send image to wear
Daemon.with(getApplicationContext()).load("http://i.imgur.com/o3ELrbX.jpg").send();
or with "/image/0" path
Daemon.with(getApplicationContext()).load("http://i.imgur.com/o3ELrbX.jpg").into("/image/0");
You can specify custom transformations on your Bitmaps
public class ResizeTransformation implements Transformation {
private int targetWidth;
public ResizeTransformation(int width) {
this.targetWidth = width;
}
@Override
public Bitmap transform(Bitmap source) {
double aspectRatio = (double) source.getHeight() / (double) source.getWidth();
int targetHeight = (int) (targetWidth * aspectRatio);
Bitmap result = Bitmap.createScaledBitmap(source, targetWidth, targetHeight, false);
if (result != source) {
// Same bitmap is returned if sizes are the same
source.recycle();
}
return result;
}
@Override
public String key() {
return "ResizeTransformation"+targetWidth;
}
}
Pass an instance of this class to the transform method
Loader.with(context).load(url).transform(new ResizeTransformation(300)).into(imageView);
Prodvided Transformations :
Blur
Loader.with(context).load(url).transform(new BlurTransformation()).into(imageView);
Resizing
Loader.with(context).load(url).transform(new ResizeTransformation(maxWidth)).into(imageView);
Add in your root build.gradle at the end of repositories
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
In your wear module
compile 'de.mdxdave.WearImageLoader:Loader:1.1.1';
In your smartphone module
compile 'de.mdxdave.WearImageLoader:Daemon:1.1.1';
Don't forget to add WRITE_EXTERNAL_STORAGE in your Wear AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- Customize bitmap resizing (actually : width=300px)
- Enabling multiples transformations
- Apply transformations on Smartphone then send them to Wear
- Picasso used in DaVinciDaemon (from Square)
- DiskLruCache used in DaVinci (from JakeWharton)
1.1.2
- Bugfixes
1.1.1
- Made runnable again
Author: Florent Champigny www.florentchampigny.com/ Updated by: MDXDave https://mdxdave.de
Pictures by Logan Bourgouin

Copyright 2015 florent37, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.