Skip to content

Commit

Permalink
Merge pull request #42 from Fill-ENERGY/Feature/#4-community
Browse files Browse the repository at this point in the history
Feature/#4 community
  • Loading branch information
seohyeon121 authored Aug 5, 2024
2 parents 816cab5 + cc49292 commit 7e86c10
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 21 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<activity
android:name=".presentation.view.community.NotificationActivity" />

<activity
android:name=".presentation.view.community.CommentEditActivity" />

<activity
android:name=".presentation.view.login.LoginActivity" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@ class CommentEditActivity : AppCompatActivity(){
super.onCreate(savedInstanceState)
binding = ActivityCommunityCommentEditBinding.inflate(layoutInflater)
setContentView(binding.root)


// 뒤로 가기 버튼
binding.commentEditBackIcon.setOnClickListener {
finish()
}

// 완료 버튼
binding.commentEditDone.setOnClickListener {
finish()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.room.Room
import com.example.energy.R
Expand All @@ -27,6 +28,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
Expand All @@ -45,8 +47,10 @@ class CommunityDetailActivity : AppCompatActivity(){
binding = ActivityCommunityDetailBinding.inflate(layoutInflater)
setContentView(binding.root)

// Initialize dataList
// Initialize comment dataList
dataList = ArrayList()
dataList.add(Comment(1, "김한주", "제가 도와드릴 수 있습니다", parentCommentId, "10분 전"))
dataList.add(Comment(2, "김규리", "혹시 쪽지로 연락 가능하신가요? 도움 주시면 정말 감사할 것 같습니다...", 0, "10분 전"))

// 댓글 RecyclerView 연결
commentAdapter = ItemCommentAdapter(this, dataList)
Expand Down Expand Up @@ -328,6 +332,7 @@ class CommunityDetailActivity : AppCompatActivity(){
// val intent = Intent(binding.root.context, CommentEditActivity::class.java)
// intent.putExtra("postId", postInfo.id)
// binding.root.context.startActivity(intent)
startActivity(Intent(this, CommentEditActivity::class.java))
}

// 댓글 삭제 버튼
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,36 @@ class CommunityWritingActivity : AppCompatActivity(), GalleryAdapter.MyItemClick
) {
// 결과 코드 OK, 결과값 null 아니면 (이미지를 선택하면..)
if (it.resultCode == RESULT_OK) {
// 멀티 선택은 clip Data
if (it.data!!.clipData != null) { // 멀티 이미지
val count = it.data!!.clipData!!.itemCount // 선택한 이미지 갯수
for (index in 0 until count) {
val imageUri = it.data!!.clipData!!.getItemAt(index).uri // 이미지 담기
addImageToList(imageUri) // 이미지 추가
val clipData = it.data?.clipData //멀티 이미지
val data = it.data?.data //단일 이미지

if (clipData != null) { // 멀티 이미지 선택 시
val count = clipData.itemCount // 선택한 이미지 갯수
if (count > 10) {
Toast.makeText(this, "10장까지 선택할 수 있습니다.", Toast.LENGTH_SHORT).show()
} else {
for (index in 0 until count) {
val imageUri = clipData.getItemAt(index).uri // 이미지 담기
addImageToList(imageUri)
}
}
} else { // 싱글 이미지
val imageUri = it.data!!.data
addImageToList(imageUri!!)
} else if (data != null) { // 단일 이미지 선택 시
addImageToList(data)
}


// // 멀티 선택은 clip Data
// if (it.data!!.clipData != null) { // 멀티 이미지
// val count = it.data!!.clipData!!.itemCount // 선택한 이미지 갯수
// for (index in 0 until count) {
// val imageUri = it.data!!.clipData!!.getItemAt(index).uri // 이미지 담기
// addImageToList(imageUri) // 이미지 추가
// }
// } else { // 싱글 이미지
// val imageUri = it.data!!.data
// addImageToList(imageUri!!)
// }

adapter.notifyDataSetChanged()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ class ItemCommentAdapter(
binding.itemComment.layoutParams = layoutParams //자식 뷰에 마진을 넣어줌
}
binding.commentText.text = data.body
binding.commentUserName.text = data.userInfo

// 댓글 작성 시간 계산
val commentTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).parse(data.createTime)
val currentTime = Date() //현재 시간
if (commentTime != null) {
val diffInMillis = currentTime.time - commentTime.time
val diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffInMillis)
binding.commentTimeText.text = if (diffInMinutes < 1) "방금 전" else "${diffInMinutes}분 전"
}
// // 댓글 작성 시간 계산
// val commentTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).parse(data.createTime)
// val currentTime = Date() //현재 시간
// if (commentTime != null) {
// val diffInMillis = currentTime.time - commentTime.time
// val diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffInMillis)
// binding.commentTimeText.text = if (diffInMinutes < 1) "방금 전" else "${diffInMinutes}분 전"
// }

// data.userInfo?.let { user ->
// binding.commentUserName.text = user.id
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_community_detail.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/community_detail">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_comment_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<!-- 하단 삭제 view 영역 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/erase_item_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/erase_item_view"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_like_notifications.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<!-- 하단 삭제 view 영역 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/erase_item_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/erase_item_view"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down

0 comments on commit 7e86c10

Please sign in to comment.