From 5a83bc3e15d8590197919d94e604265d7a521e7b Mon Sep 17 00:00:00 2001 From: Hyuns66 Date: Wed, 22 Jun 2022 22:21:28 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Design=20:=20Add=20default=20image=20for=20?= =?UTF-8?q?Bnv=20=EB=B0=94=ED=84=B4=E3=85=81=20=EB=84=A4=EB=B9=84=EA=B2=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EB=B7=B0=20=EB=8F=99=EC=9E=91=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B8=B0=EB=B3=B8=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=84=A4=EC=A0=95=ED=95=B4=EB=91=A0=20=EB=82=98?= =?UTF-8?q?=EC=A4=91=EC=97=90=20=EB=94=94=EC=9E=90=EC=9D=B4=EB=84=88?= =?UTF-8?q?=EB=8B=98=EA=BB=98=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EB=B0=9B?= =?UTF-8?q?=EC=95=84=EC=84=9C=20selector=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit with '#' will be ignored, and an empty message aborts the commit. --- .../config/XAccessTokenInterceptor.kt | 4 +- .../ui/calendar/CalendarFragment.kt | 2 +- .../ui/community/CommunityFragment.kt | 2 +- .../bottom_nav_menu_archive_selector.xml | 5 ++ .../bottom_nav_menu_history_selector.xml | 5 ++ .../bottom_nav_menu_home_selector.xml | 5 ++ .../bottom_nav_menu_profile_selector.xml | 5 ++ app/src/main/res/drawable/ic_bnv_archive.xml | 49 ++++++++++++++++++ app/src/main/res/drawable/ic_bnv_history.xml | 28 ++++++++++ app/src/main/res/drawable/ic_bnv_home.xml | 21 ++++++++ app/src/main/res/drawable/ic_bnv_profile.xml | 21 ++++++++ .../main/res/drawable/select_bnv_archive.xml | 9 ++++ .../main/res/drawable/select_bnv_history.xml | 9 ++++ app/src/main/res/drawable/select_bnv_home.xml | 9 ++++ .../main/res/drawable/select_bnv_profile.xml | 9 ++++ app/src/main/res/drawable/selector_bnv.png | Bin 0 -> 4503 bytes 16 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/bottom_nav_menu_archive_selector.xml create mode 100644 app/src/main/res/drawable/bottom_nav_menu_history_selector.xml create mode 100644 app/src/main/res/drawable/bottom_nav_menu_home_selector.xml create mode 100644 app/src/main/res/drawable/bottom_nav_menu_profile_selector.xml create mode 100644 app/src/main/res/drawable/ic_bnv_archive.xml create mode 100644 app/src/main/res/drawable/ic_bnv_history.xml create mode 100644 app/src/main/res/drawable/ic_bnv_home.xml create mode 100644 app/src/main/res/drawable/ic_bnv_profile.xml create mode 100644 app/src/main/res/drawable/select_bnv_archive.xml create mode 100644 app/src/main/res/drawable/select_bnv_history.xml create mode 100644 app/src/main/res/drawable/select_bnv_home.xml create mode 100644 app/src/main/res/drawable/select_bnv_profile.xml create mode 100644 app/src/main/res/drawable/selector_bnv.png diff --git a/app/src/main/java/com/likefirst/meyouhouse/config/XAccessTokenInterceptor.kt b/app/src/main/java/com/likefirst/meyouhouse/config/XAccessTokenInterceptor.kt index ae0b156..86bd1eb 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/config/XAccessTokenInterceptor.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/config/XAccessTokenInterceptor.kt @@ -9,7 +9,9 @@ class XAccessTokenInterceptor: Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val builder: Request.Builder = chain.request().newBuilder() - val jwtToken: String? = getJwt() + // TODO + // null 대신에 getUser() sharedPreferencesManager에 정의해서 사용해야 합니다 + val jwtToken: String? = null jwtToken?.let{ builder.addHeader(X_ACCESS_TOKEN, jwtToken) diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/calendar/CalendarFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/calendar/CalendarFragment.kt index a93ec5f..218d5a4 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/calendar/CalendarFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/calendar/CalendarFragment.kt @@ -5,6 +5,6 @@ import com.likefirst.meyouhouse.ui.BaseFragment class CalendarFragment : BaseFragment(FragmentCalendarBinding::inflate) { override fun initAfterBinding() { - TODO("Not yet implemented") + } } \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt index 57af88c..891cfa6 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt @@ -5,6 +5,6 @@ import com.likefirst.meyouhouse.ui.BaseFragment class CommunityFragment : BaseFragment(FragmentCommunityBinding::inflate) { override fun initAfterBinding() { - TODO("Not yet implemented") + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_nav_menu_archive_selector.xml b/app/src/main/res/drawable/bottom_nav_menu_archive_selector.xml new file mode 100644 index 0000000..0e680d7 --- /dev/null +++ b/app/src/main/res/drawable/bottom_nav_menu_archive_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_nav_menu_history_selector.xml b/app/src/main/res/drawable/bottom_nav_menu_history_selector.xml new file mode 100644 index 0000000..6c95937 --- /dev/null +++ b/app/src/main/res/drawable/bottom_nav_menu_history_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_nav_menu_home_selector.xml b/app/src/main/res/drawable/bottom_nav_menu_home_selector.xml new file mode 100644 index 0000000..3d6520e --- /dev/null +++ b/app/src/main/res/drawable/bottom_nav_menu_home_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_nav_menu_profile_selector.xml b/app/src/main/res/drawable/bottom_nav_menu_profile_selector.xml new file mode 100644 index 0000000..5d6cbee --- /dev/null +++ b/app/src/main/res/drawable/bottom_nav_menu_profile_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bnv_archive.xml b/app/src/main/res/drawable/ic_bnv_archive.xml new file mode 100644 index 0000000..ee5014a --- /dev/null +++ b/app/src/main/res/drawable/ic_bnv_archive.xml @@ -0,0 +1,49 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_bnv_history.xml b/app/src/main/res/drawable/ic_bnv_history.xml new file mode 100644 index 0000000..da63b07 --- /dev/null +++ b/app/src/main/res/drawable/ic_bnv_history.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_bnv_home.xml b/app/src/main/res/drawable/ic_bnv_home.xml new file mode 100644 index 0000000..839785c --- /dev/null +++ b/app/src/main/res/drawable/ic_bnv_home.xml @@ -0,0 +1,21 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_bnv_profile.xml b/app/src/main/res/drawable/ic_bnv_profile.xml new file mode 100644 index 0000000..6f2e4f2 --- /dev/null +++ b/app/src/main/res/drawable/ic_bnv_profile.xml @@ -0,0 +1,21 @@ + + + + + diff --git a/app/src/main/res/drawable/select_bnv_archive.xml b/app/src/main/res/drawable/select_bnv_archive.xml new file mode 100644 index 0000000..93fd21e --- /dev/null +++ b/app/src/main/res/drawable/select_bnv_archive.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/select_bnv_history.xml b/app/src/main/res/drawable/select_bnv_history.xml new file mode 100644 index 0000000..1a00791 --- /dev/null +++ b/app/src/main/res/drawable/select_bnv_history.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/select_bnv_home.xml b/app/src/main/res/drawable/select_bnv_home.xml new file mode 100644 index 0000000..09b8098 --- /dev/null +++ b/app/src/main/res/drawable/select_bnv_home.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/select_bnv_profile.xml b/app/src/main/res/drawable/select_bnv_profile.xml new file mode 100644 index 0000000..20d4f5e --- /dev/null +++ b/app/src/main/res/drawable/select_bnv_profile.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_bnv.png b/app/src/main/res/drawable/selector_bnv.png new file mode 100644 index 0000000000000000000000000000000000000000..f24754197d72f448fe738a7ebdc227c300e91e93 GIT binary patch literal 4503 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 literal 0 HcmV?d00001 From e38e696c6653523339c7dd356d66efb367707007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8D=EA=B9=80=ED=98=B8=EC=A4=80=28=ED=95=99=EB=B6=80?= =?UTF-8?q?=EC=83=9D-=EC=86=8C=ED=94=84=ED=8A=B8=EC=9B=A8=EC=96=B4?= =?UTF-8?q?=EC=A0=84=EA=B3=B5=29?= Date: Thu, 23 Jun 2022 15:31:45 +0900 Subject: [PATCH 2/5] Feat : Community Fragmnet, Add DetailActivity, PostingActivity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 커뮤니티, 글작성, 상세보기 페이지 구현 구현 - 해당 리싸이클러뷰 및 더미 데이터로 구현 TODO - 서버에서 받아오기 미구현 - 서버에 맞게 DTO 만들어야함 --- app/build.gradle | 4 + app/src/main/AndroidManifest.xml | 5 + .../meyouhouse/data/dto/community/Article.kt | 7 + .../meyouhouse/data/dto/community/Comment.kt | 6 + .../data/dto/community/DetailImage.kt | 6 + .../data/dto/community/SelectedImage.kt | 8 + .../likefirst/meyouhouse/ui/BaseFragment.kt | 7 +- .../ui/community/ArticleDetailActivity.kt | 72 ++++++++ .../ui/community/ArticlePostingActivity.kt | 110 ++++++++++++ .../ui/community/ArticleRVAdapter.kt | 46 +++++ .../ui/community/CommentRVAdapter.kt | 40 +++++ .../ui/community/CommunityFragment.kt | 43 +++++ .../ui/community/DetailImageRVAdapter.kt | 42 +++++ .../ui/community/SelectedImageRVAdapter.kt | 39 +++++ .../meyouhouse/util/MultiPartResolver.kt | 51 ++++++ .../main/res/drawable/ic_icon_camera_grey.xml | 16 ++ .../res/drawable/ic_icon_comment_black.xml | 13 ++ .../res/drawable/ic_icon_comment_blue.xml | 13 ++ .../ic_icon_default_thumbnail_image.xml | 14 ++ .../res/drawable/ic_icon_float_add_white.xml | 5 + .../drawable/ic_icon_float_addbtn_blue.xml | 12 ++ .../res/layout/activity_article_detail.xml | 164 ++++++++++++++++++ .../res/layout/activity_article_posting.xml | 139 +++++++++++++++ .../main/res/layout/fragment_community.xml | 60 ++++++- app/src/main/res/layout/item_comment_rv.xml | 55 ++++++ app/src/main/res/layout/item_community_rv.xml | 68 ++++++++ .../main/res/layout/item_detail_image_rv.xml | 27 +++ .../res/layout/item_selected_image_rv.xml | 29 ++++ app/src/main/res/values/strings.xml | 6 + 29 files changed, 1102 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Article.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/SelectedImage.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/ui/community/SelectedImageRVAdapter.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt create mode 100644 app/src/main/res/drawable/ic_icon_camera_grey.xml create mode 100644 app/src/main/res/drawable/ic_icon_comment_black.xml create mode 100644 app/src/main/res/drawable/ic_icon_comment_blue.xml create mode 100644 app/src/main/res/drawable/ic_icon_default_thumbnail_image.xml create mode 100644 app/src/main/res/drawable/ic_icon_float_add_white.xml create mode 100644 app/src/main/res/drawable/ic_icon_float_addbtn_blue.xml create mode 100644 app/src/main/res/layout/activity_article_detail.xml create mode 100644 app/src/main/res/layout/activity_article_posting.xml create mode 100644 app/src/main/res/layout/item_comment_rv.xml create mode 100644 app/src/main/res/layout/item_community_rv.xml create mode 100644 app/src/main/res/layout/item_detail_image_rv.xml create mode 100644 app/src/main/res/layout/item_selected_image_rv.xml diff --git a/app/build.gradle b/app/build.gradle index dc9addd..b2d80ee 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -51,4 +51,8 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.okhttp3:okhttp:4.9.0' implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.4' + + //Glide + implementation 'com.github.bumptech.glide:glide:4.12.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 94286d5..14490f6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Article.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Article.kt new file mode 100644 index 0000000..2d9b48c --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Article.kt @@ -0,0 +1,7 @@ +package com.likefirst.meyouhouse.data.dto.community + +data class Article( + val body : String, + val date : String, + val commentCount : Int +) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt new file mode 100644 index 0000000..8fec93d --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt @@ -0,0 +1,6 @@ +package com.likefirst.meyouhouse.data.dto.community + +data class Comment( + val date : String, + val body : String +) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt new file mode 100644 index 0000000..241f0c6 --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt @@ -0,0 +1,6 @@ +package com.likefirst.meyouhouse.data.dto.community + +data class DetailImage( + val name : String, + val url : String, +) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/SelectedImage.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/SelectedImage.kt new file mode 100644 index 0000000..b630758 --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/SelectedImage.kt @@ -0,0 +1,8 @@ +package com.likefirst.meyouhouse.data.dto.community + +import android.net.Uri + +data class SelectedImage( + val name : String, + val uri : Uri +) diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/BaseFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/BaseFragment.kt index 6ea1766..fa986a7 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/BaseFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/BaseFragment.kt @@ -10,16 +10,16 @@ import androidx.viewbinding.ViewBinding import com.likefirst.meyouhouse.util.Inflate abstract class BaseFragment( - private val inflate: Inflate + private val inflate: Inflate, -) : Fragment() { + ) : Fragment() { private var _binding: VB? = null protected val binding get() = _binding!! override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { _binding = inflate.invoke(inflater, container, false) @@ -36,6 +36,7 @@ abstract class BaseFragment( _binding = null } + protected abstract fun initAfterBinding() fun showToast(message: String) { diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt new file mode 100644 index 0000000..65db7bb --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt @@ -0,0 +1,72 @@ +package com.likefirst.meyouhouse.ui.community + +import androidx.recyclerview.widget.LinearLayoutManager +import com.likefirst.meyouhouse.data.dto.community.Article +import com.likefirst.meyouhouse.data.dto.community.Comment +import com.likefirst.meyouhouse.data.dto.community.DetailImage +import com.likefirst.meyouhouse.databinding.ActivityArticleDetailBinding +import com.likefirst.meyouhouse.ui.BaseActivity + +class ArticleDetailActivity : + BaseActivity(ActivityArticleDetailBinding::inflate) { + //더미데이터셋 + val DummyDetail = mutableListOf(Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!"), + Comment("06/22 03:00", "점점 졸린것이야!")) + + val DummyImages = mutableListOf( +// DetailImage("여기에는 사진명", DUMMY_URL), +// DetailImage("여기에는 사진명", DUMMY_URL), +// DetailImage("여기에는 사진명", DUMMY_URL), +// DetailImage("여기에는 사진명", DUMMY_URL) + ) + + private lateinit var commentAdapter: CommentRVAdapter + private lateinit var detailImageAdapter: DetailImageRVAdapter + + override fun initAfterBinding() { + + // TODO + // 글 정보를 토대로 댓글에서 세부내용을 긁어옴 + // 아마 이미지를 표현해야하겠지? + // 이미지 URL 받아서 리사이클러뷰에 넣어주기 + initCommentRV() + initDetailImageRV() + initBodyAndDateTextView() + initCommentSubmitButton() + } + + private fun initDetailImageRV() { + detailImageAdapter = DetailImageRVAdapter(DummyImages) + binding.detailImageRecyclerView.layoutManager = LinearLayoutManager(this).apply { + orientation = LinearLayoutManager.HORIZONTAL + } + binding.detailImageRecyclerView.adapter = detailImageAdapter + } + + private fun initBodyAndDateTextView() { + binding.detailBodyTextView.text = "여기에 받아온 데이터를 넣으면 되겠다!" + binding.detailDate.text = "06/22 12:34" + } + + private fun initCommentRV() { + commentAdapter = CommentRVAdapter(DummyDetail) + binding.commentRecyclerView.layoutManager = LinearLayoutManager(this) + binding.commentRecyclerView.adapter = commentAdapter + } + + private fun initCommentSubmitButton() { + // TODO 버튼 클릭시, 서버에 전송, 및 화면 재로딩 + } + + companion object { + const val DUMMY_URL = "https://www.e2news.com/news/photo/202108/235458_90085_818.jpg" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt new file mode 100644 index 0000000..8077dbc --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt @@ -0,0 +1,110 @@ +package com.likefirst.meyouhouse.ui.community + +import android.content.ClipData +import android.content.Intent +import android.util.Log +import com.likefirst.meyouhouse.databinding.ActivityArticlePostingBinding +import com.likefirst.meyouhouse.databinding.FragmentCommunityBinding +import com.likefirst.meyouhouse.ui.BaseActivity +import com.likefirst.meyouhouse.ui.BaseFragment +import android.graphics.BitmapFactory + +import android.graphics.Bitmap +import android.net.Uri +import androidx.core.net.toUri +import androidx.recyclerview.widget.LinearLayoutManager +import com.likefirst.meyouhouse.data.dto.community.SelectedImage +import java.io.FileNotFoundException + + +class ArticlePostingActivity : + BaseActivity(ActivityArticlePostingBinding::inflate) { + override fun initAfterBinding() { + initSelectedImageRV() + initPhotoButton() + initSubmitButton() + initCancelButton() + } + + + private val selectedImageList = mutableListOf() + private lateinit var selectedImageAdapter : SelectedImageRVAdapter + + private fun initPhotoButton() { + binding.selectPhotoButton.setOnClickListener { + val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { + addCategory(Intent.CATEGORY_OPENABLE) + putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) + type = "image/*" + } + startActivityForResult(intent, READ_REQUEST_CODE) // 4 + } + } + + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + if (requestCode == READ_REQUEST_CODE) { + if (resultCode == RESULT_OK) { + //선택된 이미지 리스트 초기화 + selectedImageList.clear() + if (data == null) return + val clipData = data.getClipData() + if (clipData == null) { + Log.d(TAG, "한장일때" + data.data.toString()) + selectedImageList.add(SelectedImage("img1",data.data.toString().toUri())) + selectedImageAdapter.setData(selectedImageList) + binding.selectedImageCountTextView.text = "${1}/5" + } else{ + if (clipData.itemCount > 5) { + showToast("사진은 5장까지만 등록가능해요") + } else { + Log.d(TAG, clipData.itemCount.toString()) + for (i in 0 until clipData.itemCount) { + val imageSingleUri = clipData.getItemAt(i).uri + selectedImageList.add(SelectedImage("img${i+1}",imageSingleUri)) + Log.d(TAG, "${i}장일때" + imageSingleUri.toString()) + } + selectedImageAdapter.setData(selectedImageList) + binding.selectedImageCountTextView.text = "${clipData.itemCount}/5" + } + } + } + } + } + + private fun initSelectedImageRV() { + val initList = mutableListOf() + selectedImageAdapter = SelectedImageRVAdapter(initList) + binding.selectedPhotoRecyclerView.layoutManager = LinearLayoutManager(this).apply { + orientation = LinearLayoutManager.HORIZONTAL + } + binding.selectedPhotoRecyclerView.adapter = selectedImageAdapter + } + + private fun initSubmitButton() { + //TODO 서버에 이미지 업로드 + binding.submitTextButton.setOnClickListener { + showToast("버튼클릭") + } + } + + private fun initCancelButton() { + binding.cancelTextButton.setOnClickListener { + selectedImageList.clear() + finish() + } + } + + override fun onDestroy() { + super.onDestroy() + selectedImageList.clear() + Log.d(TAG,"onDestoryed! list be cleard") + } + + + companion object { + const val READ_REQUEST_CODE = 1000 + const val TAG = "ArticlePostAv" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt new file mode 100644 index 0000000..8a720b4 --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt @@ -0,0 +1,46 @@ +package com.likefirst.meyouhouse.ui.community + +import android.annotation.SuppressLint +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import android.widget.Toast +import androidx.recyclerview.widget.RecyclerView +import com.likefirst.meyouhouse.data.dto.community.Article +import com.likefirst.meyouhouse.databinding.ItemCommunityRvBinding + +class ArticleRVAdapter(val Articles : MutableList
, private val viewOnClickListener : ()->Unit) : RecyclerView.Adapter() { + + inner class ViewHolder(private val binding: ItemCommunityRvBinding) : RecyclerView.ViewHolder(binding.root) { + fun bind(article : Article) { + binding.articleBodyTextView.text = article.body + binding.communityDate.text = article.date + binding.commentCountTextView.text = article.commentCount.toString() + binding.root.setOnClickListener { + viewOnClickListener() + } + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(ItemCommunityRvBinding.inflate(LayoutInflater.from(parent.context),parent,false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bind(Articles[position]) + } + + override fun getItemCount(): Int { + return Articles.size + } + + @SuppressLint("NotifyDataSetChanged") + fun setData(list : MutableList
){ + Articles.clear() + Articles.addAll(list) + notifyDataSetChanged() + } + +} diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt new file mode 100644 index 0000000..d210dac --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt @@ -0,0 +1,40 @@ +package com.likefirst.meyouhouse.ui.community + +import android.annotation.SuppressLint +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.likefirst.meyouhouse.data.dto.community.Article +import com.likefirst.meyouhouse.data.dto.community.Comment +import com.likefirst.meyouhouse.databinding.ItemCommentRvBinding +import com.likefirst.meyouhouse.databinding.ItemCommunityRvBinding + +class CommentRVAdapter(val Comments : MutableList) : RecyclerView.Adapter() { + + inner class ViewHolder(private val binding: ItemCommentRvBinding) : RecyclerView.ViewHolder(binding.root) { + fun bind(comment : Comment) { + binding.commentBodyTextView.text = comment.body + binding.commentDetailDate.text = comment.date + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(ItemCommentRvBinding.inflate(LayoutInflater.from(parent.context),parent,false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bind(Comments[position]) + } + + override fun getItemCount(): Int { + return Comments.size + } + + @SuppressLint("NotifyDataSetChanged") + fun setData(list : MutableList){ + Comments.clear() + Comments.addAll(list) + notifyDataSetChanged() + } + +} diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt index 891cfa6..b25f6ac 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt @@ -1,10 +1,53 @@ package com.likefirst.meyouhouse.ui.community +import android.content.Intent +import android.util.Log +import androidx.recyclerview.widget.LinearLayoutManager +import com.likefirst.meyouhouse.data.dto.community.Article import com.likefirst.meyouhouse.databinding.FragmentCommunityBinding import com.likefirst.meyouhouse.ui.BaseFragment class CommunityFragment : BaseFragment(FragmentCommunityBinding::inflate) { + + //Dummy Article Data + val DummyArticles = mutableListOf
(Article("안녕하세요",date="6/22 05:24",commentCount=5),Article("안녕하세요2",date="6/22 05:24",commentCount=5),Article("안녕하세요",date="6/22 05:24",commentCount=5)) + private lateinit var articleAdapter : ArticleRVAdapter + override fun initAfterBinding() { + initFloatButton() + + // TODO 리사이클러뷰 만들기 + // TODO 게시글 눌렀을때 상세정보 뿌려주기 + initArticleRecyclerView() + + } + + + private fun initFloatButton() { + binding.addArticleFloatingButton.setOnClickListener { + context?.let{ + val intent = Intent(it,ArticlePostingActivity::class.java) + startActivity(intent) + } + } + } + + private fun initArticleRecyclerView() { + articleAdapter = ArticleRVAdapter(DummyArticles, viewOnClickListener = { + context?.let{ + val intent = Intent(it,ArticleDetailActivity::class.java) + startActivity(intent) + } + }) + binding.communityArticleRecyclerView.layoutManager = LinearLayoutManager(context) + binding.communityArticleRecyclerView.adapter = articleAdapter + + } + + + + companion object { + const val TAG = "CommunityFg" } } \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt new file mode 100644 index 0000000..27d89be --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt @@ -0,0 +1,42 @@ +package com.likefirst.meyouhouse.ui.community + +import android.annotation.SuppressLint +import android.util.Log +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import com.likefirst.meyouhouse.data.dto.community.DetailImage +import com.likefirst.meyouhouse.databinding.ItemDetailImageRvBinding + +class DetailImageRVAdapter (private val Images : MutableList) : RecyclerView.Adapter() { + + inner class ViewHolder(private val binding: ItemDetailImageRvBinding) : RecyclerView.ViewHolder(binding.root) { + fun bind(Image: DetailImage) { + Glide.with(binding.detailImageView.context) + .load(Image.url) + .into(binding.detailImageView) + Log.d("Adapter",Image.url) + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(ItemDetailImageRvBinding.inflate(LayoutInflater.from(parent.context),parent,false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bind(Images[position]) + } + + override fun getItemCount(): Int { + return Images.size + } + + @SuppressLint("NotifyDataSetChanged") + fun setData(list : MutableList){ + Images.clear() + Images.addAll(list) + notifyDataSetChanged() + } + +} diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/SelectedImageRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/SelectedImageRVAdapter.kt new file mode 100644 index 0000000..db95c3b --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/SelectedImageRVAdapter.kt @@ -0,0 +1,39 @@ +package com.likefirst.meyouhouse.ui.community + +import android.annotation.SuppressLint +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.likefirst.meyouhouse.data.dto.community.Article +import com.likefirst.meyouhouse.data.dto.community.SelectedImage +import com.likefirst.meyouhouse.databinding.ItemCommunityRvBinding +import com.likefirst.meyouhouse.databinding.ItemSelectedImageRvBinding + +class SelectedImageRVAdapter(val SelectedImages : MutableList) : RecyclerView.Adapter() { + + inner class ViewHolder(private val binding: ItemSelectedImageRvBinding) : RecyclerView.ViewHolder(binding.root) { + fun bind(SelectedImage : SelectedImage) { + binding.selectedImageView.setImageURI(SelectedImage.uri) + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(ItemSelectedImageRvBinding.inflate(LayoutInflater.from(parent.context),parent,false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bind(SelectedImages[position]) + } + + override fun getItemCount(): Int { + return SelectedImages.size + } + + @SuppressLint("NotifyDataSetChanged") + fun setData(list : MutableList){ + SelectedImages.clear() + SelectedImages.addAll(list) + notifyDataSetChanged() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt b/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt new file mode 100644 index 0000000..b8590e2 --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt @@ -0,0 +1,51 @@ +package com.likefirst.meyouhouse.util + +import android.content.Context +import android.database.Cursor +import android.net.Uri +import android.provider.DocumentsContract +import android.provider.MediaStore +import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.MultipartBody +import okhttp3.RequestBody +import java.io.File + +class MultiPartResolver { + fun createImgMultiPart(uri: Uri, context: Context): MultipartBody.Part { + val file = File((getPath(context, uri).toString())) + // RequestBody.create(MediaType.parse("image/*"), file) -> 수정 + val surveyBody = RequestBody.create("image/*".toMediaTypeOrNull(), file) + return MultipartBody.Part.createFormData("image", file.name, surveyBody) + } + + private fun getPath(context: Context, uri: Uri): String? { + val docId = DocumentsContract.getDocumentId(uri) + val split = docId.split(":".toRegex()).toTypedArray() + val contentUri: Uri? = MediaStore.Images.Media.EXTERNAL_CONTENT_URI + val selection = "_id=?" + val selectionArgs = arrayOf(split[1]) + return getDataColumn(context, contentUri!!, selection, selectionArgs) + } + + private fun getDataColumn( + context: Context, + uri: Uri, + selection: String?, + selectionArgs: Array? + ): String? { + var cursor: Cursor? = null + val column = "_data" + val projection = arrayOf(column) + try { + cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) + if (cursor != null && cursor.moveToFirst()) { + val columnIndex: Int = cursor.getColumnIndexOrThrow(column) + return cursor.getString(columnIndex) + } + } finally { + cursor?.close() + } + return null + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_icon_camera_grey.xml b/app/src/main/res/drawable/ic_icon_camera_grey.xml new file mode 100644 index 0000000..78271ec --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_camera_grey.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_comment_black.xml b/app/src/main/res/drawable/ic_icon_comment_black.xml new file mode 100644 index 0000000..85bf9fd --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_comment_black.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_comment_blue.xml b/app/src/main/res/drawable/ic_icon_comment_blue.xml new file mode 100644 index 0000000..4c80fd8 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_comment_blue.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_default_thumbnail_image.xml b/app/src/main/res/drawable/ic_icon_default_thumbnail_image.xml new file mode 100644 index 0000000..3f8e195 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_default_thumbnail_image.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_float_add_white.xml b/app/src/main/res/drawable/ic_icon_float_add_white.xml new file mode 100644 index 0000000..70046c4 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_float_add_white.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_icon_float_addbtn_blue.xml b/app/src/main/res/drawable/ic_icon_float_addbtn_blue.xml new file mode 100644 index 0000000..59e0175 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_float_addbtn_blue.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/layout/activity_article_detail.xml b/app/src/main/res/layout/activity_article_detail.xml new file mode 100644 index 0000000..066af66 --- /dev/null +++ b/app/src/main/res/layout/activity_article_detail.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_article_posting.xml b/app/src/main/res/layout/activity_article_posting.xml new file mode 100644 index 0000000..dbbb799 --- /dev/null +++ b/app/src/main/res/layout/activity_article_posting.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_community.xml b/app/src/main/res/layout/fragment_community.xml index 77d9ef6..222defe 100644 --- a/app/src/main/res/layout/fragment_community.xml +++ b/app/src/main/res/layout/fragment_community.xml @@ -1,6 +1,62 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_comment_rv.xml b/app/src/main/res/layout/item_comment_rv.xml new file mode 100644 index 0000000..c1a82b9 --- /dev/null +++ b/app/src/main/res/layout/item_comment_rv.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_community_rv.xml b/app/src/main/res/layout/item_community_rv.xml new file mode 100644 index 0000000..3120b1a --- /dev/null +++ b/app/src/main/res/layout/item_community_rv.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_detail_image_rv.xml b/app/src/main/res/layout/item_detail_image_rv.xml new file mode 100644 index 0000000..bf0b7c8 --- /dev/null +++ b/app/src/main/res/layout/item_detail_image_rv.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_selected_image_rv.xml b/app/src/main/res/layout/item_selected_image_rv.xml new file mode 100644 index 0000000..0e7ef6a --- /dev/null +++ b/app/src/main/res/layout/item_selected_image_rv.xml @@ -0,0 +1,29 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5572221..a3cb5c0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,9 @@ MeYouHouse + 익명 + 커뮤니티 + 글쓰기 + 취소 + 등록 + 글을 작성해 주세요. \ No newline at end of file From 960d8d17e349e9e774551b81a213ada5d7b4a587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8D=EA=B9=80=ED=98=B8=EC=A4=80=28=ED=95=99=EB=B6=80?= =?UTF-8?q?=EC=83=9D-=EC=86=8C=ED=94=84=ED=8A=B8=EC=9B=A8=EC=96=B4?= =?UTF-8?q?=EC=A0=84=EA=B3=B5=29?= Date: Thu, 23 Jun 2022 20:47:41 +0900 Subject: [PATCH 3/5] Feat : Upload comment, Get community data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 댓글 작성 및 커뮤니티 글 받아오기 성공, 디테일 페이지 성공 - 이미지 업로드 구현중 --- app/src/main/AndroidManifest.xml | 1 + .../config/XAccessTokenInterceptor.kt | 2 +- .../meyouhouse/data/dto/community/Article.kt | 11 +- .../meyouhouse/data/dto/community/Articles.kt | 7 + .../meyouhouse/data/dto/community/Comment.kt | 7 +- .../data/dto/community/DetailArticle.kt | 10 ++ .../data/dto/community/DetailImage.kt | 5 +- .../data/dto/community/PostCommentResult.kt | 9 ++ .../ui/community/ArticleDetailActivity.kt | 121 +++++++++++++----- .../ui/community/ArticlePostingActivity.kt | 7 +- .../ui/community/ArticleRVAdapter.kt | 13 +- .../ui/community/CommentRVAdapter.kt | 4 +- .../ui/community/CommunityFragment.kt | 48 ++++++- .../ui/community/DetailImageRVAdapter.kt | 10 +- .../meyouhouse/util/RetrofitInterface.kt | 17 +++ .../res/layout/activity_article_detail.xml | 1 + 16 files changed, 212 insertions(+), 61 deletions(-) create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Articles.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailArticle.kt create mode 100644 app/src/main/java/com/likefirst/meyouhouse/data/dto/community/PostCommentResult.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 14490f6..d16674d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + android:usesCleartextTraffic="true" android:theme="@style/Theme.MeYouHouse"> +) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt index 8fec93d..2fc0fb1 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/Comment.kt @@ -1,6 +1,9 @@ package com.likefirst.meyouhouse.data.dto.community +import com.google.gson.annotations.SerializedName + data class Comment( - val date : String, - val body : String + @SerializedName("id") val id : Int, + @SerializedName("content") val content : String, + @SerializedName("createdAt") val createdAt : String ) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailArticle.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailArticle.kt new file mode 100644 index 0000000..ee76279 --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailArticle.kt @@ -0,0 +1,10 @@ +package com.likefirst.meyouhouse.data.dto.community + +import com.google.gson.annotations.SerializedName + +data class DetailArticle( + @SerializedName("postId") val postId : Int, + @SerializedName("content") val content : String, + @SerializedName("imgs") val imgs : MutableList, + @SerializedName("comments") val comments : MutableList +) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt index 241f0c6..a266b83 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/DetailImage.kt @@ -1,6 +1,7 @@ package com.likefirst.meyouhouse.data.dto.community +import com.google.gson.annotations.SerializedName + data class DetailImage( - val name : String, - val url : String, + @SerializedName("imgs") val url : MutableList, ) diff --git a/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/PostCommentResult.kt b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/PostCommentResult.kt new file mode 100644 index 0000000..2aefaf8 --- /dev/null +++ b/app/src/main/java/com/likefirst/meyouhouse/data/dto/community/PostCommentResult.kt @@ -0,0 +1,9 @@ +package com.likefirst.meyouhouse.data.dto.community + +import com.google.gson.annotations.SerializedName + +data class PostCommentResult ( + @SerializedName("content") val content : String, + @SerializedName("userId") val userId : Int, + @SerializedName("postId") val postId : Int +) \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt index 65db7bb..293a2b4 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt @@ -1,72 +1,127 @@ package com.likefirst.meyouhouse.ui.community +import android.util.Log import androidx.recyclerview.widget.LinearLayoutManager -import com.likefirst.meyouhouse.data.dto.community.Article -import com.likefirst.meyouhouse.data.dto.community.Comment -import com.likefirst.meyouhouse.data.dto.community.DetailImage +import com.likefirst.meyouhouse.data.dto.community.* import com.likefirst.meyouhouse.databinding.ActivityArticleDetailBinding import com.likefirst.meyouhouse.ui.BaseActivity +import com.likefirst.meyouhouse.util.RetrofitInterface +import okhttp3.ResponseBody +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.text.SimpleDateFormat +import java.util.* class ArticleDetailActivity : BaseActivity(ActivityArticleDetailBinding::inflate) { - //더미데이터셋 - val DummyDetail = mutableListOf(Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!"), - Comment("06/22 03:00", "점점 졸린것이야!")) - - val DummyImages = mutableListOf( -// DetailImage("여기에는 사진명", DUMMY_URL), -// DetailImage("여기에는 사진명", DUMMY_URL), -// DetailImage("여기에는 사진명", DUMMY_URL), -// DetailImage("여기에는 사진명", DUMMY_URL) - ) + val comments = mutableListOf() + val images = mutableListOf() + + lateinit var retrofit: Retrofit + lateinit var retrofitService : RetrofitInterface private lateinit var commentAdapter: CommentRVAdapter private lateinit var detailImageAdapter: DetailImageRVAdapter + private var postId = 0 + private lateinit var date : String override fun initAfterBinding() { + postId = intent.getIntExtra(CommunityFragment.POST_ID,0) + date = intent.getStringExtra(CommunityFragment.DATE).toString() - // TODO - // 글 정보를 토대로 댓글에서 세부내용을 긁어옴 - // 아마 이미지를 표현해야하겠지? - // 이미지 URL 받아서 리사이클러뷰에 넣어주기 initCommentRV() initDetailImageRV() - initBodyAndDateTextView() + initRetrofit() + getDetailArticle() initCommentSubmitButton() } private fun initDetailImageRV() { - detailImageAdapter = DetailImageRVAdapter(DummyImages) + detailImageAdapter = DetailImageRVAdapter(images) binding.detailImageRecyclerView.layoutManager = LinearLayoutManager(this).apply { orientation = LinearLayoutManager.HORIZONTAL } binding.detailImageRecyclerView.adapter = detailImageAdapter } - private fun initBodyAndDateTextView() { - binding.detailBodyTextView.text = "여기에 받아온 데이터를 넣으면 되겠다!" - binding.detailDate.text = "06/22 12:34" + private fun initBodyAndDateTextView(content : String, date : String) { + binding.detailBodyTextView.text = content + binding.detailDate.text = date } private fun initCommentRV() { - commentAdapter = CommentRVAdapter(DummyDetail) + commentAdapter = CommentRVAdapter(comments) binding.commentRecyclerView.layoutManager = LinearLayoutManager(this) binding.commentRecyclerView.adapter = commentAdapter } + + private fun initRetrofit() { + retrofit = Retrofit.Builder().baseUrl(CommunityFragment.BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .build() + + retrofitService = retrofit.create(RetrofitInterface::class.java) + } + + private fun getDetailArticle() { + retrofitService.getArticlesDetail(postId.toString()) + .enqueue(object : Callback{ + override fun onResponse( + call: Call, + response: Response, + ) { + if(response.isSuccessful.not()) return + response.body().let { + if (it == null ) return + initBodyAndDateTextView(it.content,date) + detailImageAdapter.setData(it.imgs) + commentAdapter.setData(it.comments) + } + } + override fun onFailure(call: Call, t: Throwable) { + showToast("데이터 불러오기 실패") + } + + }) + + } + + private fun initCommentSubmitButton() { - // TODO 버튼 클릭시, 서버에 전송, 및 화면 재로딩 + binding.commentSubmitButton.setOnClickListener { + val content = binding.commentEditText.text.toString() + // TODO userID를 어떻게 처리해야하는지 질문 + val userId = 1 + val comment = PostCommentResult(content,userId,postId.toInt()) + + //TODO 코맨트가 서버에 저장이 안됨 ㅠㅠ + retrofitService.postComment(comment) + .enqueue(object : Callback{ + override fun onResponse( + call: Call, + response: Response, + ) { + if(response.isSuccessful.not()) return + Log.d(TAG,response.body().toString()) + binding.commentEditText.text.clear() + getDetailArticle() + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d(TAG,t.message.toString()) + showToast("네트워크 오류") + } + + }) + + } } companion object { - const val DUMMY_URL = "https://www.e2news.com/news/photo/202108/235458_90085_818.jpg" + const val TAG = "ArticleDetailAt" } } \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt index 8077dbc..68b7a1c 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt @@ -37,7 +37,7 @@ class ArticlePostingActivity : putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) type = "image/*" } - startActivityForResult(intent, READ_REQUEST_CODE) // 4 + startActivityForResult(intent, READ_REQUEST_CODE) } } @@ -85,7 +85,10 @@ class ArticlePostingActivity : private fun initSubmitButton() { //TODO 서버에 이미지 업로드 binding.submitTextButton.setOnClickListener { - showToast("버튼클릭") + //TODO 글내용 + 이미지 보내기 + val userId = 2 + val homeId = 1 + val content = binding.bodyEditText.text.toString() } } diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt index 8a720b4..9b89bc1 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleRVAdapter.kt @@ -10,16 +10,18 @@ import android.widget.Toast import androidx.recyclerview.widget.RecyclerView import com.likefirst.meyouhouse.data.dto.community.Article import com.likefirst.meyouhouse.databinding.ItemCommunityRvBinding +import java.text.SimpleDateFormat +import java.util.* -class ArticleRVAdapter(val Articles : MutableList
, private val viewOnClickListener : ()->Unit) : RecyclerView.Adapter() { +class ArticleRVAdapter(val Articles : MutableList
, private val viewOnClickListener : (Int,String)->Unit) : RecyclerView.Adapter() { inner class ViewHolder(private val binding: ItemCommunityRvBinding) : RecyclerView.ViewHolder(binding.root) { fun bind(article : Article) { - binding.articleBodyTextView.text = article.body - binding.communityDate.text = article.date - binding.commentCountTextView.text = article.commentCount.toString() + binding.articleBodyTextView.text = article.content + binding.communityDate.text = article.createdAt + binding.commentCountTextView.text = article.commentCnt.toString() binding.root.setOnClickListener { - viewOnClickListener() + viewOnClickListener(article.postId,article.createdAt) } } } @@ -36,6 +38,7 @@ class ArticleRVAdapter(val Articles : MutableList
, private val viewOnCl return Articles.size } + @SuppressLint("NotifyDataSetChanged") fun setData(list : MutableList
){ Articles.clear() diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt index d210dac..ccacfcb 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommentRVAdapter.kt @@ -13,8 +13,8 @@ class CommentRVAdapter(val Comments : MutableList) : RecyclerView.Adapt inner class ViewHolder(private val binding: ItemCommentRvBinding) : RecyclerView.ViewHolder(binding.root) { fun bind(comment : Comment) { - binding.commentBodyTextView.text = comment.body - binding.commentDetailDate.text = comment.date + binding.commentBodyTextView.text = comment.content + binding.commentDetailDate.text = comment.createdAt } } diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt index b25f6ac..a8d398d 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt @@ -4,23 +4,49 @@ import android.content.Intent import android.util.Log import androidx.recyclerview.widget.LinearLayoutManager import com.likefirst.meyouhouse.data.dto.community.Article +import com.likefirst.meyouhouse.data.dto.community.Articles import com.likefirst.meyouhouse.databinding.FragmentCommunityBinding import com.likefirst.meyouhouse.ui.BaseFragment +import com.likefirst.meyouhouse.util.RetrofitInterface +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory class CommunityFragment : BaseFragment(FragmentCommunityBinding::inflate) { //Dummy Article Data - val DummyArticles = mutableListOf
(Article("안녕하세요",date="6/22 05:24",commentCount=5),Article("안녕하세요2",date="6/22 05:24",commentCount=5),Article("안녕하세요",date="6/22 05:24",commentCount=5)) + lateinit var retrofit: Retrofit + lateinit var retrofitService : RetrofitInterface private lateinit var articleAdapter : ArticleRVAdapter + val Articles = mutableListOf
() override fun initAfterBinding() { initFloatButton() - + initRetroFit() // TODO 리사이클러뷰 만들기 // TODO 게시글 눌렀을때 상세정보 뿌려주기 initArticleRecyclerView() + getArticles() + } + private fun getArticles(){ + retrofitService.getArticles() + .enqueue(object :Callback{ + override fun onResponse(call: Call, response: Response) { + Log.d(TAG,"netwokring good") + if(response.isSuccessful.not()) return + response.body()?.let { + articleAdapter.setData(it.items) + } + } + override fun onFailure(call: Call, t: Throwable) { + Log.d(TAG,t.message.toString()) + showToast("데이터 가져오기 실패!") + } + }) } @@ -34,20 +60,32 @@ class CommunityFragment : BaseFragment(FragmentCommuni } private fun initArticleRecyclerView() { - articleAdapter = ArticleRVAdapter(DummyArticles, viewOnClickListener = { + articleAdapter = ArticleRVAdapter(Articles, viewOnClickListener = { postid,date -> + val postId = postid + val date = date context?.let{ val intent = Intent(it,ArticleDetailActivity::class.java) + intent.putExtra(POST_ID,postId) + intent.putExtra(DATE,date) startActivity(intent) } }) binding.communityArticleRecyclerView.layoutManager = LinearLayoutManager(context) binding.communityArticleRecyclerView.adapter = articleAdapter - } - + private fun initRetroFit() { + retrofit = Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .build() + retrofitService = retrofit.create(RetrofitInterface::class.java) + } companion object { const val TAG = "CommunityFg" + const val BASE_URL = "http://43.200.5.11:8080/" + const val POST_ID = "POST_ID" + const val DATE = "DATE" } } \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt index 27d89be..d44594b 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/DetailImageRVAdapter.kt @@ -9,14 +9,14 @@ import com.bumptech.glide.Glide import com.likefirst.meyouhouse.data.dto.community.DetailImage import com.likefirst.meyouhouse.databinding.ItemDetailImageRvBinding -class DetailImageRVAdapter (private val Images : MutableList) : RecyclerView.Adapter() { +class DetailImageRVAdapter (private val Images : MutableList) : RecyclerView.Adapter() { inner class ViewHolder(private val binding: ItemDetailImageRvBinding) : RecyclerView.ViewHolder(binding.root) { - fun bind(Image: DetailImage) { + fun bind(Image: String) { Glide.with(binding.detailImageView.context) - .load(Image.url) + .load(Image) .into(binding.detailImageView) - Log.d("Adapter",Image.url) + Log.d("Adapter",Image) } } @@ -33,7 +33,7 @@ class DetailImageRVAdapter (private val Images : MutableList) : Rec } @SuppressLint("NotifyDataSetChanged") - fun setData(list : MutableList){ + fun setData(list : MutableList){ Images.clear() Images.addAll(list) notifyDataSetChanged() diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt b/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt index 2865ce3..8b3616b 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt @@ -1,5 +1,10 @@ package com.likefirst.meyouhouse.util +import com.likefirst.meyouhouse.data.dto.community.Article +import com.likefirst.meyouhouse.data.dto.community.Articles +import com.likefirst.meyouhouse.data.dto.community.DetailArticle +import com.likefirst.meyouhouse.data.dto.community.PostCommentResult +import okhttp3.ResponseBody import retrofit2.Call import retrofit2.http.* @@ -23,4 +28,16 @@ interface RetrofitInterface { // @Path("userIdx") userIdx: Int, // @Body isSad : UserIsSad // ) : Call> + + //Community main + @GET("api/community/home/1") + fun getArticles() : Call + + //Community Detail + @GET("api/community/post/{postid}") + fun getArticlesDetail(@Path("postid") postid:String) : Call + + //Community Detail comment post + @POST("/api/community/comment") + fun postComment(@Body comment : PostCommentResult) : Call } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_article_detail.xml b/app/src/main/res/layout/activity_article_detail.xml index 066af66..1db4c13 100644 --- a/app/src/main/res/layout/activity_article_detail.xml +++ b/app/src/main/res/layout/activity_article_detail.xml @@ -135,6 +135,7 @@ app:layout_constraintStart_toStartOf="parent"> Date: Fri, 24 Jun 2022 01:18:02 +0900 Subject: [PATCH 4/5] Feat : Design Home Fragment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 초기 시작시 home 프래그먼트 자동 등록되도록 메인액티비티 수정 --- app/src/main/AndroidManifest.xml | 2 + .../ui/community/ArticleDetailActivity.kt | 4 - .../ui/community/ArticlePostingActivity.kt | 96 +++++- .../ui/community/CommunityFragment.kt | 4 +- .../meyouhouse/ui/main/MainActivity.kt | 9 + .../meyouhouse/util/MultiPartResolver.kt | 7 +- .../meyouhouse/util/RetrofitInterface.kt | 13 + .../main/res/drawable/ic_icon_home_bell.xml | 13 + .../main/res/drawable/ic_icon_home_elec.xml | 19 ++ .../main/res/drawable/ic_icon_home_gas.xml | 16 + .../main/res/drawable/ic_icon_home_logo.xml | 23 ++ .../main/res/drawable/ic_icon_home_water.xml | 19 ++ app/src/main/res/drawable/round_button_5.xml | 11 + app/src/main/res/layout/fragment_home.xml | 311 +++++++++++++++++- 14 files changed, 518 insertions(+), 29 deletions(-) create mode 100644 app/src/main/res/drawable/ic_icon_home_bell.xml create mode 100644 app/src/main/res/drawable/ic_icon_home_elec.xml create mode 100644 app/src/main/res/drawable/ic_icon_home_gas.xml create mode 100644 app/src/main/res/drawable/ic_icon_home_logo.xml create mode 100644 app/src/main/res/drawable/ic_icon_home_water.xml create mode 100644 app/src/main/res/drawable/round_button_5.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d16674d..c38b213 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,8 @@ package="com.likefirst.meyouhouse"> + + { override fun onResponse( @@ -110,14 +109,11 @@ class ArticleDetailActivity : binding.commentEditText.text.clear() getDetailArticle() } - override fun onFailure(call: Call, t: Throwable) { Log.d(TAG,t.message.toString()) showToast("네트워크 오류") } - }) - } } diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt index 68b7a1c..c75ad58 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticlePostingActivity.kt @@ -1,27 +1,38 @@ package com.likefirst.meyouhouse.ui.community -import android.content.ClipData +import android.annotation.SuppressLint import android.content.Intent -import android.util.Log -import com.likefirst.meyouhouse.databinding.ActivityArticlePostingBinding -import com.likefirst.meyouhouse.databinding.FragmentCommunityBinding -import com.likefirst.meyouhouse.ui.BaseActivity -import com.likefirst.meyouhouse.ui.BaseFragment -import android.graphics.BitmapFactory - -import android.graphics.Bitmap import android.net.Uri +import android.util.Log import androidx.core.net.toUri import androidx.recyclerview.widget.LinearLayoutManager import com.likefirst.meyouhouse.data.dto.community.SelectedImage -import java.io.FileNotFoundException +import com.likefirst.meyouhouse.databinding.ActivityArticlePostingBinding +import com.likefirst.meyouhouse.ui.BaseActivity +import com.likefirst.meyouhouse.util.MultiPartResolver +import com.likefirst.meyouhouse.util.RetrofitInterface +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.MultipartBody +import okhttp3.RequestBody.Companion.asRequestBody +import okhttp3.ResponseBody +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.io.File class ArticlePostingActivity : BaseActivity(ActivityArticlePostingBinding::inflate) { + + lateinit var retrofit: Retrofit + lateinit var retrofitService : RetrofitInterface + override fun initAfterBinding() { initSelectedImageRV() initPhotoButton() + initRetroFit() initSubmitButton() initCancelButton() } @@ -82,21 +93,47 @@ class ArticlePostingActivity : binding.selectedPhotoRecyclerView.adapter = selectedImageAdapter } + private fun initCancelButton() { + binding.cancelTextButton.setOnClickListener { + selectedImageList.clear() + finish() + } + } + + private fun initRetroFit() { + retrofit = Retrofit.Builder() + .baseUrl(CommunityFragment.BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .build() + retrofitService = retrofit.create(RetrofitInterface::class.java) + } + private fun initSubmitButton() { - //TODO 서버에 이미지 업로드 binding.submitTextButton.setOnClickListener { - //TODO 글내용 + 이미지 보내기 - val userId = 2 + showToast("등록") + val userId = 1 val homeId = 1 val content = binding.bodyEditText.text.toString() + val files = arrayListOf() + selectedImageList.forEachIndexed { index, selectedImage -> + val file = File(selectedImage.uri.path) + + } + val fUserId = FormDataUtil.getBody("userId",userId) + val fHomeId = FormDataUtil.getBody("homeId",userId) + val fContent = FormDataUtil.getBody("content",userId) } } - private fun initCancelButton() { - binding.cancelTextButton.setOnClickListener { - selectedImageList.clear() - finish() - } + //핸드폰 갤러리에 있는 사진의 uri 를 통해 경로를 얻는 것. + @SuppressLint("Range") + fun getPathFromUri(uri: Uri): String { + val cursor = contentResolver.query(uri, null, null, null, null) + cursor!!.moveToNext() + val path = cursor.getString(cursor!!.getColumnIndex("_data")) + cursor.close() + + return path } override fun onDestroy() { @@ -110,4 +147,27 @@ class ArticlePostingActivity : const val READ_REQUEST_CODE = 1000 const val TAG = "ArticlePostAv" } +} + +object FormDataUtil { + + fun getBody(key: String, value: Any): MultipartBody.Part { + return MultipartBody.Part.createFormData(key, value.toString()) + } + + fun getImageBody(key: String, file: File): MultipartBody.Part { + return MultipartBody.Part.createFormData( + name = key, + filename = file.name, + body = file.asRequestBody("image/*".toMediaType()) + ) + } + + fun getVideoBody(key: String, file: File): MultipartBody.Part { + return MultipartBody.Part.createFormData( + name = key, + filename = file.name, + body = file.asRequestBody("video/*".toMediaType()) + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt index a8d398d..44456d6 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt @@ -82,9 +82,11 @@ class CommunityFragment : BaseFragment(FragmentCommuni retrofitService = retrofit.create(RetrofitInterface::class.java) } + + companion object { const val TAG = "CommunityFg" - const val BASE_URL = "http://43.200.5.11:8080/" + const val BASE_URL = "http://52.78.12.56:8080/" const val POST_ID = "POST_ID" const val DATE = "DATE" } diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt index 0831ee2..001f9d9 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt @@ -12,6 +12,15 @@ import com.likefirst.meyouhouse.ui.search.SearchFragment class MainActivity : BaseActivity(ActivityMainBinding::inflate) { override fun initAfterBinding() { + + // 초기 시작시 홈화면 자동 로딩 + supportFragmentManager.popBackStack("homeFragment", FragmentManager.POP_BACK_STACK_INCLUSIVE) + supportFragmentManager.beginTransaction() + .replace(R.id.main_frm, HomeFragment()) + .addToBackStack("homeFragment") + .commitAllowingStateLoss() + + // 바텀 네비게이션 뷰 binding.mainBnv.setOnItemSelectedListener { when (it.itemId) { diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt b/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt index b8590e2..43eb0b4 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/util/MultiPartResolver.kt @@ -12,11 +12,12 @@ import okhttp3.RequestBody import java.io.File class MultiPartResolver { - fun createImgMultiPart(uri: Uri, context: Context): MultipartBody.Part { + fun createImgMultiPart(uri: Uri,filename : String, context: Context): MultipartBody.Part { val file = File((getPath(context, uri).toString())) - // RequestBody.create(MediaType.parse("image/*"), file) -> 수정 +// RequestBody.create(MediaType.parse("image/*"), file) -> 수정 +// val surveyBody = RequestBody.create(MediaType.parse("image/*"), file) val surveyBody = RequestBody.create("image/*".toMediaTypeOrNull(), file) - return MultipartBody.Part.createFormData("image", file.name, surveyBody) + return MultipartBody.Part.createFormData(filename, file.name, surveyBody) } private fun getPath(context: Context, uri: Uri): String? { diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt b/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt index 8b3616b..408c9ce 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt @@ -4,8 +4,11 @@ import com.likefirst.meyouhouse.data.dto.community.Article import com.likefirst.meyouhouse.data.dto.community.Articles import com.likefirst.meyouhouse.data.dto.community.DetailArticle import com.likefirst.meyouhouse.data.dto.community.PostCommentResult +import okhttp3.MultipartBody +import okhttp3.RequestBody import okhttp3.ResponseBody import retrofit2.Call +import retrofit2.Callback import retrofit2.http.* interface RetrofitInterface { @@ -40,4 +43,14 @@ interface RetrofitInterface { //Community Detail comment post @POST("/api/community/comment") fun postComment(@Body comment : PostCommentResult) : Call + + // Community article post + @Multipart + @POST("/api/community") + fun postCommunityArticle( + @Part ("userId") userId: MultipartBody.Part, + @Part ("homeId") homeId: MultipartBody.Part, + @Part ("content") content: MultipartBody.Part, + @Part imgs: ArrayList? + ) : Call } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_icon_home_bell.xml b/app/src/main/res/drawable/ic_icon_home_bell.xml new file mode 100644 index 0000000..d79dbbf --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_home_bell.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_home_elec.xml b/app/src/main/res/drawable/ic_icon_home_elec.xml new file mode 100644 index 0000000..0fc7408 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_home_elec.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_home_gas.xml b/app/src/main/res/drawable/ic_icon_home_gas.xml new file mode 100644 index 0000000..3feceb2 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_home_gas.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_home_logo.xml b/app/src/main/res/drawable/ic_icon_home_logo.xml new file mode 100644 index 0000000..6ffe6f4 --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_home_logo.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_icon_home_water.xml b/app/src/main/res/drawable/ic_icon_home_water.xml new file mode 100644 index 0000000..ce743ab --- /dev/null +++ b/app/src/main/res/drawable/ic_icon_home_water.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/round_button_5.xml b/app/src/main/res/drawable/round_button_5.xml new file mode 100644 index 0000000..e3049d8 --- /dev/null +++ b/app/src/main/res/drawable/round_button_5.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 63d12a4..a6f17ee 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,7 +1,312 @@ - + + + android:layout_height="match_parent" + android:background="#f8f9fa"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + From 0a3fed8f94eb9f4d2b8ca0eac68923a2fe69798a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8D=EA=B9=80=ED=98=B8=EC=A4=80=28=ED=95=99=EB=B6=80?= =?UTF-8?q?=EC=83=9D-=EC=86=8C=ED=94=84=ED=8A=B8=EC=9B=A8=EC=96=B4?= =?UTF-8?q?=EC=A0=84=EA=B3=B5=29?= Date: Fri, 24 Jun 2022 09:27:36 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Fix=20:=20base=5Furl=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=20=EB=A7=88=EC=A7=80=EB=A7=89=20"/"=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 + .../meyouhouse/ui/community/ArticleDetailActivity.kt | 3 --- .../meyouhouse/ui/community/CommunityFragment.kt | 2 +- .../java/com/likefirst/meyouhouse/ui/main/MainActivity.kt | 4 +++- .../com/likefirst/meyouhouse/ui/search/SearchFragment.kt | 1 - .../com/likefirst/meyouhouse/util/ApplicationClass.kt | 3 ++- .../com/likefirst/meyouhouse/util/RetrofitInterface.kt | 8 +++----- .../likefirst/meyouhouse/util/SharedPreferencesManager.kt | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b2d80ee..71a4028 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,6 +3,7 @@ plugins { id 'kotlin-android' } + android { compileSdk 31 diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt index 311dd4d..80493d8 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/ArticleDetailActivity.kt @@ -85,12 +85,9 @@ class ArticleDetailActivity : override fun onFailure(call: Call, t: Throwable) { showToast("데이터 불러오기 실패") } - }) - } - private fun initCommentSubmitButton() { binding.commentSubmitButton.setOnClickListener { val content = binding.commentEditText.text.toString() diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt index 44456d6..50d97d2 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/community/CommunityFragment.kt @@ -86,7 +86,7 @@ class CommunityFragment : BaseFragment(FragmentCommuni companion object { const val TAG = "CommunityFg" - const val BASE_URL = "http://52.78.12.56:8080/" + const val BASE_URL = "http://52.78.12.56:8080" const val POST_ID = "POST_ID" const val DATE = "DATE" } diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt index 001f9d9..b4a2d95 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/main/MainActivity.kt @@ -1,5 +1,6 @@ package com.likefirst.meyouhouse.ui.main +import android.util.Log import androidx.fragment.app.FragmentManager import com.likefirst.meyouhouse.R import com.likefirst.meyouhouse.databinding.ActivityMainBinding @@ -8,11 +9,12 @@ import com.likefirst.meyouhouse.ui.calendar.CalendarFragment import com.likefirst.meyouhouse.ui.community.CommunityFragment import com.likefirst.meyouhouse.ui.home.HomeFragment import com.likefirst.meyouhouse.ui.search.SearchFragment +import com.likefirst.meyouhouse.util.ApplicationClass + class MainActivity : BaseActivity(ActivityMainBinding::inflate) { override fun initAfterBinding() { - // 초기 시작시 홈화면 자동 로딩 supportFragmentManager.popBackStack("homeFragment", FragmentManager.POP_BACK_STACK_INCLUSIVE) supportFragmentManager.beginTransaction() diff --git a/app/src/main/java/com/likefirst/meyouhouse/ui/search/SearchFragment.kt b/app/src/main/java/com/likefirst/meyouhouse/ui/search/SearchFragment.kt index 6e0b8cd..aee8fe5 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/ui/search/SearchFragment.kt @@ -5,6 +5,5 @@ import com.likefirst.meyouhouse.ui.BaseFragment class SearchFragment : BaseFragment(FragmentSearchBinding::inflate) { override fun initAfterBinding() { - } } \ No newline at end of file diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/ApplicationClass.kt b/app/src/main/java/com/likefirst/meyouhouse/util/ApplicationClass.kt index 2a4d128..783fe90 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/util/ApplicationClass.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/util/ApplicationClass.kt @@ -3,6 +3,7 @@ package com.likefirst.meyouhouse.util import android.app.Application import android.content.Context import android.content.SharedPreferences +import android.util.Log import androidx.appcompat.app.AppCompatDelegate import com.likefirst.meyouhouse.config.XAccessTokenInterceptor import okhttp3.OkHttpClient @@ -14,7 +15,7 @@ import java.net.SocketException import java.util.concurrent.TimeUnit class ApplicationClass : Application() { - companion object{ + companion object { const val X_ACCESS_TOKEN: String = "x-access-token" // JWT Token Key const val TAG: String = "MeYou-APP" // Log, SharedPreference const val APP_DATABASE = "$TAG-DB" diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt b/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt index 408c9ce..040a894 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/util/RetrofitInterface.kt @@ -1,14 +1,11 @@ package com.likefirst.meyouhouse.util -import com.likefirst.meyouhouse.data.dto.community.Article import com.likefirst.meyouhouse.data.dto.community.Articles import com.likefirst.meyouhouse.data.dto.community.DetailArticle import com.likefirst.meyouhouse.data.dto.community.PostCommentResult import okhttp3.MultipartBody -import okhttp3.RequestBody import okhttp3.ResponseBody import retrofit2.Call -import retrofit2.Callback import retrofit2.http.* interface RetrofitInterface { @@ -32,12 +29,13 @@ interface RetrofitInterface { // @Body isSad : UserIsSad // ) : Call> + //Community main - @GET("api/community/home/1") + @GET("/api/community/home/1") fun getArticles() : Call //Community Detail - @GET("api/community/post/{postid}") + @GET("/api/community/post/{postid}") fun getArticlesDetail(@Path("postid") postid:String) : Call //Community Detail comment post diff --git a/app/src/main/java/com/likefirst/meyouhouse/util/SharedPreferencesManager.kt b/app/src/main/java/com/likefirst/meyouhouse/util/SharedPreferencesManager.kt index 7306eb1..8e6dc80 100644 --- a/app/src/main/java/com/likefirst/meyouhouse/util/SharedPreferencesManager.kt +++ b/app/src/main/java/com/likefirst/meyouhouse/util/SharedPreferencesManager.kt @@ -15,4 +15,4 @@ import com.likefirst.meyouhouse.util.ApplicationClass.Companion.mSharedPreferenc // val editor = mSharedPreferences.edit() // editor.remove("jwt") // editor.commit() -//} \ No newline at end of file +//}