fixed app crash if the tt cannot be loaded
This commit is contained in:
parent
2d525c394b
commit
2c81c80456
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "org.mosad.seil0.projectlaogai"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode 4
|
||||
versionName "0.1.3"
|
||||
versionCode 5
|
||||
versionName "0.1.4"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -27,7 +27,7 @@ android {
|
|||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.0.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.0.1'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme" android:fullBackupContent="@xml/backup_descriptor">
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:name=".SplashActivity"
|
||||
|
|
|
@ -48,7 +48,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
|
||||
private var weekMenus = ArrayList<Meal>()
|
||||
private var courseTTLinkList = ArrayList<CourseTTLink>()
|
||||
private lateinit var timeTableWeek: Array<Array<Lesson>>
|
||||
private var timeTableWeek = arrayOf<Array<Lesson>>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -170,7 +170,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
|
||||
val t2 = doAsync {
|
||||
timeTableWeek = timeTableParser.getTimeTable("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")
|
||||
try {
|
||||
timeTableWeek = timeTableParser.getTimeTable("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")
|
||||
}catch (e: Exception) {
|
||||
e.stackTrace
|
||||
}
|
||||
}
|
||||
|
||||
t1.get()
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
import org.jetbrains.anko.doAsync
|
||||
import org.jetbrains.anko.uiThread
|
||||
|
@ -94,26 +95,35 @@ class HomeFragment : Fragment() {
|
|||
* add the current timetable to the home screen
|
||||
*/
|
||||
private fun addCurrentTimeTable() {
|
||||
val timeTableDay = mainActivity.getCurrentTimeTableWeek()[Calendar.getInstance().get(Calendar.DAY_OF_WEEK) -2]
|
||||
|
||||
for (i in 0..5) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
// TODO this needs to be reworked, currently we display the waring if there is no lecture at all not only if we're unable to load the tt
|
||||
if (mainActivity.getCurrentTimeTableWeek().isNotEmpty()) {
|
||||
val timeTableDay = mainActivity.getCurrentTimeTableWeek()[Calendar.getInstance().get(Calendar.DAY_OF_WEEK) -2]
|
||||
|
||||
lessonCardView.getTxtViewLesson().text = resources.getString(R.string.string_new_line, timeTableDay[i].lessonSubject)
|
||||
lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonTeacher + "\n")
|
||||
lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonRoom)
|
||||
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||
for (i in 0..5) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
|
||||
if(lessonCardView.getTxtViewLesson().text.length > 2)
|
||||
linLayoutTimeTable.addView(lessonCardView)
|
||||
}
|
||||
lessonCardView.getTxtViewLesson().text = resources.getString(R.string.string_new_line, timeTableDay[i].lessonSubject)
|
||||
lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonTeacher + "\n")
|
||||
lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonRoom)
|
||||
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||
|
||||
// add a card if there is no lesson today
|
||||
if (linLayoutTimeTable.childCount == 0) {
|
||||
// TODO we could display the next day with a lecture
|
||||
val noLessonCardView = LessonCardView(context!!, null)
|
||||
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
|
||||
linLayoutTimeTable.addView(noLessonCardView)
|
||||
if(lessonCardView.getTxtViewLesson().text.length > 2)
|
||||
linLayoutTimeTable.addView(lessonCardView)
|
||||
}
|
||||
|
||||
// add a card if there is no lesson today
|
||||
if (linLayoutTimeTable.childCount == 0) {
|
||||
// TODO we could display the next day with a lecture
|
||||
val noLessonCardView = LessonCardView(context!!, null)
|
||||
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today)
|
||||
linLayoutTimeTable.addView(noLessonCardView)
|
||||
}
|
||||
} else {
|
||||
MaterialDialog(context!!)
|
||||
.title(R.string.error)
|
||||
.message(R.string.nott_info)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<string name="no_meal_today">heute keine Essensausgabe</string>
|
||||
<string name="no_more_food">Diese Woche keine weitere Essensausgabe</string>
|
||||
<string name="no_lesson_today">heute keine Vorlesung</string>
|
||||
<string name="error">Fehler</string>
|
||||
<string name="nott_info">Stundenplan konnte nicht geladen werden!</string>
|
||||
<string name="info">Info</string>
|
||||
<string name="user">Benutzer</string>
|
||||
<string name="course_desc">Tippen, um den Kurs zu ändern</string>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<string name="app_name" translatable="false">Project Laogai</string>
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.1.3</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.1.4</string>
|
||||
<string name="nav_header_subtitle" translatable="false">seil0@mosad.xyz</string>
|
||||
<string name="nav_header_desc" translatable="false">Project Laogai</string>
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
|||
<string name="no_more_food">No more Food this week</string>
|
||||
|
||||
<string name="no_lesson_today">"no lecture today "</string>
|
||||
<string name="error">Error</string>
|
||||
<string name="nott_info">Could not load timetabl!"</string>
|
||||
|
||||
<string name="sample_user" translatable="false">SampleUser@stud.hs-offenburg.de</string>
|
||||
<string name="sample_course" translatable="false">SampleCourse 3</string>
|
||||
|
@ -32,7 +34,7 @@
|
|||
<string name="primary_color">primary color</string>
|
||||
<string name="main_color_desc">The primary color, default is indigo</string>
|
||||
<string name="select">select</string>
|
||||
<string name="version" translatable="false">version 0.1.3</string>
|
||||
<string name="version" translatable="false">version 0.1.4</string>
|
||||
<string name="about">about</string>
|
||||
<string name="about_txtView" translatable="false">hso App by @Seil0</string>
|
||||
<string name="about_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018 seil0@mosad.xyz "</string>
|
||||
|
|
Loading…
Reference in New Issue