package com.kdanmobile.reader

import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri
import org.koin.android.ext.android.startKoin

/**
 * This ContentProvider is used for initializing some stuff.
 */
class InitializerContentProvider : ContentProvider() {

    override fun onCreate(): Boolean {
        val context = context.applicationContext
        startKoin(context, listOf(KoinModule.m))
        return true
    }

    override fun delete(uri: Uri, selection: String?, selectionArgs: Array<String>?): Int {
        unsupported()
    }

    override fun getType(uri: Uri): String? {
        unsupported()
    }

    override fun insert(uri: Uri, values: ContentValues): Uri? {
        unsupported()
    }

    override fun query(uri: Uri, projection: Array<String>?, selection: String?, selectionArgs: Array<String>?, sortOrder: String?): Cursor? {
        unsupported()
    }

    override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<String>?): Int {
        unsupported()
    }

    private fun unsupported(): Nothing {
        throw UnsupportedOperationException()
    }
}
