@ -22,6 +22,7 @@
package org.mosad.seil0.projectlaogai.fragments
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -95,39 +96,8 @@ class SettingsFragment : Fragment() {
}
linLayoutCourse . setOnClickListener {
// open a new dialog
val courseNameList = ArrayList < String > ( )
coursesList . forEach { ( _ , courseName ) ->
courseNameList . add ( courseName )
}
MaterialDialog ( context !! ) . listItems ( items = courseNameList ) { _ , index , text ->
txtView _Course . text = text // update txtView
val dialog = MaterialDialog ( context !! ) . cancelable ( false )
. cancelOnTouchOutside ( false )
. customView ( R . layout . dialog _loading )
dialog . show ( )
doAsync {
cCourse = coursesList [ index ] // set the course
PreferencesController . save ( context !! )
// update current & next weeks timetable
TCoRAPIController ( context !! ) . getTimetable ( cCourse . courseName , 0 )
TCoRAPIController ( context !! ) . getTimetable ( cCourse . courseName , 1 )
CacheController ( context !! ) . readTimetable ( cCourse . courseName , 0 )
CacheController ( context !! ) . readTimetable ( cCourse . courseName , 1 )
uiThread {
dialog . dismiss ( )
}
}
}
. show ( )
selectCourse ( context !! )
txtView _Course . text = cCourse . courseName // update txtView
}
linLayoutInfo . setOnClickListener {
@ -162,7 +132,6 @@ class SettingsFragment : Fragment() {
MaterialDialog ( context !! )
. title ( R . string . accent _color )
. colorChooser ( DataTypes ( ) . accentColors , allowCustomArgb = true , initialSelection = cColorAccent ) { _ , color ->
//viewAccentColor.setBackgroundColor(color)
view _AccentColor . setBackgroundColor ( color )
Aesthetic . config {
colorAccent ( color )
@ -184,4 +153,40 @@ class SettingsFragment : Fragment() {
}
fun selectCourse ( context : Context ) {
val courseNameList = ArrayList < String > ( )
coursesList . forEach { ( _ , courseName ) ->
courseNameList . add ( courseName )
}
// open a new dialog
MaterialDialog ( context )
. title ( R . string . select _course )
. listItems ( items = courseNameList ) { _ , index , text ->
val dialog = MaterialDialog ( context ) . cancelable ( false )
. cancelOnTouchOutside ( false )
. customView ( R . layout . dialog _loading )
dialog . show ( )
doAsync {
cCourse = coursesList [ index ] // set the course
PreferencesController . save ( context )
// update current & next weeks timetable
TCoRAPIController ( context ) . getTimetable ( cCourse . courseName , 0 )
TCoRAPIController ( context ) . getTimetable ( cCourse . courseName , 1 )
CacheController ( context ) . readTimetable ( cCourse . courseName , 0 )
CacheController ( context ) . readTimetable ( cCourse . courseName , 1 )
uiThread {
dialog . dismiss ( )
}
}
}
. show ( )
}
}