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
4a4d3b11
Commit
4a4d3b11
authored
Sep 07, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine handler
parent
3538caa8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
36 deletions
+55
-36
.travis.yml
.travis.yml
+1
-0
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+46
-35
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+8
-1
No files found.
.travis.yml
View file @
4a4d3b11
...
@@ -24,3 +24,4 @@ script:
...
@@ -24,3 +24,4 @@ script:
-
./build-ndk.sh
-
./build-ndk.sh
-
cp local.properties.travis local.properties
-
cp local.properties.travis local.properties
-
sbt android:package-release
-
sbt android:package-release
-
exit
0
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
4a4d3b11
...
@@ -206,8 +206,19 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
...
@@ -206,8 +206,19 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
saveAppSettings
(
this
)
saveAppSettings
(
this
)
}
}
override
def
onDestroy
()
{
super
.
onDestroy
()
if
(
handler
!=
null
)
{
handler
.
removeCallbacksAndMessages
(
null
)
handler
=
null
}
}
protected
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
protected
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
handler
=
new
Handler
()
getActionBar
.
setTitle
(
R
.
string
.
proxied_help
)
getActionBar
.
setTitle
(
R
.
string
.
proxied_help
)
this
.
setContentView
(
R
.
layout
.
layout_apps
)
this
.
setContentView
(
R
.
layout
.
layout_apps
)
this
.
overlay
=
View
.
inflate
(
this
,
R
.
layout
.
overlay
,
null
).
asInstanceOf
[
TextView
]
this
.
overlay
=
View
.
inflate
(
this
,
R
.
layout
.
overlay
,
null
).
asInstanceOf
[
TextView
]
...
@@ -237,10 +248,10 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
...
@@ -237,10 +248,10 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
super
.
onResume
()
super
.
onResume
()
new
Thread
{
new
Thread
{
override
def
run
()
{
override
def
run
()
{
handler
.
sendEmptyMessage
(
MSG_LOAD_START
)
handler
.
post
(
loadStartRunnable
)
appListView
=
findViewById
(
R
.
id
.
applistview
).
asInstanceOf
[
ListView
]
appListView
=
findViewById
(
R
.
id
.
applistview
).
asInstanceOf
[
ListView
]
if
(!
appsLoaded
)
loadApps
()
if
(!
appsLoaded
)
loadApps
()
handler
.
sendEmptyMessage
(
MSG_LOAD_FINISH
)
handler
.
post
(
loadFinishRunnable
)
}
}
}.
start
()
}.
start
()
}
}
...
@@ -259,46 +270,46 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
...
@@ -259,46 +270,46 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
edit
.
commit
edit
.
commit
}
}
val
handler
:
Handler
=
new
Handler
{
val
loadStartRunnable
=
new
Runnable
{
override
def
handleMessage
(
msg
:
Message
)
{
override
def
run
()
{
msg
.
what
match
{
progressDialog
=
ProgressDialog
case
MSG_LOAD_START
=>
.
show
(
AppManager
.
this
,
""
,
getString
(
R
.
string
.
loading
),
true
,
true
)
progressDialog
=
ProgressDialog
}
.
show
(
AppManager
.
this
,
""
,
getString
(
R
.
string
.
loading
),
true
,
true
)
}
case
MSG_LOAD_FINISH
=>
appListView
.
setAdapter
(
adapter
)
appListView
.
setOnScrollListener
(
new
AbsListView
.
OnScrollListener
{
def
onScroll
(
view
:
AbsListView
,
firstVisibleItem
:
Int
,
visibleItemCount
:
Int
,
totalItemCount
:
Int
)
{
if
(
visible
)
{
val
name
:
String
=
apps
(
firstVisibleItem
).
name
if
(
name
!=
null
&&
name
.
length
>
1
)
{
overlay
.
setText
(
apps
(
firstVisibleItem
).
name
.
substring
(
0
,
1
))
}
else
{
overlay
.
setText
(
"*"
)
}
overlay
.
setVisibility
(
View
.
VISIBLE
)
}
}
def
onScrollStateChanged
(
view
:
AbsListView
,
scrollState
:
Int
)
{
val
loadFinishRunnable
=
new
Runnable
{
visible
=
true
override
def
run
()
=
{
if
(
scrollState
==
OnScrollListener
.
SCROLL_STATE_IDLE
)
{
appListView
.
setAdapter
(
adapter
)
overlay
.
setVisibility
(
View
.
INVISIBLE
)
appListView
.
setOnScrollListener
(
new
AbsListView
.
OnScrollListener
{
}
def
onScroll
(
view
:
AbsListView
,
firstVisibleItem
:
Int
,
visibleItemCount
:
Int
,
totalItemCount
:
Int
)
{
if
(
visible
)
{
val
name
:
String
=
apps
(
firstVisibleItem
).
name
if
(
name
!=
null
&&
name
.
length
>
1
)
{
overlay
.
setText
(
apps
(
firstVisibleItem
).
name
.
substring
(
0
,
1
))
}
else
{
overlay
.
setText
(
"*"
)
}
}
overlay
.
setVisibility
(
View
.
VISIBLE
)
var
visible
=
false
}
})
}
if
(
progressDialog
!=
null
)
{
def
onScrollStateChanged
(
view
:
AbsListView
,
scrollState
:
Int
)
{
progressDialog
.
dismiss
()
visible
=
true
progressDialog
=
null
if
(
scrollState
==
OnScrollListener
.
SCROLL_STATE_IDLE
)
{
overlay
.
setVisibility
(
View
.
INVISIBLE
)
}
}
}
var
visible
=
false
})
if
(
progressDialog
!=
null
)
{
progressDialog
.
dismiss
()
progressDialog
=
null
}
}
super
.
handleMessage
(
msg
)
}
}
}
}
var
handler
:
Handler
=
null
class
AppIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
class
AppIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
4a4d3b11
...
@@ -67,6 +67,7 @@ import net.simonvt.menudrawer.MenuDrawer
...
@@ -67,6 +67,7 @@ import net.simonvt.menudrawer.MenuDrawer
import
scala.collection.mutable.
{
ArrayBuffer
,
ListBuffer
}
import
scala.collection.mutable.
{
ArrayBuffer
,
ListBuffer
}
import
scala.concurrent.ops._
import
scala.concurrent.ops._
import
scala.ref.WeakReference
class
ProfileIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
class
ProfileIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
...
@@ -236,7 +237,7 @@ class Shadowsocks
...
@@ -236,7 +237,7 @@ class Shadowsocks
private
lazy
val
application
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
]
private
lazy
val
application
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
]
va
l
handler
=
new
Handler
()
va
r
handler
:
Handler
=
null
def
isSinglePane
:
Boolean
=
{
def
isSinglePane
:
Boolean
=
{
if
(
singlePane
==
-
1
)
{
if
(
singlePane
==
-
1
)
{
...
@@ -442,6 +443,8 @@ class Shadowsocks
...
@@ -442,6 +443,8 @@ class Shadowsocks
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
handler
=
new
Handler
()
addPreferencesFromResource
(
R
.
xml
.
pref_all
)
addPreferencesFromResource
(
R
.
xml
.
pref_all
)
// Initialize the profile
// Initialize the profile
...
@@ -797,6 +800,10 @@ class Shadowsocks
...
@@ -797,6 +800,10 @@ class Shadowsocks
Crouton
.
cancelAllCroutons
()
Crouton
.
cancelAllCroutons
()
unregisterReceiver
(
preferenceReceiver
)
unregisterReceiver
(
preferenceReceiver
)
new
BackupManager
(
this
).
dataChanged
()
new
BackupManager
(
this
).
dataChanged
()
if
(
handler
!=
null
)
{
handler
.
removeCallbacksAndMessages
(
null
)
handler
=
null
}
}
}
def
copyToSystem
()
{
def
copyToSystem
()
{
...
...
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