DaVinci is an image downloading and caching library for Android Wear

Related tags

ViewPager DaVinci
Overview

DaVinci

Android Arsenal Android Weekly

Alt DaVinciDroid

DaVinci is an image downloading and caching library for Android Wear

Android app on Google Play

Usage

Use DaVinci from your SmartWatch app

DaVinci.with(context).load("/image/0").into(imageView);
DaVinci.with(context).load("http://i.imgur.com/o3ELrbX.jpg").into(imageView);

Into an imageview

DaVinci.with(context).load("/image/0").into(imageView);

Into a FragmentGridPagerAdapter

@Override
public Drawable getBackgroundForRow(final int row) {
    return DaVinci.with(context).load("/image/" + row).into(this, row);
}

Into a CallBack

DaVinci.with(context).load("http://i.imgur.com/o3ELrbX.jpg").into(new DaVinci.Callback() {
            @Override
            public void onBitmapLoaded(String path, Bitmap bitmap) {

            }
});

By default, the asset name used for the bitmap is "image", you can modify this

DaVinci.with(context).load("/image/0").setImageAssetName("myImage").into(imageView);

Send Bitmaps

In your smartphone service

    @Override
    public void onMessageReceived(MessageEvent messageEvent) {
        super.onMessageReceived(messageEvent);
        DaVinciDaemon.with(getApplicationContext()).handleMessage(messageEvent);
        ...
    }

Preload Bitmaps

Send image to wear

DaVinciDaemon.with(getApplicationContext()).load("http://i.imgur.com/o3ELrbX.jpg").send();

or with "/image/0" path

DaVinciDaemon.with(getApplicationContext()).load("http://i.imgur.com/o3ELrbX.jpg").into("/image/0");

Image Transformation

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

DaVinci.with(context).load(url).transform(new ResizeTransformation(300)).into(imageView);

Prodvided Transformations :

Blur

DaVinci.with(context).load(url).transform(new BlurTransformation()).into(imageView);

Resizing

DaVinci.with(context).load(url).transform(new ResizeTransformation(maxWidth)).into(imageView);

Download

In your wear module Download

compile ('com.github.florent37:davinci:1.0.3@aar'){
    transitive = true
}

In your smartphone module Download

compile ('com.github.florent37:davincidaemon:1.0.3@aar'){
     transitive = true
}

Don't forget to add WRITE_EXTERNAL_STORAGE in your Wear AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

TODO

  • Customize bitmap resizing (actually : width=300px)
  • Enabling multiples transformations
  • Apply transformations on Smartphone then send them to Wear

Community

Looking for contributors, feel free to fork !

Wear

If you want to learn wear development : http://tutos-android-france.com/developper-une-application-pour-les-montres-android-wear/.

Dependencies

Changelog

1.0.2

  • Bitmaps are now saved as PNG to preserve transparency

Credits

Author: Florent Champigny www.florentchampigny.com/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

Pictures by Logan Bourgouin

Follow me on Google+

License

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.
You might also like...
Circular motion is a ViewPager library that can be used to make Awesome Onboarding designs.

CircularMotion Android Circular Motion Onboarding library Circular motion is a ViewPager library that can be used to make Awesome Onboarding designs.

A nicer-looking, more intuitive and highly customizable alternative for radio buttons and dropdowns for Android.
A nicer-looking, more intuitive and highly customizable alternative for radio buttons and dropdowns for Android.

SwipeSelector Undergoing for some API changes for a 2.0 major version, see example usage in the sample module! What and why? Bored of dull looking rad

Silver is a programming language designed to have the look and feel of python combined with the simplicity and efficiency of C, combined with a rich plugin system for extending the capabilities of the language
Silver is a programming language designed to have the look and feel of python combined with the simplicity and efficiency of C, combined with a rich plugin system for extending the capabilities of the language

Silver Programming Language Silver is a programming language designed to resemble Python with some C features, packed with a rich plugin system. Contr

[Development stopped in 2014. Unfinished and not stable - not recommended to use.] An easy-to-use ViewPager subclass with parallax background effect for Android apps.

Development stopped in 2014 Not developed since 2014. Unfinished and not stable - not recommended to use. ParallaxViewPager An easy-to-use ViewPager s

Android - A ViewPager page indicator that displays the current page number and (optionally) the page count
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count

NumericPageIndicator A ViewPager page indicator that displays the current page number and (optionally) the page count. It can also display buttons to

PagedGrid - Custom android view composed by multiple page grids with custom content and layout
PagedGrid - Custom android view composed by multiple page grids with custom content and layout

PagedGrid A PagedGrid is a ViewPager which pages are GridLayout with equal distributed rows and columns. This project is an Android library, written i

Combine ViewPager and Animations to provide a simple way to create applications' guide pages.
Combine ViewPager and Animations to provide a simple way to create applications' guide pages.

WoWoViewPager WoWoViewPager combines ViewPager and Animations to provide a simple way to create applications' guide pages. When users are dragging WoW

Put some bubble in your tabs and give your apps a supa fresh style !
Put some bubble in your tabs and give your apps a supa fresh style !

BubbleTab Put some bubble in your tabs and give your apps a supa fresh style ! Usage Add a BubbleTab with your icons on the layout.xml Customisable pa

