first download & preview scratch, removing unused code, changing noncompatible code
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / FileDownloader.java
index 87e8d96..3245be1 100644 (file)
@@ -8,6 +8,7 @@ import android.app.Notification;
 import android.app.NotificationManager;\r
 import android.app.PendingIntent;\r
 import android.app.Service;\r
+import android.content.ContentValues;\r
 import android.content.Intent;\r
 import android.net.Uri;\r
 import android.os.Binder;\r
@@ -20,6 +21,8 @@ import android.os.Message;
 import android.os.Process;\r
 import android.util.Log;\r
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
+import eu.alefzero.owncloud.db.DbHandler;\r
+import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;\r
 import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
@@ -71,8 +74,7 @@ public class FileDownloader extends Service {
     Message msg = mServiceHandler.obtainMessage();\r
     msg.arg1 = startId;\r
     mServiceHandler.sendMessage(msg);\r
-    \r
-    \r
+\r
     return START_NOT_STICKY;\r
   }\r
   \r
@@ -87,7 +89,6 @@ public class FileDownloader extends Service {
     try {\r
       password = am.blockingGetAuthToken(mAccount, AccountAuthenticator.AUTH_TOKEN_TYPE, true);\r
     } catch (Exception e) {\r
-      // TODO Auto-generated catch block\r
       e.printStackTrace();\r
     }\r
     \r
@@ -105,6 +106,12 @@ public class FileDownloader extends Service {
     File file = new File(dir, mFilePath.replace('/', '.'));\r
     \r
     wdc.downloadFile(mFilePath, file);\r
+    ContentValues cv = new ContentValues();\r
+    cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getAbsolutePath());\r
+    getContentResolver().update(ProviderTableMeta.CONTENT_URI,\r
+        cv,\r
+        ProviderTableMeta.FILE_NAME +"=? AND "+ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",\r
+        new String[]{mFilePath.substring(mFilePath.lastIndexOf('/')+1), mAccount.name});\r
     nm.cancel(1);\r
   }\r
   \r