mirror of
https://github.com/etesync/android
synced 2025-02-02 02:41:31 +00:00
LocalEtebaseCache: make sure we always return the same item.
This commit is contained in:
parent
eeb93f523d
commit
79b650da38
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import com.etebase.client.*
|
||||
import com.etebase.client.Collection
|
||||
import java.io.File
|
||||
import java.util.HashMap
|
||||
|
||||
/*
|
||||
File structure:
|
||||
@ -83,8 +84,19 @@ class EtebaseLocalCache private constructor(context: Context, username: String)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val localCacheCache: HashMap<String, EtebaseLocalCache> = HashMap()
|
||||
|
||||
fun getInstance(context: Context, username: String): EtebaseLocalCache {
|
||||
return EtebaseLocalCache(context, username)
|
||||
synchronized(localCacheCache) {
|
||||
val cached = localCacheCache.get(username)
|
||||
if (cached != null) {
|
||||
return cached
|
||||
} else {
|
||||
val ret = EtebaseLocalCache(context, username)
|
||||
localCacheCache.set(username, ret)
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getEtebase(context: Context, settings: AccountSettings): Account {
|
||||
|
Loading…
Reference in New Issue
Block a user