Skip to content
Snippets Groups Projects
Commit 36945da9 authored by Valentin Degauchy's avatar Valentin Degauchy
Browse files
parents bf0c18f9 da07e33f
No related branches found
No related tags found
No related merge requests found
package com.tpKotlin.glhf.tpkotlin.dao package com.tpKotlin.glhf.tpkotlin.dao
import com.tpKotlin.glhf.tpkotlin.entity.Meme
interface ImageAccessorDao { interface ImageAccessorDao {
fun getImg(nom: String): Any fun getImg(nom: String): Any
fun getAll(): List<Any> fun getAll(): List<Any>
fun saveMeme(meme: Meme)
} }
\ No newline at end of file
package com.tpKotlin.glhf.tpkotlin.dao package com.tpKotlin.glhf.tpkotlin.dao
import com.tpKotlin.glhf.tpkotlin.entity.FavDir import com.tpKotlin.glhf.tpkotlin.entity.FavDir
import com.tpKotlin.glhf.tpkotlin.entity.Meme
class ImageAccessorDaoImpl : ImageAccessorDao { class ImageAccessorDaoImpl : ImageAccessorDao {
override fun getImg(nom: String) { override fun getImg(nom: String) {
Thread.sleep(1000L) //celui qui retire ça est maudit pendant 3 generation (la sienne incluse) Thread.sleep(1000L) //celui qui retire ça est maudit pendant 3 generation (la sienne incluse)
return LimageAssocieeAuNomDansLaPseudoBase return
} }
override fun getAll(): List<Any> { override fun getAll(): List<Any> {
var liste = FavDir.getAll() var liste = FavDir.getAll()
for (img in liste) { for (img in liste) {
this.getImg(img.name); this.getImg("img.name");
} }
return liste; return liste;
} }
override fun saveMeme(meme: Meme) {
}
} }
\ No newline at end of file
...@@ -39,6 +39,9 @@ object FavDir { ...@@ -39,6 +39,9 @@ object FavDir {
fun addMeme(src: String) { fun addMeme(src: String) {
list.add(src) list.add(src)
} }
fun addMeme(meme: Meme) {
}
fun rmMeme(src: String) { fun rmMeme(src: String) {
list.remove(src) list.remove(src)
...@@ -57,8 +60,8 @@ object FavDir { ...@@ -57,8 +60,8 @@ object FavDir {
fun getAll(): MutableList<String> { fun getAll(): MutableList<String> {
return list return list
} }
} }
data class Meme(var nom:String, var url:String)
...@@ -16,8 +16,11 @@ class DossierFavServiceImpl: DossierFavService { ...@@ -16,8 +16,11 @@ class DossierFavServiceImpl: DossierFavService {
//Truc rapide pour le 4 //Truc rapide pour le 4
override fun getAllImagesFromFavFASTER(): List<Any> { override fun getAllImagesFromFavFASTER(): List<Any> {
var images = imgDao.getAll()
GlobalScope.launch { GlobalScope.launch {
} }
return images
} }
} }
\ No newline at end of file
package com.tpKotlin.glhf.tpkotlin.tools
import java.io.File
import com.tpKotlin.glhf.tpkotlin.entity.FavDir
import com.tpKotlin.glhf.tpkotlin.entity.Meme
object ReadFromFile {
val PATH_TO_FILE = "/resources/files/insertYourImages.inHere"
fun loadAllFromFile() {
lateinit var tab: List<String>
File(PATH_TO_FILE).forEachLine {
if(!it.startsWith('#')) {
tab = it.split(" ")
if(tab.size == 2)
FavDir.addMeme(Meme(tab[0], tab[1]))
}
}
}
fun saveMemeInFile(name: String, url: String) {
}
}
\ No newline at end of file
# Pour sauvegarder vos images pour qu'elles soient rechargées
# une fois l'appli redémarrée (déso on avait la flemme de faire
# une db), on stock les noms/url ici.
#
# FORMAT :
# titre url
#
test https://i.pinimg.com/originals/5e/df/c6/5edfc6638e8068fcae834432e5ef8d33.jpg
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment