-
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.
๐ Feature Updates - ๊ทธ๋ํ ๋ฐ์ดํฐ ๋ณํ ๋ฒ๊ทธ ์์ - ๋ค์ด๋๋ฏน ํ ๋ง ์ง์ - ์ํ ์ ๋ณด๋ก๊น์ง ๋ฅ๋งํฌ ์ง์ - ์ ๊ทผ์ฑ ๊ฐ์ (Talkback ์ ๋ถ ์ง์) - ํธ์ ์๋ฆผ ์ง์ ๐งNotice ํ์ฌ ์๋ฆผ ์ค์ ํ ๊ธ์ ๋ฒ๊ทธ๊ฐ ์์ต๋๋ค. ๋น ๋ฅธ ์์ผ ๋ด์ ์์ ํ๊ฒ ์ต๋๋ค. Co-Authored-By: EunhoKang <[email protected]> Co-Authored-By: ootr47 <[email protected]> Co-Authored-By: ์๋ฌธ๊ธฐ <[email protected]> Co-Authored-By: ByeongIk Choi <[email protected]>
- Loading branch information
1 parent
fda3a6d
commit fd7b149
Showing
172 changed files
with
5,097 additions
and
1,605 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 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
97 changes: 97 additions & 0 deletions
97
android/app/src/main/java/app/priceguard/data/GraphDataConverter.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,97 @@ | ||
package app.priceguard.data | ||
|
||
import app.priceguard.data.dto.PriceDataDTO | ||
import app.priceguard.data.graph.ProductChartData | ||
import app.priceguard.materialchart.data.GraphMode | ||
|
||
class GraphDataConverter { | ||
|
||
fun toDataset(priceData: List<PriceDataDTO>?): List<ProductChartData> { | ||
priceData ?: return listOf() | ||
if (priceData.isEmpty()) { | ||
return listOf() | ||
} | ||
|
||
val dataList = mutableListOf<ProductChartData>() | ||
priceData.forEach { dto -> | ||
dto.time ?: return@forEach | ||
dto.price ?: return@forEach | ||
dto.isSoldOut ?: return@forEach | ||
dataList.add( | ||
ProductChartData( | ||
x = dto.time / 1000, | ||
y = dto.price.toFloat(), | ||
valid = dto.isSoldOut.not() | ||
) | ||
) | ||
} | ||
|
||
return dataList.toList() | ||
} | ||
|
||
fun packWithEdgeData( | ||
list: List<ProductChartData>, | ||
period: GraphMode = GraphMode.DAY | ||
): List<ProductChartData> { | ||
val currentTime = getCurrentTime() | ||
val startTime = getStartTime(period, currentTime) | ||
val sortedList = list.sortedBy { it.x } | ||
val filteredList = sortedList.filter { it.x in startTime..currentTime } | ||
val sievedList = sortedList.filter { it.x !in startTime..currentTime } | ||
val startData = if (sievedList.none()) { | ||
list.first() | ||
} else { | ||
sievedList.last() | ||
} | ||
|
||
return if (filteredList.isEmpty()) { | ||
listOf( | ||
ProductChartData(startTime, startData.y, startData.valid), | ||
ProductChartData(currentTime, list.last().y, list.last().valid) | ||
) | ||
} else { | ||
listOf( | ||
ProductChartData( | ||
startTime, | ||
startData.y, | ||
startData.valid | ||
) | ||
) + filteredList + ProductChartData( | ||
currentTime, | ||
filteredList.last().y, | ||
filteredList.last().valid | ||
) | ||
} | ||
} | ||
|
||
private fun getStartTime(period: GraphMode, currentTime: Float = getCurrentTime()): Float { | ||
return when (period) { | ||
GraphMode.DAY -> { | ||
currentTime - DAY | ||
} | ||
|
||
GraphMode.WEEK -> { | ||
currentTime - WEEK | ||
} | ||
|
||
GraphMode.MONTH -> { | ||
currentTime - MONTH | ||
} | ||
|
||
GraphMode.QUARTER -> { | ||
currentTime - QUARTER | ||
} | ||
} | ||
} | ||
|
||
private fun getCurrentTime(): Float { | ||
return (System.currentTimeMillis() / 1000).toFloat() | ||
} | ||
|
||
companion object { | ||
const val DAY = 86400 | ||
const val WEEK = DAY * 7 | ||
const val MONTH = DAY * 31 | ||
const val QUARTER = MONTH * 3 | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
android/app/src/main/java/app/priceguard/data/datastore/ConfigDataSource.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,8 @@ | ||
package app.priceguard.data.datastore | ||
|
||
interface ConfigDataSource { | ||
suspend fun saveDynamicMode(mode: Int) | ||
suspend fun saveDarkMode(mode: Int) | ||
suspend fun getDynamicMode(): Int? | ||
suspend fun getDarkMode(): Int? | ||
} |
42 changes: 42 additions & 0 deletions
42
android/app/src/main/java/app/priceguard/data/datastore/ConfigDataSourceImpl.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,42 @@ | ||
package app.priceguard.data.datastore | ||
|
||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.edit | ||
import androidx.datastore.preferences.core.intPreferencesKey | ||
import app.priceguard.di.ConfigQualifier | ||
import javax.inject.Inject | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.map | ||
|
||
class ConfigDataSourceImpl @Inject constructor( | ||
@ConfigQualifier private val dataStore: DataStore<Preferences> | ||
) : ConfigDataSource { | ||
|
||
private val dynamicMode = intPreferencesKey("dynamic_mode") | ||
private val darkMode = intPreferencesKey("dark_mode") | ||
|
||
override suspend fun saveDynamicMode(mode: Int) { | ||
dataStore.edit { preferences -> | ||
preferences[dynamicMode] = mode | ||
} | ||
} | ||
|
||
override suspend fun saveDarkMode(mode: Int) { | ||
dataStore.edit { preferences -> | ||
preferences[darkMode] = mode | ||
} | ||
} | ||
|
||
override suspend fun getDynamicMode(): Int? { | ||
return dataStore.data.map { preferences -> | ||
preferences[dynamicMode] | ||
}.first() | ||
} | ||
|
||
override suspend fun getDarkMode(): Int? { | ||
return dataStore.data.map { preferences -> | ||
preferences[darkMode] | ||
}.first() | ||
} | ||
} |
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
23 changes: 0 additions & 23 deletions
23
android/app/src/main/java/app/priceguard/data/dto/LoginResponse.kt
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
android/app/src/main/java/app/priceguard/data/dto/ProductInfo.kt
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
android/app/src/main/java/app/priceguard/data/dto/ProductVerifyDTO.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
android/app/src/main/java/app/priceguard/data/dto/SignupResponse.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
.../priceguard/data/dto/ProductAddRequest.kt โ ...ceguard/data/dto/add/ProductAddRequest.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package app.priceguard.data.dto | ||
package app.priceguard.data.dto.add | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
|
Oops, something went wrong.