Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
3ac77e1f
Commit
3ac77e1f
authored
Feb 08, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash on back pressed after MainActivity recreated
parent
fd2c67d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
16 deletions
+12
-16
mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala
.../src/main/scala/com/github/shadowsocks/MainActivity.scala
+12
-16
No files found.
mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
3ac77e1f
...
@@ -84,11 +84,6 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -84,11 +84,6 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
private
var
txRateText
:
TextView
=
_
private
var
txRateText
:
TextView
=
_
private
var
rxRateText
:
TextView
=
_
private
var
rxRateText
:
TextView
=
_
private
var
currentFragment
:
ToolbarFragment
=
_
private
lazy
val
profilesFragment
=
new
ProfilesFragment
()
private
lazy
val
customRulesFragment
=
new
CustomRulesFragment
()
private
lazy
val
globalSettingsFragment
=
new
GlobalSettingsFragment
()
private
lazy
val
aboutFragment
=
new
AboutFragment
()
private
lazy
val
customTabsIntent
=
new
CustomTabsIntent
.
Builder
()
private
lazy
val
customTabsIntent
=
new
CustomTabsIntent
.
Builder
()
.
setToolbarColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
material_primary_500
))
.
setToolbarColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
material_primary_500
))
.
build
()
.
build
()
...
@@ -255,7 +250,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -255,7 +250,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
val
tf
=
Typefaces
.
get
(
this
,
"fonts/Iceland.ttf"
)
val
tf
=
Typefaces
.
get
(
this
,
"fonts/Iceland.ttf"
)
if
(
tf
!=
null
)
title
.
setTypeface
(
tf
)
if
(
tf
!=
null
)
title
.
setTypeface
(
tf
)
if
(
savedInstanceState
==
null
)
displayFragment
(
p
rofilesFragment
)
if
(
savedInstanceState
==
null
)
displayFragment
(
new
P
rofilesFragment
)
statusText
=
findViewById
(
R
.
id
.
status
).
asInstanceOf
[
TextView
]
statusText
=
findViewById
(
R
.
id
.
status
).
asInstanceOf
[
TextView
]
txText
=
findViewById
(
R
.
id
.
tx
).
asInstanceOf
[
TextView
]
txText
=
findViewById
(
R
.
id
.
tx
).
asInstanceOf
[
TextView
]
txRateText
=
findViewById
(
R
.
id
.
txRate
).
asInstanceOf
[
TextView
]
txRateText
=
findViewById
(
R
.
id
.
txRate
).
asInstanceOf
[
TextView
]
...
@@ -364,14 +359,13 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -364,14 +359,13 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
}
}
private
def
displayFragment
(
fragment
:
ToolbarFragment
)
{
private
def
displayFragment
(
fragment
:
ToolbarFragment
)
{
currentFragment
=
fragment
getFragmentManager
.
beginTransaction
().
replace
(
R
.
id
.
fragment_holder
,
fragment
).
commitAllowingStateLoss
()
getFragmentManager
.
beginTransaction
().
replace
(
R
.
id
.
fragment_holder
,
fragment
).
commitAllowingStateLoss
()
drawer
.
closeDrawer
()
drawer
.
closeDrawer
()
}
}
override
def
onItemClick
(
view
:
View
,
position
:
Int
,
drawerItem
:
IDrawerItem
[
_
,
_
<:
ViewHolder
])
:
Boolean
=
{
override
def
onItemClick
(
view
:
View
,
position
:
Int
,
drawerItem
:
IDrawerItem
[
_
,
_
<:
ViewHolder
])
:
Boolean
=
{
drawerItem
.
getIdentifier
match
{
drawerItem
.
getIdentifier
match
{
case
DRAWER_PROFILES
=>
displayFragment
(
p
rofilesFragment
)
case
DRAWER_PROFILES
=>
displayFragment
(
new
P
rofilesFragment
)
case
DRAWER_RECOVERY
=>
case
DRAWER_RECOVERY
=>
app
.
track
(
"GlobalConfigFragment"
,
"reset"
)
app
.
track
(
"GlobalConfigFragment"
,
"reset"
)
if
(
bgService
!=
null
)
bgService
.
use
(-
1
)
if
(
bgService
!=
null
)
bgService
.
use
(-
1
)
...
@@ -384,12 +378,12 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -384,12 +378,12 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
app
.
copyAssets
()
app
.
copyAssets
()
handler
.
sendEmptyMessage
(
0
)
handler
.
sendEmptyMessage
(
0
)
}
}
case
DRAWER_GLOBAL_SETTINGS
=>
displayFragment
(
g
lobalSettingsFragment
)
case
DRAWER_GLOBAL_SETTINGS
=>
displayFragment
(
new
G
lobalSettingsFragment
)
case
DRAWER_ABOUT
=>
case
DRAWER_ABOUT
=>
app
.
track
(
TAG
,
"about"
)
app
.
track
(
TAG
,
"about"
)
displayFragment
(
a
boutFragment
)
displayFragment
(
new
A
boutFragment
)
case
DRAWER_FAQ
=>
launchUrl
(
getString
(
R
.
string
.
faq_url
))
case
DRAWER_FAQ
=>
launchUrl
(
getString
(
R
.
string
.
faq_url
))
case
DRAWER_CUSTOM_RULES
=>
displayFragment
(
c
ustomRulesFragment
)
case
DRAWER_CUSTOM_RULES
=>
displayFragment
(
new
C
ustomRulesFragment
)
}
}
true
// unexpected cases will throw exception
true
// unexpected cases will throw exception
}
}
...
@@ -408,12 +402,14 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -408,12 +402,14 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
setListeningForBandwidth
(
true
)
setListeningForBandwidth
(
true
)
}
}
override
def
onBackPressed
()
:
Unit
=
override
def
onBackPressed
()
:
Unit
=
if
(
drawer
.
isDrawerOpen
)
drawer
.
closeDrawer
()
else
{
if
(
drawer
.
isDrawerOpen
)
drawer
.
closeDrawer
()
else
if
(!
currentFragment
.
onBackPressed
())
val
currentFragment
=
getFragmentManager
.
findFragmentById
(
R
.
id
.
fragment_holder
).
asInstanceOf
[
ToolbarFragment
]
if
(
currentFragment
!=
profilesFragment
)
{
if
(!
currentFragment
.
onBackPressed
())
displayFragment
(
profilesFragment
)
if
(
currentFragment
.
isInstanceOf
[
ProfilesFragment
])
super
.
onBackPressed
()
else
{
displayFragment
(
new
ProfilesFragment
)
drawer
.
setSelection
(
DRAWER_PROFILES
)
drawer
.
setSelection
(
DRAWER_PROFILES
)
}
else
super
.
onBackPressed
()
}
}
override
def
onStop
()
{
override
def
onStop
()
{
setListeningForBandwidth
(
false
)
setListeningForBandwidth
(
false
)
...
...
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