added a splah screen
This commit is contained in:
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* ProjectLaogai
|
||||
*
|
||||
* Copyright 2018 <seil0@mosad.xyz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.mosad.seil0.projectlaogai.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import org.jetbrains.anko.doAsync
|
||||
import org.jetbrains.anko.uiThread
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.MensaParser
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MenuCardView
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* The mensa controller class
|
||||
* contains all needed parts to display and the mensa detail screen
|
||||
*/
|
||||
class MensaFragment : Fragment() {
|
||||
|
||||
private lateinit var linLayoutMensaFragment: LinearLayout
|
||||
private lateinit var weekMenus: ArrayList<Meal>
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
val view: View = inflater.inflate(R.layout.fragment_mensa, container, false)
|
||||
|
||||
linLayoutMensaFragment = view.findViewById(R.id.linLayout_MensaFragment)
|
||||
|
||||
addCurrentWeek()
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
private fun addCurrentWeek() {
|
||||
|
||||
doAsync {
|
||||
|
||||
uiThread {
|
||||
|
||||
for(day in Calendar.getInstance().get(Calendar.DAY_OF_WEEK)..7) {
|
||||
|
||||
val strDay: String = when(day) {
|
||||
Calendar.MONDAY -> "Mon"
|
||||
Calendar.TUESDAY -> "Die"
|
||||
Calendar.WEDNESDAY -> "Mit"
|
||||
Calendar.THURSDAY -> "Don"
|
||||
Calendar.FRIDAY -> "Fre"
|
||||
Calendar.SATURDAY -> "Sam"
|
||||
else -> "TODAY" //TODO
|
||||
}
|
||||
|
||||
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
||||
var add = false
|
||||
|
||||
for (meal in weekMenus) {
|
||||
//println("Day: " + meal.day)
|
||||
if (meal.day.contains(strDay)) {
|
||||
|
||||
val menuViewMenu = MenuCardView(context!!, null)
|
||||
menuViewMenu.setMenuHeading(meal.heading)
|
||||
|
||||
for(part in meal.parts) {
|
||||
menuViewMenu.getTxtViewMenu().append(part)
|
||||
}
|
||||
|
||||
cardViewMensaDay.setDayHeading(meal.day) //TODO move this out of the first for loop, performance!!
|
||||
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu)
|
||||
add = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(add)
|
||||
linLayoutMensaFragment.addView(cardViewMensaDay)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun addDay(day: Int) {
|
||||
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
||||
|
||||
doAsync {
|
||||
val mensaParser = MensaParser()
|
||||
val dayMenus: ArrayList<Meal> = mensaParser.getMensaMenuDay(mensaParser.getMensaMenu(), day)
|
||||
|
||||
uiThread {
|
||||
|
||||
for (meal in dayMenus) {
|
||||
val menuViewMenu = MenuCardView(context!!, null)
|
||||
menuViewMenu.setMenuHeading(meal.heading)
|
||||
|
||||
for(part in meal.parts) {
|
||||
menuViewMenu.getTxtViewMenu().append(part)
|
||||
}
|
||||
|
||||
cardViewMensaDay.setDayHeading(meal.day) //TODO move this out of the first for loop, performance!!
|
||||
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu)
|
||||
}
|
||||
|
||||
linLayoutMensaFragment.addView(cardViewMensaDay)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setWeekMenu(weekMenus: ArrayList<Meal>){
|
||||
this.weekMenus = weekMenus
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user