Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
18933591
Unverified
Commit
18933591
authored
Jan 27, 2022
by
LoveSy
Committed by
GitHub
Jan 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash when fragment is detached from activity
parent
f5e5ab24
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
18 additions
and
18 deletions
+18
-18
BaseFragment.kt
app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt
+4
-4
ViewEvents.kt
app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt
+1
-1
DenyListFragment.kt
...ain/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt
+1
-1
FlashFragment.kt
.../main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt
+5
-5
HomeFragment.kt
...rc/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt
+2
-2
LogFragment.kt
app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt
+1
-1
ModuleFragment.kt
...ain/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt
+1
-1
SettingsFragment.kt
...java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt
+1
-1
SuperuserFragment.kt
...va/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt
+1
-1
ThemeFragment.kt
.../main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt
View file @
18933591
...
@@ -15,11 +15,11 @@ import com.topjohnwu.magisk.ktx.startAnimations
...
@@ -15,11 +15,11 @@ import com.topjohnwu.magisk.ktx.startAnimations
abstract
class
BaseFragment
<
Binding
:
ViewDataBinding
>
:
Fragment
(),
ViewModelHolder
{
abstract
class
BaseFragment
<
Binding
:
ViewDataBinding
>
:
Fragment
(),
ViewModelHolder
{
val
activity
get
()
=
requireActivity
()
as
NavigationActivity
<*>
val
activity
get
()
=
getActivity
()
as
?
NavigationActivity
<*>
protected
lateinit
var
binding
:
Binding
protected
lateinit
var
binding
:
Binding
protected
abstract
val
layoutRes
:
Int
protected
abstract
val
layoutRes
:
Int
private
val
navigation
get
()
=
activity
.
navigation
private
val
navigation
get
()
=
activity
?
.
navigation
open
val
snackbarAnchorView
:
View
?
get
()
=
null
open
val
snackbarAnchorView
:
View
?
get
()
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
@@ -41,12 +41,12 @@ abstract class BaseFragment<Binding : ViewDataBinding> : Fragment(), ViewModelHo
...
@@ -41,12 +41,12 @@ abstract class BaseFragment<Binding : ViewDataBinding> : Fragment(), ViewModelHo
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
activity
.
supportActionBar
?.
subtitle
=
null
activity
?
.
supportActionBar
?.
subtitle
=
null
}
}
override
fun
onEventDispatched
(
event
:
ViewEvent
)
=
when
(
event
)
{
override
fun
onEventDispatched
(
event
:
ViewEvent
)
=
when
(
event
)
{
is
ContextExecutor
->
event
(
requireContext
())
is
ContextExecutor
->
event
(
requireContext
())
is
ActivityExecutor
->
event
(
activity
)
is
ActivityExecutor
->
activity
?.
let
{
event
(
it
)
}
?:
Unit
is
FragmentExecutor
->
event
(
this
)
is
FragmentExecutor
->
event
(
this
)
else
->
Unit
else
->
Unit
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt
View file @
18933591
...
@@ -83,7 +83,7 @@ class SelectModuleEvent : ViewEvent(), FragmentExecutor {
...
@@ -83,7 +83,7 @@ class SelectModuleEvent : ViewEvent(), FragmentExecutor {
override
fun
invoke
(
fragment
:
BaseFragment
<
*
>)
{
override
fun
invoke
(
fragment
:
BaseFragment
<
*
>)
{
try
{
try
{
fragment
.
apply
{
fragment
.
apply
{
activity
.
getContent
(
"application/zip"
)
{
activity
?
.
getContent
(
"application/zip"
)
{
MainDirections
.
actionFlashFragment
(
Const
.
Value
.
FLASH_ZIP
,
it
).
navigate
()
MainDirections
.
actionFlashFragment
(
Const
.
Value
.
FLASH_ZIP
,
it
).
navigate
()
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt
View file @
18933591
...
@@ -26,7 +26,7 @@ class DenyListFragment : BaseFragment<FragmentDenyMd2Binding>() {
...
@@ -26,7 +26,7 @@ class DenyListFragment : BaseFragment<FragmentDenyMd2Binding>() {
override
fun
onAttach
(
context
:
Context
)
{
override
fun
onAttach
(
context
:
Context
)
{
super
.
onAttach
(
context
)
super
.
onAttach
(
context
)
activity
.
setTitle
(
R
.
string
.
denylist
)
activity
?
.
setTitle
(
R
.
string
.
denylist
)
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt
View file @
18933591
...
@@ -31,10 +31,10 @@ class FlashFragment : BaseFragment<FragmentFlashMd2Binding>() {
...
@@ -31,10 +31,10 @@ class FlashFragment : BaseFragment<FragmentFlashMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
activity
.
setTitle
(
R
.
string
.
flash_screen_title
)
activity
?
.
setTitle
(
R
.
string
.
flash_screen_title
)
viewModel
.
subtitle
.
observe
(
this
)
{
viewModel
.
subtitle
.
observe
(
this
)
{
activity
.
supportActionBar
?.
setSubtitle
(
it
)
activity
?
.
supportActionBar
?.
setSubtitle
(
it
)
}
}
}
}
...
@@ -49,15 +49,15 @@ class FlashFragment : BaseFragment<FragmentFlashMd2Binding>() {
...
@@ -49,15 +49,15 @@ class FlashFragment : BaseFragment<FragmentFlashMd2Binding>() {
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
defaultOrientation
=
activity
.
requestedOrientation
defaultOrientation
=
activity
?.
requestedOrientation
?:
-
1
activity
.
requestedOrientation
=
ActivityInfo
.
SCREEN_ORIENTATION_NOSENSOR
activity
?
.
requestedOrientation
=
ActivityInfo
.
SCREEN_ORIENTATION_NOSENSOR
viewModel
.
startFlashing
()
viewModel
.
startFlashing
()
}
}
@SuppressLint
(
"WrongConstant"
)
@SuppressLint
(
"WrongConstant"
)
override
fun
onDestroyView
()
{
override
fun
onDestroyView
()
{
if
(
defaultOrientation
!=
-
1
)
{
if
(
defaultOrientation
!=
-
1
)
{
activity
.
requestedOrientation
=
defaultOrientation
activity
?
.
requestedOrientation
=
defaultOrientation
}
}
super
.
onDestroyView
()
super
.
onDestroyView
()
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt
View file @
18933591
...
@@ -19,7 +19,7 @@ class HomeFragment : BaseFragment<FragmentHomeMd2Binding>() {
...
@@ -19,7 +19,7 @@ class HomeFragment : BaseFragment<FragmentHomeMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
activity
.
title
=
resources
.
getString
(
R
.
string
.
section_home
)
activity
?
.
title
=
resources
.
getString
(
R
.
string
.
section_home
)
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
DownloadService
.
observeProgress
(
this
,
viewModel
::
onProgressUpdate
)
DownloadService
.
observeProgress
(
this
,
viewModel
::
onProgressUpdate
)
}
}
...
@@ -64,7 +64,7 @@ class HomeFragment : BaseFragment<FragmentHomeMd2Binding>() {
...
@@ -64,7 +64,7 @@ class HomeFragment : BaseFragment<FragmentHomeMd2Binding>() {
when
(
item
.
itemId
)
{
when
(
item
.
itemId
)
{
R
.
id
.
action_settings
->
R
.
id
.
action_settings
->
HomeFragmentDirections
.
actionHomeFragmentToSettingsFragment
().
navigate
()
HomeFragmentDirections
.
actionHomeFragmentToSettingsFragment
().
navigate
()
R
.
id
.
action_reboot
->
RebootEvent
.
inflateMenu
(
activity
).
show
()
R
.
id
.
action_reboot
->
activity
?.
let
{
RebootEvent
.
inflateMenu
(
it
).
show
()
}
else
->
return
super
.
onOptionsItemSelected
(
item
)
else
->
return
super
.
onOptionsItemSelected
(
item
)
}
}
return
true
return
true
...
...
app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt
View file @
18933591
...
@@ -38,7 +38,7 @@ class LogFragment : BaseFragment<FragmentLogMd2Binding>() {
...
@@ -38,7 +38,7 @@ class LogFragment : BaseFragment<FragmentLogMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
activity
.
title
=
resources
.
getString
(
R
.
string
.
logs
)
activity
?
.
title
=
resources
.
getString
(
R
.
string
.
logs
)
}
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt
View file @
18933591
...
@@ -19,7 +19,7 @@ class ModuleFragment : BaseFragment<FragmentModuleMd2Binding>() {
...
@@ -19,7 +19,7 @@ class ModuleFragment : BaseFragment<FragmentModuleMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
activity
.
title
=
resources
.
getString
(
R
.
string
.
modules
)
activity
?
.
title
=
resources
.
getString
(
R
.
string
.
modules
)
}
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt
View file @
18933591
...
@@ -18,7 +18,7 @@ class SettingsFragment : BaseFragment<FragmentSettingsMd2Binding>() {
...
@@ -18,7 +18,7 @@ class SettingsFragment : BaseFragment<FragmentSettingsMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
activity
.
title
=
resources
.
getString
(
R
.
string
.
settings
)
activity
?
.
title
=
resources
.
getString
(
R
.
string
.
settings
)
}
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt
View file @
18933591
...
@@ -17,7 +17,7 @@ class SuperuserFragment : BaseFragment<FragmentSuperuserMd2Binding>() {
...
@@ -17,7 +17,7 @@ class SuperuserFragment : BaseFragment<FragmentSuperuserMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
activity
.
title
=
resources
.
getString
(
R
.
string
.
superuser
)
activity
?
.
title
=
resources
.
getString
(
R
.
string
.
superuser
)
}
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt
View file @
18933591
...
@@ -61,7 +61,7 @@ class ThemeFragment : BaseFragment<FragmentThemeMd2Binding>() {
...
@@ -61,7 +61,7 @@ class ThemeFragment : BaseFragment<FragmentThemeMd2Binding>() {
override
fun
onStart
()
{
override
fun
onStart
()
{
super
.
onStart
()
super
.
onStart
()
activity
.
title
=
getString
(
R
.
string
.
section_theme
)
activity
?
.
title
=
getString
(
R
.
string
.
section_theme
)
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment