├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── objectbox-models
│ ├── default.json
│ └── default.json.bak
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── freeportmetrics
│ │ └── kotlin_internal_project
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── freeportmetrics
│ │ │ └── kotlin_internal_project
│ │ │ ├── database
│ │ │ └── ObjectBox.kt
│ │ │ ├── di
│ │ │ └── AppModule.kt
│ │ │ ├── helper
│ │ │ ├── ConvertHelper.kt
│ │ │ ├── DarkModeHelper.kt
│ │ │ └── DialogHelper.kt
│ │ │ ├── model
│ │ │ ├── Event.kt
│ │ │ ├── Flight.kt
│ │ │ └── Rocket.kt
│ │ │ ├── repository
│ │ │ ├── BaseRepository.kt
│ │ │ ├── EventRepository.kt
│ │ │ ├── FlightRepository.kt
│ │ │ └── RocketRepository.kt
│ │ │ ├── retrofit
│ │ │ └── SpaceXService.kt
│ │ │ ├── view
│ │ │ ├── EventViewHolder.kt
│ │ │ ├── FlightViewHolder.kt
│ │ │ ├── GenericAdapter.kt
│ │ │ ├── MainActivity.kt
│ │ │ └── RocketViewHolder.kt
│ │ │ └── viewmodel
│ │ │ ├── BaseViewModel.kt
│ │ │ ├── EventViewModel.kt
│ │ │ ├── FlightViewModel.kt
│ │ │ └── RocketViewModel.kt
│ └── res
│ │ ├── drawable-night
│ │ └── ic_btn.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_btn.xml
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── dialog_message.xml
│ │ ├── item_event.xml
│ │ ├── item_flight.xml
│ │ └── item_rocket.xml
│ │ ├── menu
│ │ └── switch_modes_menu.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── freeportmetrics
│ └── kotlin_internal_project
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Freeport Metrics Inc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **Android Kotlin starter project**
2 |
3 | ### **Purpose**
4 | To show possibilities and good practices using Kotlin language.
5 |
6 |
7 | ### **Description**
8 | Application connects to SpaceX API to download 3 types of data:
9 |
10 | * SpaceX rocket fleet
11 | * Upcoming flights
12 | * Past events
13 |
14 | Data is presented with generic adapter approach and is saved in the database.
15 |
16 | Clicking on each item navigates user to a browser to read more information on the Web.
17 |
18 | Use swipe-down gesture to refresh downloaded data.
19 |
20 | Click on top-right button to change between Light Mode and Dark Mode.
21 |
22 |
23 | ### **Libraries/concepts used**
24 |
25 | * MVVM architecture
26 | * Retrofit - for networking
27 | * Gson converter - for JSON parsing
28 | * ObjectBox - for NoSQL database
29 | * Koin - for service locator pattern implementation
30 | * Glide - for image loading
31 | * Timber - for logging
32 | * Android Architecture Components (LiveData, ViewModel classes) - for observer pattern and MVVM implementation
33 | * Kotlin coroutines - to manage threads gracefully
34 | * Kotlin View Binding - to ease connection with XML code
35 | * Generic adapter - to use single adapter for multiple object types
36 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 | apply plugin: 'io.objectbox'
6 |
7 | android {
8 | flavorDimensions "default"
9 | compileSdkVersion 28
10 | defaultConfig {
11 | applicationId "com.freeportmetrics.kotlin_internal_project"
12 | minSdkVersion 23
13 | targetSdkVersion 28
14 | versionCode 1
15 | versionName "1.0"
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | productFlavors {
25 | dev {
26 | buildConfigField "String", "SPACEX_API_URL", "\"https://api.spacexdata.com/v3/\""
27 | }
28 | }
29 | }
30 |
31 | ext {
32 | coroutinesVersion = '1.0.1'
33 | ktxVersion = '1.0.1'
34 | appCompatVersion = '1.0.2'
35 | recyclerViewVersion = '1.0.0'
36 | lifecycleExtensionsVersion = '2.0.0'
37 |
38 | retrofitVersion = '2.5.0'
39 | retrofitCoroutinesAdapterVersion = '0.9.2'
40 | timberVersion = '4.7.1'
41 | koinVersion = '2.0.0-rc-2'
42 | glideVersion = '4.9.0'
43 |
44 | testJunitVersion = '4.12'
45 | testRunnerVersion = '1.1.1'
46 | testEspressoVersion = '3.1.1'
47 | }
48 |
49 | dependencies {
50 | implementation fileTree(dir: 'libs', include: ['*.jar'])
51 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
52 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
53 | implementation "androidx.core:core-ktx:$ktxVersion"
54 | implementation "androidx.appcompat:appcompat:$appCompatVersion"
55 | implementation "androidx.recyclerview:recyclerview:$recyclerViewVersion"
56 | implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleExtensionsVersion"
57 |
58 | implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
59 | implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
60 | implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$retrofitCoroutinesAdapterVersion"
61 | implementation "com.jakewharton.timber:timber:$timberVersion"
62 | implementation "org.koin:koin-android:$koinVersion"
63 | implementation "org.koin:koin-androidx-viewmodel:$koinVersion"
64 | implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
65 | implementation "com.github.bumptech.glide:glide:$glideVersion"
66 | kapt "com.github.bumptech.glide:compiler:$glideVersion"
67 |
68 | testImplementation "junit:junit:$testJunitVersion"
69 | androidTestImplementation "androidx.test:runner:$testRunnerVersion"
70 | androidTestImplementation "androidx.test.espresso:espresso-core:$testEspressoVersion"
71 | }
72 |
--------------------------------------------------------------------------------
/app/objectbox-models/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
3 | "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
4 | "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
5 | "entities": [
6 | {
7 | "id": "4:8997267092427629326",
8 | "lastPropertyId": "11:8196038746891972390",
9 | "name": "Rocket",
10 | "properties": [
11 | {
12 | "id": "1:7139511088173987756",
13 | "name": "image"
14 | },
15 | {
16 | "id": "4:4956696553688012856",
17 | "name": "id"
18 | },
19 | {
20 | "id": "5:3006712570559858515",
21 | "name": "name"
22 | },
23 | {
24 | "id": "6:4694656277290009100",
25 | "name": "cost"
26 | },
27 | {
28 | "id": "7:2998340680876056352",
29 | "name": "firstFlight"
30 | },
31 | {
32 | "id": "8:153683174949848154",
33 | "name": "url"
34 | },
35 | {
36 | "id": "10:6002916619708317047",
37 | "name": "height"
38 | },
39 | {
40 | "id": "11:8196038746891972390",
41 | "name": "weight"
42 | }
43 | ],
44 | "relations": []
45 | },
46 | {
47 | "id": "5:3774110694116411874",
48 | "lastPropertyId": "6:3676800138233286703",
49 | "name": "Flight",
50 | "properties": [
51 | {
52 | "id": "1:626332835206343025",
53 | "name": "id"
54 | },
55 | {
56 | "id": "2:7993802601039111357",
57 | "name": "name"
58 | },
59 | {
60 | "id": "3:8192067070488677027",
61 | "name": "launchDate"
62 | },
63 | {
64 | "id": "6:3676800138233286703",
65 | "name": "urls"
66 | }
67 | ],
68 | "relations": []
69 | },
70 | {
71 | "id": "6:3199441985123381604",
72 | "lastPropertyId": "5:8609104638879090383",
73 | "name": "Event",
74 | "properties": [
75 | {
76 | "id": "1:137238333079015904",
77 | "name": "id"
78 | },
79 | {
80 | "id": "2:9205777784403291666",
81 | "name": "name"
82 | },
83 | {
84 | "id": "3:2799334129419917946",
85 | "name": "date"
86 | },
87 | {
88 | "id": "4:4898210385303123729",
89 | "name": "info"
90 | },
91 | {
92 | "id": "5:8609104638879090383",
93 | "name": "urls"
94 | }
95 | ],
96 | "relations": []
97 | }
98 | ],
99 | "lastEntityId": "6:3199441985123381604",
100 | "lastIndexId": "0:0",
101 | "lastRelationId": "0:0",
102 | "lastSequenceId": "0:0",
103 | "modelVersion": 4,
104 | "modelVersionParserMinimum": 4,
105 | "retiredEntityUids": [
106 | 9059557678869301136,
107 | 2595229960809927845,
108 | 797828973248672978
109 | ],
110 | "retiredIndexUids": [],
111 | "retiredPropertyUids": [
112 | 4051168560384758984,
113 | 6984389046907358508,
114 | 7623821168106054916,
115 | 1305947313796483568,
116 | 6589822814077259068,
117 | 8039739031557401805,
118 | 7976486627180801383,
119 | 433828257879240310,
120 | 9110279351248890984,
121 | 3879260289940935174,
122 | 7618930284939146735,
123 | 7867750146084933515,
124 | 8878250518912646344,
125 | 4289558388605460653,
126 | 528841095966552631,
127 | 8499293206396390180,
128 | 8805483336228136972,
129 | 6813566292694380342,
130 | 5196026490206898654,
131 | 1029942598495812163,
132 | 8153309559121762549,
133 | 6971054748935808656
134 | ],
135 | "retiredRelationUids": [],
136 | "version": 1
137 | }
--------------------------------------------------------------------------------
/app/objectbox-models/default.json.bak:
--------------------------------------------------------------------------------
1 | {
2 | "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
3 | "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
4 | "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
5 | "entities": [
6 | {
7 | "id": "4:8997267092427629326",
8 | "lastPropertyId": "11:8196038746891972390",
9 | "name": "Rocket",
10 | "properties": [
11 | {
12 | "id": "1:7139511088173987756",
13 | "name": "image"
14 | },
15 | {
16 | "id": "4:4956696553688012856",
17 | "name": "id"
18 | },
19 | {
20 | "id": "5:3006712570559858515",
21 | "name": "name"
22 | },
23 | {
24 | "id": "6:4694656277290009100",
25 | "name": "cost"
26 | },
27 | {
28 | "id": "7:2998340680876056352",
29 | "name": "firstFlight"
30 | },
31 | {
32 | "id": "8:153683174949848154",
33 | "name": "url"
34 | },
35 | {
36 | "id": "10:6002916619708317047",
37 | "name": "height"
38 | },
39 | {
40 | "id": "11:8196038746891972390",
41 | "name": "weight"
42 | }
43 | ],
44 | "relations": []
45 | },
46 | {
47 | "id": "5:3774110694116411874",
48 | "lastPropertyId": "5:6971054748935808656",
49 | "name": "Flight",
50 | "properties": [
51 | {
52 | "id": "1:626332835206343025",
53 | "name": "id"
54 | },
55 | {
56 | "id": "2:7993802601039111357",
57 | "name": "name"
58 | },
59 | {
60 | "id": "3:8192067070488677027",
61 | "name": "launchDate"
62 | }
63 | ],
64 | "relations": []
65 | },
66 | {
67 | "id": "6:3199441985123381604",
68 | "lastPropertyId": "5:8609104638879090383",
69 | "name": "Event",
70 | "properties": [
71 | {
72 | "id": "1:137238333079015904",
73 | "name": "id"
74 | },
75 | {
76 | "id": "2:9205777784403291666",
77 | "name": "name"
78 | },
79 | {
80 | "id": "3:2799334129419917946",
81 | "name": "date"
82 | },
83 | {
84 | "id": "4:4898210385303123729",
85 | "name": "info"
86 | },
87 | {
88 | "id": "5:8609104638879090383",
89 | "name": "urls"
90 | }
91 | ],
92 | "relations": []
93 | }
94 | ],
95 | "lastEntityId": "6:3199441985123381604",
96 | "lastIndexId": "0:0",
97 | "lastRelationId": "0:0",
98 | "lastSequenceId": "0:0",
99 | "modelVersion": 4,
100 | "modelVersionParserMinimum": 4,
101 | "retiredEntityUids": [
102 | 9059557678869301136,
103 | 2595229960809927845,
104 | 797828973248672978
105 | ],
106 | "retiredIndexUids": [],
107 | "retiredPropertyUids": [
108 | 4051168560384758984,
109 | 6984389046907358508,
110 | 7623821168106054916,
111 | 1305947313796483568,
112 | 6589822814077259068,
113 | 8039739031557401805,
114 | 7976486627180801383,
115 | 433828257879240310,
116 | 9110279351248890984,
117 | 3879260289940935174,
118 | 7618930284939146735,
119 | 7867750146084933515,
120 | 8878250518912646344,
121 | 4289558388605460653,
122 | 528841095966552631,
123 | 8499293206396390180,
124 | 8805483336228136972,
125 | 6813566292694380342,
126 | 5196026490206898654,
127 | 1029942598495812163,
128 | 8153309559121762549,
129 | 6971054748935808656
130 | ],
131 | "retiredRelationUids": [],
132 | "version": 1
133 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/freeportmetrics/kotlin_internal_project/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.freeportmetrics.kotlin_internal_project
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.freeportmetrics.kotlin_internal_project", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/freeportmetrics/kotlin_internal_project/database/ObjectBox.kt:
--------------------------------------------------------------------------------
1 | package com.freeportmetrics.kotlin_internal_project.database
2 |
3 | import android.content.Context
4 | import com.freeportmetrics.kotlin_internal_project.model.MyObjectBox
5 | import io.objectbox.BoxStore
6 |
7 | object ObjectBox {
8 |
9 | lateinit var boxStore: BoxStore
10 | private set
11 |
12 | fun init(context: Context): BoxStore {
13 | if (::boxStore.isInitialized && !boxStore.isClosed) {
14 | return boxStore
15 | }
16 |
17 | boxStore = MyObjectBox.builder().androidContext(context.applicationContext).build()
18 | return boxStore
19 | }
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/freeportmetrics/kotlin_internal_project/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package com.freeportmetrics.kotlin_internal_project.di
2 |
3 | import com.freeportmetrics.kotlin_internal_project.database.ObjectBox
4 | import com.freeportmetrics.kotlin_internal_project.helper.DarkModeHelper
5 | import com.freeportmetrics.kotlin_internal_project.helper.DialogHelper
6 | import com.freeportmetrics.kotlin_internal_project.repository.EventRepository
7 | import com.freeportmetrics.kotlin_internal_project.repository.FlightRepository
8 | import com.freeportmetrics.kotlin_internal_project.repository.RocketRepository
9 | import com.freeportmetrics.kotlin_internal_project.retrofit.SpaceXService
10 | import com.freeportmetrics.kotlin_internal_project.viewmodel.EventViewModel
11 | import com.freeportmetrics.kotlin_internal_project.viewmodel.FlightViewModel
12 | import com.freeportmetrics.kotlin_internal_project.viewmodel.RocketViewModel
13 | import org.koin.android.ext.koin.androidContext
14 | import org.koin.androidx.viewmodel.dsl.viewModel
15 | import org.koin.dsl.module
16 |
17 | val helperModule = module {
18 | single { DarkModeHelper(androidContext()) }
19 | single { DialogHelper(androidContext()) }
20 | }
21 |
22 | val networkModule = module {
23 | single { SpaceXService.create() }
24 | }
25 |
26 | val boxModule = module {
27 | single { ObjectBox.init(androidContext()) }
28 | }
29 |
30 | val repositoryModule = module {
31 | single { RocketRepository(get(), get()) }
32 | single { FlightRepository(get(), get()) }
33 | single { EventRepository(get(), get()) }
34 | }
35 |
36 | val viewModelModule = module {
37 | viewModel { RocketViewModel(get()) }
38 | viewModel { FlightViewModel(get()) }
39 | viewModel { EventViewModel(get()) }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/freeportmetrics/kotlin_internal_project/helper/ConvertHelper.kt:
--------------------------------------------------------------------------------
1 | package com.freeportmetrics.kotlin_internal_project.helper
2 |
3 | import com.freeportmetrics.kotlin_internal_project.model.Flight.Link
4 | import io.objectbox.converter.PropertyConverter
5 | import java.text.SimpleDateFormat
6 | import java.util.*
7 |
8 | fun epochToDate(epoch: Long?): String {
9 | if (epoch != null) {
10 | val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US)
11 | return dateFormat.format(java.util.Date(epoch * 1000))
12 | }
13 | return ""
14 | }
15 |
16 | abstract class BaseMapConverter(private val property: String) : PropertyConverter