Skip to content

Commit

Permalink
Merge pull request #33 from SSU-Plector/feat/#32-dev-project-api-view
Browse files Browse the repository at this point in the history
[Feat/#32 dev project api view]: 프로젝트, 개발자 API 붙이기, 데이터 핸들링
  • Loading branch information
kangyuri1114 authored May 26, 2024
2 parents d1931ac + 05ed178 commit 324cf41
Show file tree
Hide file tree
Showing 52 changed files with 775 additions and 710 deletions.
40 changes: 40 additions & 0 deletions core/common/src/main/java/com/zucchini/view/ViewExt.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.zucchini.view

import android.app.Activity
import android.content.Context
import android.graphics.Rect
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView

Expand Down Expand Up @@ -36,3 +41,38 @@ class HorizontalSpaceItemDecoration(private val horizontalSpaceHeight: Int) :
}
}
}

fun Context.showShortToast(message: String) {
Toast.makeText(
this,
message,
Toast.LENGTH_SHORT,
).show()
}

fun Fragment.hideKeyboard() {
view?.let { activity?.hideKeyboard(it) }
}

fun Activity.hideKeyboard() {
hideKeyboard(currentFocus ?: View(this))
}

fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}

inline fun View.setOnSingleClickListener(
delay: Long = 1000L,
crossinline block: (View) -> Unit,
) {
var previousClickedTime = 0L
setOnClickListener { view ->
val clickedTime = System.currentTimeMillis()
if (clickedTime - previousClickedTime >= delay) {
block(view)
previousClickedTime = clickedTime
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,51 @@ data class DevelopersDetailResponse(
@SerialName("id")
val id: Int,
@SerialName("name")
val name: String,
val name: String?,
@SerialName("shortIntro")
val shortIntro: String,
val shortIntro: String?,
@SerialName("university")
val university: String,
val university: String?,
@SerialName("major")
val major: String,
val major: String?,
@SerialName("studentNumber")
val studentNumber: String,
val studentNumber: String?,
@SerialName("email")
val email: String,
val email: String?,
@SerialName("hits")
val hits: Int,
val hits: Int?,
@SerialName("kakaoId")
val kakaoId: String,
val kakaoId: String?,
@SerialName("githubLink")
val githubLink: String,
val githubLink: String?,
@SerialName("imageLink")
val imageLink: String?,
@SerialName("projectList")
val projectsListInDevelopersDetail: List<ProjectsListInDevelopersDetail>,
val projectsListInDevelopersDetail: List<ProjectsListInDevelopersDetail>?,
@SerialName("languageList")
val languageList: List<String>,
val languageList: List<String?>?,
@SerialName("devToolList")
val devToolList: List<String>,
val devToolList: List<String?>?,
@SerialName("techStackList")
val techStackList: List<String>,
val techStackList: List<String?>?,
@SerialName("part1")
val part1: String?,
@SerialName("part2")
val part2: String?,
@SerialName("developer")
val developer: Boolean,
val developer: Boolean?,
) {
@Serializable
data class ProjectsListInDevelopersDetail(
@SerialName("id")
val id: Int,
@SerialName("name")
val name: String,
val name: String?,
@SerialName("imageLink")
val imageLink: String,
val imageLink: String?,
@SerialName("shortIntro")
val shortIntro: String,
val shortIntro: String?,
@SerialName("category")
val category: String,
@SerialName("hits")
val hits: Int,
val category: String?,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ data class DevelopersListResponse(
@SerialName("id")
val id: Int,
@SerialName("name")
val name: String,
val name: String?,
@SerialName("part1")
val part1: String?,
@SerialName("part2")
val part2: String?,
@SerialName("githubLink")
val githubLink: String,
val githubLink: String?,
@SerialName("hits")
val hits: Int,
val hits: Int = 0,
@SerialName("imageLink")
val imageLink: String?,
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ data class ProjectsDetailResponse(
@SerialName("name")
val name: String,
@SerialName("imageLink")
val imageLink: String,
val imageLink: String?,
@SerialName("developerList")
val developerList: List<DeveloperListInProjectDetail>,
val developerList: List<DeveloperListInProjectDetail>? = emptyList(),
@SerialName("shortIntro")
val shortIntro: String,
val shortIntro: String?,
@SerialName("longIntro")
val longIntro: String,
val longIntro: String?,
@SerialName("category")
val category: String,
@SerialName("hits")
val hits: Int,
@SerialName("githubLink")
val githubLink: String,
val githubLink: String?,
@SerialName("infoPageLink")
val infoPageLink: String,
val infoPageLink: String?,
@SerialName("webLink")
val webLink: String,
val webLink: String?,
@SerialName("appLink")
val appLink: String,
val appLink: String?,
@SerialName("languageList")
val languageList: List<String>,
val languageList: List<String?>?,
@SerialName("devToolList")
val devToolList: List<String>,
val devToolList: List<String?>?,
@SerialName("techStackList")
val techStackList: List<String>,
val techStackList: List<String?>?,
) {
@Serializable
data class DeveloperListInProjectDetail(
Expand All @@ -43,6 +43,6 @@ data class ProjectsDetailResponse(
@SerialName("name")
val name: String,
@SerialName("partList")
val partList: List<String>,
val partList: List<String?>,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data class ProjectsListResponse(
@SerialName("name")
val name: String,
@SerialName("imagePath")
val imagePath: String,
val imagePath: String?,
@SerialName("shortIntro")
val shortIntro: String,
@SerialName("category")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import retrofit2.http.Query
interface ProjectsService {
@GET("api/projects/list")
suspend fun getProjectsListData(
@Query("searchString") searchString: String? = "",
@Query("category") category: String,
@Query("searchString") searchString: String?,
@Query("category") category: String?,
@Query("sortType") sortType: String,
@Query("page") page: Int = 0,
@Query("page") page: Int,
): BaseResponse<ProjectsListResponse>

@GET("api/projects/{projectId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import javax.inject.Inject
class DevelopersRepositoryImpl @Inject constructor(
private val developersService: DevelopersService,
) : DevelopersRepository {
override suspend fun getDevelopersListData(): Result<DevelopersListModel> {
override suspend fun getDevelopersListData(page: Int, part: String?): Result<DevelopersListModel> {
return runCatching {
developersService.getDevelopersListData(
sortType = null,
part = null,
page = 0,
part = part,
page = page,
).data.toDevelopersListModel()
}
}
Expand Down
10 changes: 5 additions & 5 deletions data/src/main/java/com/zucchini/data/ProjectsRepositoryImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import javax.inject.Inject
class ProjectsRepositoryImpl @Inject constructor(
private val projectsService: ProjectsService,
) : ProjectsRepository {
override suspend fun getProjectsListData(): Result<ProjectsListModel> {
override suspend fun getProjectsListData(searchString: String?, category: String?, sortType: String, page: Int): Result<ProjectsListModel> {
return runCatching {
projectsService.getProjectsListData(
searchString = "",
category = "SERVICE",
sortType = "recent",
page = 0,
searchString = searchString,
category = category,
sortType = sortType,
page = page,
).data.toProjectsListModel()
}
}
Expand Down
8 changes: 4 additions & 4 deletions data/src/main/java/com/zucchini/mapper/DevelopersDetail.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.zucchini.mapper

import com.sample.network.reponse.DevelopersDetailResponse
import com.zucchini.domain.model.DeveloperInfoInDetailModel
import com.zucchini.domain.model.DevelopersDetailModel
import com.zucchini.domain.model.ProjectInfoInDevDetailModel

internal fun DevelopersDetailResponse.toDevelopersDetailModel(): DevelopersDetailModel {
val projectsListInDevelopersDetail = projectsListInDevelopersDetail.map { developerInfo ->
DeveloperInfoInDetailModel(
val projectsListInDevelopersDetail = projectsListInDevelopersDetail?.map { developerInfo ->
ProjectInfoInDevDetailModel(
id = developerInfo.id,
name = developerInfo.name,
imageLink = developerInfo.imageLink,
shortIntro = developerInfo.shortIntro,
category = developerInfo.category,
hits = developerInfo.hits,
)
}

Expand All @@ -27,6 +26,7 @@ internal fun DevelopersDetailResponse.toDevelopersDetailModel(): DevelopersDetai
hits = hits,
kakaoId = kakaoId,
githubLink = githubLink,
imageLink = imageLink,
projectList = projectsListInDevelopersDetail,
languageList = languageList,
devToolList = devToolList,
Expand Down
1 change: 1 addition & 0 deletions data/src/main/java/com/zucchini/mapper/DevelopersList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal fun DevelopersListResponse.toDevelopersListModel(): DevelopersListModel
part2 = dto.part2,
githubLink = dto.githubLink,
hits = dto.hits,
imageLink = dto.imageLink,
)
}

Expand Down
10 changes: 3 additions & 7 deletions data/src/main/java/com/zucchini/mapper/ProjectsDetail.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.zucchini.mapper

import com.sample.network.reponse.DevelopersDetailResponse
import com.sample.network.reponse.ProjectsDetailResponse
import com.zucchini.domain.model.DeveloperInfoInDetailModel
import com.zucchini.domain.model.DeveloperListInProjectDetail
import com.zucchini.domain.model.DevelopersDetailModel
import com.zucchini.domain.model.ProjectsDetailModel

internal fun ProjectsDetailResponse.toProjectsDetailModel(): ProjectsDetailModel {
val developerListInProjectDetail = developerList.map { developerList ->
DeveloperListInProjectDetail(
val developerListInProjectDetail = developerList?.map { developerList ->
ProjectsDetailModel.DeveloperListInProjectDetail(
id = developerList.id,
name = developerList.name,
partList = developerList.partList,
Expand All @@ -20,7 +16,7 @@ internal fun ProjectsDetailResponse.toProjectsDetailModel(): ProjectsDetailModel
id = id,
name = name,
imageLink = imageLink,
developerList = developerListInProjectDetail,
developerList = developerListInProjectDetail ?: emptyList(),
shortIntro = shortIntro,
longIntro = longIntro,
category = category,
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions domain/src/main/java/com/zucchini/domain/model/DeveloperInfo.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ package com.zucchini.domain.model

data class DevelopersDetailModel(
val id: Int,
val name: String,
val shortIntro: String,
val university: String,
val major: String,
val studentNumber: String,
val email: String,
val hits: Int,
val kakaoId: String,
val githubLink: String,
val projectList: List<DeveloperInfoInDetailModel>,
val languageList: List<String>,
val devToolList: List<String>,
val techStackList: List<String>,
val name: String?,
val shortIntro: String?,
val university: String?,
val major: String?,
val studentNumber: String?,
val email: String?,
val hits: Int?,
val kakaoId: String?,
val githubLink: String?,
val imageLink: String?,
val projectList: List<ProjectInfoInDevDetailModel>?,
val languageList: List<String?>?,
val devToolList: List<String?>?,
val techStackList: List<String?>?,
val part1: String?,
val part2: String?,
val developer: Boolean,
val developer: Boolean?,
)

data class DeveloperInfoInDetailModel(
data class ProjectInfoInDevDetailModel(
val id: Int,
val name: String,
val imageLink: String,
val shortIntro: String,
val category: String,
val hits: Int,
val name: String?,
val imageLink: String?,
val shortIntro: String?,
val category: String?,
)
Loading

0 comments on commit 324cf41

Please sign in to comment.