From d69880138e5bace99dcc81d0e301b635943287f9 Mon Sep 17 00:00:00 2001 From: GKF Date: Thu, 23 May 2019 09:50:10 +0800 Subject: [PATCH] ViewModel --- app/.gitignore | 1 + app/src/main/java/io/legado/app/ui/main/MainActivity.kt | 3 ++- app/src/main/java/io/legado/app/ui/main/MainModel.kt | 5 +++++ app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 9 +++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/io/legado/app/ui/main/MainModel.kt create mode 100644 app/src/main/java/io/legado/app/ui/main/MainViewModel.kt diff --git a/app/.gitignore b/app/.gitignore index 796b96d1c..3f2a4d9f6 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ /build +/schemas diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index c11148349..2b0156d5d 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -7,6 +7,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.AppCompatActivity import androidx.core.view.GravityCompat import androidx.drawerlayout.widget.DrawerLayout +import androidx.lifecycle.ViewModelProviders import com.google.android.material.navigation.NavigationView import io.legado.app.R import io.legado.app.utils.longSnackbar @@ -19,7 +20,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - setSupportActionBar(toolbar) fab.setOnClickListener { it.longSnackbar(R.string.app_name) } @@ -33,6 +33,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte toggle.syncState() nav_view.setNavigationItemSelectedListener(this) + val mainViewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) } override fun onBackPressed() { diff --git a/app/src/main/java/io/legado/app/ui/main/MainModel.kt b/app/src/main/java/io/legado/app/ui/main/MainModel.kt new file mode 100644 index 000000000..86da567f6 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/main/MainModel.kt @@ -0,0 +1,5 @@ +package io.legado.app.ui.main + +class MainModel { + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt new file mode 100644 index 000000000..82a9146c5 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -0,0 +1,9 @@ +package io.legado.app.ui.main + +import android.app.Application +import androidx.lifecycle.AndroidViewModel + +class MainViewModel(application: Application) : AndroidViewModel(application) { + + +} \ No newline at end of file