Panagiotis Triantafyllou

db fixes

......@@ -258,8 +258,8 @@
<!-- </intent-filter>-->
<!-- </receiver>-->
<!-- <provider-->
<!-- android:name=".utils.WarplyProvider"-->
<!-- android:authorities="ly.warp.sdk.utils.WarplyProvider" />-->
<provider
android:name=".utils.WarplyProvider"
android:authorities="ly.warp.sdk.utils.WarplyProvider" />
</application>
</manifest>
\ No newline at end of file
......
......@@ -2,6 +2,7 @@ package ly.warp.sdk.utils;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
......@@ -9,6 +10,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
import ly.warp.sdk.db.WarplyDBHelper;
/**
* Created by Panagiotis Triantafyllou on 05/Αυγ/2022.
*/
......@@ -16,7 +19,14 @@ public class WarplyProvider extends ContentProvider {
@Override
public boolean onCreate() {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// Initialize the database helper
Context context = getContext();
if (context != null) {
WarplyDBHelper dbHelper = WarplyDBHelper.getInstance(context);
dbHelper.initialize(); // This will initialize the database connection on a background thread
}
// ViewPump.init(ViewPump.builder()
// .addInterceptor(new CalligraphyInterceptor(
// new CalligraphyConfig.Builder()
......@@ -34,6 +44,18 @@ public class WarplyProvider extends ContentProvider {
return true;
}
@Override
public void shutdown() {
// Get the database helper instance and shut it down
Context context = getContext();
if (context != null) {
WarplyDBHelper dbHelper = WarplyDBHelper.getInstance(context);
dbHelper.shutdown();
}
super.shutdown();
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] strings, @Nullable String s, @Nullable String[] strings1, @Nullable String s1) {
......