add refresh gesture to GradesFragment
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
d94f38de93
commit
d6eb1ff1e5
|
@ -30,7 +30,6 @@ import android.view.ViewGroup
|
|||
import android.widget.TextView
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import kotlinx.android.synthetic.main.fragment_grades.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
|
@ -49,8 +48,6 @@ import kotlin.system.measureTimeMillis
|
|||
*/
|
||||
class GradesFragment : Fragment() {
|
||||
|
||||
private lateinit var refreshLayoutGrades: SwipeRefreshLayout
|
||||
|
||||
private lateinit var parser: QISPOSParser
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
@ -60,9 +57,8 @@ class GradesFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
refreshLayoutGrades = view.findViewById(R.id.refreshLayout_Grades)
|
||||
refreshLayoutGrades.isEnabled = false // disable swipe
|
||||
refreshLayoutGrades.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
|
||||
refreshLayout_Grades.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
|
||||
initActions()
|
||||
|
||||
parser = QISPOSParser(context!!)// init the parser
|
||||
|
||||
|
@ -74,6 +70,21 @@ class GradesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize the actions
|
||||
*/
|
||||
private fun initActions() = GlobalScope.launch(Dispatchers.Default) {
|
||||
refreshLayout_Grades.setOnRefreshListener {
|
||||
linLayout_Grades.removeAllViews() // clear layout
|
||||
// TODO add loading textView
|
||||
|
||||
GlobalScope.launch(Dispatchers.Default) {
|
||||
CacheController.updateGrades(context!!).join()
|
||||
addGrades()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the credentials are set, if not show a login dialog
|
||||
*/
|
||||
|
@ -210,7 +221,7 @@ class GradesFragment : Fragment() {
|
|||
}
|
||||
|
||||
}
|
||||
println("startup completed in $addGradesTime ms")
|
||||
println("added grades in $addGradesTime ms")
|
||||
}
|
||||
|
||||
}
|
|
@ -58,7 +58,7 @@ class MensaFragment : Fragment() {
|
|||
|
||||
refreshLayout_Mensa.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
|
||||
|
||||
refreshAction() // init actions
|
||||
initActions() // init actions
|
||||
|
||||
GlobalScope.launch(Dispatchers.Default) {
|
||||
val dayCurrent = if(NotRetardedCalendar.getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar.getDayOfWeekIndex()
|
||||
|
@ -113,15 +113,12 @@ class MensaFragment : Fragment() {
|
|||
}
|
||||
|
||||
/**
|
||||
* initialize the refresh action
|
||||
* initialize the actions
|
||||
*/
|
||||
private fun refreshAction() = GlobalScope.launch(Dispatchers.Default) {
|
||||
withContext(Dispatchers.Main) {
|
||||
// set the refresh listener
|
||||
refreshLayout_Mensa.setOnRefreshListener {
|
||||
updateMensaScreen()
|
||||
}
|
||||
|
||||
private fun initActions() {
|
||||
// set the refresh listener
|
||||
refreshLayout_Mensa.setOnRefreshListener {
|
||||
updateMensaScreen()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class TimeTableFragment : Fragment() {
|
|||
/**
|
||||
* initialize the actions
|
||||
*/
|
||||
private fun initActions() = GlobalScope.launch(Dispatchers.Main) {
|
||||
private fun initActions() {
|
||||
|
||||
refreshLayout_Timetable.setOnRefreshListener {
|
||||
runBlocking { TimetableController.update(context!!).joinAll() }
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?themePrimary"
|
||||
tools:context=".fragments.GradesFragment">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refreshLayout_Grades"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?themePrimary">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView_Grades"
|
||||
|
|
Loading…
Reference in New Issue