Try to reproduce 'Twitter style': notify success and then remove the notification...
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / services / FileDownloader.java
index 7a03135..b525bc4 100644 (file)
@@ -494,29 +494,28 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 mDownloadClient = null;   // grant that future retries on the same account will get the fresh credentials
                 
             } else {
-                Intent showDetailsIntent = null;
-                if (downloadResult.isSuccess()) {
-                    if (PreviewImageFragment.canBePreviewed(download.getFile())) {
-                        showDetailsIntent = new Intent(this, PreviewImageActivity.class);
-                    } else {
-                        showDetailsIntent = new Intent(this, FileDisplayActivity.class);
-                    }
-                    showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
-                    showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
-                    showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-                    
-                } else {
-                    // TODO put something smart in showDetailsIntent
-                    showDetailsIntent = new Intent();
-                }
+                // TODO put something smart in showDetailsIntent
+                Intent   showDetailsIntent = new Intent();
                 mNotificationBuilder
                     .setContentIntent(PendingIntent.getActivity(
                         this, (int) System.currentTimeMillis(), showDetailsIntent, 0));
             }
             
             mNotificationBuilder.setContentText(ErrorMessageAdapter.getErrorCauseMessage(downloadResult, download, getResources()));
-            
             mNotificationManager.notify(tickerId, mNotificationBuilder.build());
+            
+            // Remove success notification
+            if (downloadResult.isSuccess()) {   
+                // Sleep 2 seconds, so show the notification before remove it
+                Handler handler = new Handler(); 
+                handler.postDelayed(new Runnable() { 
+                     public void run() { 
+                         mNotificationManager.cancel(R.string.downloader_download_succeeded_ticker);
+                     } 
+                }, 2000); 
+                
+            }
+                
         }
     }