-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#4 community
- Loading branch information
Showing
30 changed files
with
657 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/example/energy/data/repository/community/CommunityPost.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.energy.data.repository.community | ||
|
||
import android.net.Uri | ||
|
||
data class CommunityPost( | ||
val userProfile: Int, //프로필 사진 | ||
val userName: String, //사용자 이름 | ||
val title: String, //제목 | ||
val content: String, //내용 | ||
val category: List<String>, //카테고리 리스트 | ||
val imageUrl: List<Uri>, //사진 리스트 | ||
val likes: String, //좋아요 수 | ||
val comments: String, //댓글 수 | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/energy/data/repository/community/WritingCommunityImage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.energy.data.repository.community | ||
|
||
import android.net.Uri | ||
|
||
data class WritingCommunityImage( | ||
val imageUrl: Uri, // 선택한 이미지 | ||
var isRepresentative: Boolean = false, // 대표 이미지 여부를 나타내는 속성 추가 | ||
) |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/example/energy/presentation/view/community/CommunityWholeFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
package com.example.energy.presentation.view.community | ||
|
||
import android.net.Uri | ||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.example.energy.R | ||
import com.example.energy.data.repository.community.CommunityPost | ||
import com.example.energy.data.repository.community.WritingCommunityImage | ||
import com.example.energy.databinding.FragmentCommunityWholeBinding | ||
import com.example.energy.presentation.view.base.BaseFragment | ||
|
||
class CommunityWholeFragment : BaseFragment<FragmentCommunityWholeBinding>({ FragmentCommunityWholeBinding.inflate(it)}) { | ||
|
||
var postInfo = ArrayList<CommunityPost>() //선택한 이미지 데이터 리스트 | ||
val categoriesList = listOf("도와줘요", "요청 중") //임시 카테고리 리스트 | ||
val imageUrlsList: List<Uri> = emptyList() // 임시 이미지 리스트 | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
// RecyclerView 연결 및 초기화 | ||
binding.wholeCommunityPostRv.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) | ||
val postCommunityAdapter = PostCommunityRVAdapter(postInfo) | ||
binding.wholeCommunityPostRv.adapter = postCommunityAdapter | ||
|
||
// 더미데이터 | ||
postInfo.apply{ | ||
add(CommunityPost(R.drawable.user_profile, "김규리", "연희동 급 SOS", "혹시 지금 연희동 쪽으로 도움 주러 오실 수 있는 분 계신가요? 멈춰서 움직일수가 없어요ㅠㅠ", | ||
categoriesList, imageUrlsList, "1", "3")) | ||
add(CommunityPost(R.drawable.user_profile, "김규리", "연희동 급 SOS", "혹시 지금 연희동 쪽으로 도움 주러 오실 수 있는 분 계신가요? 멈춰서 움직일수가 없어요ㅠㅠ", | ||
categoriesList, imageUrlsList, "1", "3")) | ||
add(CommunityPost(R.drawable.user_profile, "김규리", "연희동 급 SOS", "혹시 지금 연희동 쪽으로 도움 주러 오실 수 있는 분 계신가요? 멈춰서 움직일수가 없어요ㅠㅠ", | ||
categoriesList, imageUrlsList, "1", "3")) | ||
add(CommunityPost(R.drawable.user_profile, "김규리", "연희동 급 SOS", "혹시 지금 연희동 쪽으로 도움 주러 오실 수 있는 분 계신가요? 멈춰서 움직일수가 없어요ㅠㅠ", | ||
categoriesList, imageUrlsList, "1", "3")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/example/energy/presentation/view/community/PostCommunityRVAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.energy.presentation.view.community | ||
|
||
import android.annotation.SuppressLint | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import com.example.energy.data.repository.community.CommunityPost | ||
import com.example.energy.databinding.ItemCommunityPostBinding | ||
import com.example.energy.databinding.ItemWritingCommunityImageBinding | ||
|
||
class PostCommunityRVAdapter (private val postInfo: ArrayList<CommunityPost>): RecyclerView.Adapter<PostCommunityRVAdapter.ViewHolder>() { | ||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): PostCommunityRVAdapter.ViewHolder { | ||
// itemview 객체 생성 | ||
val binding: ItemCommunityPostBinding = ItemCommunityPostBinding.inflate( | ||
LayoutInflater.from(viewGroup.context), viewGroup, false) | ||
return ViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.bind(postInfo[position]) | ||
} | ||
|
||
|
||
override fun getItemCount(): Int = postInfo.size | ||
|
||
inner class ViewHolder(val binding: ItemCommunityPostBinding): RecyclerView.ViewHolder(binding.root) { | ||
fun bind(postInfo: CommunityPost) { | ||
binding.itemCommunityPostUserProfile.setImageResource(postInfo.userProfile) | ||
binding.itemCommunityPostUserName.text = postInfo.userName | ||
binding.itemCommunityPostTitle.text = postInfo.title | ||
binding.itemCommunityPostContent.text = postInfo.content | ||
binding.itemCommunityPostLikeNum.text = postInfo.likes | ||
binding.itemCommunityPostCommentNum.text = postInfo.comments | ||
} | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
app/src/main/java/com/example/energy/presentation/view/community/WritingCommunityImage.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> | ||
<solid android:color="@color/gray_scale8"/> | ||
<size android:width="4dp" android:height="4dp"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> | ||
<solid android:color="@color/gray_scale6"/> | ||
<size android:width="4dp" android:height="4dp"/> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/white" /> | ||
<corners | ||
android:radius="10dp" | ||
/> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
app/src/main/res/drawable/representative_label_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/main_orange" /> | ||
<corners | ||
android:bottomLeftRadius="10dp" | ||
android:bottomRightRadius="10dp" /> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.