Skip to content

Instantly share code, notes, and snippets.

@MuhammadZohair
Created January 29, 2024 21:45
Show Gist options
  • Save MuhammadZohair/ebeff6f62f6921cff19525a4112ab1ed to your computer and use it in GitHub Desktop.
Save MuhammadZohair/ebeff6f62f6921cff19525a4112ab1ed to your computer and use it in GitHub Desktop.
package io.senlab.cosmo.data.providers
import android.content.ContentResolver
import android.content.Context
import android.net.Uri
import io.senlab.cosmo.utils.toBundle
class CosmoProviderManager(context: Context) {
private val contentResolver: ContentResolver = context.contentResolver
fun insertEventLog(loggerDto: LoggerDto): ProviderResult {
val resultBundle = contentResolver.call(
CONTENT_URI,
METHOD_TYPE_INSERT,
null,
loggerDto.toBundle()
)
val providerResult = ProviderResult()
providerResult.status = resultBundle?.getString(KEY_RESPONSE_STATUS)
providerResult.message = resultBundle?.getString(KEY_RESPONSE_MESSAGE)
return providerResult
}
private companion object {
private const val URL_Table =
"content://com.cosmotogether.cosmo_logger.data.providers.CosmoEventProvider"
val CONTENT_URI: Uri = Uri.parse(URL_Table)
const val METHOD_TYPE_INSERT = "INSERT"
const val KEY_RESPONSE_STATUS = "STATUS"
const val KEY_RESPONSE_MESSAGE: String = "MESSAGE"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment