package com.gem.media;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.gem.media.splash.base.utils.ALog;
import androidx.core.util.Consumer;
import androidx.work.Configuration;
import androidx.work.WorkManager;

public class AProvider extends ContentProvider {
    @Override
    public boolean onCreate() {

        try {
            Context context = getContext();
            if (context != null) {
                Consumer<Throwable> initializationExceptionHandler = throwable ->
                        ALog.e("AProvider", "WorkManager initialization failed", throwable);

                Consumer<Throwable> schedulingExceptionHandler = throwable ->
                        Log.e("AProvider", "WorkManager scheduling failed", throwable);

                Configuration configuration = new Configuration.Builder()
                        .setInitializationExceptionHandler(initializationExceptionHandler)
                        .setSchedulingExceptionHandler(schedulingExceptionHandler)
                        .build();

                WorkManager.initialize(
                        context.getApplicationContext(),
                        configuration
                );
            }
        } catch (IllegalStateException e) {
            ALog.w("AProvider", "WorkManager already initialized or unavailable", e);
        } catch (Throwable throwable) {
            ALog.e("AProvider", "Unable to install guarded WorkManager configuration", throwable);
        }

        return false;
    }

    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
        return null;
    }

    @Nullable
    @Override
    public String getType(@NonNull Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
        return null;
    }

    @Override
    public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }

    @Override
    public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }
}
