Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make injected variables lateinit #12120

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,17 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
private var conflictUploadId: Long = 0
var mStartedDownload = false

@JvmField
@Inject
var accountManager: UserAccountManager? = null
lateinit var accountManager: UserAccountManager

@JvmField
@Inject
var uploadsStorageManager: UploadsStorageManager? = null
lateinit var uploadsStorageManager: UploadsStorageManager

@JvmField
@Inject
var localBroadcastManager: LocalBroadcastManager? = null
lateinit var localBroadcastManager: LocalBroadcastManager

@JvmField
@Inject
var viewThemeUtils: ViewThemeUtils? = null
lateinit var viewThemeUtils: ViewThemeUtils

/**
* Service initialization
Expand Down Expand Up @@ -272,7 +268,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda

override fun onAccountsUpdated(accounts: Array<Account>) {
// review the current download and cancel it if its account doesn't exist
if (mCurrentDownload != null && !accountManager!!.exists(mCurrentDownload!!.user.toPlatformAccount())) {
if (mCurrentDownload != null && !accountManager.exists(mCurrentDownload!!.user.toPlatformAccount())) {
mCurrentDownload!!.cancel()
}
// The rest of downloads are cancelled when they try to start
Expand Down Expand Up @@ -436,15 +432,15 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
mCurrentDownload = mPendingDownloads[downloadKey]

if (mCurrentDownload != null) {
val isAccountExist = accountManager?.exists(mCurrentDownload!!.user.toPlatformAccount())
val isAccountExist = accountManager.exists(mCurrentDownload!!.user.toPlatformAccount())

if (isAccountExist == true) {
notifyDownloadStart(mCurrentDownload!!)
var downloadResult: RemoteOperationResult<*>? = null
try {
// / prepare client object to send the request to the ownCloud server
val currentDownloadAccount = mCurrentDownload!!.user.toPlatformAccount()
val currentDownloadUser = accountManager!!.getUser(currentDownloadAccount.name)
val currentDownloadUser = accountManager.getUser(currentDownloadAccount.name)
if (currentUser != currentDownloadUser) {
currentUser = currentDownloadUser
mStorageManager = FileDataStorageManager(currentUser.get(), contentResolver)
Expand Down Expand Up @@ -592,7 +588,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
if (!downloadResult.isCancelled) {
if (downloadResult.isSuccess) {
if (conflictUploadId > 0) {
uploadsStorageManager!!.removeUpload(conflictUploadId)
uploadsStorageManager.removeUpload(conflictUploadId)
}
// Don't show notification except an error has occurred.
return
Expand Down Expand Up @@ -701,7 +697,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
end.putExtra(EXTRA_LINKED_TO_PATH, unlinkedFromRemotePath)
}
end.setPackage(packageName)
localBroadcastManager!!.sendBroadcast(end)
localBroadcastManager.sendBroadcast(end)
}

/**
Expand All @@ -719,7 +715,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
added.putExtra(EXTRA_REMOTE_PATH, download.remotePath)
added.putExtra(EXTRA_LINKED_TO_PATH, linkedToRemotePath)
added.setPackage(packageName)
localBroadcastManager!!.sendBroadcast(added)
localBroadcastManager.sendBroadcast(added)
}

private fun cancelPendingDownloads(accountName: String?) {
Expand Down
Loading