-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove chart border and update example app
- Loading branch information
Showing
19 changed files
with
668 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.taewooyo.volcano | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class MainApplication : Application() |
21 changes: 21 additions & 0 deletions
21
app/src/main/kotlin/com/taewooyo/volcano/core/assets/AssetLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.taewooyo.volcano.core.assets | ||
|
||
import android.content.Context | ||
import javax.inject.Inject | ||
|
||
class AssetLoader @Inject constructor(private val context: Context) { | ||
fun getJsonString(fileName: String): String? { | ||
return runCatching { | ||
loadAsset(fileName) | ||
}.getOrNull() | ||
} | ||
|
||
private fun loadAsset(fileName: String): String { | ||
return context.assets.open(fileName).use { inputStream -> | ||
val size = inputStream.available() | ||
val bytes = ByteArray(size) | ||
inputStream.read(bytes) | ||
String(bytes) | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/kotlin/com/taewooyo/volcano/core/assets/di/AssetModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.taewooyo.volcano.core.assets.di | ||
|
||
import android.content.Context | ||
import com.taewooyo.volcano.core.assets.AssetLoader | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object AssetModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideAssetLoader(@ApplicationContext context: Context): AssetLoader = AssetLoader(context) | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/kotlin/com/taewooyo/volcano/core/data/di/DataModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.taewooyo.volcano.core.data.di | ||
|
||
import com.taewooyo.volcano.core.data.stock.StockRepository | ||
import com.taewooyo.volcano.core.data.stock.StockRepositoryImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal interface DataModule { | ||
|
||
@Binds | ||
fun bindsStockRepository(stockRepositoryImpl: StockRepositoryImpl): StockRepository | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/kotlin/com/taewooyo/volcano/core/data/stock/StockRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.taewooyo.volcano.core.data.stock | ||
|
||
import com.taewooyo.volcano.core.model.Stocks | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface StockRepository { | ||
|
||
fun fetchStockList(): Stocks? | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/kotlin/com/taewooyo/volcano/core/data/stock/StockRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.taewooyo.volcano.core.data.stock | ||
|
||
import com.google.gson.Gson | ||
import com.taewooyo.volcano.core.assets.AssetLoader | ||
import com.taewooyo.volcano.core.model.Stocks | ||
import javax.inject.Inject | ||
|
||
class StockRepositoryImpl @Inject constructor( | ||
private val assetLoader: AssetLoader | ||
) : StockRepository { | ||
override fun fetchStockList(): Stocks? { | ||
val gson = Gson() | ||
return assetLoader.getJsonString("stock.json")?.let { jsonString -> | ||
gson.fromJson(jsonString, Stocks::class.java) | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/kotlin/com/taewooyo/volcano/core/model/StockItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2023 taewooyo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.taewooyo.volcano.core.model | ||
|
||
data class Stocks( | ||
val stocks: List<StockItem> | ||
) | ||
|
||
data class StockItem( | ||
val name: String, | ||
val value: Double, | ||
val oldValue: Double, | ||
val type: String, | ||
) |
Oops, something went wrong.