Three material Dots Indicators for view pagers in Android !
Three material Dots Indicators for view pagers in Android !

Material View Pager Dots Indicator This library makes it possible to represent View Pager Dots Indicator with 3 different awesome styles ! It supports

Comments
  • Getting Runtime Exception with Regular Use

    Getting Runtime Exception with Regular Use

    java.lang.RuntimeException: An error occured while executing doInBackground()
                at android.os.AsyncTask$3.done(AsyncTask.java:300)
                at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                at java.lang.Thread.run(Thread.java:818)
         Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap com.github.florent37.davinci.DiskLruImageCache.getBitmap(java.lang.String)' on a null object reference
                at com.github.florent37.davinci.DaVinci.loadFromDiskLruCache(DaVinci.java:475)
                at com.github.florent37.davinci.DaVinci.loadFromLruCache(DaVinci.java:461)
                at com.github.florent37.davinci.DaVinci.loadImage(DaVinci.java:359)
                at com.github.florent37.davinci.DaVinci.access$000(DaVinci.java:44)
                at com.github.florent37.davinci.DaVinci$1.doInBackground(DaVinci.java:183)
                at com.github.florent37.davinci.DaVinci$1.doInBackground(DaVinci.java:180)
                at android.os.AsyncTask$2.call(AsyncTask.java:288)
                at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                at java.lang.Thread.run(Thread.java:818)
    

    Using the simple code in a fragment on the watch

    ImageView logoView = (ImageView) mRootView.findViewById(R.id.brewery_logo);
    DaVinci.with(getActivity()).load("/image/0").into(logoView);
    

    I'm curious if maybe I'm not including this correctly? Any help would be an incredible help!

    Thanks!

    opened by Spittal 4
  • Add a Gitter chat badge to README.md

    Add a Gitter chat badge to README.md

    florent37/DaVinci now has a Chat Room on Gitter

    @florent37 has just created a chat room. You can visit it here: https://gitter.im/florent37/DaVinci.

    This pull-request adds this badge to your README.md:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 0
  • Support for newer Google Play Services

    Support for newer Google Play Services

    Every time I try to use the library, I get the following error: java.lang.IncompatibleClassChangeError: The method 'void com.google.android.gms.common.api.GoogleApiClient.connect()' was expected to be of type interface but instead was found to be of type virtual

    Is there any way to handle this other than downgrading to lower google play services?

    opened by dmacan23 1
  • Image from URL not loading

    Image from URL not loading

    Thanks for putting this together. I've been struggling with getting assets to transfer over from phone to Wear and this looked like a great solution. Alas, however, I can't get it to work. I'm calling it in my wear Activity like this:

    DaVinci.with(MainWearActivity.this).load("https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg").into(mImageViewPhoto);

    This is the output I see in logcat:

    10-30 12:28:43.266 9893-9893/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ ==================================== 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ load(https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg) 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ key https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg = /davinci/-1310403522 key=-558596910 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ key for https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg is -558596910 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ bitmap https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg from lruCache [-558596910] null 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ try to load from disk cache -558596910 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ bitmap https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg from diskLruCache null 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ bitmap from cache null for https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ image https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg not available in the cache, trying to download it 10-30 12:28:43.302 9893-11774/com.coffeemeetsbagel D/com.github.florent37.davinci.DaVinci﹕ loadImage https://d1ghufavkue0e7.cloudfront.net/cache/81/2f/812f6daa34dd1c9c29b5709c5b686f30.jpg send request to smartphone -1310403522

    Image never comes in. Any help appreciated!

    opened by kvarela 1
Releases(1.0.2)
Pixplicity 915 Nov 8, 2022
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Ian Thomas 2.5k Dec 31, 2022
ViewPagers library for Android

freepager Ready-to-use view pagers for your project. Based on Swipes navigation demo repository Usage: Gradle: dependencies { compile 'pro.alexza

Alex Zaitsev 460 Nov 25, 2022
Android library for fluid tablayout animation as seen on Snapchat.

SnapTabLayout Show some ❤️ and star the repo to support the project This library is the implementation of TabLayout as seen on popular messaging app S

Niranjan Kurambhatti 714 Dec 25, 2022
Android LiquidSwipe Library

Android LiquidSwipe Library

Chrisvin Jem 838 Dec 29, 2022
Android Concentric Onboarding library

Android Concentric Onboarding library

Chrisvin Jem 50 Sep 13, 2022
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

Florent CHAMPIGNY 8.2k Dec 29, 2022
Library for Sliding Tab With Color Icons!

Sliding Tab With Color Icons Sliding Tab With Color Icons! Kindly use the following links to use this library: In build.gradle (Project) allprojects {

Prabhakar Thota 35 Jan 22, 2022
A simple app that consumes The Ricky & Morty API to display the tv show characters, was trying to learn about pagination with the paging 3 library

Ricky&MortyAPIDemo A simple app that consumes The Rick and Morty API which is a REST and GraphQL API based on the television show Rick and Morty. I wa

Joel Kanyi 9 Jul 12, 2022
LiquidSwipe is a ViewPager library that can be used to make Awesome Onboarding designs.

LiquidSwipe LiquidSwipe is a ViewPager library that can be used to make Awesome Onboarding designs. Usage Set up the dependency Add the mavenCentral()

Farham Hosseini 4 Nov 5, 2021