Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 07d724d

Browse files
author
Eduard Ablekimov
committed
Companion objects formatting
1 parent 84b21e6 commit 07d724d

9 files changed

Lines changed: 39 additions & 65 deletions

File tree

firebase-fetcher/src/main/java/com/ackee/versionupdatehandler/FirebaseVersionFetcher.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ class FirebaseVersionFetcher constructor(
1515
private val currentAttributeName: String = CURRENT_VERSION
1616
) : VersionFetcher {
1717

18+
companion object {
19+
const val MINIMAL_VERSION = "minimal_version_android"
20+
const val CURRENT_VERSION = "current_version_android"
21+
22+
val DEFAULTS: Map<String, Any> by lazy {
23+
mapOf(
24+
MINIMAL_VERSION to -1,
25+
CURRENT_VERSION to -1
26+
)
27+
}
28+
}
29+
1830
override suspend fun fetch(): VersionsConfiguration {
1931
val remoteConfig = FirebaseRemoteConfig.getInstance().apply {
2032
setDefaultsAsync(DEFAULTS)
@@ -27,16 +39,4 @@ class FirebaseVersionFetcher constructor(
2739
val currentVersion = remoteConfig.getLong(currentAttributeName)
2840
return BasicVersionsConfiguration(minimalVersion, currentVersion)
2941
}
30-
31-
companion object {
32-
const val MINIMAL_VERSION = "minimal_version_android"
33-
const val CURRENT_VERSION = "current_version_android"
34-
35-
val DEFAULTS: Map<String, Any> by lazy {
36-
mapOf(
37-
MINIMAL_VERSION to -1,
38-
CURRENT_VERSION to -1
39-
)
40-
}
41-
}
4242
}

rest-fetcher/src/main/java/com/ackee/versionupdatehandler/RestVersionFetcher.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class RestVersionFetcher constructor(
2828
private val minimalAttributeName: String = MINIMAL_VERSION
2929
) : VersionFetcher {
3030

31+
companion object {
32+
const val MINIMAL_VERSION = "minimal_version_android"
33+
const val CURRENT_VERSION = "current_version_android"
34+
}
35+
3136
internal interface ApiDescription {
3237
@GET("app_version")
3338
suspend fun versions(): JsonObject?
@@ -60,11 +65,5 @@ class RestVersionFetcher constructor(
6065
BasicVersionsConfiguration(minimalVersion, currentVersion)
6166
}
6267
}
63-
64-
companion object {
65-
val TAG = RestVersionFetcher::class.java.name
66-
const val MINIMAL_VERSION = "minimal_version_android"
67-
const val CURRENT_VERSION = "current_version_android"
68-
}
6968
}
7069

rest-fetcher/src/test/java/com/ackee/versionupdatehandler/RestVersionFetcherTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import org.junit.Test
1818
*/
1919
class RestVersionFetcherTest {
2020

21+
companion object {
22+
const val MINIMAL_VERSION = "minimal_version_android"
23+
const val CURRENT_VERSION = "current_version_android"
24+
}
25+
2126
private lateinit var server: MockWebServer
2227

2328
@Before
@@ -86,9 +91,4 @@ class RestVersionFetcherTest {
8691
Truth.assertThat(result.minimalVersion())
8792
.isEqualTo(10)
8893
}
89-
90-
companion object {
91-
const val MINIMAL_VERSION = "minimal_version_android"
92-
const val CURRENT_VERSION = "current_version_android"
93-
}
9494
}

status-resolver/src/main/java/com/ackee/versioupdatehandler/UpdateDialog.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ import com.ackee.versioupdatehandler.model.DialogSettings
1717
*/
1818
class UpdateDialog : DialogFragment() {
1919

20+
companion object {
21+
private const val FORCE_UPDATE_KEY = "force_update"
22+
private const val DIALOG_SETTINGS_KEY = "dialog_settings"
23+
fun newInstance(forceUpdate: Boolean, dialogSettings: DialogSettings?): UpdateDialog {
24+
val args = Bundle()
25+
args.putBoolean(FORCE_UPDATE_KEY, forceUpdate)
26+
args.putParcelable(DIALOG_SETTINGS_KEY, dialogSettings)
27+
val updateDialog = UpdateDialog()
28+
updateDialog.arguments = args
29+
return updateDialog
30+
}
31+
}
32+
2033
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
2134
val builder = AlertDialog.Builder(activity!!)
2235
val settings: DialogSettings =
@@ -84,17 +97,4 @@ class UpdateDialog : DialogFragment() {
8497
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$appPackageName")))
8598
}
8699
}
87-
88-
companion object {
89-
private const val FORCE_UPDATE_KEY = "force_update"
90-
private const val DIALOG_SETTINGS_KEY = "dialog_settings"
91-
fun newInstance(forceUpdate: Boolean, dialogSettings: DialogSettings?): UpdateDialog {
92-
val args = Bundle()
93-
args.putBoolean(FORCE_UPDATE_KEY, forceUpdate)
94-
args.putParcelable(DIALOG_SETTINGS_KEY, dialogSettings)
95-
val updateDialog = UpdateDialog()
96-
updateDialog.arguments = args
97-
return updateDialog
98-
}
99-
}
100100
}

status-resolver/src/main/java/com/ackee/versioupdatehandler/VersionFetcher.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ import com.ackee.versioupdatehandler.model.VersionsConfiguration
77
*/
88
interface VersionFetcher {
99

10-
companion object {
11-
val TAG = VersionFetcher::class.java.name
12-
}
13-
1410
suspend fun fetch(): VersionsConfiguration
1511
}

status-resolver/src/main/java/com/ackee/versioupdatehandler/VersionStatusResolver.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,4 @@ class VersionStatusResolver(private val fetcher: VersionFetcher) {
6363
) {
6464
UpdateDialog.newInstance(forceUpdate, dialogSettings).show(fragmentManager, UpdateDialog::class.java.name)
6565
}
66-
67-
companion object {
68-
val TAG = VersionStatusResolver::class.java.name
69-
}
7066
}

