Merge remote-tracking branch 'upstream/develop' into triggerMediaScan
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / preview / PreviewImageActivity.java
index c06f341..09c2f58 100644 (file)
@@ -23,6 +23,9 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.media.MediaScannerConnection;
+import android.media.MediaScannerConnection.OnScanCompletedListener;
+import android.net.Uri;
 import android.content.SharedPreferences;
 import android.os.Build;
 import android.os.Bundle;
@@ -432,6 +435,9 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
         public void onReceive(Context context, Intent intent) {
             String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
             String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
+            
+            
+            
             if (getAccount().name.equals(accountName) && 
                     downloadedRemotePath != null) {
 
@@ -440,6 +446,14 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
                 boolean downloadWasFine = intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false);
                 //boolean isOffscreen =  Math.abs((mViewPager.getCurrentItem() - position)) <= mViewPager.getOffscreenPageLimit();
                 
+                if (downloadWasFine){
+                 // Trigger Mediascan
+                    MediaScannerConnection.scanFile(
+                            context, 
+                            new String[]{file.getStoragePath()}, 
+                            null,null);
+                }
+                
                 if (position >= 0 && intent.getAction().equals(FileDownloader.getDownloadFinishMessage())) {
                     if (downloadWasFine) {
                         mPreviewImagePagerAdapter.updateFile(position, file);