Removed redundant dependencies for WorkManager and EasyPreferences, TaskDescription colour changed to colorAccent

This commit is contained in:
Deniz Düzgören
2019-07-06 14:18:59 +02:00
parent d93407e98f
commit 3166fadf7f
15 changed files with 137 additions and 194 deletions
+3 -4
View File
@@ -9,8 +9,8 @@ android {
applicationId "com.denizd.substitutionplan" applicationId "com.denizd.substitutionplan"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode 15 versionCode 16
versionName "2.0.3" versionName "2.0.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@@ -38,7 +38,6 @@ dependencies {
// implementation 'androidx.core:core-ktx:1.0.2' // implementation 'androidx.core:core-ktx:1.0.2'
implementation 'com.jaredrummler:android-device-names:1.1.8' implementation 'com.jaredrummler:android-device-names:1.1.8'
implementation 'com.github.mukeshsolanki:easypreferences:1.0.6'
def lifecycle_version = "2.0.0" def lifecycle_version = "2.0.0"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
@@ -50,7 +49,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.work:work-runtime-ktx:2.0.1" // implementation "androidx.work:work-runtime-ktx:2.0.1"
} }
repositories { repositories {
@@ -19,7 +19,6 @@ import android.widget.RemoteViews
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.madapps.prefrences.EasyPrefrences
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.select.Elements import org.jsoup.select.Elements
@@ -60,8 +59,8 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
private val edit = prefs.edit() as SharedPreferences.Editor private val edit = prefs.edit() as SharedPreferences.Editor
private lateinit var pullToRefresh: SwipeRefreshLayout private lateinit var pullToRefresh: SwipeRefreshLayout
private lateinit var progressBar: ProgressBar private lateinit var progressBar: ProgressBar
private val easyPrefs = EasyPrefrences(mContext)
private val substViewModel = SubstViewModel(mApplication) private val substViewModel = SubstViewModel(mApplication)
private val foodViewModel = FoodViewModel(mApplication)
private val oldDateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz" private val oldDateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
private val newDateFormat = "yyyy-MM-dd, HH:mm:ss" private val newDateFormat = "yyyy-MM-dd, HH:mm:ss"
private var sdf = SimpleDateFormat(oldDateFormat) private var sdf = SimpleDateFormat(oldDateFormat)
@@ -85,6 +84,8 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
} }
var foodInt = 0 var foodInt = 0
var priority = 0
foodViewModel.deleteAll()
while (foodInt in 0 until foodElements.size) { while (foodInt in 0 until foodElements.size) {
try { // what a mess this is! try { // what a mess this is!
if (foodElements[foodInt].text().contains("Montag") || if (foodElements[foodInt].text().contains("Montag") ||
@@ -99,9 +100,9 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
foodElements[foodInt + 3].text().contains("Donnerstag") || foodElements[foodInt + 3].text().contains("Donnerstag") ||
foodElements[foodInt + 3].text().contains("Freitag") || foodElements[foodInt + 3].text().contains("Freitag") ||
foodElements[foodInt + 3].text().contains("von")) { foodElements[foodInt + 3].text().contains("von")) {
foodList.add(foodElements[foodInt].text() + "\n" foodViewModel.insert(Food(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text() + "\n" + foodElements[foodInt + 1].text() + "\n"
+ foodElements[foodInt + 2].text()) + foodElements[foodInt + 2].text(), priority))
foodInt += 2 foodInt += 2
} else if (foodElements[foodInt + 2].text().contains("Montag") || } else if (foodElements[foodInt + 2].text().contains("Montag") ||
foodElements[foodInt + 2].text().contains("Dienstag") || foodElements[foodInt + 2].text().contains("Dienstag") ||
@@ -109,27 +110,28 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
foodElements[foodInt + 2].text().contains("Donnerstag") || foodElements[foodInt + 2].text().contains("Donnerstag") ||
foodElements[foodInt + 2].text().contains("Freitag") || foodElements[foodInt + 2].text().contains("Freitag") ||
foodElements[foodInt + 2].text().contains("von")) { foodElements[foodInt + 2].text().contains("von")) {
foodList.add(foodElements[foodInt].text() + "\n" foodViewModel.insert(Food(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text()) + foodElements[foodInt + 1].text(), priority))
foodInt += 1 foodInt += 1
} }
} else { } else {
foodList.add(foodElements[foodInt].text()) foodViewModel.insert(Food(foodElements[foodInt].text(), priority))
} }
} catch (e: IndexOutOfBoundsException) { } catch (e: IndexOutOfBoundsException) {
try { try {
foodList.add(foodElements[foodInt].text() + "\n" foodViewModel.insert(Food(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text() + "\n" + foodElements[foodInt + 1].text() + "\n"
+ foodElements[foodInt + 2].text()) + foodElements[foodInt + 2].text(), priority))
break break
} catch (e1: IndexOutOfBoundsException) { } catch (e1: IndexOutOfBoundsException) {
foodList.add(foodElements[foodInt].text() + "\n" foodViewModel.insert(Food(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text()) + foodElements[foodInt + 1].text(), priority))
break break
} }
} }
foodInt++ foodInt++
priority++
mView?.let { mView?.let {
progressBar.progress = foodInt progressBar.progress = foodInt
} }
@@ -146,8 +148,6 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
} }
}) })
} }
easyPrefs.putListString("foodListPrefs", foodList)
} }
if (plan) { if (plan) {
@@ -273,7 +273,8 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
manager.notify(1, notification) manager.notify(1, notification)
} }
} }
}
if (plan || menu) {
mView?.let { v: View -> mView?.let { v: View ->
handler.postDelayed({ progressBar.startAnimation(fadeOut) }, 200) handler.postDelayed({ progressBar.startAnimation(fadeOut) }, 200)
fadeOut.setAnimationListener(object: Animation.AnimationListener { fadeOut.setAnimationListener(object: Animation.AnimationListener {
@@ -284,6 +285,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
} }
}) })
pullToRefresh.isRefreshing = false pullToRefresh.isRefreshing = false
if (plan) {
val snackbarview = v.findViewById<View>(R.id.coordination) val snackbarview = v.findViewById<View>(R.id.coordination)
sdf.applyPattern(newDateFormat) sdf.applyPattern(newDateFormat)
val sb = StringBuilder() val sb = StringBuilder()
@@ -291,7 +293,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
Snackbar.make(snackbarview, lastupdated, Snackbar.LENGTH_LONG) Snackbar.make(snackbarview, lastupdated, Snackbar.LENGTH_LONG)
.setAction("Action", null).show() .setAction("Action", null).show()
} }
}
} }
} catch (e: Exception) { } catch (e: Exception) {
@@ -1,3 +1,7 @@
package com.denizd.substitutionplan package com.denizd.substitutionplan
class Food(val food: String) import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "food_table")
class Food(val food: String, @PrimaryKey val priority: Int)
@@ -2,25 +2,15 @@ package com.denizd.substitutionplan
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.os.AsyncTask
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.preference.PreferenceManager import android.preference.PreferenceManager
import android.view.View import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.ProgressBar
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar
import com.madapps.prefrences.EasyPrefrences
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.select.Elements
import java.lang.IndexOutOfBoundsException
class FoodFragment : Fragment(R.layout.food_layout) { class FoodFragment : Fragment(R.layout.food_layout) {
@@ -29,22 +19,19 @@ class FoodFragment : Fragment(R.layout.food_layout) {
private lateinit var mContext: Context private lateinit var mContext: Context
private lateinit var prefs: SharedPreferences private lateinit var prefs: SharedPreferences
private lateinit var edit: SharedPreferences.Editor private lateinit var edit: SharedPreferences.Editor
private lateinit var easyPrefs: EasyPrefrences private lateinit var recyclerView: RecyclerView
lateinit var foodListPopulation: ArrayList<String> private lateinit var foodViewModel: FoodViewModel
lateinit var recyclerView: RecyclerView
override fun onAttach(context: Context) { override fun onAttach(context: Context) {
super.onAttach(context) super.onAttach(context)
mContext = context mContext = context
prefs = PreferenceManager.getDefaultSharedPreferences(mContext) prefs = PreferenceManager.getDefaultSharedPreferences(mContext)
edit = prefs.edit() edit = prefs.edit()
easyPrefs = EasyPrefrences(mContext)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val pullToRefresh = view.findViewById<SwipeRefreshLayout>(R.id.pullToRefresh) val pullToRefresh = view.findViewById<SwipeRefreshLayout>(R.id.pullToRefresh)
foodListPopulation = ArrayList(easyPrefs.getListString("foodListPrefs"))
try { try {
recyclerView = view.findViewById(R.id.linear_food) recyclerView = view.findViewById(R.id.linear_food)
@@ -56,144 +43,26 @@ class FoodFragment : Fragment(R.layout.food_layout) {
recyclerView.removeAllViews() recyclerView.removeAllViews()
} catch (ignored: NullPointerException) {} } catch (ignored: NullPointerException) {}
for (i in 0 until foodListPopulation.size) {
foodArrayList.add(Food(foodListPopulation[i]))
mAdapter.setFood(foodArrayList)
recyclerView.scheduleLayoutAnimation()
}
} catch (ignored: NullPointerException) {} } catch (ignored: NullPointerException) {}
foodViewModel = ViewModelProviders.of(this).get(FoodViewModel::class.java)
foodViewModel.allFoods?.observe(this, Observer<List<Food>> { foodList ->
foodArrayList.clear()
for (item in foodList) {
foodArrayList.add(item)
}
recyclerView.scheduleLayoutAnimation()
mAdapter.setFood(foodArrayList)
})
if (prefs.getBoolean("autoRefresh", false)) { if (prefs.getBoolean("autoRefresh", false)) {
pullToRefresh.isRefreshing = true pullToRefresh.isRefreshing = true
RepopulateFood(mContext, recyclerView, easyPrefs, mAdapter, foodArrayList, pullToRefresh, view.rootView).execute() DataFetcher(false, true, false, mContext, activity!!.application, view.rootView).execute()
} }
pullToRefresh.setOnRefreshListener { pullToRefresh.setOnRefreshListener {
pullToRefresh.isRefreshing = true pullToRefresh.isRefreshing = true
RepopulateFood(mContext, recyclerView, easyPrefs, mAdapter, foodArrayList, pullToRefresh, view.rootView).execute() DataFetcher(false, true, false, mContext, activity!!.application, view.rootView).execute()
}
/* bad approach - I should be using the DataFetcher.kt class, but that requires figuring out how to access the RecyclerView and its adapter from
* another class - the best approach would be to store the data in the database instead of using EasyPreferences, however, I'm not doing that now */
}
class RepopulateFood(context: Context, recyclerView: RecyclerView, easyPrefs: EasyPrefrences,
adapter: FoodAdapter, foodArrayList: ArrayList<Food>,
swipeRefreshLayout: SwipeRefreshLayout, rootView: View) : AsyncTask<Void, Void, Void>() {
private val mContext = context
private val mRecyclerView = recyclerView
private val mEasyPrefs = easyPrefs
private val mAdapter = adapter
private val mFoodArrayList = foodArrayList
private var foodList = ArrayList<String>()
private lateinit var foodElements: Elements
private lateinit var docFood: Document
private val pullToRefresh = swipeRefreshLayout
private lateinit var progressBar: ProgressBar
val mRootView = rootView
private val fadeOut = AnimationUtils.loadAnimation(context, R.anim.fade_out)
private val handler = Handler(Looper.getMainLooper())
private var exceptionOccurred = false
override fun doInBackground(vararg params: Void?): Void? {
try {
docFood = Jsoup.connect("https://djd4rkn355.github.io/food.html").get()
foodElements = docFood.select("th")
progressBar = mRootView.findViewById(R.id.progressBar)
progressBar.max = foodElements.size
var foodInt = 0
while (foodInt in 0 until foodElements.size) {
try { // what a mess this is!
if (foodElements[foodInt].text().contains("Montag") ||
foodElements[foodInt].text().contains("Dienstag") ||
foodElements[foodInt].text().contains("Mittwoch") ||
foodElements[foodInt].text().contains("Donnerstag") ||
foodElements[foodInt].text().contains("Freitag")) {
if (foodElements[foodInt + 3].text().contains("Montag") ||
foodElements[foodInt + 3].text().contains("Dienstag") ||
foodElements[foodInt + 3].text().contains("Mittwoch") ||
foodElements[foodInt + 3].text().contains("Donnerstag") ||
foodElements[foodInt + 3].text().contains("Freitag") ||
foodElements[foodInt + 3].text().contains("von")) {
foodList.add(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text() + "\n"
+ foodElements[foodInt + 2].text())
foodInt += 2
} else if (foodElements[foodInt + 2].text().contains("Montag") ||
foodElements[foodInt + 2].text().contains("Dienstag") ||
foodElements[foodInt + 2].text().contains("Mittwoch") ||
foodElements[foodInt + 2].text().contains("Donnerstag") ||
foodElements[foodInt + 2].text().contains("Freitag") ||
foodElements[foodInt + 2].text().contains("von")) {
foodList.add(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text())
foodInt += 1
}
} else {
foodList.add(foodElements[foodInt].text())
}
} catch (e: IndexOutOfBoundsException) {
try {
foodList.add(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text() + "\n"
+ foodElements[foodInt + 2].text())
break
} catch (e1: IndexOutOfBoundsException) {
foodList.add(foodElements[foodInt].text() + "\n"
+ foodElements[foodInt + 1].text())
break
}
}
foodInt++
progressBar.progress = foodInt
}
progressBar.progress = 100
mEasyPrefs.putListString("foodListPrefs", foodList)
} catch (e: Exception) { exceptionOccurred = true }
return null
}
override fun onPostExecute(result: Void?) {
super.onPostExecute(result)
if (!exceptionOccurred) {
try {
mRecyclerView.removeAllViews()
mFoodArrayList.removeAll(mFoodArrayList)
} catch (ignored: NullPointerException) {}
val foodListPopulation = ArrayList(mEasyPrefs.getListString("foodListPrefs"))
for (i in 0 until foodListPopulation.size) {
mFoodArrayList.add(Food(foodListPopulation[i]))
mAdapter.setFood(mFoodArrayList)
}
mRecyclerView.scheduleLayoutAnimation()
pullToRefresh.isRefreshing = false
handler.postDelayed({ progressBar.startAnimation(fadeOut) }, 200)
fadeOut.setAnimationListener(object: Animation.AnimationListener {
override fun onAnimationStart(arg0: Animation) {}
override fun onAnimationRepeat(arg0: Animation) {}
override fun onAnimationEnd(arg0: Animation) {
progressBar.progress = 0
}
})
} else {
pullToRefresh.isRefreshing = false
val snackbarview = mRootView.findViewById<View>(R.id.coordination)
Snackbar.make(snackbarview, mContext.getText(R.string.nointernet), Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
} }
} }
} }
@@ -0,0 +1,42 @@
package com.denizd.substitutionplan
import android.app.Application
import android.os.AsyncTask
import androidx.lifecycle.LiveData
public class FoodRepository(application: Application) {
private val substDao: SubstDao?
val allFoods: LiveData<List<Food>>?
init {
val database = SubstDatabase.getFoodInstance(application)
substDao = database?.substDao()
allFoods = substDao?.allFoods
}
fun insert(food: Food) {
InsertAsync(substDao).execute(food)
}
fun deleteAll() {
DeleteAllAsync(substDao).execute()
}
class InsertAsync(substDao: SubstDao?) : AsyncTask<Food, Void, Void>() {
private val mSubstDao = substDao
override fun doInBackground(vararg foods: Food): Void? {
mSubstDao?.insertFood(foods[0])
return null
}
}
class DeleteAllAsync(substDao: SubstDao?) : AsyncTask<Void, Void, Void>() {
private val mSubstDao = substDao
override fun doInBackground(vararg voids: Void): Void? {
mSubstDao?.deleteAllFoods()
return null
}
}
}
@@ -0,0 +1,23 @@
package com.denizd.substitutionplan
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
public class FoodViewModel(application: Application) : AndroidViewModel(application) {
private val repository: FoodRepository = FoodRepository(application)
val allFoods: LiveData<List<Food>>?
init {
allFoods = repository.allFoods
}
fun insert(food: Food) {
repository.insert(food)
}
fun deleteAll() {
repository.deleteAll()
}
}
@@ -109,10 +109,6 @@ class Main : AppCompatActivity(R.layout.activity_main) {
// } // TODO theming based on system settings for Android Q // } // TODO theming based on system settings for Android Q
} }
val bm = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
val taskDesc = ActivityManager.TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.background))
setTaskDescription(taskDesc)
if (!prefs.getBoolean("showinfotab", true)) { if (!prefs.getBoolean("showinfotab", true)) {
bottomNav.menu.removeItem(R.id.openinfopanel) bottomNav.menu.removeItem(R.id.openinfopanel)
} }
@@ -18,8 +18,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
class PlanFragment : Fragment(R.layout.plan) { class PlanFragment : Fragment(R.layout.plan) {
private lateinit var recyclerView: RecyclerView private lateinit var recyclerView: RecyclerView
private lateinit var mAdapter: CardAdapter private lateinit var mAdapter: CardAdapter
@@ -197,7 +197,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
} }
R.id.btnLicences -> { R.id.btnLicences -> {
createDialog("Licences", "Libraries:\n • Android Device Names © 2015 Jared Rummler, licensed under the Apache Licence, Version 2.0" + createDialog("Licences", "Libraries:\n • Android Device Names © 2015 Jared Rummler, licensed under the Apache Licence, Version 2.0" +
"\n • EasyPreferences © 2018 Mukesh Solanki, licensed under the MIT Licence" +
"\n • jsoup HTML parser © 2009-2018 Jonathan Hedley, licensed under the open source MIT Licence" + "\n • jsoup HTML parser © 2009-2018 Jonathan Hedley, licensed under the open source MIT Licence" +
"\n\nFont:\n • Manrope © 2018-2019 Michael Sharanda, licensed under the SIL Open Font Licence 1.1" + "\n\nFont:\n • Manrope © 2018-2019 Michael Sharanda, licensed under the SIL Open Font Licence 1.1" +
"\n\nIcons:\n • bqlqn\n • fjstudio\n • Freepik\n • Smashicons\n • © 2013-2019 Freepik Company S.L., licensed under Creative Commons BY 3.0" + "\n\nIcons:\n • bqlqn\n • fjstudio\n • Freepik\n • Smashicons\n • © 2013-2019 Freepik Company S.L., licensed under Creative Commons BY 3.0" +
@@ -387,7 +386,7 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
} }
"2018-04-20" -> { "2018-04-20" -> {
try { try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=Jc2xfYuLWgE")) val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=Jc2xfYuLWgE")) // Freak
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setPackage("com.google.android.youtube") intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setPackage("com.google.android.youtube")
startActivity(intent) startActivity(intent)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
@@ -20,4 +20,13 @@ public interface SubstDao {
@Query("DELETE FROM subst_table") @Query("DELETE FROM subst_table")
fun deleteAllSubst() fun deleteAllSubst()
@get:Query("SELECT * FROM food_table ORDER BY priority ASC")
val allFoods: LiveData<List<Food>>
@Insert
fun insertFood(food: Food)
@Query("DELETE FROM food_table")
fun deleteAllFoods()
} }
@@ -5,7 +5,7 @@ import androidx.room.Database
import androidx.room.Room import androidx.room.Room
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
@Database(entities = [Subst::class], version = 3, exportSchema = false) @Database(entities = [Subst::class, Food::class], version = 4, exportSchema = false)
public abstract class SubstDatabase : RoomDatabase() { public abstract class SubstDatabase : RoomDatabase() {
abstract fun substDao(): SubstDao abstract fun substDao(): SubstDao
@@ -26,5 +26,18 @@ public abstract class SubstDatabase : RoomDatabase() {
} }
return instance return instance
} }
fun getFoodInstance(context: Context): SubstDatabase? {
if (instance == null) {
synchronized (SubstDatabase::class) {
instance = Room.databaseBuilder(context.applicationContext,
SubstDatabase::class.java,
"food_database")
.fallbackToDestructiveMigration()
.build()
}
}
return instance
}
} }
} }
@@ -6,11 +6,10 @@ import androidx.lifecycle.LiveData
public class SubstViewModel(application: Application) : AndroidViewModel(application) { public class SubstViewModel(application: Application) : AndroidViewModel(application) {
private val repository: SubstRepository private val repository: SubstRepository = SubstRepository(application)
val allSubst: LiveData<List<Subst>>? val allSubst: LiveData<List<Subst>>?
init { init {
repository = SubstRepository(application)
allSubst = repository.allSubst allSubst = repository.allSubst
} }
-2
View File
@@ -111,10 +111,8 @@
<string name="courseWat">WAT</string> <string name="courseWat">WAT</string>
<string name="courseFor">Förderunterricht</string> <string name="courseFor">Förderunterricht</string>
<string name="courseWp">WP &amp; Methodenstunde</string> <string name="courseWp">WP &amp; Methodenstunde</string>
<string name="neoncolours">Neonfarben</string>
<string name="clearall">Alle löschen</string> <string name="clearall">Alle löschen</string>
<string name="allcolourscleared">Farben für alle Kurse wurden gelöscht</string> <string name="allcolourscleared">Farben für alle Kurse wurden gelöscht</string>
<string name="clearcolour">Farbe löschen</string>
<string name="chromecompatible">Kein Chrome-kompatibler Browser gefunden</string> <string name="chromecompatible">Kein Chrome-kompatibler Browser gefunden</string>
<string name="noyoutube">YouTube-App nicht gefunden</string> <string name="noyoutube">YouTube-App nicht gefunden</string>
<string name="swipeindependent">Unabhängig von Wischgeste</string> <string name="swipeindependent">Unabhängig von Wischgeste</string>
-3
View File
@@ -124,10 +124,7 @@
<string name="courseFor">Special Education</string> <string name="courseFor">Special Education</string>
<string name="courseWp">WP &amp; "Methodenstunde"</string> <string name="courseWp">WP &amp; "Methodenstunde"</string>
<string name="neoncolours">Neon colours</string>
<string name="clearall">Clear all</string> <string name="clearall">Clear all</string>
<string name="clearcolour">Clear colour</string>
<string name="allcolourscleared">Colours for all courses have been cleared</string> <string name="allcolourscleared">Colours for all courses have been cleared</string>
<string name="chromecompatible">No Chrome-compatible browser found</string> <string name="chromecompatible">No Chrome-compatible browser found</string>
-5
View File
@@ -25,11 +25,6 @@
<item name="android:colorEdgeEffect">@color/accent</item> <item name="android:colorEdgeEffect">@color/accent</item>
</style> </style>
<style name="AlertDialogCustomLight" parent="Theme.MaterialComponents.Light.Dialog.Alert">
<item name="android:background">#eeeeee</item>
<item name="android:textColorPrimary">#212121</item>
</style>
<style name="AlertDialog" parent="Theme.MaterialComponents.Light.Dialog.Alert"> <style name="AlertDialog" parent="Theme.MaterialComponents.Light.Dialog.Alert">
<item name="android:background">@color/lightbackground</item> <item name="android:background">@color/lightbackground</item>
<item name="android:textColorPrimary">@color/textcolor</item> <item name="android:textColorPrimary">@color/textcolor</item>