-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from APP-Android2/30-feature-자유게시판구현
30 feature 자유게시판구현
- Loading branch information
Showing
14 changed files
with
236 additions
and
50 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
8 changes: 8 additions & 0 deletions
8
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepository.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 kr.co.lion.mungnolza.data.repository | ||
|
||
import kr.co.lion.mungnolza.model.BoardModel | ||
|
||
|
||
interface BoardRepository { | ||
suspend fun getBoardData(boardIdx: Int): BoardModel? | ||
} |
28 changes: 28 additions & 0 deletions
28
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/BoardRepositoryImpl.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,28 @@ | ||
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.BoardModel | ||
import kr.co.lion.mungnolza.model.UserModel | ||
|
||
class BoardRepositoryImpl : BoardRepository{ | ||
|
||
override suspend fun getBoardData(boardIdx: Int): BoardModel? { | ||
var boardModel: BoardModel? = null | ||
|
||
val job = CoroutineScope(Dispatchers.IO).launch { | ||
val collectionReference = Firebase.firestore.collection("Board") | ||
val querySnapshot = | ||
collectionReference.whereEqualTo("boardIdx", boardIdx).get().await() | ||
|
||
if (querySnapshot.isEmpty == false) { | ||
boardModel = querySnapshot.documents[0].toObject(BoardModel::class.java) | ||
} | ||
} | ||
return boardModel | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepository.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,7 @@ | ||
package kr.co.lion.mungnolza.data.repository | ||
|
||
import kr.co.lion.mungnolza.model.UserModel | ||
|
||
interface UserRepository { | ||
suspend fun getUserData(uniqueNumber:Int): UserModel? | ||
} |
28 changes: 28 additions & 0 deletions
28
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/data/repository/UserRepositoryImpl.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,28 @@ | ||
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 | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/model/BoardModel.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
10 changes: 8 additions & 2 deletions
10
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/model/CommentModel.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,4 +1,10 @@ | ||
package kr.co.lion.mungnolza.model | ||
|
||
class CommentModel { | ||
} | ||
data class CommentModel( | ||
var commentIdx:Int, | ||
var commentContent:String, | ||
var commentDate:String, | ||
var boardIdx:Int, | ||
var writerIdx:Int, | ||
var commentState:Int | ||
) |
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
22 changes: 22 additions & 0 deletions
22
...NolZa/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselAdapter.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,22 @@ | ||
package kr.co.lion.mungnolza.ui.freeboard.adapter | ||
|
||
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<BoardCarouselViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BoardCarouselViewHolder { | ||
return BoardCarouselViewHolder(RowShowDetailBoardBinding.inflate(LayoutInflater.from(parent.context),parent, false)) | ||
} | ||
|
||
// override fun getItemCount(): Int = itemList.size | ||
override fun getItemCount(): Int = 10 | ||
|
||
override fun onBindViewHolder(holder: BoardCarouselViewHolder, position: Int) { | ||
holder.bind() | ||
//holder.bind(itemList[position]) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...Za/app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/adapter/BoardCarouselViewHolder.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,17 @@ | ||
package kr.co.lion.mungnolza.ui.freeboard.adapter | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import kr.co.lion.mungnolza.R | ||
import kr.co.lion.mungnolza.databinding.RowShowDetailBoardBinding | ||
|
||
class BoardCarouselViewHolder( | ||
private val binding:RowShowDetailBoardBinding | ||
) :RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(){ | ||
itemView.apply{ | ||
binding.imageViewCarouselShowDetailBoard.setImageResource(R.drawable.img_dog) | ||
} | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...rc/main/java/kr/co/lion/mungnolza/ui/freeboard/factory/ShowDetailBoardViewModelFactory.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,7 @@ | ||
package kr.co.lion.mungnolza.ui.freeboard.factory | ||
|
||
import androidx.lifecycle.ViewModelProvider | ||
|
||
class ShowDetailBoardViewModelFactory : ViewModelProvider.Factory{ | ||
|
||
} |
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
18 changes: 18 additions & 0 deletions
18
...app/src/main/java/kr/co/lion/mungnolza/ui/freeboard/viewmodel/ShowDetailBoardViewModel.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,6 +1,24 @@ | ||
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() { | ||
|
||
fun getUserData():UserModel{ | ||
return UserModel("1","카리나","최나연","[email protected]","010-2222-3333","송파에서 제일 비싼 집","","22","여") | ||
} | ||
|
||
fun getBoardData():BoardModel{ | ||
return BoardModel(1,"카리나 어때?","나보다 별로지 않아?\nㅇㅅㅇ", | ||
mutableListOf(),"1","2024-04-12-10:30","2024-04-12-10:48",2,1) | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.