Browse Source

code clean up

pull/46/head
Jannik 11 months ago
parent
commit
69ce9fef5a
Signed by: Seil0 GPG Key ID: E8459F3723C52C24
  1. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/TCoRAPIController.kt
  2. 14
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  3. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/onboarding/ViewPagerAdapter.kt
  4. 6
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddSubjectDialog.kt
  5. 2
      app/src/main/res/layouts/fragments/layout/fragment_timetable.xml

2
app/src/main/java/org/mosad/seil0/projectlaogai/controller/TCoRAPIController.kt

@ -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 {

14
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -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()
}
}

2
app/src/main/java/org/mosad/seil0/projectlaogai/onboarding/ViewPagerAdapter.kt

@ -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() {

6
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddLessonDialog.kt → app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddSubjectDialog.kt

@ -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()

2
app/src/main/res/layouts/fragments/layout/fragment_timetable.xml

@ -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"

Loading…
Cancel
Save