diff --git a/MungNolZa/app/build.gradle.kts b/MungNolZa/app/build.gradle.kts index 7ad2a82..4c2ec78 100644 --- a/MungNolZa/app/build.gradle.kts +++ b/MungNolZa/app/build.gradle.kts @@ -39,6 +39,7 @@ android { jvmTarget = "1.8" } + viewBinding { enable = true } @@ -46,6 +47,8 @@ android { buildFeatures{ dataBinding = true } + + } dependencies { @@ -57,6 +60,7 @@ dependencies { implementation("androidx.activity:activity:1.8.2") implementation("com.google.android.gms:play-services-maps:18.2.0") implementation("androidx.coordinatorlayout:coordinatorlayout:1.2.0") + implementation("androidx.datastore:datastore-core:1.0.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/MungNolZa/app/src/main/AndroidManifest.xml b/MungNolZa/app/src/main/AndroidManifest.xml index e401e7e..4aa001d 100644 --- a/MungNolZa/app/src/main/AndroidManifest.xml +++ b/MungNolZa/app/src/main/AndroidManifest.xml @@ -20,18 +20,24 @@ android:supportsRtl="true" android:theme="@style/Theme.MungNolZa" tools:targetApi="31"> + + + + @@ -57,23 +63,25 @@ - - + android:windowSoftInputMode="adjustPan"> + + + - diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepository.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepository.kt index e2c9e38..e0c279d 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepository.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepository.kt @@ -1,8 +1,22 @@ package kr.co.lion.mungnolza.data.repository +import android.content.Context +import android.net.Uri +import android.widget.ImageView import kr.co.lion.mungnolza.model.BoardModel interface BoardRepository { - suspend fun getBoardData(boardIdx: Int): BoardModel? + suspend fun getBoardList():ArrayList + + suspend fun insertBoard(boardModel:BoardModel) + + suspend fun deleteBoard(boardModel: BoardModel) + + + suspend fun updateBoard(boardModel:BoardModel, isRemoveImage:Boolean) + + suspend fun getBoardImageUri(boardIdx:Int,imageFilePath: String):Uri? + + suspend fun getBoardImageUriList(boardModel:BoardModel): MutableList } \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepositoryImpl.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepositoryImpl.kt index 421b210..43c5f8a 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepositoryImpl.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepositoryImpl.kt @@ -1,28 +1,97 @@ package kr.co.lion.mungnolza.data.repository +import android.content.Context +import android.net.Uri +import android.util.Log +import android.widget.ImageView +import com.bumptech.glide.Glide import com.google.firebase.Firebase +import com.google.firebase.firestore.Query import com.google.firebase.firestore.firestore +import com.google.firebase.storage.storage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.tasks.await import kr.co.lion.mungnolza.model.BoardModel import kr.co.lion.mungnolza.model.UserModel +import kr.co.lion.mungnolza.util.ContentState -class BoardRepositoryImpl : BoardRepository{ +class BoardRepositoryImpl() : BoardRepository { - override suspend fun getBoardData(boardIdx: Int): BoardModel? { - var boardModel: BoardModel? = null + private val boardStore = Firebase.firestore.collection("Board") + private val storage = Firebase.storage.reference - val job = CoroutineScope(Dispatchers.IO).launch { - val collectionReference = Firebase.firestore.collection("Board") - val querySnapshot = - collectionReference.whereEqualTo("boardIdx", boardIdx).get().await() + override suspend fun getBoardList(): ArrayList { + val boardList = arrayListOf() - if (querySnapshot.isEmpty == false) { - boardModel = querySnapshot.documents[0].toObject(BoardModel::class.java) + try { + var query = + boardStore.whereEqualTo("boardState", ContentState.CONTENT_STATE_NORMAL.number) + query = query.orderBy("boardIdx", Query.Direction.DESCENDING) + val querySnapShot = query.get().await() + + querySnapShot.forEach { + val boardModel = it.toObject(BoardModel::class.java) + boardList.add(boardModel) } + + } catch (e: Exception) { + Log.e("FirebaseResult", "Error Get Board Data: ${e.message}") } - return boardModel + return boardList + } + + override suspend fun insertBoard(boardModel: BoardModel) { + boardStore.add(boardModel) } + + override suspend fun updateBoard(boardModel: BoardModel, isRemoveImage: Boolean) { + try{ + val query = boardStore.whereEqualTo("boardIdx",boardModel.boardIdx).get().await() + + // 저장 데이터를 HashMap으로 만든다. + val map = mutableMapOf() + map["boardTitle"] = boardModel.boardTitle + map["boardContent"] = boardModel.boardContent + + if(boardModel.boardImagePathList.isNotEmpty()){ + map["boardImagePathList"] = boardModel.boardImagePathList + } + if(isRemoveImage == true){ + map["boardImagePathList"] = null + } + + query.documents[0].reference.update(map) + }catch (e: Exception) { + Log.e("FirebaseResult", "Error Update Board Data: ${e.message}") + } + + } + + override suspend fun deleteBoard(boardModel: BoardModel) { + // 삭제가 아닌 BoardState 변경 + } + + override suspend fun getBoardImageUri(boardIdx:Int,imageFilePath: String):Uri?{ + var response:Uri? = null + val path = "board/${boardIdx}/${imageFilePath}" + try{ + response = storage.child(path).downloadUrl.await() + }catch (e:Exception){ + Log.e("FirebaseResult", + "Error Get BoardImageListPath : ${storage.child(path)}") + } + return response + } + + override suspend fun getBoardImageUriList(boardModel:BoardModel): MutableList { + var imageUriList:MutableList = mutableListOf() + + boardModel.boardImagePathList.forEach { + imageUriList.add(getBoardImageUri(boardModel.boardIdx,it!!)!!) + } + return imageUriList + } + } \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepository.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepository.kt deleted file mode 100644 index d1cd87e..0000000 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package kr.co.lion.mungnolza.data.repository - -import kr.co.lion.mungnolza.model.UserModel - -interface UserRepository { - suspend fun getUserData(uniqueNumber:Int): UserModel? -} \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepositoryImpl.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepositoryImpl.kt deleted file mode 100644 index 4ea4bbc..0000000 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepositoryImpl.kt +++ /dev/null @@ -1,28 +0,0 @@ -package kr.co.lion.mungnolza.data.repository - -import com.google.firebase.Firebase -import com.google.firebase.firestore.firestore -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.tasks.await -import kr.co.lion.mungnolza.model.UserModel - -class UserRepositoryImpl : UserRepository { - - override suspend fun getUserData(uniqueNumber: Int): UserModel? { - var userModel: UserModel? = null - - val job = CoroutineScope(Dispatchers.IO).launch { - val collectionReference = Firebase.firestore.collection("User") - val querySnapshot = - collectionReference.whereEqualTo("uniqueNumber", uniqueNumber).get().await() - - if (querySnapshot.isEmpty == false) { - userModel = querySnapshot.documents[0].toObject(UserModel::class.java) - } - } - job.join() - return userModel - } -} \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/datasource/MainDataStore.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/datasource/MainDataStore.kt index 2cca9e6..07fe394 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/datasource/MainDataStore.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/datasource/MainDataStore.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kr.co.lion.mungnolza.util.App + object MainDataStore { private fun getContext(): Context = App.context() diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/repository/user/UserRepository.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/repository/user/UserRepository.kt index 5c8d936..52ac17b 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/repository/user/UserRepository.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/repository/user/UserRepository.kt @@ -5,6 +5,7 @@ import java.net.URI interface UserRepository { suspend fun fetchAllUserData() : List + suspend fun fetchUserAddress(uniqueNumber: String) : String suspend fun fetchAllUserNickName(uniqueNumber: String) : List suspend fun fetchUserProfileImage(path: String) : URI? diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/chat/ChatActivity.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/chat/ChatActivity.kt index e06dc02..b7fa3d2 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/chat/ChatActivity.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/chat/ChatActivity.kt @@ -23,7 +23,7 @@ class ChatActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = ActivityChatBinding.inflate(layoutInflater) - replaceFragment(ChatFragmentName.MAIN_CHAT_FRAGMENT,false,false,null) + replaceFragment(ChatFragmentName.DETAIL_CHAT_FRAGMENT,false,false,null) setContentView(binding.root) } diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/AddBoardActivity.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/AddBoardActivity.kt new file mode 100644 index 0000000..85b7a2e --- /dev/null +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/AddBoardActivity.kt @@ -0,0 +1,152 @@ +package kr.co.lion.mungnolza.ui.freeboard + +import android.os.Bundle +import android.os.SystemClock +import android.view.LayoutInflater +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import com.google.android.material.transition.MaterialSharedAxis +import kr.co.lion.mungnolza.R +import kr.co.lion.mungnolza.databinding.ActivityAddBoardBinding +import kr.co.lion.mungnolza.ui.freeboard.fragment.AddBoardFragment +import kr.co.lion.mungnolza.ui.freeboard.fragment.ModifyBoardFragment +import kr.co.lion.mungnolza.ui.freeboard.fragment.ShowDetailBoardFragment +import kr.co.lion.mungnolza.ui.main.fragment.FreeBoardFragment +import kr.co.lion.mungnolza.util.BoardFragmentName + +class AddBoardActivity : AppCompatActivity() { + + private var _binding: ActivityAddBoardBinding ?= null + private val binding get() = _binding!! + + lateinit var addBoardActivity: AddBoardActivity + + var oldFragment: Fragment? = null + var newFragment: Fragment? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + _binding = ActivityAddBoardBinding.inflate(layoutInflater) + + replaceFragment(BoardFragmentName.ADD_BOARD_FRAGMENT,false,true,null) + + setContentView(binding.root) + + } + + override fun onDestroy() { + super.onDestroy() + _binding = null + } + + fun replaceFragment(name: BoardFragmentName, addToBackStack:Boolean, isAnimate:Boolean, data:Bundle?){ + + SystemClock.sleep(200) + + // Fragment를 교체할 수 있는 객체를 추출한다. + val fragmentTransaction = supportFragmentManager.beginTransaction() + + // oldFragment에 newFragment가 가지고 있는 Fragment 객체를 담아준다. + if(newFragment != null){ + oldFragment = newFragment + } + + // 이름으로 분기한다. + // Fragment의 객체를 생성하여 변수에 담아준다. + when(name){ + BoardFragmentName.FREE_BOARD_FRAGMENT -> { + newFragment = FreeBoardFragment() + } + + BoardFragmentName.ADD_BOARD_FRAGMENT -> { + newFragment = AddBoardFragment() + } + BoardFragmentName.SHOW_DETAIL_BOARD_FRAGMENT -> { + newFragment = ShowDetailBoardFragment() + } + BoardFragmentName.MODIFY_BOARD_FRAGMENT -> { + newFragment = ModifyBoardFragment() + } + + + else -> { + + } + + } + + // 새로운 Fragment에 전달할 객체가 있다면 arguments 프로퍼티에 넣어준다. + if(data != null){ + newFragment?.arguments = data + } + + if(newFragment != null){ + // 애니메이션 설정 + if(isAnimate == true){ + + // oldFragment -> newFragment + // oldFragment : exitTransition + // newFragment : enterTransition + + // newFragment -> oldFragment + // oldFragment : reenterTransition + // newFragment : returnTransition + + // MaterialSharedAxis : 좌우, 위아래, 공중 바닥 사이로 이동하는 애니메이션 효과 + // X - 좌우 + + // Y - 위아래 + // Z - 공중 바닥 + // 두 번째 매개변수 : 새로운 화면이 나타나는 것인지 여부를 설정해준다. + // true : 새로운 화면이 나타나는 애니메이션이 동작한다. + // false : 이전으로 되돌아가는 애니메이션이 동작한다. + + if(oldFragment != null){ + // old에서 new가 새롭게 보여질 때 old의 애니메이션 + oldFragment?.exitTransition = MaterialSharedAxis(MaterialSharedAxis.X, true) + // new에서 old로 되돌아갈때 old의 애니메이션 + oldFragment?.reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false) + + oldFragment?.enterTransition = null + oldFragment?.returnTransition = null + } + + // old에서 new가 새롭게 보여질 때 new의 애니메이션 + newFragment?.enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true) + // new에서 old로 되돌아갈때 new의 애니메이션 + newFragment?.returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false) + + newFragment?.exitTransition = null + newFragment?.reenterTransition = null + + + } + + // Fragment를 교체한다.(이전 Fragment가 없으면 새롭게 추가하는 역할을 수행한다) + // 첫 번째 매개 변수 : Fragment를 배치할 FragmentContainerView의 ID + // 두 번째 매개 변수 : 보여주고하는 Fragment 객체를 + fragmentTransaction.replace(R.id.fragmentContainerAddBoard, newFragment!!) + + // addToBackStack 변수의 값이 true면 새롭게 보여질 Fragment를 BackStack에 포함시켜 준다. + if(addToBackStack == true){ + // BackStack 포함 시킬때 이름을 지정해주면 원하는 Fragment를 BackStack에서 제거할 수 있다. + fragmentTransaction.addToBackStack(name.str) + } + // Fragment 교체를 확정한다. + fragmentTransaction.commit() + } + } + + // BackStack에서 Fragment를 제거한다. + fun removeFragment(name: BoardFragmentName){ + SystemClock.sleep(200) + + // 지정한 이름으로 있는 Fragment를 BackStack에서 제거한다. + supportFragmentManager.popBackStack(name.str, FragmentManager.POP_BACK_STACK_INCLUSIVE) + } +} \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselAdapter.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselAdapter.kt index 8e6d926..22f8e46 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselAdapter.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselAdapter.kt @@ -1,19 +1,20 @@ package kr.co.lion.mungnolza.ui.freeboard.adapter +import android.net.Uri import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import kr.co.lion.mungnolza.R import kr.co.lion.mungnolza.databinding.RowShowDetailBoardBinding -class BoardCarouselAdapter(): RecyclerView.Adapter() { +class BoardCarouselAdapter(var imageUriList:MutableList): RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BoardCarouselViewHolder { - return BoardCarouselViewHolder(RowShowDetailBoardBinding.inflate(LayoutInflater.from(parent.context),parent, false)) + return BoardCarouselViewHolder(RowShowDetailBoardBinding.inflate(LayoutInflater.from(parent.context),parent, false), imageUriList) } // override fun getItemCount(): Int = itemList.size - override fun getItemCount(): Int = 10 + override fun getItemCount(): Int = imageUriList.size override fun onBindViewHolder(holder: BoardCarouselViewHolder, position: Int) { holder.bind() diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselViewHolder.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselViewHolder.kt index 978d689..4484c4f 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselViewHolder.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselViewHolder.kt @@ -1,16 +1,26 @@ package kr.co.lion.mungnolza.ui.freeboard.adapter +import android.net.Uri import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import kr.co.lion.mungnolza.R import kr.co.lion.mungnolza.databinding.RowShowDetailBoardBinding class BoardCarouselViewHolder( - private val binding:RowShowDetailBoardBinding + private val binding:RowShowDetailBoardBinding, + private val imageUriList:MutableList ) :RecyclerView.ViewHolder(binding.root) { fun bind(){ itemView.apply{ - binding.imageViewCarouselShowDetailBoard.setImageResource(R.drawable.img_dog) + CoroutineScope(Dispatchers.Main).launch { + imageUriList.forEach { + Glide.with(context).load(imageUriList).into(binding.imageViewCarouselShowDetailBoard) + } + } } } diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/AddBoardFragment.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/AddBoardFragment.kt index 7044776..8e8c2bf 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/AddBoardFragment.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/AddBoardFragment.kt @@ -6,7 +6,6 @@ import android.graphics.BitmapFactory import android.graphics.ImageDecoder import android.os.Build import android.os.Bundle -import android.os.SystemClock import android.provider.MediaStore import android.util.Log import androidx.fragment.app.Fragment @@ -17,23 +16,27 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil +import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.RecyclerView import com.google.android.material.carousel.CarouselLayoutManager -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kr.co.lion.mungnolza.R +import kr.co.lion.mungnolza.data.repository.BoardRepositoryImpl import kr.co.lion.mungnolza.databinding.FragmentAddBoardBinding import kr.co.lion.mungnolza.databinding.RowAddBoardBinding +import kr.co.lion.mungnolza.model.BoardModel +import kr.co.lion.mungnolza.repository.user.UserRepositoryImpl +import kr.co.lion.mungnolza.ui.freeboard.AddBoardActivity import kr.co.lion.mungnolza.ui.freeboard.BoardActivity import kr.co.lion.mungnolza.ui.freeboard.viewmodel.AddBoardViewModel -import kr.co.lion.mungnolza.util.BoardFragmentName import kr.co.lion.mungnolza.util.BoardUtil +import java.text.SimpleDateFormat +import java.util.Date class AddBoardFragment : Fragment() { lateinit var binding: FragmentAddBoardBinding - lateinit var boardActivity: BoardActivity + lateinit var addBoardActivity: AddBoardActivity lateinit var addBoardViewModel: AddBoardViewModel lateinit var boardImageList: MutableList @@ -50,13 +53,14 @@ class AddBoardFragment : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, ): View? { + binding = DataBindingUtil.inflate(layoutInflater,R.layout.fragment_add_board,container,false) + - binding = DataBindingUtil.inflate(inflater, R.layout.fragment_add_board, container, false) addBoardViewModel = AddBoardViewModel() binding.addBoardViewModel = addBoardViewModel binding.lifecycleOwner = this - boardActivity = activity as BoardActivity + addBoardActivity = activity as AddBoardActivity initData() setToolbar() @@ -72,6 +76,38 @@ class AddBoardFragment : Fragment() { adapterAddBoard = RecyclerViewAdapterAddBoard() } + fun uploadBoardData(){ + lifecycleScope.launch { + var serverFileName:String? = null + + if(isAddPicture){ + + } + + val boardRepository = BoardRepositoryImpl() + val userRepository = UserRepositoryImpl() + + // boardIdx 수정 필요 + val boardIdx = 2 + val boardTitle = addBoardViewModel.editTextTitleAddBoard.value!! + val boardContent = addBoardViewModel.editTextContentAddBoard.value!! + val boardImagePathList = mutableListOf() + val boardWriterIdx = "" + val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd-HH-mm") + val boardWriteDate = simpleDateFormat.format(Date()) + val boardLikeNumber = 0 + val boardState = 1 + + val boardModel = BoardModel(boardIdx,boardTitle,boardContent,boardImagePathList,boardWriterIdx,boardWriteDate,boardWriteDate,boardLikeNumber,boardState) + + boardRepository.insertBoard(boardModel) + + val intent = Intent(requireContext(),BoardActivity::class.java) + intent.putExtra("boardData",boardModel) + startActivity(intent) + } + } + fun setCarousel() { binding.apply { // RecyclerView 셋팅 @@ -92,17 +128,14 @@ class AddBoardFragment : Fragment() { toolbarAddBoard.apply { setNavigationIcon(R.drawable.ic_arrow_back_24) - // 백버튼 이벤트 - setNavigationOnClickListener { - boardActivity.removeFragment(BoardFragmentName.ADD_BOARD_FRAGMENT) - } + inflateMenu(R.menu.menu_add_board) setOnMenuItemClickListener { when (it.itemId) { // 완료 버튼 이벤트 R.id.menuCompleteAddBoard -> { - + uploadBoardData() } } true @@ -137,13 +170,13 @@ class AddBoardFragment : Fragment() { val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // 이미지를 생성할 수 있는 객체를 생성한다. val source = - ImageDecoder.createSource(boardActivity.contentResolver, uri) + ImageDecoder.createSource(addBoardActivity.contentResolver, uri) // Bitmap을 생성한다. ImageDecoder.decodeBitmap(source) } else { // 컨텐츠 프로바이더를 통해 이미지 데이터에 접근한다. val cursor = - boardActivity.contentResolver.query(uri, null, null, null, null) + addBoardActivity.contentResolver.query(uri, null, null, null, null) if (cursor != null) { cursor.moveToNext() @@ -159,7 +192,7 @@ class AddBoardFragment : Fragment() { } // 회전 각도값을 가져온다. - val degree = BoardUtil.getDegree(boardActivity, uri) + val degree = BoardUtil.getDegree(addBoardActivity, uri) // 회전 이미지를 가져온다. val bitmap2 = BoardUtil.rotateBitmap(bitmap!!, degree.toFloat()) // 크기를 줄인 이미지를 가져온다. diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ModifyBoardFragment.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ModifyBoardFragment.kt index f14686b..cb5a8ac 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ModifyBoardFragment.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ModifyBoardFragment.kt @@ -12,6 +12,7 @@ import kr.co.lion.mungnolza.R import kr.co.lion.mungnolza.databinding.FragmentModifyBoardBinding import kr.co.lion.mungnolza.databinding.RowAddBoardBinding import kr.co.lion.mungnolza.databinding.RowModifyBoardBinding +import kr.co.lion.mungnolza.model.BoardModel import kr.co.lion.mungnolza.ui.freeboard.BoardActivity import kr.co.lion.mungnolza.ui.freeboard.viewmodel.ModifyBoardViewModel import kr.co.lion.mungnolza.util.BoardFragmentName @@ -22,6 +23,7 @@ class ModifyBoardFragment : Fragment() { lateinit var boardActivity: BoardActivity lateinit var modifyBoardViewModel: ModifyBoardViewModel + lateinit var boardData:BoardModel override fun onCreateView( @@ -35,13 +37,24 @@ class ModifyBoardFragment : Fragment() { binding.modifyBoardViewModel = modifyBoardViewModel binding.lifecycleOwner = this + boardData = arguments?.getParcelable("boardData")!! + + setToolbar() setCarousel() + setData() return binding.root } + fun setData(){ + binding.apply { + editTextTitleModifyBoard.setText(boardData.boardTitle) + editTextContentModifyBoard.setText(boardData.boardContent) + } + } + fun setCarousel(){ binding.apply{ // RecyclerView 셋팅 @@ -97,5 +110,4 @@ class ModifyBoardFragment : Fragment() { holder.rowModifyBoardBinding.imageViewCarouselModifyBoard.setImageResource(R.drawable.img_dog) } } - } \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ShowDetailBoardFragment.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ShowDetailBoardFragment.kt index cac3787..1e09ea4 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ShowDetailBoardFragment.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/fragment/ShowDetailBoardFragment.kt @@ -1,40 +1,61 @@ package kr.co.lion.mungnolza.ui.freeboard.fragment import android.content.DialogInterface +import android.net.Uri +import android.os.Build import android.os.Bundle +import android.util.Log import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.viewModels + +import androidx.lifecycle.lifecycleScope +import com.bumptech.glide.Glide import com.google.android.material.carousel.CarouselLayoutManager import com.google.android.material.dialog.MaterialAlertDialogBuilder +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.job +import kotlinx.coroutines.launch import kr.co.lion.mungnolza.R +import kr.co.lion.mungnolza.data.repository.BoardRepository +import kr.co.lion.mungnolza.data.repository.BoardRepositoryImpl import kr.co.lion.mungnolza.databinding.FragmentShowDetailBoardBinding import kr.co.lion.mungnolza.model.BoardModel import kr.co.lion.mungnolza.model.UserModel +import kr.co.lion.mungnolza.repository.user.UserRepository +import kr.co.lion.mungnolza.repository.user.UserRepositoryImpl import kr.co.lion.mungnolza.ui.freeboard.BoardActivity import kr.co.lion.mungnolza.ui.freeboard.adapter.BoardCarouselAdapter -import kr.co.lion.mungnolza.ui.freeboard.viewmodel.ShowDetailBoardViewModel +import kr.co.lion.mungnolza.ui.freeboard.viewmodel.BoardViewModel import kr.co.lion.mungnolza.util.BoardFragmentName +import java.net.URI class ShowDetailBoardFragment : Fragment() { - private var _binding: FragmentShowDetailBoardBinding?= null + private var _binding: FragmentShowDetailBoardBinding? = null private val binding get() = _binding!! lateinit var boardActivity: BoardActivity - private val showDetailBoardViewModel by viewModels() - var userModel: UserModel?= null - var boardModel: BoardModel?= null + private val boardViewModel by viewModels() - var imagePathList = mutableListOf() + var userData: UserModel? = null + var boardData: BoardModel? = null + var boardList: ArrayList? = null + lateinit var userRepository: UserRepository + lateinit var boardRepository: BoardRepository + var imgUri: URI? = null - var boardIdx:Int = 0 + var imageUriList: MutableList = mutableListOf() + + var imagePathList = mutableListOf() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -46,9 +67,13 @@ class ShowDetailBoardFragment : Fragment() { setTest() + lifecycleScope.launch { + initData() + + } + applyUserData() - // boardIdx = arguments?.getInt("boardIdx")!! return binding.root } @@ -56,10 +81,10 @@ class ShowDetailBoardFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - setToolbar() setCarousel() - setCommentButton() + setToolbar() + setCommentButton() } override fun onDestroy() { @@ -69,35 +94,84 @@ class ShowDetailBoardFragment : Fragment() { // ---------------------------------------------------------------------------- - fun setTest(){ + suspend fun initData(){ + userRepository = UserRepositoryImpl() + boardRepository = BoardRepositoryImpl() - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + boardData = boardActivity.intent.getParcelableExtra("boardData", BoardModel::class.java) + userData = boardActivity.intent.getParcelableExtra("userData", UserModel::class.java) + } else { + boardData = boardActivity.intent.getParcelableExtra("boardData") + userData = boardActivity.intent.getParcelableExtra("userData") + } - fun applyUserData(){ - binding.editTextTitleShowDetailBoard.setText(showDetailBoardViewModel.getBoardData().boardTitle) - binding.editTextContentShowDetailBoard.setText(showDetailBoardViewModel.getBoardData().boardContent) - binding.textViewDateShowDetailBoard.text = showDetailBoardViewModel.getBoardData().boardWriteDate + boardData?.boardImagePathList?.forEach { + Log.d("게시판 boardImagePathList","${it}") + } - // 유저 정보는 boardModel로 접근해야 하는데 테스트는 일단 직접 호출 - binding.textViewNickNameShowDetailBoard.text = showDetailBoardViewModel.getUserData().userNickname + + val job1 = CoroutineScope(Dispatchers.IO).launch { + imgUri = userRepository.fetchUserProfileImage(userData?.userProfileImgPath!!)!! + Log.d("프로필 이미지 uri","${imgUri}") + + } + job1.join() + + val job2 = CoroutineScope(Dispatchers.IO).launch { + boardList = boardRepository.getBoardList() + imageUriList = boardRepository.getBoardImageUriList(boardData!!) + imageUriList.forEach { + Log.d("이미지 Uri 리스트",it.toString()) + } + + + } + job2.join() + } + fun setTest() { } - fun setCommentButton(){ + fun applyUserData() { binding.apply{ + editTextTitleShowDetailBoard.setText(boardData?.boardTitle) + editTextContentShowDetailBoard.setText(boardData?.boardContent) + textViewDateShowDetailBoard.text = boardData?.boardWriteDate + textViewNickNameShowDetailBoard.text = userData?.userNickname + + + lifecycleScope.launch { + + Log.d("이미지 Uri 리스트 Glide 이전",imgUri.toString()) + Glide.with(this@ShowDetailBoardFragment) + .load(imgUri) + .error(R.drawable.eunwoo) + .into(binding.imageViewProfileShowDetailBoard) + + // boardRepository.applyBoardImage(requireContext(), boardData!!.boardImagePathList[0]!!, binding.imageViewProfileShowDetailBoard) + } + + } + // 유저 정보는 boardModel로 접근해야 하는데 테스트는 일단 직접 호출 + } + + + fun setCommentButton() { + binding.apply { imageViewCommentShowDetailBoard.setOnClickListener { showBottomCommentSheet() } } } - fun setCarousel(){ - binding.apply{ + fun setCarousel() { + binding.apply { // RecyclerView 셋팅 - recyclerViewPhotosShowDetailBoard.apply{ + recyclerViewPhotosShowDetailBoard.apply { // 어댑터 - adapter = BoardCarouselAdapter() + adapter = BoardCarouselAdapter(imageUriList) // 레이아웃 매니저 layoutManager = CarouselLayoutManager() // layoutManager = CarouselLayoutManager(MultiBrowseCarouselStrategy()) @@ -108,9 +182,9 @@ class ShowDetailBoardFragment : Fragment() { } // 툴바 설정 - fun setToolbar(){ - binding.apply{ - toolbarShowDetailBoard.apply{ + fun setToolbar() { + binding.apply { + toolbarShowDetailBoard.apply { setNavigationIcon(R.drawable.ic_arrow_back_24) setNavigationOnClickListener { @@ -121,10 +195,18 @@ class ShowDetailBoardFragment : Fragment() { inflateMenu(R.menu.menu_show_detail_board) setOnMenuItemClickListener { - when(it.itemId){ + when (it.itemId) { // 수정 아이콘 클릭 시 R.id.menuItemModifyShowDetailBoard -> { - boardActivity.replaceFragment(BoardFragmentName.MODIFY_BOARD_FRAGMENT,true,true,null) + val bundle = Bundle() + bundle.putParcelable("boardData",boardData) + + boardActivity.replaceFragment( + BoardFragmentName.MODIFY_BOARD_FRAGMENT, + true, + true, + bundle + ) } // 삭제 아이콘 클릭 시 @@ -138,51 +220,29 @@ class ShowDetailBoardFragment : Fragment() { } } - fun setDeleteDialog(){ + fun setDeleteDialog() { val materialAlertDialogBuilder = MaterialAlertDialogBuilder(requireContext()) - materialAlertDialogBuilder.apply{ + materialAlertDialogBuilder.apply { setTitle("삭제") setMessage("정말로 삭제하시겠습니까?") - setPositiveButton("삭제"){ dialogInterface: DialogInterface, i: Int -> + setPositiveButton("삭제") { dialogInterface: DialogInterface, i: Int -> } - setNegativeButton("닫기"){ dialogInterface: DialogInterface, i: Int -> + setNegativeButton("닫기") { dialogInterface: DialogInterface, i: Int -> } show() } } - fun showBottomCommentSheet(){ + fun showBottomCommentSheet() { val bottomCommentFragment = BottomCommentFragment() - bottomCommentFragment.apply{ + bottomCommentFragment.apply { } bottomCommentFragment.show(boardActivity.supportFragmentManager, "BottomCommentSheet") } - -// inner class RecyclerViewAdapterShowDetailBoard: RecyclerView.Adapter() { -// inner class ViewHolderShowDetailBoard(rowShowDetailBoardBinding: RowShowDetailBoardBinding): RecyclerView.ViewHolder(rowShowDetailBoardBinding.root){ -// val rowShowDetailBoardBinding: RowShowDetailBoardBinding -// -// init{ -// this.rowShowDetailBoardBinding = rowShowDetailBoardBinding -// } -// } -// -// override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderShowDetailBoard { -// val rowShowDetailBoardBinding = RowShowDetailBoardBinding.inflate(layoutInflater) -// val viewHolderAddBoard = ViewHolderShowDetailBoard(rowShowDetailBoardBinding) -// return viewHolderAddBoard -// } -// -// override fun getItemCount(): Int = 5 -// -// override fun onBindViewHolder(holder: ViewHolderShowDetailBoard, position: Int) { -// holder.rowShowDetailBoardBinding.imageViewCarouselShowDetailBoard.setImageResource(R.drawable.img_dog) -// } -// } } \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/AddBoardViewModel.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/AddBoardViewModel.kt index c51227e..c76dfcd 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/AddBoardViewModel.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/AddBoardViewModel.kt @@ -1,6 +1,12 @@ package kr.co.lion.mungnolza.ui.freeboard.viewmodel +import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel class AddBoardViewModel:ViewModel() { + + val editTextTitleAddBoard = MutableLiveData() + val editTextContentAddBoard = MutableLiveData() + + } \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/BoardViewModel.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/BoardViewModel.kt new file mode 100644 index 0000000..74f635a --- /dev/null +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/BoardViewModel.kt @@ -0,0 +1,34 @@ +package kr.co.lion.mungnolza.ui.freeboard.viewmodel + +import android.net.Uri +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import kr.co.lion.mungnolza.data.repository.BoardRepository +import kr.co.lion.mungnolza.model.BoardModel +import kr.co.lion.mungnolza.repository.user.UserRepository + +class BoardViewModel( + private val boardRepository:BoardRepository, + private val userRepository: UserRepository +):ViewModel() { + + private var _boardList = MutableStateFlow>(emptyList()) + val boardList = _boardList.asStateFlow() + + init{ + + } + + private fun getBoardList():ArrayList { + var boardList = ArrayList() + viewModelScope.launch(Dispatchers.IO) { + boardList = boardRepository.getBoardList() + } + return boardList + } + +} \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/ShowDetailBoardViewModel.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/ShowDetailBoardViewModel.kt index 3644cf7..1576554 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/ShowDetailBoardViewModel.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/ShowDetailBoardViewModel.kt @@ -1,13 +1,8 @@ package kr.co.lion.mungnolza.ui.freeboard.viewmodel import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.launch -import kr.co.lion.mungnolza.data.repository.BoardRepository -import kr.co.lion.mungnolza.data.repository.UserRepository import kr.co.lion.mungnolza.model.BoardModel import kr.co.lion.mungnolza.model.UserModel -import javax.inject.Inject class ShowDetailBoardViewModel:ViewModel() { diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/FreeBoardFragment.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/FreeBoardFragment.kt index b9add49..c41e8df 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/FreeBoardFragment.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/FreeBoardFragment.kt @@ -2,6 +2,7 @@ package kr.co.lion.mungnolza.ui.main.fragment import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.fragment.app.Fragment import android.view.View import androidx.fragment.app.activityViewModels @@ -13,6 +14,7 @@ import com.google.android.material.divider.MaterialDividerItemDecoration import kotlinx.coroutines.launch import kr.co.lion.mungnolza.R import kr.co.lion.mungnolza.databinding.FragmentFreeBoardBinding +import kr.co.lion.mungnolza.ui.freeboard.AddBoardActivity import kr.co.lion.mungnolza.ui.freeboard.BoardActivity import kr.co.lion.mungnolza.ui.main.adapter.FreeBoardAdapter import kr.co.lion.mungnolza.ui.main.vm.MainViewModel @@ -24,6 +26,8 @@ class FreeBoardFragment : Fragment(R.layout.fragment_free_board) { private val binding get() = _binding!! private val viewModel: MainViewModel by activityViewModels { MainViewModelFactory() } + private lateinit var freeBoardAdapter: FreeBoardAdapter + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) _binding = FragmentFreeBoardBinding.bind(view) @@ -43,8 +47,10 @@ class FreeBoardFragment : Fragment(R.layout.fragment_free_board) { val writerData = viewModel.findUserData(selectedItemData.boardWriterIdx) val intent = Intent(requireContext(), BoardActivity::class.java) - intent.putExtra("content", selectedItemData) - intent.putExtra("writer", writerData) + + intent.putExtra("boardData", selectedItemData) + intent.putExtra("userData", writerData) + startActivity(intent) } @@ -61,10 +67,17 @@ class FreeBoardFragment : Fragment(R.layout.fragment_free_board) { } } } + + binding.buttonAddBoardFreeBoard.setOnClickListener{ + val intent = Intent(requireContext(), AddBoardActivity::class.java) + startActivity(intent) + } + } override fun onDestroyView() { super.onDestroyView() _binding = null } + } \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/MainChatFragment.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/MainChatFragment.kt index 68c16cc..e16c3ac 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/MainChatFragment.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/fragment/MainChatFragment.kt @@ -1,5 +1,6 @@ package kr.co.lion.mungnolza.ui.main.fragment +import android.content.Intent import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater @@ -69,7 +70,7 @@ class MainChatFragment : Fragment() { } override fun getItemCount(): Int { - return 100 + return 3 } override fun onBindViewHolder(holder: ViewHolderMainChat, position: Int) { @@ -79,7 +80,9 @@ class MainChatFragment : Fragment() { holder.rowMainChatBinding.imageViewProfileRowMainChat.setImageResource(R.drawable.img_jch) holder.rowMainChatBinding.root.setOnClickListener { + val intent = Intent(requireContext(),ChatActivity::class.java) + startActivity(intent) } } } diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/viewmodel/MainViewModel.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/viewmodel/MainViewModel.kt new file mode 100644 index 0000000..51bfcdf --- /dev/null +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/main/viewmodel/MainViewModel.kt @@ -0,0 +1,105 @@ +package kr.co.lion.mungnolza.ui.main.viewmodel + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.launch +import kr.co.lion.mungnolza.datasource.MainDataStore +import kr.co.lion.mungnolza.model.BoardAddUerInfoModel +import kr.co.lion.mungnolza.model.PetImgModel +import kr.co.lion.mungnolza.model.UserModel +import kr.co.lion.mungnolza.repository.freeboard.FreeBoardRepositoryImpl +import kr.co.lion.mungnolza.repository.pet.PetRepositoryImpl +import kr.co.lion.mungnolza.repository.user.UserRepositoryImpl +import java.net.URI + +class MainViewModel( + private val freeBoardRepository: FreeBoardRepositoryImpl, + private val userRepository: UserRepositoryImpl, + private val petRepositoryImpl: PetRepositoryImpl +): ViewModel() { + + private val _userList = MutableStateFlow>(emptyList()) + val userList = _userList.asStateFlow() + + private var _boardContentList = MutableStateFlow>(emptyList()) + val boardContentList = _boardContentList.asStateFlow() + + private val _myUserNumber = MutableStateFlow(null) + private val myUserNumber = _myUserNumber.asStateFlow() + + private val _myPetData = MutableStateFlow>(emptyList()) + val myPetData = _myPetData.asStateFlow() + + init { + viewModelScope.launch { + fetchAllUserData() + fetchAllBoardDataWithUserInfo() + + //MainDataStore.setUserNumber("1234") + MainDataStore.getUserNumber().collect { + _myUserNumber.value = it + } + } + + } + + private suspend fun fetchAllUserData(){ + val response = userRepository.fetchAllUserData() + _userList.value = response + } + + private suspend fun fetchAllBoardDataWithUserInfo(){ + val response = freeBoardRepository.fetchAllBoardData() + val contentList = ArrayList() + + response.mapIndexed { index, boardModel -> + val nickName = userRepository.fetchAllUserNickName(boardModel.boardWriterIdx) + val imgUri = fetchBoardImg(boardModel.boardIdx.toString(), boardModel.boardImagePathList[0].toString()) + val content = imgUri?.let { uri -> BoardAddUerInfoModel(boardModel, nickName[index], uri) } + if (content != null) { + contentList.add(content) + } + } + _boardContentList.value = contentList + } + + fun fetchMyAllPetData() = viewModelScope.launch { + val petList = ArrayList() + + myUserNumber.collect { myUserNumber -> + val result = myUserNumber?.let { data-> petRepositoryImpl.fetchMyPetData(data) } + result?.map{ + val imgUri = fetchPetImg(it.ownerIdx, it.imgName) + val pet = imgUri?.let { data -> PetImgModel(it, data) } + + if (pet != null) { + petList.add(pet) + } + } + _myPetData.value = petList + } + } + + private suspend fun fetchPetImg(userIdx: String, petName: String): URI? { + return petRepositoryImpl.fetchMyPetImage(userIdx, petName) + } + + private suspend fun fetchBoardImg(boardIdx: String, imgName: String): URI? { + return freeBoardRepository.fetchAllBoardImage(boardIdx, imgName) + } + + suspend fun fetchUserProfileImage(path: String): URI? { + return userRepository.fetchUserProfileImage(path) + } + + fun findUserData(writerIdx: String): UserModel? { + return userList.value.find { it.uniqueNumber == writerIdx } + } + + fun setMyPetData(myPets: List){ + _myPetData.value = myPets + } +} \ No newline at end of file diff --git a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/reservation_list/PetsitterReviewWriteActivity.kt b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/reservation_list/PetsitterReviewWriteActivity.kt index 10232ce..6c9709d 100644 --- a/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/reservation_list/PetsitterReviewWriteActivity.kt +++ b/MungNolZa/app/src/main/java/kr/co/lion/mungnolza/ui/reservation_list/PetsitterReviewWriteActivity.kt @@ -9,16 +9,24 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kr.co.lion.mungnolza.R + import kr.co.lion.mungnolza.databinding.ActivityPetsitterReviewWriteBinding import kr.co.lion.mungnolza.ext.hideSoftInput import kr.co.lion.mungnolza.ext.showErrorDialog import kr.co.lion.mungnolza.model.PetsitterReviewModel -import kr.co.lion.mungnolza.repository.PetsitterReviewRepository + + + import kr.co.lion.mungnolza.ui.reservation_list.viewmodel.PetSitterReviewWriteViewModel import kr.co.lion.mungnolza.util.ReservationListFragmentName import java.text.SimpleDateFormat import java.util.Date +// ContextExt.kt에 정의된 확장 함수를 import +import kr.co.lion.mungnolza.ext.hideSoftInput +import kr.co.lion.mungnolza.ext.showErrorDialog +import kr.co.lion.mungnolza.repository.PetsitterReviewRepository + class PetsitterReviewWriteActivity : AppCompatActivity() { lateinit var activityPetsitterReviewWriteBinding: ActivityPetsitterReviewWriteBinding diff --git a/MungNolZa/app/src/main/res/layout/activity_add_board.xml b/MungNolZa/app/src/main/res/layout/activity_add_board.xml new file mode 100644 index 0000000..8e72483 --- /dev/null +++ b/MungNolZa/app/src/main/res/layout/activity_add_board.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/MungNolZa/app/src/main/res/layout/activity_board.xml b/MungNolZa/app/src/main/res/layout/activity_board.xml index e79fcd2..ee223e4 100644 --- a/MungNolZa/app/src/main/res/layout/activity_board.xml +++ b/MungNolZa/app/src/main/res/layout/activity_board.xml @@ -11,19 +11,9 @@ android:id="@+id/fragmentContainerFreeBoard" android:layout_width="0dp" android:layout_height="0dp" - app:layout_constraintBottom_toTopOf="@+id/bottomNavigationActivityBoard" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/MungNolZa/app/src/main/res/layout/activity_main.xml b/MungNolZa/app/src/main/res/layout/activity_main.xml index 2cdc2b4..50f4165 100644 --- a/MungNolZa/app/src/main/res/layout/activity_main.xml +++ b/MungNolZa/app/src/main/res/layout/activity_main.xml @@ -17,7 +17,7 @@ @@ -79,6 +80,7 @@ android:layout_height="@dimen/edittext_height_board_content" android:background="@color/transparent" android:gravity="start|top" + android:text="@={addBoardViewModel.editTextContentAddBoard}" android:inputType="text|textMultiLine" /> diff --git a/MungNolZa/app/src/main/res/layout/fragment_detail_chat.xml b/MungNolZa/app/src/main/res/layout/fragment_detail_chat.xml index 34c7039..2f30483 100644 --- a/MungNolZa/app/src/main/res/layout/fragment_detail_chat.xml +++ b/MungNolZa/app/src/main/res/layout/fragment_detail_chat.xml @@ -26,15 +26,19 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" > + + android:textStyle="bold" + tools:layout_editor_absoluteX="16dp" + tools:layout_editor_absoluteY="18dp" /> + android:theme="?attr/actionBarTheme" > + + + + + + + + + + + \ No newline at end of file diff --git a/MungNolZa/app/src/main/res/layout/fragment_main_chat.xml b/MungNolZa/app/src/main/res/layout/fragment_main_chat.xml index 29718b4..d8a7bc0 100644 --- a/MungNolZa/app/src/main/res/layout/fragment_main_chat.xml +++ b/MungNolZa/app/src/main/res/layout/fragment_main_chat.xml @@ -11,28 +11,33 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" - app:title="@string/menu_item_bottom_navigation_chatting" android:theme="?attr/actionBarTheme"> + + + + - - - - + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/MungNolZa/app/src/main/res/layout/fragment_modify_board.xml b/MungNolZa/app/src/main/res/layout/fragment_modify_board.xml index 31aca9d..4120714 100644 --- a/MungNolZa/app/src/main/res/layout/fragment_modify_board.xml +++ b/MungNolZa/app/src/main/res/layout/fragment_modify_board.xml @@ -74,9 +74,10 @@ + android:gravity="start|top" + android:inputType="text|textMultiLine" /> - + android:layout_height="@dimen/profile_imageview_width" + app:civ_border_width="1dp" + tools:srcCompat="@tools:sample/avatars" /> + + + android:layout_height="wrap_content"> + android:layout_height="wrap_content"> - - @@ -175,6 +169,12 @@ app:srcCompat="@drawable/ic_comment_24px" /> + +