-
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.
Merge pull request #28 from teamcadi/taeho
Taeho
- Loading branch information
Showing
26 changed files
with
639 additions
and
243 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
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/example/noogabab/data/api/model/FeedModel.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,13 @@ | ||
package com.example.noogabab.data.api.model | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class FeedModel( | ||
@SerializedName("data") | ||
val data: Any?, | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("success") | ||
val success: Boolean | ||
) |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/example/noogabab/data/api/model/MealLatestModel.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,13 @@ | ||
package com.example.noogabab.data.api.model | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class MealLatestModel( | ||
@SerializedName("data") | ||
val content: String?, | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("success") | ||
val success: Boolean | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/noogabab/data/api/request/FeedRequest.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 com.example.noogabab.data.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class FeedRequest( | ||
@SerializedName("userId") | ||
val userId: Int, | ||
) |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/example/noogabab/domain/repository/DogRepository.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,9 +1,13 @@ | ||
package com.example.noogabab.domain.repository | ||
|
||
import com.example.noogabab.data.api.ApiService | ||
import com.example.noogabab.data.api.request.FeedRequest | ||
import okhttp3.Headers | ||
import javax.inject.Inject | ||
|
||
class DogRepository @Inject constructor(private val apiService: ApiService) { | ||
suspend fun getDog(key: String) = apiService.getDog(key) | ||
suspend fun getMealLatest(dogId: Int) = apiService.getMealLatest(dogId) | ||
suspend fun feedMeal(key: String, dogId: Int, feed: FeedRequest) = apiService.feedMealDog(key, dogId, feed) | ||
suspend fun feedSnack(key: String, dogId: Int, feed: FeedRequest) = apiService.feedSnackDog(key, dogId, feed) | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/example/noogabab/presentation/ui/main/chart/ChartValueFormatter.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.example.noogabab.presentation.ui.main.chart | ||
|
||
import com.github.mikephil.charting.data.Entry | ||
import com.github.mikephil.charting.formatter.ValueFormatter | ||
import com.github.mikephil.charting.utils.ViewPortHandler | ||
import java.text.DecimalFormat | ||
|
||
class ChartValueFormatter: ValueFormatter { | ||
override fun getFormattedValue( | ||
value: Float, | ||
entry: Entry?, | ||
dataSetIndex: Int, | ||
viewPortHandler: ViewPortHandler? | ||
): String { | ||
return "" | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
app/src/main/java/com/example/noogabab/presentation/ui/main/chart/ChartViewModel.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,83 @@ | ||
package com.example.noogabab.presentation.ui.main.chart | ||
|
||
import android.annotation.SuppressLint | ||
import androidx.hilt.lifecycle.ViewModelInject | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.liveData | ||
import com.example.noogabab.data.api.model.ResultData | ||
import com.example.noogabab.domain.usecase.GroupUseCase | ||
import kotlin.collections.ArrayList | ||
|
||
class ChartViewModel @ViewModelInject constructor(private val groupUseCase: GroupUseCase): ViewModel() { | ||
private val _currentWeekXGroups = MutableLiveData<ArrayList<String>>() | ||
private val _currentWeekYBobs = MutableLiveData<FloatArray>() | ||
private val _currentWeekYSnacks = MutableLiveData<FloatArray>() | ||
private val _currentMonthXGroups = MutableLiveData<ArrayList<String>>() | ||
private val _currentMonthYBobs = MutableLiveData<FloatArray>() | ||
private val _currentMonthYSnacks = MutableLiveData<FloatArray>() | ||
private val _currentWeekDate = MutableLiveData<String>() | ||
private val _currentMonthDate = MutableLiveData<String>() | ||
|
||
init { | ||
_currentWeekXGroups.value = ArrayList<String>() | ||
_currentWeekYBobs.value = floatArrayOf() | ||
_currentWeekYSnacks.value = floatArrayOf() | ||
_currentMonthXGroups.value = ArrayList<String>() | ||
_currentMonthYBobs.value = floatArrayOf() | ||
_currentMonthYSnacks.value = floatArrayOf() | ||
_currentWeekDate.value = "1970-12-10" | ||
_currentMonthDate.value = "1970-12-10" | ||
} | ||
|
||
fun getStatistics(key: String, groupId: Int, type: String, date: String) = liveData { | ||
emit(ResultData.Loading()) | ||
emit(groupUseCase.getGroupStatistics(key, groupId, type, date)) | ||
} | ||
|
||
val currentWeekXGroups: LiveData<ArrayList<String>> | ||
get() = _currentWeekXGroups | ||
|
||
val currentWeekDate: LiveData<String> | ||
get() = _currentWeekDate | ||
|
||
val currentWeekYBobs: FloatArray? | ||
get() = _currentWeekYBobs.value | ||
|
||
val currentWeekYSnacks: FloatArray? | ||
get() = _currentWeekYSnacks.value | ||
|
||
val currentMonthXGroups: LiveData<ArrayList<String>> | ||
get() = _currentMonthXGroups | ||
|
||
val currentMonthDate: LiveData<String> | ||
get() = _currentMonthDate | ||
|
||
val currentMonthYBobs: FloatArray? | ||
get() = _currentMonthYBobs.value | ||
|
||
val currentMonthYSnacks: FloatArray? | ||
get() = _currentMonthYSnacks.value | ||
|
||
fun updateChart(xGroups: ArrayList<String>, yBobs: FloatArray, ySnacks: FloatArray, type: String) { | ||
when(type) { | ||
"week" -> { | ||
_currentWeekYBobs.value = yBobs | ||
_currentWeekYSnacks.value = ySnacks | ||
_currentWeekXGroups.value = xGroups // 마지막에 위치시킴 | ||
} | ||
"month" -> { | ||
_currentMonthYBobs.value = yBobs | ||
_currentMonthYSnacks.value = ySnacks | ||
_currentMonthXGroups.value = xGroups | ||
} | ||
} | ||
|
||
} | ||
|
||
fun updateDate(input: String, type: String) { | ||
if (type == "week") _currentWeekDate.value = input | ||
else if (type == "month") _currentMonthDate.value = input | ||
} | ||
} |
Oops, something went wrong.