package com.mytatvarnsdk

import android.content.Context
import android.util.Log
import androidx.multidex.MultiDex
import cgmblelib.base.BApplication
import cgmblelib.base.BSharedPreferences
import cgmblelib.ble.BleService
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader

class MainApplication : BApplication(), ReactApplication {

  override fun attachBaseContext(base: Context?) {
    super.attachBaseContext(base)
    MultiDex.install(base)
  }

  private val mReactNativeHost = object : DefaultReactNativeHost(this) {
    override fun getUseDeveloperSupport(): Boolean {
      return BuildConfig.DEBUG
    }

    override fun getPackages(): MutableList<ReactPackage> {
      val packages = ArrayList<ReactPackage>()
      packages.add(CgmTrackyLibPackage())
      return packages
    }

    override fun getJSMainModuleName(): String {
      return "index"
    }
  }

  override fun onCreate() {
    super.onCreate()
    Log.d("MainApplication", "MainApplication onCreate called")
    SoLoader.init(this, false)
//    BleService.startService(this)
//    BSharedPreferences.init(this)
  }

  override fun getReactNativeHost(): ReactNativeHost {
    return mReactNativeHost
  }
}
