using Android.App;
using Android.Runtime;
using Android.Util;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace NexusReader.Maui;

[Application]
public class MainApplication : MauiApplication
{
    private const string Tag = "NEXUS_MAUI";

	public MainApplication(IntPtr handle, JniHandleOwnership ownership)
		: base(handle, ownership)
	{
        Log.Debug(Tag, "MainApplication constructor called");
	}

	protected override MauiApp CreateMauiApp() 
    {
        Log.Debug(Tag, "CreateMauiApp starting...");
        try 
        {
            var app = MauiProgram.CreateMauiApp();
            Log.Debug(Tag, "CreateMauiApp successful");
            return app;
        }
        catch (Exception ex)
        {
            Log.Error(Tag, $"CreateMauiApp FAILED: {ex.Message}");
            Log.Error(Tag, ex.StackTrace);
            throw;
        }
    }
}
