From ba96a97785d427192fe31ee43373487ca113952f Mon Sep 17 00:00:00 2001 From: Xiang Fan Date: Sat, 30 Dec 2017 19:32:46 +0800 Subject: [PATCH] UploadController: add javadoc --- .../nrw/commons/upload/UploadController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/src/main/java/fr/free/nrw/commons/upload/UploadController.java b/app/src/main/java/fr/free/nrw/commons/upload/UploadController.java index 1d080e78f..d2119dfc3 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/UploadController.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/UploadController.java @@ -36,6 +36,9 @@ public class UploadController { void onUploadStarted(Contribution contribution); } + /** + * Constructs a new UploadController. + */ public UploadController(SessionManager sessionManager, Context context, SharedPreferences sharedPreferences) { this.sessionManager = sessionManager; this.context = context; @@ -57,6 +60,9 @@ public class UploadController { } }; + /** + * Prepares the upload service. + */ public void prepareService() { Intent uploadServiceIntent = new Intent(context, UploadService.class); uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE); @@ -64,12 +70,25 @@ public class UploadController { context.bindService(uploadServiceIntent, uploadServiceConnection, Context.BIND_AUTO_CREATE); } + /** + * Disconnects the upload service. + */ public void cleanup() { if (isUploadServiceConnected) { context.unbindService(uploadServiceConnection); } } + /** + * Starts a new upload task. + * @param title the title of the contribution + * @param mediaUri the media URI of the contribution + * @param description the description of the contribution + * @param mimeType the MIME type of the contribution + * @param source the source of the contribution + * @param decimalCoords the coordinates in decimal. (e.g. "37.51136|-77.602615") + * @param onComplete the progress tracker + */ public void startUpload(String title, Uri mediaUri, String description, String mimeType, String source, String decimalCoords, ContributionUploadProgress onComplete) { Contribution contribution; @@ -85,6 +104,11 @@ public class UploadController { startUpload(contribution, onComplete); } + /** + * Starts a new upload task. + * @param contribution the contribution object + * @param onComplete the progress tracker + */ public void startUpload(final Contribution contribution, final ContributionUploadProgress onComplete) { //Set creator, desc, and license if (TextUtils.isEmpty(contribution.getCreator())) { @@ -173,6 +197,12 @@ public class UploadController { } + /** + * Counts the number of bytes in {@code stream}. + * @param stream the stream + * @return the number of bytes in {@code stream} + * @throws IOException if an I/O error occurs + */ private long countBytes(InputStream stream) throws IOException { long count = 0; BufferedInputStream bis = new BufferedInputStream(stream);