Browse Source

added a loading diaolg, when you change the course & code cleanup

pull/20/head
Jannik 4 years ago
parent
commit
2d525c394b
  1. 2
      app/src/main/AndroidManifest.xml
  2. 16
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  3. 13
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt
  4. 23
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  5. 3
      app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/MensaParser.kt
  6. 4
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MenuCardView.kt
  7. 2
      app/src/main/res/layout/app_bar_main.xml
  8. 17
      app/src/main/res/layout/dialog_loading.xml
  9. 2
      app/src/main/res/layout/nav_header_main.xml
  10. 1
      app/src/main/res/values-de-rDE/strings.xml
  11. 7
      app/src/main/res/values-v21/styles.xml
  12. 7
      app/src/main/res/values/strings.xml
  13. 4
      app/src/main/res/xml/backup_descriptor.xml
  14. 2
      gradle/wrapper/gradle-wrapper.properties

2
app/src/main/AndroidManifest.xml

@ -9,7 +9,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme" android:fullBackupContent="@xml/backup_descriptor">
<activity
android:name=".SplashActivity"

16
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -23,13 +23,13 @@
package org.mosad.seil0.projectlaogai
import android.os.Bundle
import com.google.android.material.navigation.NavigationView
import androidx.core.view.GravityCompat
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
import androidx.fragment.app.FragmentTransaction
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import org.jetbrains.anko.doAsync
@ -38,7 +38,6 @@ import org.mosad.seil0.projectlaogai.fragments.MensaFragment
import org.mosad.seil0.projectlaogai.fragments.SettingsFragment
import org.mosad.seil0.projectlaogai.fragments.TimeTableFragment
import org.mosad.seil0.projectlaogai.hsoparser.*
import kotlin.collections.ArrayList
import kotlin.system.measureTimeMillis
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
@ -48,8 +47,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private val timeTableParser = TimeTableParser()
private var weekMenus = ArrayList<Meal>()
private lateinit var timeTableWeek: Array<Array<Lesson>>
private var courseTTLinkList = ArrayList<CourseTTLink>()
private lateinit var timeTableWeek: Array<Array<Lesson>>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -150,10 +149,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
println(course.course)
println(course.courseTTLink)
// the app is hanging here TODO show loading dialog
doAsync {
timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
}.get()
timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
}
/**

13
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt

@ -63,18 +63,22 @@ class HomeFragment : Fragment() {
return view
}
/**
* add the current mensa meal to the home screens
* TODO show meals of the next day if its later than 1500
*/
private fun addCurrentMensaMenu() {
doAsync {
doAsync {
val dayMenus: ArrayList<Meal> = MensaParser().getMensaMenuDay(mainActivity.getWeekMenu(), Calendar.getInstance().get(Calendar.DAY_OF_WEEK))
uiThread {
if (dayMenus.size >= 2) {
for(part in dayMenus[0].parts) {
for (part in dayMenus[0].parts) {
txtViewMenu1.append(part)
}
for(part in dayMenus[1].parts) {
for (part in dayMenus[1].parts) {
txtViewMenu2.append(part)
}
} else {
@ -86,6 +90,9 @@ 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]

23
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -31,8 +31,11 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.color.colorChooser
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.list.listItems
import kotlinx.android.synthetic.main.fragment_settings.*
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.MainActivity
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.CourseTTLink
@ -86,12 +89,22 @@ class SettingsFragment : Fragment() {
courseList.add(course)
}
MaterialDialog(context!!)
.listItems(items = courseList){ _, index, text ->
// update txtView
txtView_Course.text = text
MaterialDialog(context!!).listItems(items = courseList){ _, index, text ->
txtView_Course.text = text // update txtView
val dialog = MaterialDialog(context!!).cancelable(false)
.cancelOnTouchOutside(false)
.customView(R.layout.dialog_loading)
dialog.show()
doAsync {
mainActivity.updateCourse(courseTTLinkList[index])
uiThread {
dialog.dismiss()
}
}
mainActivity.updateCourse(courseTTLinkList[index])
}
.show()
}

3
app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/MensaParser.kt

@ -52,7 +52,6 @@ class MensaParser {
}
}
}
return mealList
}
@ -61,7 +60,7 @@ class MensaParser {
*/
fun getMensaMenuDay(mealList: ArrayList<Meal>, day: Int): ArrayList<Meal> {
val dayMenus = ArrayList<Meal>()
val strDay: String = when(day) {
val strDay: String = when (day) {
Calendar.MONDAY -> "Mon"
Calendar.TUESDAY -> "Die"
Calendar.WEDNESDAY -> "Mit"

4
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/MenuCardView.kt

@ -21,10 +21,6 @@ class MenuCardView @JvmOverloads constructor(context: Context, attrs: AttributeS
this.setBackgroundColor(Color.TRANSPARENT)
}
fun getTxtViewMenuHeading(): TextView {
return txtViewMenuHeading
}
fun setMenuHeading(heading: String) {
txtViewMenuHeading.text = heading
}

2
app/src/main/res/layout/app_bar_main.xml

@ -27,7 +27,7 @@
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
android:layout_height="match_parent"/>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

17
app/src/main/res/layout/dialog_loading.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center" android:paddingBottom="9dp">
<ProgressBar
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/progressBar"/>
<TextView
android:text="@string/loading_timetable"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView2" android:gravity="center"
android:textSize="18sp"/>
</LinearLayout>

2
app/src/main/res/layout/nav_header_main.xml

@ -2,7 +2,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:paddingBottom="@dimen/activity_vertical_margin"

1
app/src/main/res/values-de-rDE/strings.xml

@ -18,6 +18,7 @@
<string name="main_color_desc">Die Primärfarbe, standard ist Indigo</string>
<string name="select">auswählen</string>
<string name="about">über</string>
<string name="loading_timetable">lade Stundenplan …</string>
<string name="hello_blank_fragment">bald ™</string>
<string name="navigation_drawer_close">Navigationsleiste schließen</string>
<string name="navigation_drawer_open">Navigationsleiste öffnen</string>

7
app/src/main/res/values-v21/styles.xml

@ -1,7 +0,0 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

7
app/src/main/res/values/strings.xml

@ -35,11 +35,10 @@
<string name="version" translatable="false">version 0.1.3</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 git.mosad.xyz/Seil0/ProjectLaogai © 2018 seil0@mosad.xyz "
</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>
<string name="loading_timetable">loading timetable …</string>
<string name="hello_blank_fragment">soon ™</string>
<string name="string_new_line" translatable="false">%1$s\n</string>
</resources>

4
app/src/main/res/xml/backup_descriptor.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Exclude specific shared preferences that contain GCM registration Id -->
</full-backup-content>

2
gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close