Skip to content

Commit

Permalink
fix kotlin spotlessCheck
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Mayer <[email protected]>
  • Loading branch information
JonasMayerDev committed Dec 7, 2023
1 parent 73446e0 commit 95d509d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
12 changes: 8 additions & 4 deletions app/src/main/java/com/nextcloud/client/jobs/FilesUploadWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class FilesUploadWorker(
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
private val fileUploaderDelegate = FileUploaderDelegate()


override fun doWork(): Result {
val accountName = inputData.getString(ACCOUNT)
if (accountName.isNullOrEmpty()) {
Expand Down Expand Up @@ -156,7 +155,6 @@ class FilesUploadWorker(
}
}


@Suppress("TooGenericExceptionCaught")
private fun upload(uploadFileOperation: UploadFileOperation, user: User): RemoteOperationResult<Any?> {
lateinit var uploadResult: RemoteOperationResult<Any?>
Expand Down Expand Up @@ -380,10 +378,16 @@ class FilesUploadWorker(
val text = String.format(context.getString(R.string.uploader_upload_in_progress_content), percent, fileName)
notificationBuilder.setContentText(text)
notificationManager.notify(FOREGROUND_SERVICE_ID, notificationBuilder.build())
FilesUploadHelper.onTransferProgress(currentUploadFileOperation?.user?.accountName,currentUploadFileOperation?.remotePath,progressRate,totalTransferredSoFar,totalToTransfer,fileAbsoluteName)
FilesUploadHelper.onTransferProgress(
currentUploadFileOperation?.user?.accountName,
currentUploadFileOperation?.remotePath,
progressRate,
totalTransferredSoFar,
totalToTransfer,
fileAbsoluteName
)
}
lastPercent = percent

}

override fun onStopped() {
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/com/owncloud/android/utils/FilesUploadHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,39 @@ class FilesUploadHelper {

fun addDatatransferProgressListener(
listener: OnDatatransferProgressListener,
targetKey : String
targetKey: String
) {
mBoundListeners[targetKey] = listener
}

fun removeDatatransferProgressListener(
listener: OnDatatransferProgressListener,
targetKey : String
){
targetKey: String
) {
if (mBoundListeners[targetKey] === listener) {
mBoundListeners.remove(targetKey)
}
}

companion object Progress{
companion object Progress {
val mBoundListeners = HashMap<String, OnDatatransferProgressListener>()

fun onTransferProgress(accountName : String?, remotePath : String?, progressRate: Long, totalTransferredSoFar: Long, totalToTransfer: Long, fileName: String?) {
fun onTransferProgress(
accountName: String?,
remotePath: String?,
progressRate: Long,
totalTransferredSoFar: Long,
totalToTransfer: Long,
fileName: String?
) {
if (accountName == null || remotePath == null) return

val key: String =
FileUploaderBinder.buildRemoteName(accountName,remotePath)
FileUploaderBinder.buildRemoteName(accountName, remotePath)
val boundListener = mBoundListeners[key]

boundListener?.onTransferProgress(progressRate, totalTransferredSoFar, totalToTransfer, fileName)
Log_OC.d("TAG","Hello")
Log_OC.d("TAG", "Hello")
}
}

}

0 comments on commit 95d509d

Please sign in to comment.