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
abcbc98c
Commit
abcbc98c
authored
Oct 05, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine MyNumberPicker
parent
2722b1aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
19 deletions
+9
-19
src/main/scala/be/mygod/preference/NumberPickerPreference.scala
...in/scala/be/mygod/preference/NumberPickerPreference.scala
+6
-18
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+3
-1
No files found.
src/main/scala/be/mygod/preference/NumberPickerPreference.scala
View file @
abcbc98c
...
@@ -6,30 +6,18 @@ import android.support.v7.preference.DialogPreference
...
@@ -6,30 +6,18 @@ import android.support.v7.preference.DialogPreference
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.view.View
import
android.view.View
import
android.view.ViewGroup.LayoutParams
import
android.view.ViewGroup.LayoutParams
import
android.widget.NumberPicker
import
android.widget.
{
EditText
,
NumberPicker
}
import
android.widget.EditText
import
com.github.shadowsocks.R
import
com.github.shadowsocks.R
import
com.github.shadowsocks.utils.Utils
class
MyNumberPicker
(
private
val
context
:
Context
,
attrs
:
AttributeSet
=
null
)
class
MyNumberPicker
(
private
val
context
:
Context
,
attrs
:
AttributeSet
=
null
)
extends
NumberPicker
(
context
,
attrs
)
{
extends
NumberPicker
(
context
,
attrs
)
{
override
def
addView
(
child
:
View
)
{
super
.
addView
(
child
)
updateView
(
child
)
}
override
def
addView
(
child
:
View
,
params
:
LayoutParams
)
{
super
.
addView
(
child
,
params
)
updateView
(
child
)
}
override
def
addView
(
child
:
View
,
index
:
Int
,
params
:
LayoutParams
)
{
override
def
addView
(
child
:
View
,
index
:
Int
,
params
:
LayoutParams
)
{
super
.
addView
(
child
,
index
,
params
)
super
.
addView
(
child
,
index
,
params
)
updateView
(
child
)
child
match
{
}
case
et
:
EditText
=>
et
.
setTextSize
(
Utils
.
spToPx
(
context
,
6
))
def
updateView
(
child
:
View
)
{
case
_
=>
if
(
child
.
isInstanceOf
[
EditText
])
{
child
.
asInstanceOf
[
EditText
].
setTextSize
(
dp2px
(
6
))
}
}
}
}
def
dp2px
(
dp
:
Float
)
:
Int
=
(
dp
*
getResources
().
getDisplayMetrics
().
density
).
toInt
}
}
class
NumberPickerPreference
(
private
val
context
:
Context
,
attrs
:
AttributeSet
=
null
)
class
NumberPickerPreference
(
private
val
context
:
Context
,
attrs
:
AttributeSet
=
null
)
...
...
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
abcbc98c
...
@@ -78,7 +78,9 @@ object Utils {
...
@@ -78,7 +78,9 @@ object Utils {
}
}
def
dpToPx
(
context
:
Context
,
dp
:
Int
)
:
Int
=
def
dpToPx
(
context
:
Context
,
dp
:
Int
)
:
Int
=
Math
.
round
(
dp
*
(
context
.
getResources
.
getDisplayMetrics
.
xdpi
/
DisplayMetrics
.
DENSITY_DEFAULT
))
Math
.
round
(
dp
*
context
.
getResources
.
getDisplayMetrics
.
density
)
def
spToPx
(
context
:
Context
,
sp
:
Int
)
:
Int
=
Math
.
round
(
sp
*
context
.
getResources
.
getDisplayMetrics
.
scaledDensity
)
/*
/*
* round or floor depending on whether you are using offsets(floor) or
* round or floor depending on whether you are using offsets(floor) or
...
...
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