-
Notifications
You must be signed in to change notification settings - Fork 1
Add: GitHub Client with Retrofit #25
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
base: feature/TE7-T1049_WebServiceGsonOkHttp3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.krunal.demo.githubclient.annotation | ||
|
|
||
| @Target(AnnotationTarget.FUNCTION) | ||
| annotation class Retry(val max: Int = 3) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 AIReviewRadar The code changes in the patch for Here are a few suggestions to improve the code:
Updated code: package com.krunal.demo.githubclient.annotation
// Annotation used to specify the maximum number of retries for a function
@Target(AnnotationTarget.FUNCTION)
annotation class Retry(val max: Int = 3)Please make these changes and let me know if you have any further questions or concerns. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.krunal.demo.githubclient.data.local | ||
|
|
||
| sealed interface DownloadState { | ||
| data class Downloading(val progress: Int) : DownloadState | ||
| object Finished : DownloadState | ||
| data class Failed(val message: String, val error: Throwable? = null) : DownloadState | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 AIReviewRadar The code changes in the There are no issues with the code according to the provided guidelines. The file defines a sealed interface I would recommend adding a newline at the end of the file to follow common coding conventions. Overall, the code changes in this patch are fine. Please let me know if you have any further questions or if there's anything else I can assist you with. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.krunal.demo.githubclient.data.local | ||
|
|
||
| import android.graphics.drawable.Drawable | ||
| import androidx.annotation.ColorInt | ||
| import androidx.annotation.DrawableRes | ||
|
|
||
| sealed interface HomeItem { | ||
| val type: Type | ||
|
|
||
| data class Heading( | ||
| val title: String, | ||
| override val type: Type = Type.HEADING | ||
| ): HomeItem | ||
|
|
||
| data class WorkItem( | ||
| @DrawableRes val icon: Int, | ||
| @ColorInt val iconBackground: Int, | ||
| val title: String, | ||
| override val type: Type = Type.WORK | ||
| ): HomeItem | ||
|
|
||
| data class Favorite( | ||
| val image: Drawable, | ||
| val organization: String, | ||
| val repoName: String, | ||
| override val type: Type = Type.FAVORITES | ||
| ): HomeItem | ||
|
|
||
| data class Recent( | ||
| @DrawableRes val icon: Int, | ||
| val repo: String, | ||
| val title: String, | ||
| val authorAvatar: String, | ||
| val description: String, | ||
| override val type: Type = Type.RECENT | ||
| ): HomeItem | ||
|
|
||
| enum class Type { | ||
| HEADING, | ||
| WORK, | ||
| FAVORITES, | ||
| RECENT | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.krunal.demo.githubclient.data.local | ||
|
|
||
| import androidx.databinding.BaseObservable | ||
| import androidx.databinding.Bindable | ||
| import com.krunal.demo.BR | ||
|
|
||
| data class IssueModel( | ||
| private var _title: String, | ||
| private var _authorAvatar: String? = null, | ||
| private var _body: String? = null, | ||
| ) : BaseObservable() { | ||
|
|
||
| @get:Bindable | ||
| var authorAvatar: String? = _authorAvatar | ||
| set(value) { | ||
| _authorAvatar = value | ||
| field = value | ||
| notifyPropertyChanged(BR.authorAvatar) | ||
| } | ||
|
|
||
| @get:Bindable | ||
| var title: String = _title | ||
| set(value) { | ||
| _title = value | ||
| field = value | ||
| notifyPropertyChanged(BR.title) | ||
| } | ||
|
|
||
| @get:Bindable | ||
| var body: String? = _body | ||
| set(value) { | ||
| _body = value | ||
| field = value | ||
| notifyPropertyChanged(BR.body) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.krunal.demo.githubclient.data.local | ||
|
|
||
| import androidx.annotation.DrawableRes | ||
|
|
||
| enum class NotificationType { | ||
| ISSUE_OPENED, PULL_OPENED, PULL_MERGED, PULL_DRAFT, PULL_CLOSED | ||
| } | ||
|
|
||
| data class NotificationItem( | ||
| @DrawableRes val icon: Int, | ||
| val repoName: String, | ||
| val issueId: Int?, | ||
| val title: String, | ||
| val isUnread: Boolean, | ||
| var description: String? = null, | ||
| var authorAvatar: String? = null, | ||
| ) { | ||
|
|
||
| val heading: String | ||
| get() = "$repoName #$issueId" | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 AIReviewRadar The code changes in the Here are a few suggestions to improve the code:
Other than these suggestions, the code looks fine. Please make the necessary changes and respond with the updated code. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| package com.krunal.demo.githubclient.data.local | ||
|
|
||
| import androidx.annotation.ColorInt | ||
| import androidx.annotation.DrawableRes | ||
| import com.krunal.demo.R | ||
| import com.krunal.demo.githubclient.data.remote.model.response.UserResponse | ||
| import com.krunal.demo.helpers.ResourceHelper | ||
|
|
||
| enum class DetailType { | ||
| NAME, INFO | ||
| } | ||
|
|
||
| enum class ProfileType { | ||
| DETAIL, ITEM | ||
| } | ||
|
|
||
| data class ProfileModel( | ||
| val items: List<ProfileInfo> | ||
| ) | ||
|
|
||
| sealed interface ProfileDetail { | ||
|
|
||
| val type: DetailType | ||
|
|
||
| data class ProfileName( | ||
| val avatar: String, | ||
| val username: String, | ||
| val name: String? = null, | ||
| override val type: DetailType = DetailType.NAME | ||
| ) : ProfileDetail | ||
|
|
||
| data class ProfileInfo( | ||
| @DrawableRes val icon: Int, | ||
| val title: String, | ||
| override val type: DetailType = DetailType.INFO | ||
| ) : ProfileDetail { | ||
| companion object { | ||
|
|
||
| fun from(userResponse: UserResponse) = buildList { | ||
| with(userResponse) { | ||
| bio?.let { | ||
| add(ProfileInfo(R.drawable.ic_info, it)) | ||
| } | ||
| company?.let { | ||
| add(ProfileInfo(R.drawable.ic_chat, it)) | ||
| } | ||
| blog?.let { | ||
| add(ProfileInfo(R.drawable.ic_link_logo, it)) | ||
| } | ||
| email?.let { | ||
| add(ProfileInfo(R.drawable.ic_email, it)) | ||
| } | ||
| add( | ||
| ProfileInfo( | ||
| R.drawable.ic_person_24, | ||
| ResourceHelper.resources.getString(R.string.follow_info, followers, following) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| sealed interface ProfileInfo { | ||
| val type: ProfileType | ||
|
|
||
| data class ProfileCard( | ||
| val profileDetail: List<ProfileDetail>, | ||
| override val type: ProfileType = ProfileType.DETAIL | ||
| ) : ProfileInfo { | ||
| companion object { | ||
|
|
||
| fun from(userResponse: UserResponse): ProfileCard { | ||
| val profileName = with(userResponse) { | ||
| ProfileDetail.ProfileName(avatarUrl, username, name) | ||
| } | ||
| val profileDetails: MutableList<ProfileDetail> = | ||
| ProfileDetail.ProfileInfo.from(userResponse).toMutableList() | ||
| profileDetails.add(0, profileName) | ||
| return ProfileCard(profileDetails) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| data class ProfileItem( | ||
| @DrawableRes val icon: Int, | ||
| @ColorInt val iconBackground: Int, | ||
| val title: String, | ||
| val count: Int? = null, | ||
| override val type: ProfileType = ProfileType.ITEM | ||
| ) : ProfileInfo { | ||
|
|
||
| companion object { | ||
| fun from(userResponse: UserResponse) = with(userResponse) { | ||
| with(ResourceHelper.resources) { | ||
| listOf( | ||
| ProfileItem( | ||
| R.drawable.ic_repo_24, | ||
| getColor(R.color.github_pull, null), | ||
| getString(R.string.repositories), | ||
| publicRepos | ||
| ), ProfileItem( | ||
| R.drawable.ic_git_pull_request, | ||
| getColor(R.color.github_gists, null), | ||
| getString(R.string.gists), | ||
| publicGists | ||
| ), ProfileItem( | ||
| R.drawable.ic_organization_24, | ||
| getColor(R.color.github_organization, null), | ||
| getString(R.string.organizations) | ||
| ), ProfileItem( | ||
| R.drawable.ic_star_24, | ||
| getColor(R.color.github_starred, null), | ||
| getString(R.string.starred) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 AIReviewRadar The code looks good overall. Here are a few suggestions:
Other than these minor suggestions, the code looks fine. It follows the naming conventions, has proper access modifiers, and doesn't have any syntax errors or logic issues. Please make the necessary changes and reply with the updated code. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.krunal.demo.githubclient.data.local | ||
|
|
||
| import java.util.Date | ||
|
|
||
| data class Release( | ||
| val repoFullName: String, | ||
| val releaseName: String, | ||
| val author: String, | ||
| val authorAvatar: String, | ||
| val releaseDate: Date, | ||
| val releaseAssets: List<ReleaseAsset> | ||
| ) | ||
|
|
||
| data class ReleaseAsset( | ||
| val name: String, | ||
| val size: Int, | ||
| val contentType: String, | ||
| val downloadUrl: String, | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 AIReviewRadar The code changes in the Here are a few suggestions to improve the code:
Other than that, the code follows the guidelines mentioned earlier. Therefore, the code changes in this patch look good to me. Please let me know if you have any further questions or concerns. |
||
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.
🤖 AIReviewRadar
The code changes look good. The addition of the
GITHUB_AUTHORIZATION_TOKENconstant in theIntentDataobject seems appropriate.However, I have a few suggestions for improving the code and documentation:
Add a comment above the
GITHUB_AUTHORIZATION_TOKENconstant to explain its purpose and usage.Example:
Consider adding a brief description of the
IntentDataobject in the file-level documentation comment.Example:
Update the existing comments in the file to reflect the latest changes. For example, update the comment for
AUTH_KEYto mention that it is used for passing authentication keys as an intent extra.Example:
These suggestions will help improve the readability and maintainability of the code.