Created
July 4, 2019 21:53
-
-
Save leocruzdev/31499428bd9a8a361a9213e69cba2387 to your computer and use it in GitHub Desktop.
repository
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
package com.dacruzl2.gitmvpkoin.data.source | |
import com.dacruzl2.gitmvpkoin.data.Root | |
class GithubRepository( | |
private val remoteDataSource: GithubDataSource, | |
private val localDataSource: GithubDataSource | |
) : GithubDataSource { | |
internal var cachedItemList: List<Root>? = null | |
/** | |
* Marks the cache as invalid, to force an update the next time data is requested. This variable | |
* has package local visibility so it can be accessed from tests. | |
*/ | |
internal var cacheIsDirty = false | |
override suspend fun getIssues(onSuccess: (issues: List<Root>) -> Unit) { | |
} | |
override suspend fun saveIssues(issues: List<Root>) { | |
} | |
} | |
/* withContext(Dispatchers.IO) { | |
try { | |
val request = remoteDataSource.getIssues().await() | |
if (request.isSuccessful) { | |
withContext(Dispatchers.Main) { | |
val issuesList = request.body()!! | |
onSuccess(issuesList) | |
withContext(Dispatchers.IO){ | |
Log.d("DB", "initSaveDB") | |
localDataSource.saveIssues(issuesList) | |
Log.d("DB", "DBsaved: $issuesList") | |
} | |
} | |
} else { | |
} | |
} catch (t: Exception) { | |
} | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment