Android App Development around onwcloud as a image provider

development
android

#1

Hello, there is not much information out there for the newbies.. not even in Stack Overflow, a little background on what im trying to achieve is:

-Already managed to sync my project to the owncloud library via gradlle.
- The provided examples are not of much help for me you will see why.

I use this library https://github.com/bumptech/glide to stream images URLs to some imageviews in my app, as i was on a web server I had no problem but now that I moved to owncloud, I can do the same if i provide my app with the "download link" from the stored images.

That said, what I need is to some how be able to select the owncloud stored images(access the shared folder and download) by name and or read the download link from where ever is stored..

here is the use the glide library on my project

  String url = null;
            if (plato.getFoto_movil().equals("churrasco.jpg"))
            {
                url = "http://192.168.0.20/owncloud/index.php/s/EqX7LxLpUeBCzF4/download";
            }

            if (plato.getFoto_movil().equals("pizza.jpg"))
            {
                url = "http://192.168.0.20/owncloud/index.php/s/VGQJh6ii36PLGsN/download";
        }


            if (plato.getFoto_movil().equals("torta_chocolate.jpg"))
            {
                url = "http://192.168.0.20/owncloud/index.php/s/K0TaHRMPuMrs0Fx/download";
            }


            Glide.with(mContext).load(url).into(imageView);

which is sad because I had to manually get those URLs from my browser and it does not work with the newly added images from any othere device, so I need to be able to get any new image and show it too.

I have the library installed 100% and implemented but

        private void startDownload(String filePath, File targetDirectory) {
            DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(filePath, targetDirectory.getAbsolutePath());
            downloadOperation.addDatatransferProgressListener((OnDatatransferProgressListener) mContext);
            downloadOperation.execute( mClient, (OnRemoteOperationListener) mContext, mHandler);
        }

        @Override
        public void onTransferProgress(long l, long l1, long l2, String s) {
            mHandler.post( new Runnable() {
                @Override
                public void run() {
                    // do your UI updates about progress here
                }
            });
        }

        @Override
        public void onRemoteOperationFinish(RemoteOperation remoteOperation, RemoteOperationResult remoteOperationResult) {
            if (remoteOperation instanceof DownloadRemoteFileOperation) {
                if (remoteOperationResult.isSuccess()) {
                }
            }
        }

got those and

got also this two
mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri,mContext,true);
mClient.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials(username,password));

then I call the method

        startDownload(plato.getFoto_movil(),downloadfolder);

the app crashes here when I call the startdowonload method
with the error java.lang.ClassCastException: com.eidotab.eidotab.MainActivity cannot be cast to com.owncloud.android.lib.common.network.OnDatatransferProgressListener

and even if it does have success, donĀ“t know where or how to get the download links, like I said, I need the download link from every image stored in the server..

is this possible?

thanks in advance


#2

Got an update, managed to solve the downloading issue, and got the files downloading to my internal sd card, is not the best solution but, im ok with it, the problem was that i was implementing the methos to a recyclerview and the must be implemented in an activity... and well.. case closed, thanks