Skip to content

Commit 67d2ea4

Browse files
nicholaspoon03mergify[bot]
authored andcommitted
Lazy-initialize FileSizeFormatter and use it in DownloadService
1 parent 720ac26 commit 67d2ea4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

app/src/main/java/org/mozilla/reference/browser/Components.kt

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import android.annotation.SuppressLint
88
import android.content.Context
99
import androidx.core.app.NotificationManagerCompat
1010
import mozilla.components.feature.autofill.AutofillConfiguration
11+
import mozilla.components.feature.downloads.DefaultFileSizeFormatter
12+
import mozilla.components.feature.downloads.FileSizeFormatter
1113
import mozilla.components.support.base.android.NotificationsDelegate
1214
import org.mozilla.reference.browser.autofill.AutofillConfirmActivity
1315
import org.mozilla.reference.browser.autofill.AutofillSearchActivity
@@ -78,4 +80,6 @@ class Components(private val context: Context) {
7880
notificationManagerCompat,
7981
)
8082
}
83+
84+
val fileSizeFormatter: FileSizeFormatter by lazy { DefaultFileSizeFormatter(context.applicationContext) }
8185
}

app/src/main/java/org/mozilla/reference/browser/downloads/DownloadService.kt

+2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ package org.mozilla.reference.browser.downloads
66

77
import mozilla.components.browser.state.store.BrowserStore
88
import mozilla.components.feature.downloads.AbstractFetchDownloadService
9+
import mozilla.components.feature.downloads.FileSizeFormatter
910
import mozilla.components.support.base.android.NotificationsDelegate
1011
import org.mozilla.reference.browser.ext.components
1112

1213
class DownloadService : AbstractFetchDownloadService() {
1314
override val httpClient by lazy { components.core.client }
1415
override val store: BrowserStore by lazy { components.core.store }
1516
override val notificationsDelegate: NotificationsDelegate by lazy { components.notificationsDelegate }
17+
override val fileSizeFormatter: FileSizeFormatter by lazy { components.fileSizeFormatter }
1618
}

0 commit comments

Comments
 (0)