-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
168 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 68 additions & 71 deletions
139
app/src/main/java/com/developer/kulloveth/expandablelistsamplewithroom/data/DataGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,101 @@ | ||
package com.developer.kulloveth.expandablelistsamplewithroom.data | ||
|
||
import com.developer.kulloveth.expandablelistsamplewithroom.data.model.ContinentEntity | ||
import com.developer.kulloveth.expandablelistsamplewithroom.data.model.Continents | ||
import com.developer.kulloveth.expandablelistsamplewithroom.data.model.Countrys | ||
import java.sql.Array | ||
|
||
class DataGenerator { | ||
|
||
companion object { | ||
fun getContinents(): List<Continents> { | ||
fun getContinents(): List<ContinentEntity> { | ||
return listOf( | ||
Continents("Europe", europeCountrys()), | ||
Continents("Africa", africaCountrys()), | ||
Continents("Asia", asiaCountrys()), | ||
Continents("North America", northAmericaCountrys()), | ||
Continents("South America", southAmericaCountrys()), | ||
Continents("Antarctica", antarcticaCountrys()), | ||
Continents("Oceania", oceaniaCountrys()), | ||
Continents("Australia", austrailaCountrys()) | ||
ContinentEntity("Europe", europeCountrys()), | ||
ContinentEntity("Africa", africaCountrys()), | ||
ContinentEntity("Asia", asiaCountrys()), | ||
ContinentEntity("North America", northAmericaCountrys()), | ||
ContinentEntity("South America", southAmericaCountrys()), | ||
ContinentEntity("Antarctica", antarcticaCountrys()), | ||
ContinentEntity("Oceania", oceaniaCountrys()) | ||
) | ||
} | ||
|
||
fun europeCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("Germany"), | ||
Countrys("Italy"), | ||
Countrys("France"), | ||
Countrys("United Kingdom"), | ||
Countrys("NertherLand") | ||
|
||
) | ||
} | ||
fun europeCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
coun.add(Countrys("Germany")) | ||
coun.add(Countrys("Italy")) | ||
coun.add(Countrys("France")) | ||
coun.add(Countrys("United Kingdom")) | ||
coun.add(Countrys("NertherLand")) | ||
return coun | ||
|
||
fun africaCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("South Africa"), | ||
Countrys("Nigeria"), | ||
Countrys("Kenya"), | ||
Countrys("Ghana"), | ||
Countrys("Ethiopia") | ||
|
||
) | ||
} | ||
|
||
fun asiaCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("Japan"), | ||
Countrys("India"), | ||
Countrys("Indonesi"), | ||
Countrys("China"), | ||
Countrys("Thailand") | ||
fun africaCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
coun.add(Countrys("South Africa")) | ||
coun.add(Countrys("Nigeria")) | ||
coun.add(Countrys("Kenya")) | ||
coun.add(Countrys("Ghana")) | ||
coun.add(Countrys("Ethiopia")) | ||
return coun | ||
} | ||
|
||
) | ||
fun asiaCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
coun.add(Countrys("Japan")) | ||
coun.add(Countrys("India")) | ||
coun.add(Countrys("Indonesi")) | ||
coun.add(Countrys("China")) | ||
coun.add(Countrys("Thailand")) | ||
return coun | ||
} | ||
|
||
fun northAmericaCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("United States"), | ||
Countrys("Mexico"), | ||
Countrys("Cuba"), | ||
Countrys("Green Land") | ||
fun northAmericaCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
|
||
) | ||
} | ||
coun.add(Countrys("United States")) | ||
coun.add(Countrys("Mexico")) | ||
coun.add(Countrys("Cuba")) | ||
coun.add(Countrys("Green Land")) | ||
return coun | ||
|
||
fun southAmericaCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("Brazil"), | ||
Countrys("Argentina"), | ||
Countrys("Columbia"), | ||
Countrys("Peru"), | ||
Countrys("Chile") | ||
|
||
) | ||
} | ||
|
||
fun antarcticaCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("Esperenza Base"), | ||
Countrys("Villa az Estrellaz"), | ||
Countrys("General Bernando O'Higging"), | ||
Countrys("Bellgrano II base"), | ||
Countrys("Carlini Base") | ||
fun southAmericaCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
coun.add(Countrys("Brazil")) | ||
coun.add(Countrys("Argentina")) | ||
coun.add(Countrys("Columbia")) | ||
coun.add(Countrys("Peru")) | ||
coun.add(Countrys("Chile")) | ||
|
||
) | ||
} | ||
return coun | ||
|
||
fun oceaniaCountrys(): List<Countrys> { | ||
return listOf( | ||
Countrys("Australia"), | ||
Countrys("Newzeland"), | ||
Countrys("Fiji"), | ||
Countrys("Samao"), | ||
Countrys("Federated States") | ||
|
||
) | ||
} | ||
|
||
fun austrailaCountrys(): List<Countrys> { | ||
return listOf( | ||
fun antarcticaCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
coun.add(Countrys("Esperenza Base")) | ||
coun.add(Countrys("Villa az Estrellaz")) | ||
coun.add(Countrys("General Bernando O'Higging")) | ||
coun.add(Countrys("Bellgrano II base")) | ||
coun.add(Countrys("Carlini Base")) | ||
return coun | ||
} | ||
|
||
) | ||
fun oceaniaCountrys(): ArrayList<Countrys> { | ||
val coun = ArrayList<Countrys>() | ||
coun.add(Countrys("Australia")) | ||
coun.add(Countrys("Newzeland")) | ||
coun.add(Countrys("Fiji")) | ||
coun.add(Countrys("Samao")) | ||
coun.add(Countrys("Federated States")) | ||
return coun | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
app/src/main/java/com/developer/kulloveth/expandablelistsamplewithroom/data/db/CountryDao.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ava/com/developer/kulloveth/expandablelistsamplewithroom/data/model/ContinentConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.developer.kulloveth.expandablelistsamplewithroom.data.model | ||
|
||
import androidx.room.TypeConverter | ||
import com.google.gson.Gson | ||
import com.google.gson.reflect.TypeToken | ||
import java.lang.reflect.Type | ||
import java.util.* | ||
|
||
|
||
class ContinentConverter { | ||
|
||
|
||
companion object { | ||
var gson: Gson = Gson() | ||
@TypeConverter @JvmStatic | ||
fun stringToSomeObjectList(data: String?): ArrayList<Countrys> { | ||
val listType: Type = | ||
object : TypeToken<ArrayList<Countrys?>?>() {}.getType() | ||
return gson.fromJson(data, listType) | ||
} | ||
|
||
@TypeConverter @JvmStatic | ||
fun someObjectListToString(someObjects: ArrayList<Countrys?>?): String { | ||
return gson.toJson(someObjects) | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/java/com/developer/kulloveth/expandablelistsamplewithroom/data/model/ContinentEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.developer.kulloveth.expandablelistsamplewithroom.data.model | ||
|
||
import android.os.Parcelable | ||
import androidx.room.* | ||
import com.thoughtbot.expandablerecyclerview.models.ExpandableGroup | ||
|
||
@Entity(tableName = "continent-table") | ||
@TypeConverters(ContinentConverter::class) | ||
data class ContinentEntity (@PrimaryKey @ColumnInfo(name = "continent") val continentName: String, val countrys: ArrayList<Countrys> | ||
) |
11 changes: 4 additions & 7 deletions
11
...c/main/java/com/developer/kulloveth/expandablelistsamplewithroom/data/model/Continents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
package com.developer.kulloveth.expandablelistsamplewithroom.data.model | ||
|
||
import android.os.Parcelable | ||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import androidx.room.* | ||
import com.thoughtbot.expandablerecyclerview.models.ExpandableGroup | ||
import kotlinx.android.parcel.Parcelize | ||
|
||
|
||
@Entity(tableName = "continent-table") | ||
|
||
data class Continents( | ||
@PrimaryKey @ColumnInfo(name = "continent") val ContinentName: String, | ||
@ColumnInfo(name = "countrys__layout") val countrys: List<Countrys> | ||
) : ExpandableGroup<Countrys>(ContinentName, countrys) | ||
val continentName: String, val countrys: List<Countrys> | ||
): ExpandableGroup<Countrys>(continentName, countrys) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.