Add user icon choice fragment and functionality
This commit is contained in:
parent
0316099a0f
commit
35040d34f4
|
|
@ -46,14 +46,27 @@ class AddStudentFragment : Fragment() {
|
||||||
|
|
||||||
binding.setLifecycleOwner(this)
|
binding.setLifecycleOwner(this)
|
||||||
|
|
||||||
// Listen for when we navigate to student list
|
// // Add an Observer to the state variable for Navigating when student icon is clicked.
|
||||||
addStudentViewModel.navigateToStudentList.observe(viewLifecycleOwner, Observer {
|
// addStudentViewModel.navigateToChooseIcon.observe(viewLifecycleOwner, Observer {student ->
|
||||||
|
// student?.let {
|
||||||
|
// this.findNavController().navigate(AddStudentFragmentDirections
|
||||||
|
// .actionAddStudentFragmentToChooseIconFragment(student.studentId))
|
||||||
|
// addStudentViewModel.doneNavigating()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Add an Observer to the state variable for Navigating when a Quality icon is tapped.
|
||||||
|
addStudentViewModel.navigateToChooseIcon.observe(viewLifecycleOwner, Observer {
|
||||||
if (it == true) { // Observed state is true.
|
if (it == true) { // Observed state is true.
|
||||||
this.findNavController().navigate(
|
this.findNavController().navigate(
|
||||||
AddStudentFragmentDirections.actionAddStudentFragmentToStudentListFragment())
|
AddStudentFragmentDirections.actionAddStudentFragmentToChooseIconFragment())
|
||||||
|
// Reset state to make sure we only navigate once, even if the device
|
||||||
|
// has a configuration change.
|
||||||
addStudentViewModel.doneNavigating()
|
addStudentViewModel.doneNavigating()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,53 @@
|
||||||
package com.taymath.tutortoolkit.addstudent
|
package com.taymath.tutortoolkit.addstudent
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.ImageView
|
||||||
|
import androidx.databinding.BindingAdapter
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MediatorLiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.taymath.tutortoolkit.R
|
||||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||||
|
import com.taymath.tutortoolkit.studentdetail.StudentDetailFragmentArgs
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
|
|
||||||
class AddStudentViewModel(
|
class AddStudentViewModel(
|
||||||
val database: StudentDatabaseDao
|
val database: StudentDatabaseDao
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
|
val newStudent = Student()
|
||||||
|
|
||||||
// Initialize viewModelJob
|
// Initialize viewModelJob
|
||||||
private val viewModelJob = Job()
|
private val viewModelJob = Job()
|
||||||
|
|
||||||
// Initialize uiScope
|
// Initialize uiScope
|
||||||
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
||||||
|
|
||||||
// Setup Livdata to signal when to navigate to studentList
|
private var currentStudent = MutableLiveData<Student?>()
|
||||||
private val _navigateToStudentList = MutableLiveData<Boolean?>()
|
|
||||||
val navigateToStudentList: LiveData<Boolean?>
|
// Setup Livdata to signal when to navigate to chooseIcon
|
||||||
get() = _navigateToStudentList
|
private val _navigateToChooseIcon = MutableLiveData<Boolean?>()
|
||||||
|
val navigateToChooseIcon: LiveData<Boolean?>
|
||||||
|
get() = _navigateToChooseIcon
|
||||||
|
|
||||||
// Initialize Student and add to student_table
|
// Initialize Student and add to student_table
|
||||||
fun onAddStudent(studentNameString : String, subjectString: String,
|
fun onChooseIcon(studentNameString : String, subjectString: String,
|
||||||
gradeLevelString: String, addressString: String, emailString: String) {
|
gradeLevelString: String, addressString: String, emailString: String) {
|
||||||
|
newStudent.studentNameString = studentNameString
|
||||||
|
newStudent.subjectString = subjectString
|
||||||
|
newStudent.emailString = emailString
|
||||||
|
newStudent.gradeLevelString = gradeLevelString
|
||||||
|
newStudent.addressString = addressString
|
||||||
|
|
||||||
uiScope.launch {
|
uiScope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val newStudent = Student()
|
|
||||||
newStudent.studentNameString = studentNameString
|
|
||||||
newStudent.subjectString = subjectString
|
|
||||||
newStudent.emailString = emailString
|
|
||||||
newStudent.gradeLevelString = gradeLevelString
|
|
||||||
newStudent.addressString = addressString
|
|
||||||
insert(newStudent)
|
insert(newStudent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_navigateToStudentList.value = true
|
_navigateToChooseIcon.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
|
@ -45,7 +56,7 @@ class AddStudentViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doneNavigating() {
|
fun doneNavigating() {
|
||||||
_navigateToStudentList.value = null
|
_navigateToChooseIcon.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun insert(student: Student) {
|
private suspend fun insert(student: Student) {
|
||||||
|
|
@ -54,14 +65,17 @@ class AddStudentViewModel(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fun onSetSleepQuality(quality: Int) {
|
private suspend fun getCurrentStudentFromDatabase(): Student? {
|
||||||
// uiScope.launch {
|
return withContext(Dispatchers.IO) {
|
||||||
// withContext(Dispatchers.IO) {
|
var student = database.getCurrentStudent()
|
||||||
// val tonight = database.get(sleepNightKey) ?: return@withContext
|
student
|
||||||
// tonight.sleepQuality = quality
|
}
|
||||||
// database.update(tonight)
|
}
|
||||||
// }
|
|
||||||
// _navigateToSleepTracker.value = true
|
private fun initializeCurrentStudent() {
|
||||||
// }
|
uiScope.launch {
|
||||||
// }
|
currentStudent.value = getCurrentStudentFromDatabase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,12 +6,19 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.taymath.tutortoolkit.R
|
import com.taymath.tutortoolkit.R
|
||||||
import com.taymath.tutortoolkit.databinding.FragmentChooseIconBinding
|
import com.taymath.tutortoolkit.databinding.FragmentChooseIconBinding
|
||||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
import com.taymath.tutortoolkit.studentdatabase.StudentDatabase
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fragment that displays a list of clickable icons,
|
||||||
|
* each representing a sleep quality rating.
|
||||||
|
* Once the user taps an icon, the quality is set in the current sleepNight
|
||||||
|
* and the database is updated.
|
||||||
|
*/
|
||||||
class ChooseIconFragment : Fragment() {
|
class ChooseIconFragment : Fragment() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,8 +35,6 @@ class ChooseIconFragment : Fragment() {
|
||||||
|
|
||||||
val application = requireNotNull(this.activity).application
|
val application = requireNotNull(this.activity).application
|
||||||
|
|
||||||
// val arguments = SleepQualityFragmentArgs.fromBundle(arguments!!)
|
|
||||||
|
|
||||||
// Create an instance of the ViewModel Factory.
|
// Create an instance of the ViewModel Factory.
|
||||||
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
val dataSource = StudentDatabase.getInstance(application).studentDatabaseDao
|
||||||
val viewModelFactory = ChooseIconViewModelFactory(dataSource)
|
val viewModelFactory = ChooseIconViewModelFactory(dataSource)
|
||||||
|
|
@ -44,16 +49,16 @@ class ChooseIconFragment : Fragment() {
|
||||||
binding.chooseIconViewModel = chooseIconViewModel
|
binding.chooseIconViewModel = chooseIconViewModel
|
||||||
|
|
||||||
// Add an Observer to the state variable for Navigating when a Quality icon is tapped.
|
// Add an Observer to the state variable for Navigating when a Quality icon is tapped.
|
||||||
// chooseIconViewModel.navigateToSleepTracker.observe(this, Observer {
|
chooseIconViewModel.navigateToStudentList.observe(viewLifecycleOwner, Observer {
|
||||||
// if (it == true) { // Observed state is true.
|
if (it == true) { // Observed state is true.
|
||||||
// this.findNavController().navigate(
|
this.findNavController().navigate(
|
||||||
// SleepQualityFragmentDirections.actionSleepQualityFragmentToSleepTrackerFragment())
|
ChooseIconFragmentDirections.actionChooseIconFragmentToStudentListFragment())
|
||||||
// // Reset state to make sure we only navigate once, even if the device
|
// Reset state to make sure we only navigate once, even if the device
|
||||||
// // has a configuration change.
|
// has a configuration change.
|
||||||
// sleepQualityViewModel.doneNavigating()
|
chooseIconViewModel.doneNavigating()
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,42 +6,25 @@ import androidx.lifecycle.ViewModel
|
||||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewModel for SleepQualityFragment.
|
||||||
|
*
|
||||||
|
* @param sleepNightKey The key of the current night we are working on.
|
||||||
|
*/
|
||||||
class ChooseIconViewModel(
|
class ChooseIconViewModel(
|
||||||
val database: StudentDatabaseDao) : ViewModel() {
|
val database: StudentDatabaseDao) : ViewModel() {
|
||||||
|
|
||||||
/** Coroutine setup variables */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* viewModelJob allows us to cancel all coroutines started by this ViewModel.
|
|
||||||
*/
|
|
||||||
private val viewModelJob = Job()
|
private val viewModelJob = Job()
|
||||||
|
|
||||||
/**
|
|
||||||
* A [CoroutineScope] keeps track of all coroutines started by this ViewModel.
|
|
||||||
*
|
|
||||||
* Because we pass it [viewModelJob], any coroutine started in this scope can be cancelled
|
|
||||||
* by calling `viewModelJob.cancel()`
|
|
||||||
*
|
|
||||||
* By default, all coroutines started in uiScope will launch in [Dispatchers.Main] which is
|
|
||||||
* the main thread on Android. This is a sensible default because most coroutines started by
|
|
||||||
* a [ViewModel] update the UI after performing some processing.
|
|
||||||
*/
|
|
||||||
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
|
||||||
|
|
||||||
/**
|
private val _navigateToStudentList = MutableLiveData<Boolean?>()
|
||||||
* Variable that tells the fragment whether it should navigate to [SleepTrackerFragment].
|
|
||||||
*
|
|
||||||
* This is `private` because we don't want to expose the ability to set [MutableLiveData] to
|
|
||||||
* the [Fragment]
|
|
||||||
*/
|
|
||||||
private val _navigateToSleepTracker = MutableLiveData<Boolean?>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When true immediately navigate back to the [SleepTrackerFragment]
|
* When true immediately navigate back to the [SleepTrackerFragment]
|
||||||
*/
|
*/
|
||||||
val navigateToSleepTracker: LiveData<Boolean?>
|
val navigateToStudentList: LiveData<Boolean?>
|
||||||
get() = _navigateToSleepTracker
|
get() = _navigateToStudentList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels all coroutines when the ViewModel is cleared, to cleanup any pending work.
|
* Cancels all coroutines when the ViewModel is cleared, to cleanup any pending work.
|
||||||
*
|
*
|
||||||
|
|
@ -53,29 +36,23 @@ class ChooseIconViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this immediately after navigating to [SleepTrackerFragment]
|
* Call this immediately after navigating to [StudentListFragment]
|
||||||
*/
|
*/
|
||||||
fun doneNavigating() {
|
fun doneNavigating() {
|
||||||
_navigateToSleepTracker.value = null
|
_navigateToStudentList.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
fun onChooseIcon(iconNumber: Int) {
|
||||||
* Sets the sleep quality and updates the database.
|
uiScope.launch {
|
||||||
*
|
// IO is a thread pool for running operations that access the disk, such as
|
||||||
* Then navigates back to the SleepTrackerFragment.
|
// our Room database.
|
||||||
*/
|
withContext(Dispatchers.IO) {
|
||||||
// fun onSetSleepQuality(quality: Int) {
|
val currentStudent = database.getCurrentStudent() ?: return@withContext
|
||||||
// uiScope.launch {
|
currentStudent.iconNumber = iconNumber
|
||||||
// // IO is a thread pool for running operations that access the disk, such as
|
database.updateStudent(currentStudent)
|
||||||
// // our Room database.
|
}
|
||||||
// withContext(Dispatchers.IO) {
|
}
|
||||||
// val tonight = database.get(sleepNightKey) ?: return@withContext
|
// Setting this state variable to true will alert the observer and trigger navigation.
|
||||||
// tonight.sleepQuality = quality
|
_navigateToStudentList.value = true
|
||||||
// database.update(tonight)
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Setting this state variable to true will alert the observer and trigger navigation.
|
|
||||||
// _navigateToSleepTracker.value = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,11 @@ import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
import com.taymath.tutortoolkit.studentdatabase.StudentDatabaseDao
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is pretty much boiler plate code for a ViewModel Factory.
|
||||||
|
*
|
||||||
|
* Provides the key for the night and the SleepDatabaseDao to the ViewModel.
|
||||||
|
*/
|
||||||
class ChooseIconViewModelFactory(
|
class ChooseIconViewModelFactory(
|
||||||
private val dataSource: StudentDatabaseDao) : ViewModelProvider.Factory {
|
private val dataSource: StudentDatabaseDao) : ViewModelProvider.Factory {
|
||||||
@Suppress("unchecked_cast")
|
@Suppress("unchecked_cast")
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ data class Student (
|
||||||
var addressString: String = "CHECK_Student.KT",
|
var addressString: String = "CHECK_Student.KT",
|
||||||
|
|
||||||
@ColumnInfo(name = "email")
|
@ColumnInfo(name = "email")
|
||||||
var emailString: String = "CHECK_Student.KT"
|
var emailString: String = "CHECK_Student.KT",
|
||||||
|
|
||||||
|
@ColumnInfo(name="iconNumber")
|
||||||
|
var iconNumber: Int = 1
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,13 @@
|
||||||
package com.taymath.tutortoolkit.studentdatabase
|
package com.taymath.tutortoolkit.studentdatabase
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.room.Dao
|
import androidx.room.*
|
||||||
import androidx.room.Insert
|
|
||||||
import androidx.room.Query
|
|
||||||
import androidx.room.Update
|
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface StudentDatabaseDao {
|
interface StudentDatabaseDao {
|
||||||
|
|
||||||
// Student Table Dao
|
// Student Table Dao
|
||||||
@Insert
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
fun insertStudent(student: Student)
|
fun insertStudent(student: Student)
|
||||||
|
|
||||||
@Update
|
@Update
|
||||||
|
|
@ -47,12 +44,15 @@ interface StudentDatabaseDao {
|
||||||
@Query("SELECT * from student_table WHERE studentId = :key")
|
@Query("SELECT * from student_table WHERE studentId = :key")
|
||||||
fun getStudentWithId(key: Long): LiveData<Student>
|
fun getStudentWithId(key: Long): LiveData<Student>
|
||||||
|
|
||||||
@Query("SELECT * FROM student_table WHERE studentId = :studentId")
|
@Query("SELECT * from student_table WHERE studentId = :key")
|
||||||
fun getStudentClassWithId(studentId: Long): Student
|
fun getStudentClassWithId(key: Long): Student?
|
||||||
|
|
||||||
@Query("SELECT * from student_table WHERE student_name = :studentName")
|
@Query("SELECT * from student_table WHERE student_name = :studentName")
|
||||||
fun getStudentWithName(studentName: String): LiveData<Student>
|
fun getStudentWithName(studentName: String): LiveData<Student>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM student_table ORDER BY studentId DESC LIMIT 1")
|
||||||
|
fun getCurrentStudent(): Student?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Grade Table Dao
|
// Grade Table Dao
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,6 @@ import androidx.databinding.BindingAdapter
|
||||||
import com.taymath.tutortoolkit.R
|
import com.taymath.tutortoolkit.R
|
||||||
import com.taymath.tutortoolkit.studentdatabase.Student
|
import com.taymath.tutortoolkit.studentdatabase.Student
|
||||||
|
|
||||||
@BindingAdapter("studentImage")
|
|
||||||
fun ImageView.setStudentImage(item: Student?){
|
|
||||||
item?.let {
|
|
||||||
setImageResource(R.drawable.ic_item_test)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@BindingAdapter("subjectText")
|
@BindingAdapter("subjectText")
|
||||||
fun TextView.setSubjectText(item: Student?){
|
fun TextView.setSubjectText(item: Student?){
|
||||||
item?.let {
|
item?.let {
|
||||||
|
|
@ -33,3 +26,20 @@ fun TextView.setGradeLevelText(item: Student?){
|
||||||
text =item.gradeLevelString
|
text =item.gradeLevelString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("studentImage")
|
||||||
|
fun ImageView.setStudentImage(item: Student?) {
|
||||||
|
item?.let {
|
||||||
|
setImageResource(when (item.iconNumber) {
|
||||||
|
1 -> R.drawable.icon_1
|
||||||
|
2 -> R.drawable.icon_2
|
||||||
|
3 -> R.drawable.icon_3
|
||||||
|
4 -> R.drawable.icon_4
|
||||||
|
5 -> R.drawable.icon_5
|
||||||
|
6 -> R.drawable.icon_6
|
||||||
|
7 -> R.drawable.icon_7
|
||||||
|
8 -> R.drawable.icon_8
|
||||||
|
else -> R.drawable.icon_1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,29 +91,17 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/address_text" />
|
app:layout_constraintTop_toBottomOf="@+id/address_text" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/add_student_button"
|
|
||||||
style="@style/AddButtons"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:onClick="@{() -> addStudentViewModel.onAddStudent(studentNameText.getText().toString(), subjectText.getText().toString(), gradeText.getText().toString(), addressText.getText().toString(), emailText.getText().toString())}"
|
|
||||||
android:text="@string/add_student"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/imageButton" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/imageButton"
|
android:id="@+id/imageButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/margin"
|
android:layout_margin="@dimen/margin"
|
||||||
|
android:onClick="@{() -> addStudentViewModel.onChooseIcon(studentNameText.getText().toString(), subjectText.getText().toString(), gradeText.getText().toString(), addressText.getText().toString(), emailText.getText().toString())}"
|
||||||
|
app:srcCompat="@drawable/icon_1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/email_text"
|
app:layout_constraintTop_toBottomOf="@+id/email_text"
|
||||||
app:srcCompat="@drawable/icon_1"
|
|
||||||
android:contentDescription="@string/student_image_icon_choice" />
|
android:contentDescription="@string/student_image_icon_choice" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
~ Copyright 2018, The Android Open Source Project
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Wrapping the layout into /layout to make it available with data binding. -->
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
@ -23,7 +7,6 @@
|
||||||
the whole ViewModel, so that we can access the LiveData,
|
the whole ViewModel, so that we can access the LiveData,
|
||||||
click handlers, and state variables. -->
|
click handlers, and state variables. -->
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="chooseIconViewModel"
|
name="chooseIconViewModel"
|
||||||
type="com.taymath.tutortoolkit.chooseicon.ChooseIconViewModel"/>
|
type="com.taymath.tutortoolkit.chooseicon.ChooseIconViewModel"/>
|
||||||
|
|
@ -45,14 +28,100 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<ImageButton
|
||||||
android:id="@+id/quality_zero_image"
|
android:id="@+id/icon_one_image"
|
||||||
android:layout_width="@dimen/icon_size"
|
android:layout_width="@dimen/icon_size"
|
||||||
android:layout_height="@dimen/icon_size"
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
android:contentDescription="@string/icon_1"
|
android:contentDescription="@string/icon_1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(1)}"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/title_text"
|
app:layout_constraintTop_toBottomOf="@+id/title_text"
|
||||||
app:srcCompat="@drawable/icon_1" />
|
app:srcCompat="@drawable/icon_1" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_two_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(2)}"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/icon_three_image"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/icon_one_image"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title_text"
|
||||||
|
app:srcCompat="@drawable/icon_2" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_three_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(3)}"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title_text"
|
||||||
|
app:srcCompat="@drawable/icon_3" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_four_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(4)}"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon_two_image"
|
||||||
|
app:srcCompat="@drawable/icon_4" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_five_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:layout_marginStart="74dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(5)}"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/icon_six_image"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/icon_four_image"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon_two_image"
|
||||||
|
app:srcCompat="@drawable/icon_5" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_six_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(6)}"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon_two_image"
|
||||||
|
app:srcCompat="@drawable/icon_6" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_seven_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(7)}"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon_five_image"
|
||||||
|
app:srcCompat="@drawable/icon_7" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_eight_image"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_margin="@dimen/triple_margin"
|
||||||
|
android:layout_marginTop="105dp"
|
||||||
|
android:contentDescription="@string/icon_1"
|
||||||
|
android:onClick="@{() -> chooseIconViewModel.onChooseIcon(8)}"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon_five_image"
|
||||||
|
app:srcCompat="@drawable/icon_8" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
@ -1,59 +1,64 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/navigation"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
app:startDestination="@id/studentListFragment">
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/navigation"
|
||||||
|
app:startDestination="@id/studentListFragment"
|
||||||
|
tools:ignore="ExtraText">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/studentListFragment"
|
android:id="@+id/addGradeFragment"
|
||||||
android:name="com.taymath.tutortoolkit.studentlist.StudentListFragment"
|
android:name="com.taymath.tutortoolkit.addgrade.AddGradeFragment"
|
||||||
android:label="StudentListFragment" >
|
android:label="AddGradeFragment" >
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_studentListFragment_to_addStudentFragment"
|
android:id="@+id/action_addGradeFragment_to_studentListFragment"
|
||||||
app:destination="@id/addStudentFragment" />
|
app:destination="@id/studentListFragment" />
|
||||||
<action
|
<argument
|
||||||
android:id="@+id/action_studentListFragment_to_studentDetailFragment"
|
android:name="student_id"
|
||||||
app:destination="@id/studentDetailFragment" />
|
app:argType="long" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/addStudentFragment"
|
android:id="@+id/addStudentFragment"
|
||||||
android:name="com.taymath.tutortoolkit.addstudent.AddStudentFragment"
|
android:name="com.taymath.tutortoolkit.addstudent.AddStudentFragment"
|
||||||
android:label="AddStudentFragment" >
|
android:label="AddStudentFragment" >
|
||||||
<action
|
|
||||||
android:id="@+id/action_addStudentFragment_to_studentListFragment"
|
|
||||||
app:destination="@id/studentListFragment" />
|
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_addStudentFragment_to_chooseIconFragment"
|
android:id="@+id/action_addStudentFragment_to_chooseIconFragment"
|
||||||
app:destination="@id/chooseIconFragment" />
|
app:destination="@id/chooseIconFragment" />
|
||||||
<action
|
|
||||||
android:id="@+id/action_addStudentFragment_to_chooseIconFragment2"
|
|
||||||
app:destination="@id/chooseIconFragment" />
|
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/studentDetailFragment"
|
android:id="@+id/studentDetailFragment"
|
||||||
android:name="com.taymath.tutortoolkit.studentdetail.StudentDetailFragment"
|
android:name="com.taymath.tutortoolkit.studentdetail.StudentDetailFragment"
|
||||||
android:label="StudentDetailFragment" >
|
android:label="StudentDetailFragment" >
|
||||||
<action
|
|
||||||
android:id="@+id/action_studentDetailFragment_to_studentListFragment"
|
|
||||||
app:destination="@id/studentListFragment" />
|
|
||||||
<action
|
|
||||||
android:id="@+id/action_studentDetailFragment_to_addGradeFragment"
|
|
||||||
app:destination="@id/addGradeFragment" />
|
|
||||||
<argument android:name="student_id"
|
|
||||||
app:argType="long" />
|
|
||||||
</fragment>
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/addGradeFragment"
|
|
||||||
android:name="com.taymath.tutortoolkit.addgrade.AddGradeFragment"
|
|
||||||
android:label="AddGradeFragment" >
|
|
||||||
<argument
|
<argument
|
||||||
android:name="student_id"
|
android:name="student_id"
|
||||||
app:argType="long" />
|
app:argType="long" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_addGradeFragment_to_studentListFragment"
|
android:id="@+id/action_studentDetailFragment_to_addGradeFragment"
|
||||||
|
app:destination="@id/addGradeFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_studentDetailFragment_to_studentListFragment"
|
||||||
app:destination="@id/studentListFragment" />
|
app:destination="@id/studentListFragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/studentListFragment"
|
||||||
|
android:name="com.taymath.tutortoolkit.studentlist.StudentListFragment"
|
||||||
|
android:label="StudentListFragment" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_studentListFragment_to_studentDetailFragment"
|
||||||
|
app:destination="@id/studentDetailFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_studentListFragment_to_addStudentFragment"
|
||||||
|
app:destination="@id/addStudentFragment" />
|
||||||
|
</fragment>
|
||||||
|
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/chooseIconFragment"
|
android:id="@+id/chooseIconFragment"
|
||||||
android:name="com.taymath.tutortoolkit.chooseicon.ChooseIconFragment"
|
android:name="com.taymath.tutortoolkit.chooseicon.ChooseIconFragment"
|
||||||
android:label="ChooseIconFragment" />
|
android:label="ChooseIconFragment">
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_chooseIconFragment_to_studentListFragment"
|
||||||
|
app:destination="@id/studentListFragment" />
|
||||||
|
</fragment>
|
||||||
|
|
||||||
</navigation>
|
</navigation>
|
||||||
Loading…
Reference in New Issue