-
Notifications
You must be signed in to change notification settings - Fork 0
dahyee step2 #8
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: kimdahyee
Are you sure you want to change the base?
dahyee step2 #8
Changes from all commits
ab6cd00
78641bc
7769b2b
2cade6d
82bd712
4b59486
2df9562
b34b9de
3bdea4f
512c887
e154990
5d2ea16
e7ccfa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package place.pic.android.plus.data.model | ||
|
|
||
| /** | ||
| * Created By kimdahyee | ||
| * on 11월 02일, 2020 | ||
| */ | ||
|
|
||
| data class User( | ||
| val imageUrl: String, | ||
| val name: String, | ||
| val id: Long | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package place.pic.android.plus.data.model | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
|
|
||
| /** | ||
| * Created By kimdahyee | ||
| * on 11월 03일, 2020 | ||
| */ | ||
|
|
||
| data class UserDetail( | ||
| @SerializedName("avatar_url") | ||
| val imageUrl: String?, | ||
|
|
||
| @SerializedName("login") | ||
| val name: String, | ||
|
|
||
| @SerializedName("bio") | ||
| val bio: String?, | ||
|
|
||
| @SerializedName("followers") | ||
| val followers: Int, | ||
|
|
||
| @SerializedName("html_url") | ||
| val htmlUrl: String | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package place.pic.android.plus.data.remote | ||
|
|
||
| import place.pic.android.plus.data.model.UserDetail | ||
| import place.pic.android.plus.data.remote.response.UserSearchResponse | ||
| import retrofit2.Call | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Header | ||
| import retrofit2.http.Path | ||
| import retrofit2.http.Query | ||
|
|
||
| /** | ||
| * Created By kimdahyee | ||
| * on 11월 02일, 2020 | ||
| */ | ||
|
|
||
| interface GithubApiService { | ||
| @GET("search/users") | ||
| fun requestUserSearch( | ||
| @Query("q") param: String? | ||
| ): Call<UserSearchResponse> | ||
|
|
||
| @GET("users/{username}") | ||
| fun requestUserDetail( | ||
| @Header("accept") token: String, | ||
| @Path("username") login: String | ||
| ): Call<UserDetail> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package place.pic.android.plus.data.remote | ||
|
|
||
| import retrofit2.Retrofit | ||
| import retrofit2.converter.gson.GsonConverterFactory | ||
|
|
||
| /** | ||
| * Created By kimdahyee | ||
| * on 11월 02일, 2020 | ||
| */ | ||
|
|
||
| object GithubApiServiceImpl { | ||
| private val retrofit: Retrofit | ||
| get() = Retrofit.Builder() | ||
| .baseUrl("https://api.github.com/") | ||
| .addConverterFactory(GsonConverterFactory.create()) | ||
| .build() | ||
|
|
||
| val service: GithubApiService = retrofit.create(GithubApiService::class.java) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package place.pic.android.plus.data.remote.response | ||
|
|
||
| /** | ||
| * Created By kimdahyee | ||
| * on 11월 02일, 2020 | ||
| */ | ||
|
|
||
| data class UserSearchResponse( | ||
| val total_count: Int, | ||
| val incomplete_results: Boolean, | ||
| val items: List<Data> | ||
| ) { | ||
| data class Data( | ||
| val login: String, | ||
| val id: Long, | ||
| val node_id: String, | ||
| val avatar_url: String, | ||
| val url: String, | ||
| val html_url: String, | ||
| val followers_url: String, | ||
| val following_url: String, | ||
| val gists_url: String, | ||
| val starred_url: String, | ||
| val subscriptions_url: String, | ||
| val organizations_url: String, | ||
| val repos_url: String, | ||
| val events_url: String, | ||
| val received_events_url: String, | ||
| val type: String, | ||
| val site_admin: Boolean, | ||
| val score: Double | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| package place.pic.android.plus | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main) | ||
| } | ||
| } | ||
| package place.pic.android.plus.ui | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import place.pic.android.plus.R | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package place.pic.android.plus.ui.detail.view | ||
|
|
||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import androidx.activity.viewModels | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import androidx.databinding.DataBindingUtil | ||
| import place.pic.android.plus.R | ||
| import place.pic.android.plus.databinding.ActivityUserDatailBinding | ||
| import place.pic.android.plus.ui.detail.viewmodel.UserDetailViewModel | ||
|
|
||
| class UserDetailActivity : AppCompatActivity() { | ||
|
|
||
| private val userDetailViewModel: UserDetailViewModel by viewModels() | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| init() | ||
| checkErrorAndRequest() | ||
| } | ||
|
|
||
| private fun init() { | ||
| val binding = | ||
| DataBindingUtil.setContentView<ActivityUserDatailBinding>(this, R.layout.activity_user_datail) | ||
| binding.viewModel = userDetailViewModel | ||
| binding.lifecycleOwner = this | ||
| } | ||
|
|
||
| private fun checkErrorAndRequest() { | ||
| val username = intent.getStringExtra("username").toString() | ||
| if (username.isEmpty()) { | ||
| Log.d("error check", "userDetailActivity username is null") | ||
| return | ||
| } | ||
| userDetailViewModel.requestUserDetail(username) | ||
| } | ||
| } | ||
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.
intent.getStringExtra("username")이 친구의 결과물은 뭘까?지금의 요구 사항에선 필요 없는 부분이지만
만약 UserDetailActivty가 username을 받지 않고 실행되었다면 어떻게 되어야 할 것 같은지 고려해봐야 하지 않을까?
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.
에러 처리 추가하겟숨둥둥