ui: use commit extension from fragment-ktx
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
ddb6c87ebf
commit
5d7ce139bc
@ -12,6 +12,7 @@ import android.view.View
|
|||||||
import androidx.appcompat.app.ActionBar
|
import androidx.appcompat.app.ActionBar
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
|
import androidx.fragment.app.commit
|
||||||
import com.wireguard.android.R
|
import com.wireguard.android.R
|
||||||
import com.wireguard.android.fragment.TunnelDetailFragment
|
import com.wireguard.android.fragment.TunnelDetailFragment
|
||||||
import com.wireguard.android.fragment.TunnelEditorFragment
|
import com.wireguard.android.fragment.TunnelEditorFragment
|
||||||
@ -72,11 +73,11 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_action_edit -> {
|
R.id.menu_action_edit -> {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.commit {
|
||||||
.replace(R.id.detail_container, TunnelEditorFragment())
|
replace(R.id.detail_container, TunnelEditorFragment())
|
||||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||||
.addToBackStack(null)
|
addToBackStack(null)
|
||||||
.commit()
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
// This menu item is handled by the editor fragment.
|
// This menu item is handled by the editor fragment.
|
||||||
@ -104,11 +105,11 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
|
|||||||
fragmentManager.popBackStackImmediate()
|
fragmentManager.popBackStackImmediate()
|
||||||
} else if (backStackEntries == 0) {
|
} else if (backStackEntries == 0) {
|
||||||
// Create and show a new detail fragment.
|
// Create and show a new detail fragment.
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.commit {
|
||||||
.add(R.id.detail_container, TunnelDetailFragment())
|
add(R.id.detail_container, TunnelDetailFragment())
|
||||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||||
.addToBackStack(null)
|
addToBackStack(null)
|
||||||
.commit()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import android.content.Intent
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import androidx.fragment.app.commit
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
@ -28,9 +29,9 @@ class SettingsActivity : ThemeChangeAwareActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
|
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.commit {
|
||||||
.add(android.R.id.content, SettingsFragment())
|
add(android.R.id.content, SettingsFragment())
|
||||||
.commit()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package com.wireguard.android.activity
|
package com.wireguard.android.activity
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.commit
|
||||||
import com.wireguard.android.fragment.TunnelEditorFragment
|
import com.wireguard.android.fragment.TunnelEditorFragment
|
||||||
import com.wireguard.android.model.ObservableTunnel
|
import com.wireguard.android.model.ObservableTunnel
|
||||||
|
|
||||||
@ -15,9 +16,9 @@ class TunnelCreatorActivity : BaseActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
|
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.commit {
|
||||||
.add(android.R.id.content, TunnelEditorFragment())
|
add(android.R.id.content, TunnelEditorFragment())
|
||||||
.commit()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user