print specific toast when download failed because of write error
This commit is contained in:
		
							parent
							
								
									594aab56db
								
							
						
					
					
						commit
						583aba1b44
					
				| @ -140,12 +140,18 @@ public class HttpDownloadConnection implements Transferable { | ||||
| 		mXmppConnectionService.updateConversationUi(); | ||||
| 	} | ||||
| 
 | ||||
| 	private class WriteException extends IOException { | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	private void showToastForException(Exception e) { | ||||
| 		e.printStackTrace(); | ||||
| 		if (e instanceof java.net.UnknownHostException) { | ||||
| 			mXmppConnectionService.showErrorToastInUi(R.string.download_failed_server_not_found); | ||||
| 		} else if (e instanceof java.net.ConnectException) { | ||||
| 			mXmppConnectionService.showErrorToastInUi(R.string.download_failed_could_not_connect); | ||||
| 		} else if (e instanceof WriteException) { | ||||
| 			mXmppConnectionService.showErrorToastInUi(R.string.download_failed_could_not_write_file); | ||||
| 		} else if (!(e instanceof  CancellationException)) { | ||||
| 			mXmppConnectionService.showErrorToastInUi(R.string.download_failed_file_not_found); | ||||
| 		} | ||||
| @ -284,11 +290,15 @@ public class HttpDownloadConnection implements Transferable { | ||||
| 					file.createNewFile(); | ||||
| 					os = AbstractConnectionManager.createOutputStream(file, true); | ||||
| 				} | ||||
| 				int count = -1; | ||||
| 				int count; | ||||
| 				byte[] buffer = new byte[1024]; | ||||
| 				while ((count = is.read(buffer)) != -1) { | ||||
| 					transmitted += count; | ||||
| 					os.write(buffer, 0, count); | ||||
| 					try { | ||||
| 						os.write(buffer, 0, count); | ||||
| 					} catch (IOException e) { | ||||
| 						throw new WriteException(); | ||||
| 					} | ||||
| 					updateProgress((int) ((((double) transmitted) / expected) * 100)); | ||||
| 					if (canceled) { | ||||
| 						throw new CancellationException(); | ||||
|  | ||||
| @ -539,6 +539,7 @@ | ||||
| 	<string name="download_failed_server_not_found">Download failed: Server not found</string> | ||||
| 	<string name="download_failed_file_not_found">Download failed: File not found</string> | ||||
| 	<string name="download_failed_could_not_connect">Download failed: Could not connect to host</string> | ||||
| 	<string name="download_failed_could_not_write_file">Download failed: Could not write file</string> | ||||
| 	<string name="pref_use_white_background">Use white background</string> | ||||
| 	<string name="pref_use_white_background_summary">Show received messages as black text on a white background</string> | ||||
| 	<string name="account_status_tor_unavailable">Tor network unavailable</string> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch