Skip to content

Commit

Permalink
That's all for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ForceTower committed Aug 13, 2024
1 parent 0071f25 commit 0647cd4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import android.content.Context
import androidx.lifecycle.LiveData
import com.forcetower.uefs.AppExecutors
import com.forcetower.uefs.core.model.unes.Account
import com.forcetower.uefs.core.model.unes.EdgeServiceAccount
import com.forcetower.uefs.core.model.unes.Message
import com.forcetower.uefs.core.model.unes.SStudent
import com.forcetower.uefs.core.storage.database.UDatabase
import com.forcetower.uefs.core.storage.database.aggregation.ClassLocationWithData
import com.forcetower.uefs.core.work.affinity.AnswerAffinityWorker
import dagger.Reusable
import kotlinx.coroutines.flow.Flow
import java.util.Calendar
import javax.inject.Inject

Expand All @@ -42,6 +44,9 @@ class DashboardRepository @Inject constructor(
fun getAccount(): LiveData<Account?> {
return database.accountDao().getAccountNullable()
}
fun getEdgeServiceAccount(): Flow<EdgeServiceAccount> {
return database.edgeServiceAccount.me()
}

fun getCurrentClass(): LiveData<ClassLocationWithData?> {
val calendar = Calendar.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.forcetower.uefs.core.model.unes.Account
import com.forcetower.uefs.core.model.unes.EdgeServiceAccount
import com.forcetower.uefs.core.model.unes.Message
import com.forcetower.uefs.core.model.unes.SStudent
import com.forcetower.uefs.core.storage.database.aggregation.AffinityQuestionFull
Expand Down Expand Up @@ -72,7 +73,7 @@ class DashboardAdapter(
differ.submitList(buildMergedList(affinity = value))
}

var currentAccount: Account? = null
var currentAccount: EdgeServiceAccount? = null
set(value) {
field = value
differ.submitList(buildMergedList(account = value))
Expand Down Expand Up @@ -142,7 +143,7 @@ class DashboardAdapter(
message: Message? = lastMessage,
updating: Boolean = updatingApp,
affinity: List<AffinityQuestionFull> = affinityList,
account: Account? = currentAccount
account: EdgeServiceAccount? = currentAccount
): List<Any> {
return mutableListOf<Any>().apply {
if (account != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.map
import com.forcetower.core.lifecycle.Event
import com.forcetower.uefs.core.model.unes.Account
import com.forcetower.uefs.core.model.unes.EdgeServiceAccount
import com.forcetower.uefs.core.model.unes.SStudent
import com.forcetower.uefs.core.storage.database.aggregation.ClassLocationWithData
import com.forcetower.uefs.core.storage.repository.SagresDataRepository
Expand All @@ -45,7 +47,7 @@ class DashboardViewModel @Inject constructor(
}

val course: LiveData<String?> by lazy { dataRepository.getCourse() }
val account: LiveData<Account?> = repository.getAccount()
val account: LiveData<EdgeServiceAccount> = repository.getEdgeServiceAccount().asLiveData()
val student: LiveData<SStudent> = repository.getStudentMe()
val lastMessage = repository.getLastMessage()
val affinity = repository.getAffinityQuestions()
Expand Down Expand Up @@ -83,10 +85,10 @@ class DashboardViewModel @Inject constructor(
}

fun onProfilePictureClick() {
val accountId = account.value?.id ?: return
val studentId = student.value?.id ?: return

_profileClick.value = Event(accountId to studentId)
// val accountId = account.value?.id ?: return
// val studentId = student.value?.id ?: return
//
// _profileClick.value = Event(accountId to studentId)
}

fun onShowAllClasses() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:minHeight="80dp"
android:paddingStart="16dp"
tools:ignore="RtlSymmetry"
app:goneIf="@{viewModel.account.username == null}">
app:goneIf="@{viewModel.student.name == null}">

<com.google.android.material.card.MaterialCardView
android:id="@+id/card_image"
Expand Down Expand Up @@ -69,7 +69,7 @@
android:layout_height="wrap_content"
android:textColor="?attr/colorOnSurface"
android:textSize="19sp"
app:accountDashboardName="@{viewModel.account.name}"
app:accountDashboardName="@{viewModel.student.name}"
app:layout_constraintBottom_toTopOf="@+id/label_course"
app:layout_constraintEnd_toStartOf="@+id/card_image"
app:layout_constraintHorizontal_bias="0.5"
Expand Down

0 comments on commit 0647cd4

Please sign in to comment.