From: fredboy Date: Fri, 24 May 2024 09:53:05 +0000 (+0700) Subject: AndroidLauncher in kotlin X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=711dc02adaeda8ee8e32aeb4ceedba6612de6764;p=cavedroid.git AndroidLauncher in kotlin --- diff --git a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java deleted file mode 100644 index 714c8df..0000000 --- a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java +++ /dev/null @@ -1,29 +0,0 @@ -package ru.deadsoftware.cavedroid; - -import android.content.pm.PackageManager; -import android.os.Bundle; -import com.badlogic.gdx.backends.android.AndroidApplication; -import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; - -public class AndroidLauncher extends AndroidApplication { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); - config.useImmersiveMode = true; - String gameFolder = ""; - try { - gameFolder = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.dataDir; - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - exit(); - } - CaveGame caveGame = new CaveGame(gameFolder, true, BuildConfig.DEBUG, - new AndroidPreferencesStore(getApplicationContext())); - initialize(caveGame, config); - } - - @Override - public void onBackPressed() { - } -} diff --git a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt new file mode 100644 index 0000000..b6fff78 --- /dev/null +++ b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt @@ -0,0 +1,34 @@ +package ru.deadsoftware.cavedroid + +import android.os.Bundle +import com.badlogic.gdx.backends.android.AndroidApplication +import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration + +class AndroidLauncher : AndroidApplication() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val gameDataDirectoryPath = packageManager.getPackageInfo(packageName, 0) + .applicationInfo.dataDir; + + val config = AndroidApplicationConfiguration() + config.useImmersiveMode = true + + initialize( + /* listener = */ CaveGame( + gameDataDirectoryPath = gameDataDirectoryPath, + isTouchScreen = true, + isDebug = BuildConfig.DEBUG, + preferencesStore = AndroidPreferencesStore(applicationContext) + ), + /* config = */ config + ) + } + + @Suppress("OVERRIDE_DEPRECATION") + override fun onBackPressed() { + // ignore + } + +} \ No newline at end of file