mhdjazmati
mhdjazmati

Reputation: 4232

Load Dropbox Photos With Picasso?

I have a problem when wanna get my photos from dropbox and load it into GridView and i want use Picasso in adapter too. method load() will take a downloadable URL ,

PS: i'm using Dropbox Android SDK 1.6.1

if i used method media() and fetch url from dropbox like that :

// Get the metadata for a directory , | request |
DropboxAPI.Entry dirent = Log_in.mApi.metadata(Log_in.APP_DIR + "/images/", 1000, null, true, null);
if (!dirent.isDir || dirent.contents == null) {
    // It's not a directory, or there's nothing in it
    mErrorMsg = "File or empty directory";
    //return false;
}

// Make a list of everything in it that we can get a thumbnail for
thumbs = new ArrayList<>();
imagePath = new ArrayList<>();
for (DropboxAPI.Entry ent : dirent.contents) {
    if (ent.thumbExists) {
        // Add it to the list of thumbs we can choose from
        thumbs.add(ent);
        // do another requests (many requests to dropbox to get the urls , and this is terrible it takes request time for each image !
            imagePath.add(Log_in.mApi.media(ent.path,true).url);
        }
    }

it is not practicle at all cuz it would take so much time to get every url this is the scenario :

  1. Search images in Photos folder (1 request)
  2. Using [media][1] for getting direct URL (1 * (images) requests)
  3. Using Picasso in adapter (1 * (images) requests) I will have count(images) * 2 + 1 requests count

it is terrible , need a better solution .

PS : i tried this https://medium.com/@jpardogo/requesthandler-api-for-picasso-library-c3ee7c4bec25#.wpmea1eci

but the code is not complete there is some classes not resolved/exist and some variables not defined .

so any one got an idea on how to work with dropbox images api using picasso .

Upvotes: 0

Views: 712

Answers (1)

Eko Putra Pratama
Eko Putra Pratama

Reputation: 377

i think there is a sample from dropbox about this, try to check this link dropbox sample

there is 2 files that you need to see PicassoClient.java And FileThumbnailRequestHandler.java

Upvotes: 1

Related Questions