Skip to content

Commit

Permalink
Improve app startup speed
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jun 15, 2021
1 parent e14d633 commit 3440e5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 15 additions & 0 deletions app/src/main/java/com/cyb3rko/logviewerforopenhab/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.cyb3rko.logviewerforopenhab

import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import es.dmoral.toasty.Toasty

class App: Application() {

override fun onCreate() {
super.onCreate()
Toasty.Config.getInstance().allowQueue(false).apply()
val mySPR = getSharedPreferences(SHARED_PREFERENCE, MODE_PRIVATE)
AppCompatDelegate.setDefaultNightMode(mySPR.getString(NIGHTMODE, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM.toString())!!.toInt())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import android.text.style.UnderlineSpan
import android.view.View
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.Toolbar
import androidx.drawerlayout.widget.DrawerLayout
import androidx.navigation.NavController
Expand All @@ -28,7 +27,6 @@ import com.google.android.material.navigation.NavigationView
import com.google.android.play.core.review.ReviewManagerFactory
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import es.dmoral.toasty.Toasty

class MainActivity : AppCompatActivity() {

Expand All @@ -43,11 +41,10 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Toasty.Config.getInstance().allowQueue(false).apply()
mySPR = getSharedPreferences(SHARED_PREFERENCE, MODE_PRIVATE)
editor = mySPR.edit()
editor.apply()
AppCompatDelegate.setDefaultNightMode(mySPR.getString(NIGHTMODE, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM.toString())!!.toInt())

requestedOrientation = mySPR.getString(ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED.toString())?.toInt()!!

setContentView(R.layout.activity_main)
Expand Down

0 comments on commit 3440e5d

Please sign in to comment.