This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
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
Goooler
commented
Mar 16, 2022
Comment on lines
8
to
9
@GET("https://api.github.com/repos/{owner}/{repo}") | ||
suspend fun getRepoDetail(@Path("owner") owner: String, @Path("repo") repo: String) |
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.
Goooler
commented
Mar 16, 2022
Comment on lines
80
to
90
Button(onClick = { | ||
"All ${model.starsCount} stars".showToast() | ||
}) { | ||
Icon( | ||
Icons.Filled.Star, | ||
contentDescription = "Star", | ||
modifier = Modifier.size(ButtonDefaults.IconSize) | ||
) | ||
Spacer(Modifier.size(ButtonDefaults.IconSpacing)) | ||
Text(model.starsCount.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.
Goooler
commented
Mar 16, 2022
detail/src/main/kotlin/io/goooler/demoapp/detail/api/DetailApi.kt
Outdated
Show resolved
Hide resolved
This reverts commit 012720a.
Goooler
commented
Mar 17, 2022
Comment on lines
+43
to
+45
SwipeRefresh(state = rememberSwipeRefreshState(isRefreshing), onRefresh = onRefresh) { | ||
DetailPage(model, onForkClick) | ||
} |
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.
Goooler
commented
Mar 17, 2022
Comment on lines
+18
to
+21
intent.getStringExtra(FULL_NAME)?.let { | ||
vm.fullName = it | ||
vm.refresh() | ||
} |
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.
Must refresh manually for the first time.
Goooler
commented
Mar 17, 2022
Comment on lines
+13
to
+46
class DetailViewModel : BaseViewModel() { | ||
|
||
private val repository = DetailRepository(RetrofitHelper.create()) | ||
private var repoDetail = RepoDetailModel() | ||
private val _repoDetailModel = MutableLiveData(repoDetail) | ||
|
||
lateinit var fullName: String | ||
val repoDetailModel: LiveData<RepoDetailModel> = _repoDetailModel | ||
val isRefreshing: MutableBooleanLiveData = MutableBooleanLiveData() | ||
|
||
fun refresh() { | ||
isRefreshing.value = true | ||
viewModelScope.launch { | ||
repository.getRepoDetail(fullName).let { | ||
repoDetail = RepoDetailModel( | ||
it.fullName, | ||
it.description.orEmpty(), | ||
it.license?.name.orEmpty(), | ||
it.starsCount, | ||
it.forksCount, | ||
it.openIssuesCount | ||
) | ||
} | ||
_repoDetailModel.value = repoDetail | ||
isRefreshing.value = false | ||
} | ||
} | ||
|
||
fun fork() { | ||
repoDetail = repoDetail.copy() | ||
repoDetail.forksCount++ | ||
_repoDetailModel.value = repoDetail | ||
} | ||
} |
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.
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up https://github.com/Goooler/AndroidUiDemo/pull/74.