billyyoyo 6 роки тому
батько
коміт
9d8c4969c3

+ 8 - 5
app/src/main/java/com/sheep/jiuyan/samllsheep/service/DownloadService.java

@@ -416,10 +416,6 @@ public class DownloadService extends Service {
             Intent din = new Intent(SheepApp.getInstance(), DownloadService.class).putExtra("download_id", id).putExtra("download_url", task.getUrl());
             Intent din = new Intent(SheepApp.getInstance(), DownloadService.class).putExtra("download_id", id).putExtra("download_url", task.getUrl());
             PendingIntent delIntent = PendingIntent.getService(SheepApp.getInstance(), 0, din, PendingIntent.FLAG_UPDATE_CURRENT);
             PendingIntent delIntent = PendingIntent.getService(SheepApp.getInstance(), 0, din, PendingIntent.FLAG_UPDATE_CURRENT);
             view.setOnClickPendingIntent(R.id.delete_btn, delIntent);
             view.setOnClickPendingIntent(R.id.delete_btn, delIntent);
-
-            Intent iin = new Intent(SheepApp.getInstance(), DownloadService.class).putExtra("install_path", task.getFile().getAbsolutePath()).putExtra("download_url", task.getUrl());
-            PendingIntent installIntent = PendingIntent.getService(SheepApp.getInstance(), 0, iin, PendingIntent.FLAG_UPDATE_CURRENT);
-            view.setOnClickPendingIntent(R.id.body_view, installIntent);
         }
         }
 
 
         public void refreshProgress(long offset) {
         public void refreshProgress(long offset) {
@@ -428,6 +424,9 @@ public class DownloadService extends Service {
             if (progress == 100) {
             if (progress == 100) {
                 view.setTextViewText(R.id.title_view, SheepApp.getInstance().getString(R.string.app_name) + "下载完成");
                 view.setTextViewText(R.id.title_view, SheepApp.getInstance().getString(R.string.app_name) + "下载完成");
                 completed = true;
                 completed = true;
+                Intent iin = new Intent(SheepApp.getInstance(), DownloadService.class).putExtra("install_path", task.getFile().getAbsolutePath()).putExtra("download_url", task.getUrl());
+                PendingIntent installIntent = PendingIntent.getService(SheepApp.getInstance(), 0, iin, PendingIntent.FLAG_UPDATE_CURRENT);
+                view.setOnClickPendingIntent(R.id.title_view, installIntent);
             }
             }
             notificationManager.notify(id, notification);
             notificationManager.notify(id, notification);
         }
         }
@@ -440,6 +439,7 @@ public class DownloadService extends Service {
         }
         }
 
 
         public static void install(String url, String path) {
         public static void install(String url, String path) {
+            LogUtil.logE("Download install path: " + path);
             DownloadNotification notification = notificationMap.get(url);
             DownloadNotification notification = notificationMap.get(url);
             if (notification != null && notification.completed) {
             if (notification != null && notification.completed) {
                 notificationMap.remove(url);
                 notificationMap.remove(url);
@@ -448,21 +448,24 @@ public class DownloadService extends Service {
                 if (nMgr != null) {
                 if (nMgr != null) {
                     nMgr.cancel(notification.id);
                     nMgr.cancel(notification.id);
                 }
                 }
-                LogUtil.logE("Download install path: " + path);
                 ApkUtils.installApk(SheepApp.getInstance(), path);
                 ApkUtils.installApk(SheepApp.getInstance(), path);
             }
             }
         }
         }
 
 
         public static void delete(String url) {
         public static void delete(String url) {
+            LogUtil.logE("Download delete url: " + url);
             DownloadNotification notification = notificationMap.get(url);
             DownloadNotification notification = notificationMap.get(url);
             if (notification != null) {
             if (notification != null) {
+                LogUtil.logE("Download delete entity");
                 notificationMap.remove(url);
                 notificationMap.remove(url);
                 notification.task.cancel();
                 notification.task.cancel();
                 if (notification.task.getFile().exists()) {
                 if (notification.task.getFile().exists()) {
+                    LogUtil.logE("Download delete file");
                     notification.task.getFile().delete();
                     notification.task.getFile().delete();
                 }
                 }
                 NotificationManager nMgr = (NotificationManager) SheepApp.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
                 NotificationManager nMgr = (NotificationManager) SheepApp.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
                 if (nMgr != null) {
                 if (nMgr != null) {
+                    LogUtil.logE("Download delete notification");
                     nMgr.cancel(notification.id);
                     nMgr.cancel(notification.id);
                 }
                 }
             }
             }