Implemented functionality to switch canteens. UI for this is not fully implemented.

This commit is contained in:
denizk0461
2023-04-25 15:38:30 +02:00
parent 840c8f1db7
commit 6b1d77dfb3
21 changed files with 363 additions and 106 deletions
@@ -11,6 +11,7 @@ import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import com.denizk0461.studip.R
import com.denizk0461.studip.data.StudIPParser
import com.denizk0461.studip.data.getThemedColor
import com.denizk0461.studip.databinding.ActivityFetcherBinding
import com.denizk0461.studip.viewmodel.FetcherViewModel
import com.google.android.material.snackbar.Snackbar
@@ -86,16 +87,6 @@ class FetcherActivity : Activity() {
}
} catch (e: IOException) {
// Set up error colours
val colorErrorContainer = TypedValue()
val colorOnErrorContainer = TypedValue()
// Resolve themed attributes to get the right values for day and night modes
theme.apply {
resolveAttribute(R.attr.colorErrorContainer, colorErrorContainer, true)
resolveAttribute(R.attr.colorOnErrorContainer, colorOnErrorContainer, true)
}
// Let the user know that an error occurred
Snackbar
.make(
@@ -104,8 +95,8 @@ class FetcherActivity : Activity() {
Snackbar.LENGTH_SHORT
)
// Set colours to signify an error
.setBackgroundTint(colorErrorContainer.data)
.setTextColor(colorOnErrorContainer.data)
.setBackgroundTint(theme.getThemedColor(R.attr.colorErrorContainer))
.setTextColor(theme.getThemedColor(R.attr.colorOnErrorContainer))
.show()
}
}
@@ -75,11 +75,12 @@ class MainActivity : AppCompatActivity() {
// Prepare and commit a transaction between the current and the next fragment
supportFragmentManager.beginTransaction()
.replace(R.id.nav_host_fragment_content_main, fragment, id.toString())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.commit()
// Set text of the app bar accordingly
binding.contentMain.appTitleBar.text = getTitleString(id)
// binding.contentMain.appTitleBar.text = getTitleString(id)
// Note down the new current fragment
currentFragment = id