Update dependencies
This commit is contained in:
@@ -12,7 +12,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.0-alpha08'
|
||||
classpath 'com.android.tools.build:gradle:4.0.0-alpha09'
|
||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.27.0'
|
||||
classpath 'com.google.gms:google-services:4.3.3'
|
||||
classpath 'io.fabric.tools:gradle:1.31.2'
|
||||
|
||||
@@ -13,7 +13,7 @@ def aux = [
|
||||
'com.crashlytics.sdk.android:crashlytics:2.10.1',
|
||||
'com.google.firebase:firebase-analytics:17.2.2',
|
||||
]
|
||||
def lifecycleVersion = '2.2.0-rc03'
|
||||
def lifecycleVersion = '2.2.0'
|
||||
def roomVersion = '2.2.3'
|
||||
|
||||
android {
|
||||
@@ -83,9 +83,8 @@ dependencies {
|
||||
implementation 'androidx.browser:browser:1.2.0'
|
||||
implementation 'androidx.core:core-ktx:1.2.0-rc01'
|
||||
implementation 'androidx.emoji:emoji:1.0.0'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.2.0-rc05'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.2.0'
|
||||
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
|
||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
|
||||
implementation 'androidx.preference:preference:1.1.0'
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.replace
|
||||
import androidx.lifecycle.observe
|
||||
import be.mygod.vpnhotspot.client.ClientViewModel
|
||||
import be.mygod.vpnhotspot.client.ClientsFragment
|
||||
@@ -27,7 +28,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.navigation.setOnNavigationItemSelectedListener(this)
|
||||
if (savedInstanceState == null) displayFragment(TetheringFragment())
|
||||
if (savedInstanceState == null) displayFragment<TetheringFragment>()
|
||||
val model by viewModels<ClientViewModel>()
|
||||
if (RepeaterService.supported) ServiceForegroundConnector(this, model, RepeaterService::class)
|
||||
model.clients.observe(this) { clients ->
|
||||
@@ -48,29 +49,29 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
|
||||
R.id.navigation_clients -> {
|
||||
if (!item.isChecked) {
|
||||
item.isChecked = true
|
||||
displayFragment(ClientsFragment())
|
||||
displayFragment<ClientsFragment>()
|
||||
}
|
||||
true
|
||||
}
|
||||
R.id.navigation_tethering -> {
|
||||
if (!item.isChecked) {
|
||||
item.isChecked = true
|
||||
displayFragment(TetheringFragment())
|
||||
displayFragment<TetheringFragment>()
|
||||
}
|
||||
true
|
||||
}
|
||||
R.id.navigation_settings -> {
|
||||
if (!item.isChecked) {
|
||||
item.isChecked = true
|
||||
displayFragment(SettingsPreferenceFragment())
|
||||
displayFragment<SettingsPreferenceFragment>()
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun displayFragment(fragment: Fragment) =
|
||||
supportFragmentManager.beginTransaction().replace(R.id.fragmentHolder, fragment).commitAllowingStateLoss()
|
||||
private inline fun <reified F : Fragment> displayFragment() =
|
||||
supportFragmentManager.beginTransaction().replace<F>(R.id.fragmentHolder).commitAllowingStateLoss()
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
@@ -12,11 +12,11 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.databinding.BaseObservable
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.observe
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
@@ -26,7 +26,6 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import be.mygod.vpnhotspot.AlertDialogFragment
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.Empty
|
||||
import be.mygod.vpnhotspot.MainActivity
|
||||
import be.mygod.vpnhotspot.R
|
||||
import be.mygod.vpnhotspot.databinding.FragmentClientsBinding
|
||||
import be.mygod.vpnhotspot.databinding.ListitemClientBinding
|
||||
@@ -212,7 +211,7 @@ class ClientsFragment : Fragment() {
|
||||
private val adapter = ClientAdapter()
|
||||
private var rates = mutableMapOf<Pair<String, Long>, TrafficRate>()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = FragmentClientsBinding.inflate(inflater, container, false)
|
||||
binding.clients.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
|
||||
binding.clients.itemAnimator = DefaultItemAnimator()
|
||||
@@ -221,9 +220,7 @@ class ClientsFragment : Fragment() {
|
||||
binding.swipeRefresher.setOnRefreshListener {
|
||||
IpNeighbourMonitor.instance?.flush()
|
||||
}
|
||||
(activity as MainActivity).viewModels<ClientViewModel>().value.clients.observe(this) {
|
||||
adapter.submitList(it.toMutableList())
|
||||
}
|
||||
activityViewModels<ClientViewModel>().value.clients.observe(this) { adapter.submitList(it.toMutableList()) }
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user