-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat/usagestatusmanager] : 이용시간 통계 뷰 구현 #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
클릭 아키텍처 열심히 공부한 게 느껴지네요,, 저도 빨리 리팩토링 하겠습니다. 수고하셨어요!
Log.d("time", time.toString()) | ||
Log.d("converted", convertMillisecondsToMinute(time).toString()) | ||
Log.d("hour", hour.toString()) | ||
Log.d("min", min.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로그가 확인용이라면 확인 후에 push할 때에는 지워줘도 될 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵! 아직 수정할 부분이 남아있을 것 같아 남겨두었습니다! 나중에 로직 완성하면 지우겠습니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 이제 지우기 ㄱㄱ?!
return listOf( | ||
UsageGoalModel("total", 201519990), | ||
UsageGoalModel("com.kakao.talk", 15686 * 2), | ||
UsageGoalModel("com.google.android.gms", 7134), | ||
UsageGoalModel("com.google.android.youtube", 71349), | ||
UsageGoalModel("com.android.chrome", 39445), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저 그냥 궁금해서 그런데 이거는 아직 특정 앱 선택 기능이 없어서 임시적으로 더미데이터로 앱 패키지 값을 넣어주신 것 맞을까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 listOf를 변수로 만들고 변수를 return 하는 것으로 수정하면 가독성이 더 좋아질 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 맞습니다! 서버에서 받아와야 하는 정보인데 일단 급하게 만든 거여서 가독성도 아주,,, bad
수정하겠습니다.
// for (i in usageStatList.value) { | ||
// Log.d("app name", i.packageName) | ||
// Log.d("total time", i.totalTimeInForeground.toString()) | ||
// Log.d("goal time", i.goalTime.toString()) | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분도 지워주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉스 넴,,,
binding.tvItemusagestatAppname.text = | ||
context.getAppNameFromPackageName(usageStatAndGoal.packageName) | ||
binding.tvItemusagestatLeftHour.text = | ||
getLeftTimeInString(usageStatAndGoal.totalTimeInForeground, usageStatAndGoal.goalTime) | ||
binding.ivItemusagestatAppicon.setImageDrawable( | ||
context.getAppIconFromPackageName( | ||
usageStatAndGoal.packageName, | ||
), | ||
) | ||
binding.pbItemUsagestat.setProgress( | ||
getUsedPercentage( | ||
usageStatAndGoal.totalTimeInForeground, | ||
usageStatAndGoal.goalTime, | ||
), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binidng.~~
을 여러번 쓰는 부분에서는 스코프 함수로
binding.run { ... } 으로 묶어줄 수 있어요!! 가독성을 위해 수정 부탁드립니답
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 감사합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
짱빠르다 안드..놀랍다..
ㅋㅋㅋㅋㅋㅋ 대장님 반갑습니당 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 확인하고 리마인드 부탁드려요~!!
특히 도메인 코드 너무 좋았습니당
Log.d("time", time.toString()) | ||
Log.d("converted", convertMillisecondsToMinute(time).toString()) | ||
Log.d("hour", hour.toString()) | ||
Log.d("min", min.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 이제 지우기 ㄱㄱ?!
fun getUsedPercentage( | ||
usage: Long, | ||
goal: Long, | ||
): Int { | ||
try { | ||
return (usage * 100 / goal).toInt() | ||
} catch (e: ArithmeticException) { | ||
return 0 | ||
} | ||
} | ||
|
||
fun getLeftTimeInString( | ||
usage: Long, | ||
goal: Long, | ||
): String { | ||
return convertTimeToString(goal - usage) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 함수들이 해당 파일에 있는 것이 맞을까요?? 관심사가 조금 다른 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네! 어제 스크럼 이후에 수정하려 했는데 아직 못했네요. 오늘 스크럼 전까지 해서 올리겠습니다!
fun provideUsageGoalModels(): List<UsageGoalModel> { | ||
val usageGoalList = listOf( | ||
UsageGoalModel("total", 201519990), | ||
UsageGoalModel("com.kakao.talk", 15686 * 2), | ||
UsageGoalModel("com.google.android.gms", 7134), | ||
UsageGoalModel("com.google.android.youtube", 71349), | ||
UsageGoalModel("com.android.chrome", 39445), | ||
) | ||
return usageGoalList | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음 이렇게 주입해줄거면 차라리 데이터 소스쪽에서 get하는 함수내에서 선언해주는 것이 더 좋을 것 같습니다, 그냥 싱글톤구조에 list넣어둔 것과 다른게 없어보여요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 수정하겠습니다!
class StaticsUseCase | ||
@Inject | ||
constructor( | ||
private val usageStatsRepository: UsageStatsRepository, | ||
private val usageGoalsRepository: UsageGoalsRepository, | ||
) { | ||
fun getStatics( | ||
startTime: Long, | ||
endTime: Long, | ||
): List<UsageStatAndGoal> { | ||
val totalUsage = | ||
getTotalUsage(startTime, endTime) | ||
val appUsageStat = | ||
getAppUsageStat(startTime, endTime) | ||
val totalUsageStatAndGoal = | ||
UsageStatAndGoal("total", totalUsage, usageGoalsRepository.getUsageGoalTime("total")) | ||
return listOf(totalUsageStatAndGoal) + appUsageStat | ||
} | ||
|
||
private fun getAppUsageStat( | ||
startTime: Long, | ||
endTime: Long, | ||
): List<UsageStatAndGoal> { | ||
val appList = getAppList() | ||
|
||
val usageStatAndGoal = | ||
usageStatsRepository.getUsageTimeForPackages(startTime, endTime, appList).map { | ||
UsageStatAndGoal( | ||
it.packageName, | ||
it.totalTimeInForeground, | ||
usageGoalsRepository.getUsageGoalTime(it.packageName), | ||
) | ||
} | ||
return usageStatAndGoal | ||
} | ||
|
||
private fun getTotalUsage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
도메인 로직이 좀 장난 아닌데요? 이런 구조를 생각하시고 개발하신 우리 팀원 너무 든든합니다 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
의진 스승님 코드 따라해보았읍니다. 더 가르쳐주십시오 꾸벅
) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(usageStatAndGoal: UsageStatAndGoal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
줄바꿈 무언가 이상합니다?!?! 혹시 셋팅이...!!??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
허거덩 확인해보겠습니다
@jumining 우리 의진이 잘 부탁한다 |
컨플릿 제가 해결할게요 |
# Conflicts: # app/src/main/AndroidManifest.xml # app/src/main/java/com/hmh/hamyeonham/SampleActivity.kt # settings.gradle.kts
451d3b0
to
e8a97ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어요~!!
개요
작업 사항
변경 사항(optional)
스크린샷(optional)
기타