code clean up

This commit is contained in:
Jannik 2020-06-11 21:51:46 +02:00
parent 2d753851c0
commit 69ce9fef5a
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
5 changed files with 13 additions and 13 deletions

View File

@ -151,7 +151,7 @@ class TCoRAPIController {
* @param courseName the course name
* @param week the week to look up
*/
fun getLessonSubjectListAsync(courseName: String, week: Int): Deferred<ArrayList<String>> {
fun getSubjectListAsync(courseName: String, week: Int): Deferred<ArrayList<String>> {
val url = URL("$tcorBaseURL/subjectList?course=$courseName&week=$week")
return GlobalScope.async {

View File

@ -40,7 +40,7 @@ import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timeta
import org.mosad.seil0.projectlaogai.controller.PreferencesController
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.uicomponents.AddLessonDialog
import org.mosad.seil0.projectlaogai.uicomponents.AddSubjectDialog
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
@ -51,13 +51,13 @@ import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
class TimeTableFragment : Fragment() {
private lateinit var scrollViewTimetable: ScrollView
private lateinit var faBtnAddLesson: FloatingActionButton
private lateinit var faBtnAddSubject: FloatingActionButton
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_timetable, container, false)
scrollViewTimetable = view.findViewById(R.id.scrollView_Timetable)
faBtnAddLesson = view.findViewById(R.id.faBtnAddLesson)
faBtnAddSubject = view.findViewById(R.id.faBtnAddSubject)
// init actions
initActions()
@ -84,8 +84,8 @@ class TimeTableFragment : Fragment() {
}
// show the AddLessonDialog if the ftaBtn is clicked
faBtnAddLesson.setOnClickListener {
AddLessonDialog(context!!).initAddLessonDialog().show{
faBtnAddSubject.setOnClickListener {
AddSubjectDialog(context!!).initialize().show{
getActionButton(WhichButton.POSITIVE).updateTextColor(PreferencesController.cColorAccent)
getActionButton(WhichButton.NEGATIVE).updateTextColor(PreferencesController.cColorAccent)
}
@ -94,9 +94,9 @@ class TimeTableFragment : Fragment() {
// hide the btnCardValue if the user is scrolling down
scrollViewTimetable.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
if (scrollY > oldScrollY) {
faBtnAddLesson.hide()
faBtnAddSubject.hide()
} else {
faBtnAddLesson.show()
faBtnAddSubject.show()
}
}

View File

@ -30,7 +30,7 @@ import androidx.viewpager.widget.PagerAdapter
import org.mosad.seil0.projectlaogai.OnboardingActivity.Companion.layouts
/**
* TODO
* a PagerAdapter
*/
class ViewPagerAdapter(cont: Context) : PagerAdapter() {

View File

@ -44,7 +44,7 @@ import java.util.stream.Collectors
/**
* This class can create a new AddLessonDialog.
*/
class AddLessonDialog(_context: Context) {
class AddSubjectDialog(_context: Context) {
private val context = _context
private lateinit var spinnerCourses: Spinner
@ -59,7 +59,7 @@ class AddLessonDialog(_context: Context) {
/**
* create a new AddLessonDialog (BottomSheet)
*/
fun initAddLessonDialog(): MaterialDialog {
fun initialize(): MaterialDialog {
val dialog = MaterialDialog(context, BottomSheet())
.title(R.string.add_lesson)
.message(R.string.add_lesson_desc)
@ -90,7 +90,7 @@ class AddLessonDialog(_context: Context) {
// TODO show loading dialog while loading
val lessonSubjects = runBlocking {
TCoRAPIController.getLessonSubjectListAsync(parent.getItemAtPosition(pos).toString(), 0).await()
TCoRAPIController.getSubjectListAsync(parent.getItemAtPosition(pos).toString(), 0).await()
}
lessonsAdapter.clear()

View File

@ -24,7 +24,7 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/faBtnAddLesson"
android:id="@+id/faBtnAddSubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center|end"