move the holiday ics files back in assets folder

This commit is contained in:
tibbi 2017-05-16 22:10:35 +02:00
parent 91ee576440
commit 4404ebb5d9
33 changed files with 42 additions and 37 deletions

View File

@ -191,6 +191,9 @@ class MainActivity : SimpleActivity(), NavigationListener {
private fun addHolidays() {
val items = getHolidayRadioItems()
RadioGroupDialog(this, items, -1) {
importEventsDialog(it as String)
}
}
private fun updateView(view: Int) {
@ -517,38 +520,38 @@ class MainActivity : SimpleActivity(), NavigationListener {
private fun getHolidayRadioItems(): ArrayList<RadioItem> {
val items = ArrayList<RadioItem>()
LinkedHashMap<String, Int>().apply {
put("Algeria", R.raw.algeria)
put("België", R.raw.belgium)
put("Bolivia", R.raw.bolivia)
put("Brasil", R.raw.brazil)
put("Canada", R.raw.canada)
put("Česká republika", R.raw.czech)
put("Deutschland", R.raw.germany)
put("Eesti", R.raw.estonia)
put("España", R.raw.spain)
put("Éire", R.raw.ireland)
put("France", R.raw.france)
put("Hanguk", R.raw.southkorea)
put("Hellas", R.raw.greece)
put("India", R.raw.india)
put("Ísland", R.raw.iceland)
put("Italia", R.raw.italy)
put("Magyarország", R.raw.hungary)
put("Nederland", R.raw.netherlands)
put("Nihon", R.raw.japan)
put("Norge", R.raw.norway)
put("Pākistān", R.raw.pakistan)
put("Polska", R.raw.poland)
put("Portugal", R.raw.portugal)
put("Rossiya", R.raw.russia)
put("Schweiz", R.raw.switzerland)
put("Slovenija", R.raw.slovenia)
put("Slovensko", R.raw.slovakia)
put("Suomi", R.raw.finland)
put("Sverige", R.raw.sweden)
put("United Kingdom", R.raw.unitedkingdom)
put("United States", R.raw.unitedstates)
LinkedHashMap<String, String>().apply {
put("Algeria", "algeria.ics")
put("België", "belgium.ics")
put("Bolivia", "bolivia.ics")
put("Brasil", "brazil.ics")
put("Canada", "canada.ics")
put("Česká republika", "czech.ics")
put("Deutschland", "germany.ics")
put("Eesti", "estonia.ics")
put("España", "spain.ics")
put("Éire", "ireland.ics")
put("France", "france.ics")
put("Hanguk", "southkorea.ics")
put("Hellas", "greece.ics")
put("India", "india.ics")
put("Ísland", "iceland.ics")
put("Italia", "italy.ics")
put("Magyarország", "hungary.ics")
put("Nederland", "netherlands.ics")
put("Nihon", "japan.ics")
put("Norge", "norway.ics")
put("Pākistān", "pakistan.ics")
put("Polska", "poland.ics")
put("Portugal", "portugal.ics")
put("Rossiya", "russia.ics")
put("Schweiz", "switzerland.ics")
put("Slovenija", "slovenia.ics")
put("Slovensko", "slovakia.ics")
put("Suomi", "finland.ics")
put("Sverige", "sweden.ics")
put("United Kingdom", "unitedkingdom.ics")
put("United States", "unitedstates.ics")
var i = 0
for ((country, file) in this) {
@ -556,10 +559,6 @@ class MainActivity : SimpleActivity(), NavigationListener {
}
}
RadioGroupDialog(this, items, -1) {
}
return items
}

View File

@ -41,7 +41,13 @@ class IcsImporter {
val importIDs = context.dbHelper.getImportIds()
var prevLine = ""
File(path).inputStream().bufferedReader().use {
val inputStream = if (path.contains("/")) {
File(path).inputStream()
} else {
context.assets.open(path)
}
inputStream.bufferedReader().use {
while (true) {
var line = it.readLine() ?: break
if (line.trim().isEmpty())