Skip to content

Commit

Permalink
Merge pull request #61 from ttoklip/feat/#3_우리동네_화면_구현
Browse files Browse the repository at this point in the history
Feat/#3 우리동네 화면 구현
  • Loading branch information
posite authored Feb 19, 2024
2 parents 36eef3e + b1cda9b commit dae9145
Show file tree
Hide file tree
Showing 31 changed files with 697 additions and 518 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.town.CommsResponse
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path

interface TogethersApi {
interface MainCommsApi {
@GET("/api/v1/town/main/community")
suspend fun commsList(
@Path("postId") postId: Long
): Response<ResponseBody<CommsResponse>>
suspend fun commsList(): Response<ResponseBody<CommsResponse>>
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.umc.ttoklip.data.api

interface CommsApi {
interface MainTogethersApi {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.umc.ttoklip.data.model.town

data class CommentResponse(
val commentId: Long,
val commentContent: String,
val commentContent: String?,
val parentId: Long?,
val writer: String,
val writtenTime: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.umc.ttoklip.data.model.town

data class CommsResponse(
val communities: List<Comms>
val communities: List<Communities>
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.umc.ttoklip.data.model.town

data class Comms(
data class Communities(
val id: Long,
val title: String,
val content: String,
val commentCount: Long,
val likeCount: Long,
val scrapCount: Long
val scrapCount: Long,
val writer: String
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.umc.ttoklip.data.model.town

data class CreateCommentRequest(
val content: String,
val comment: String,
val parentCommentId: Long
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.umc.ttoklip.data.model.town

data class ImageUrl(
val imageId: Long,
val postImageUrl: String
val imageUrl: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data class ViewCommunicationResponse(
val scrapCount: Long,
val likeCount: Long,
val commentCount: Int,
val commentResponse: List<CommentResponse>,
val commentResponses: List<CommentResponse>,
val likedByCurrentUser: Boolean,
val scrapedByCurrentUser: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.umc.ttoklip.data.repository.town

import com.umc.ttoklip.data.model.town.CommsResponse
import com.umc.ttoklip.module.NetworkResult

interface MainCommsRepository {
suspend fun getComms(): NetworkResult<CommsResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.umc.ttoklip.data.repository.town

import com.umc.ttoklip.data.api.MainCommsApi
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.town.CommsResponse
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject

class MainCommsRepositoryImpl @Inject constructor(private val api: MainCommsApi) :
MainCommsRepository {
override suspend fun getComms(): NetworkResult<CommsResponse> {
return handleApi({ api.commsList() }) { response: ResponseBody<CommsResponse> -> response.result }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.umc.ttoklip.data.repository.town

interface MainTogethersRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.umc.ttoklip.data.repository.town

import com.umc.ttoklip.data.api.MainTogethersApi
import javax.inject.Inject

class MainTogethersRepositoryImpl @Inject constructor(private val api: MainTogethersApi) :
MainTogethersRepository {

}
15 changes: 15 additions & 0 deletions app/src/main/java/com/umc/ttoklip/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.umc.ttoklip.data.api.KakaoApi
import com.umc.ttoklip.data.api.LoginApi
import com.umc.ttoklip.data.api.MyPage2Api
import com.umc.ttoklip.data.api.MyPageApi
import com.umc.ttoklip.data.api.MainCommsApi
import com.umc.ttoklip.data.api.MainTogethersApi
import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.api.MyBlockUserApi
import com.umc.ttoklip.data.api.MyPostApi
Expand Down Expand Up @@ -229,6 +231,19 @@ object NetworkModule {
return retrofit.buildService()
}

@Provides
@Singleton
fun provideMainCommsApi(retrofit: Retrofit): MainCommsApi {
return retrofit.buildService()
}

@Provides
@Singleton
fun provideMainTogethersApi(retrofit: Retrofit): MainTogethersApi {
return retrofit.buildService()
}


private inline fun <reified T> Retrofit.buildService(): T {
return this.create(T::class.java)
}
Expand Down
40 changes: 29 additions & 11 deletions app/src/main/java/com/umc/ttoklip/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package com.umc.ttoklip.di

import com.umc.ttoklip.data.api.HomeApi
import com.umc.ttoklip.data.api.MainCommsApi
import com.umc.ttoklip.data.api.MainTogethersApi
import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.api.MyBlockUserApi
import com.umc.ttoklip.data.api.MyPage2Api
import com.umc.ttoklip.data.api.MyPageApi
import com.umc.ttoklip.data.api.MyPostApi
import com.umc.ttoklip.data.api.NewsApi
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.api.ReadTogetherApi
import com.umc.ttoklip.data.api.Search2Api
import com.umc.ttoklip.data.api.SearchApi
import com.umc.ttoklip.data.repository.mypage.MyPageRepository2
import com.umc.ttoklip.data.repository.mypage.MyPageRepository2Impl
import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.api.MyBlockUserApi
import com.umc.ttoklip.data.api.MyPostApi
import com.umc.ttoklip.data.api.WriteCommsApi
import com.umc.ttoklip.data.api.WriteTogetherApi
import com.umc.ttoklip.data.repository.home.HomeRepository
import com.umc.ttoklip.data.repository.home.HomeRepositoryImpl
import com.umc.ttoklip.data.repository.mypage.MyAccountRestrictRepository
import com.umc.ttoklip.data.repository.mypage.MyAccountRestrictRepositoryImpl
import com.umc.ttoklip.data.repository.mypage.MyBlockUserRepository
import com.umc.ttoklip.data.repository.mypage.MyBlockUserRepositoryImpl
import com.umc.ttoklip.data.repository.mypage.MyPageRepository2
import com.umc.ttoklip.data.repository.mypage.MyPageRepository2Impl
import com.umc.ttoklip.data.repository.mypage.MyPostRepository
import com.umc.ttoklip.data.repository.mypage.MyPostRepositoryImpl
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.api.ReadTogetherApi
import com.umc.ttoklip.data.api.WriteCommsApi
import com.umc.ttoklip.data.api.WriteTogetherApi
import com.umc.ttoklip.data.repository.home.HomeRepository
import com.umc.ttoklip.data.repository.home.HomeRepositoryImpl
import com.umc.ttoklip.data.repository.news.NewsRepository
import com.umc.ttoklip.data.repository.news.NewsRepositoryImpl
import com.umc.ttoklip.data.repository.scrap.ScrapRepository
Expand All @@ -31,6 +33,10 @@ import com.umc.ttoklip.data.repository.search.Search2Repository
import com.umc.ttoklip.data.repository.search.Search2RepositoryImpl
import com.umc.ttoklip.data.repository.search.SearchRepository
import com.umc.ttoklip.data.repository.search.SearchRepositoryImpl
import com.umc.ttoklip.data.repository.town.MainCommsRepository
import com.umc.ttoklip.data.repository.town.MainCommsRepositoryImpl
import com.umc.ttoklip.data.repository.town.MainTogethersRepository
import com.umc.ttoklip.data.repository.town.MainTogethersRepositoryImpl
import com.umc.ttoklip.data.repository.town.ReadCommsRepository
import com.umc.ttoklip.data.repository.town.ReadCommsRepositoryImpl
import com.umc.ttoklip.data.repository.town.ReadTogetherRepository
Expand Down Expand Up @@ -88,6 +94,18 @@ object RepositoryModule {
Search2RepositoryImpl(api)


@Provides
@Singleton
fun providesMainCommsRepository(api: MainCommsApi): MainCommsRepository =
MainCommsRepositoryImpl(api)


@Provides
@Singleton
fun providesMainTogethersRepository(api: MainTogethersApi): MainTogethersRepository =
MainTogethersRepositoryImpl(api)


@Provides
@Singleton
fun providesScrapRepository(api: MyPageApi): ScrapRepository =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import dagger.hilt.android.AndroidEntryPoint
class AddressDetailActivity :
BaseActivity<ActivityAddressDetailBinding>(R.layout.activity_address_detail) {
override fun initView() {
val type = intent.getStringExtra("place")
val address = intent.getStringExtra("address")
address?.let {
binding.dealPlaceTv.text = address
}
type?.let {
binding.titleTv.text = getString(R.string.my_hometown_address_title)
}
binding.locationNextBtn.setOnClickListener {
val intent = Intent(this, PlaceActivity::class.java)
intent.putExtra("address", address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@ package com.umc.ttoklip.presentation.hometown

import android.content.Intent
import androidx.activity.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.LinearLayoutManager
import com.umc.ttoklip.R
import com.umc.ttoklip.data.model.town.Communities
import com.umc.ttoklip.databinding.ActivityCommunicationBinding
import com.umc.ttoklip.presentation.alarm.AlarmActivity
import com.umc.ttoklip.presentation.base.BaseActivity
import com.umc.ttoklip.presentation.hometown.adapter.Communication
import com.umc.ttoklip.presentation.hometown.adapter.CommunicationAdapter
import com.umc.ttoklip.presentation.hometown.adapter.OnItemClickListener
import com.umc.ttoklip.presentation.mypage.SortSpinnerAdapter
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
class CommunicationActivity :
BaseActivity<ActivityCommunicationBinding>(R.layout.activity_communication),
OnItemClickListener {
private val adapter by lazy {
CommunicationAdapter(this)
}
private val viewModel: CommunicationViewModel by viewModels<CommunicationViewModelImpl>()
override fun initView() {
binding.vm = viewModel as CommunicationViewModelImpl
Expand All @@ -29,105 +37,41 @@ class CommunicationActivity :
getString(R.string.sort_most_comments),
getString(R.string.sort_most_scrap)
)
binding.bellBtn.setOnClickListener {
startActivity(AlarmActivity.newIntent(this))
}
binding.honeyTipFilterSpinner.adapter =
SortSpinnerAdapter(this, sortFilters)
binding.honeyTipFilterSpinner.setSelection(0)

val honeyTipList = listOf(
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
Communication(
"똑똑이",
"음식물 쓰레기 냄새 방지!!",
"집에 가끔씩이지만 나타나는 바퀴벌레, 잘못 처리하면 알깐다고도...",
"1일전",
0
),
)
val adapter = CommunicationAdapter(this)


binding.communicationRv.layoutManager = LinearLayoutManager(this)
binding.communicationRv.adapter = adapter
adapter.submitList(honeyTipList)

binding.backBtn.setOnClickListener {
finish()
}
viewModel.getCommunities()
}

override fun initObserver() {

override fun initObserver() {
with(lifecycleScope) {
launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.communities.collect {
adapter.submitList(it)
}
}
}
}
}

override fun onClick(communication: Communication) {

override fun onClick(communication: Communities) {
val intent = Intent(this, ReadCommunicationActivity::class.java)
intent.putExtra("postId", communication.id)
startActivity(intent)
}

}
Loading

0 comments on commit dae9145

Please sign in to comment.