-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Team-04][Android][Linus_Jay][3주차 금요일 여섯번째 PR] #285
base: team-04
Are you sure you want to change the base?
Changes from all commits
fd6f505
56123e7
ba55b74
8140a53
bd27956
33f5026
ad7dc68
bf4294f
14aa9de
2729ddf
cd8d502
dc9b13d
61adce7
ac594e4
ef1d50f
23bd6d0
6cd50cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.example.issu_tracker.data | ||
|
||
import androidx.room.Entity | ||
import java.io.Serializable | ||
|
||
@Entity | ||
data class Label(val color: String = "", val content: String = "") :Serializable |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.issu_tracker.data.local | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import com.example.issu_tracker.data.IssueList | ||
|
||
|
||
@Dao | ||
interface IssueDao { | ||
@Insert | ||
suspend fun insert(issue: IssueList.Issue) | ||
|
||
@Delete | ||
suspend fun delete(issue: IssueList.Issue) | ||
|
||
@Query("SELECT * FROM Issue") // 테이블의 모든 값을 가져와라 | ||
suspend fun getAll(): List<IssueList.Issue> | ||
|
||
@Query("DELETE FROM Issue WHERE id = :id") | ||
suspend fun deleteIssueByName(id: String) | ||
|
||
@Query("DELETE FROM Issue") | ||
suspend fun deleteAllIssue() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example.issu_tracker.data.local | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import androidx.room.TypeConverters | ||
import com.example.issu_tracker.data.Converters | ||
import com.example.issu_tracker.data.IssueList | ||
import com.example.issu_tracker.data.User | ||
|
||
@Database(entities = [User::class , IssueList.Issue::class ], version = 2,exportSchema = false) | ||
@TypeConverters(Converters::class) | ||
abstract class IssueTrackerDatabase : RoomDatabase() { | ||
abstract fun userDao(): UserDao | ||
abstract fun issueDao(): IssueDao | ||
} | ||
Comment on lines
+10
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.issu_tracker.data.network | ||
|
||
sealed class NetworkResult<T : Any> { | ||
class Success<T : Any>(val data: T) : NetworkResult<T>() | ||
class Cached<T : Any>(val data: T) : NetworkResult<T>() | ||
class Loading<T : Any> : NetworkResult<T>() | ||
class Error<T : Any>(val code: Int = EMPTY) : NetworkResult<T>() | ||
class Exception<T : Any>(val e: Throwable) : NetworkResult<T>() | ||
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
companion object { | ||
const val EMPTY = 0 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,46 @@ package com.example.issu_tracker.data.repository | |
|
||
import android.util.Log | ||
import com.example.issu_tracker.data.User | ||
import com.example.issu_tracker.data.network.NetworkResult | ||
import com.example.issu_tracker.data.network.NetworkResult.Companion.EMPTY | ||
import com.example.issu_tracker.ui.home.userUid | ||
import com.google.firebase.firestore.FirebaseFirestore | ||
import com.google.protobuf.Empty | ||
import kotlinx.coroutines.tasks.await | ||
import java.lang.Exception | ||
import java.lang.StringBuilder | ||
import javax.inject.Inject | ||
|
||
|
||
class FriendRemoteRepositoryIml @Inject constructor(private val fireStore: FirebaseFirestore) : | ||
FriendRemoteRepository { | ||
|
||
override suspend fun loadFriendList(): List<User> { | ||
val userData = | ||
fireStore.collection(HomeRepositoryImpl.FIREBASE_COLLECTION_FRIEND_PATH) | ||
.document(userUid).get().await() | ||
val friendData = userData["friend"] as List<Map<String, String>> | ||
Log.d("friend", friendData.toString()) | ||
|
||
val friendList = mutableListOf<User>() | ||
|
||
friendData.forEach { | ||
val user = | ||
User( | ||
it["UID"] ?: "", it["name"] ?: "", | ||
it["userPhoto"] ?: "" | ||
) | ||
friendList.add(user) | ||
override suspend fun loadFriendList(): NetworkResult<List<User>> { | ||
try { | ||
val userData = | ||
fireStore.collection(HomeRepositoryImpl.FIREBASE_COLLECTION_FRIEND_PATH) | ||
.document(userUid).get().await() | ||
val friendData = userData["friend"] as List<Map<String, String>> | ||
Log.d("friend", friendData.toString()) | ||
|
||
val friendList = mutableListOf<User>() | ||
|
||
friendData.forEach { | ||
val user = | ||
User( | ||
it["uid"] ?: "", it["name"] ?: "", | ||
it["userPhoto"] ?: "" | ||
) | ||
friendList.add(user) | ||
} | ||
Comment on lines
+29
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return if (friendList.isNotEmpty()) { | ||
NetworkResult.Success(friendList) | ||
} else { | ||
NetworkResult.Error(EMPTY) | ||
} | ||
} catch (e: Exception) { | ||
return NetworkResult.Exception(e) | ||
} | ||
return friendList | ||
} | ||
|
||
override suspend fun updateFriend(users: List<User>) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package com.example.issu_tracker.data.repository | ||
|
||
import com.example.issu_tracker.data.Issue | ||
import com.example.issu_tracker.data.IssueList | ||
import com.example.issu_tracker.data.IssueList.Issue | ||
import com.example.issu_tracker.data.User | ||
import com.example.issu_tracker.data.network.NetworkResult | ||
|
||
interface HomeRepository { | ||
|
||
suspend fun loadIssues(): List<Issue> | ||
suspend fun loadFirstPageIssues(): NetworkResult<List<IssueList>> | ||
suspend fun loadNextPageIssues(currentNumber: Int): List<IssueList> | ||
suspend fun updateIssueState(itemId: String, boolean: Boolean) | ||
suspend fun deleteIssueList(list: List<IssueList>) | ||
suspend fun updateIssueListState(list: List<IssueList>, boolean: Boolean) | ||
|
||
suspend fun deleteIssueList(list: List<Issue>) | ||
|
||
suspend fun updateIssueListState(list: List<Issue>, boolean: Boolean) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sealed class
로 구현하셨던 이유가 무엇일까요?