status-resolver/src/main/java/com/ackee/versioupdatehandler/model/BasicVersionsConfiguration.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ open class BasicVersionsConfiguration(
88
private val currentVersion: Long
99
) : VersionsConfiguration {
1010

11-
companion object {
12-
val TAG = BasicVersionsConfiguration::class.java.name
13-
}
14-
1511
override fun minimalVersion(): Long {
1612
return minimalVersion
1713
}

status-resolver/src/main/java/com/ackee/versioupdatehandler/model/DialogSettings.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@ import android.os.Parcelable
88
*/
99
class DialogSettings : Parcelable {
1010

11-
companion object {
12-
val TAG = DialogSettings::class.java.name
13-
val CREATOR: Parcelable.Creator<DialogSettings> = object : Parcelable.Creator<DialogSettings> {
14-
override fun createFromParcel(parcelableValue: Parcel): DialogSettings? {
15-
return DialogSettings(parcelableValue)
16-
}
17-
18-
override fun newArray(size: Int): Array<DialogSettings?> {
19-
return arrayOfNulls(size)
20-
}
21-
}
22-
}
23-
2411
var packageName: String?
2512
var title: String?
2613
var titleRes: Int

status-resolver/src/test/java/com/ackee/versioupdatehandler/VersionStatusResolverTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import kotlinx.coroutines.runBlocking
1515
*/
1616
class VersionStatusResolverTest {
1717

18+
companion object {
19+
val BASIC_VERSIONS_CONFIGURATION = BasicVersionsConfiguration(10, 15)
20+
}
21+
1822
@Test
1923
fun should_be_up_to_date_greater_than_last() {
2024
checkSuccess(15, VersionStatus.UP_TO_DATE)
@@ -45,8 +49,4 @@ class VersionStatusResolverTest {
4549
Truth.assertThat(versionStatus)
4650
.isEqualTo(expectedResult)
4751
}
48-
49-
companion object {
50-
val BASIC_VERSIONS_CONFIGURATION = BasicVersionsConfiguration(10, 15)
51-
}
5252
}

0 commit comments

Comments
 (0)