|  |  |  | @ -223,6 +223,8 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private boolean isReDownload; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private boolean isDeleteCancelFile; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private UpdateCallback callback; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -251,6 +253,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             this.isShowPercentage = config.isShowPercentage(); | 
			
		
	
		
			
				
					|  |  |  |  |             this.isReDownload = config.isReDownload(); | 
			
		
	
		
			
				
					|  |  |  |  |             this.isDeleteCancelFile = config.isDeleteCancelFile(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -314,7 +317,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public void onError(Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |             Log.w(Constants.TAG,e); | 
			
		
	
		
			
				
					|  |  |  |  |             Log.w(Constants.TAG,"onError:"+ e.getMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |             isDownloading = false; | 
			
		
	
		
			
				
					|  |  |  |  |             //支持下载失败重新并最多支持失败下载3次
 | 
			
		
	
		
			
				
					|  |  |  |  |             boolean isReDownload = this.isReDownload && mCount < 3; | 
			
		
	
	
		
			
				
					|  |  |  | @ -338,7 +341,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  |             if(callback!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |                 callback.onCancel(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if(mFile!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |             if(isDeleteCancelFile && mFile!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |                 mFile.delete(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             stopService(); | 
			
		
	
	
		
			
				
					|  |  |  | @ -368,6 +371,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  |             createNotificationChannel(channelId,channelName,isVibrate,isSound); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         NotificationCompat.Builder builder = buildNotification(channelId,icon,title,content); | 
			
		
	
		
			
				
					|  |  |  |  |         builder.setPriority(NotificationManager.IMPORTANCE_HIGH); | 
			
		
	
		
			
				
					|  |  |  |  |         if(isVibrate && isSound){ | 
			
		
	
		
			
				
					|  |  |  |  |             builder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND); | 
			
		
	
		
			
				
					|  |  |  |  |         }else if(isVibrate){ | 
			
		
	
	
		
			
				
					|  |  |  | @ -375,6 +379,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  |         }else if(isSound){ | 
			
		
	
		
			
				
					|  |  |  |  |             builder.setDefaults(Notification.DEFAULT_SOUND); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Notification notification = builder.build(); | 
			
		
	
		
			
				
					|  |  |  |  |         notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONLY_ALERT_ONCE; | 
			
		
	
		
			
				
					|  |  |  |  |         notifyNotification(notifyId,notification); | 
			
		
	
	
		
			
				
					|  |  |  | @ -392,6 +397,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private void showProgressNotification(int notifyId,String channelId,@DrawableRes int icon,CharSequence title,CharSequence content,int progress,int size){ | 
			
		
	
		
			
				
					|  |  |  |  |         NotificationCompat.Builder builder = buildNotification(channelId,icon,title,content,progress,size); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Notification notification = builder.build(); | 
			
		
	
		
			
				
					|  |  |  |  |         notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONLY_ALERT_ONCE; | 
			
		
	
		
			
				
					|  |  |  |  |         notifyNotification(notifyId,notification); | 
			
		
	
	
		
			
				
					|  |  |  | @ -478,7 +484,7 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     @RequiresApi(api = Build.VERSION_CODES.O) | 
			
		
	
		
			
				
					|  |  |  |  |     private void createNotificationChannel(String channelId, String channelName,boolean isVibrate,boolean isSound){ | 
			
		
	
		
			
				
					|  |  |  |  |         NotificationChannel channel = new NotificationChannel(channelId,channelName, NotificationManager.IMPORTANCE_DEFAULT); | 
			
		
	
		
			
				
					|  |  |  |  |         NotificationChannel channel = new NotificationChannel(channelId,channelName, NotificationManager.IMPORTANCE_HIGH); | 
			
		
	
		
			
				
					|  |  |  |  |         channel.enableVibration(isVibrate); | 
			
		
	
		
			
				
					|  |  |  |  |         if(!isSound){ | 
			
		
	
		
			
				
					|  |  |  |  |             channel.setSound(null,null); | 
			
		
	
	
		
			
				
					|  |  |  | @ -562,4 +568,4 @@ public class DownloadService extends Service { | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | } |