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
f728a676
Commit
f728a676
authored
Nov 25, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify SummaryPreference
parent
b269d9a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
31 deletions
+1
-31
src/main/res/values/attrs.xml
src/main/res/values/attrs.xml
+0
-3
src/main/scala/com/github/shadowsocks/preferences/DropDownPreference.scala
...m/github/shadowsocks/preferences/DropDownPreference.scala
+0
-1
src/main/scala/com/github/shadowsocks/preferences/NumberPickerPreference.scala
...thub/shadowsocks/preferences/NumberPickerPreference.scala
+0
-1
src/main/scala/com/github/shadowsocks/preferences/SummaryPreference.scala
...om/github/shadowsocks/preferences/SummaryPreference.scala
+1
-26
No files found.
src/main/res/values/attrs.xml
View file @
f728a676
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<declare-styleable
name=
"SummaryPreference"
>
<attr
name=
"summary"
format=
"string"
/>
</declare-styleable>
<declare-styleable
name=
"DropDownPreference"
>
<declare-styleable
name=
"DropDownPreference"
>
<attr
name=
"entries"
format=
"reference"
/>
<attr
name=
"entries"
format=
"reference"
/>
<attr
name=
"entryValues"
format=
"reference"
/>
<attr
name=
"entryValues"
format=
"reference"
/>
...
...
src/main/scala/com/github/shadowsocks/preferences/DropDownPreference.scala
View file @
f728a676
...
@@ -38,7 +38,6 @@ final class DropDownPreference(private val mContext: Context, attrs: AttributeSe
...
@@ -38,7 +38,6 @@ final class DropDownPreference(private val mContext: Context, attrs: AttributeSe
mSpinner
.
performClick
mSpinner
.
performClick
true
true
})
})
initSummary
(
mContext
,
attrs
)
val
a
:
TypedArray
=
mContext
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DropDownPreference
)
val
a
:
TypedArray
=
mContext
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DropDownPreference
)
setEntries
(
a
.
getTextArray
(
R
.
styleable
.
DropDownPreference_entries
))
setEntries
(
a
.
getTextArray
(
R
.
styleable
.
DropDownPreference_entries
))
mEntryValues
=
a
.
getTextArray
(
R
.
styleable
.
DropDownPreference_entryValues
)
mEntryValues
=
a
.
getTextArray
(
R
.
styleable
.
DropDownPreference_entryValues
)
...
...
src/main/scala/com/github/shadowsocks/preferences/NumberPickerPreference.scala
View file @
f728a676
...
@@ -22,7 +22,6 @@ final class NumberPickerPreference(context: Context, attrs: AttributeSet = null)
...
@@ -22,7 +22,6 @@ final class NumberPickerPreference(context: Context, attrs: AttributeSet = null)
setMax
(
a
.
getInt
(
R
.
styleable
.
NumberPickerPreference_max
,
Int
.
MaxValue
-
1
))
setMax
(
a
.
getInt
(
R
.
styleable
.
NumberPickerPreference_max
,
Int
.
MaxValue
-
1
))
a
.
recycle
a
.
recycle
}
}
initSummary
(
context
,
attrs
)
def
getValue
=
value
def
getValue
=
value
def
getMin
=
if
(
picker
==
null
)
0
else
picker
.
getMinValue
def
getMin
=
if
(
picker
==
null
)
0
else
picker
.
getMinValue
...
...
src/main/scala/com/github/shadowsocks/preferences/SummaryPreference.scala
View file @
f728a676
package
com.github.shadowsocks.preferences
package
com.github.shadowsocks.preferences
import
android.content.Context
import
android.preference.Preference
import
android.preference.Preference
import
android.util.AttributeSet
import
com.github.shadowsocks.R
/**
/**
* Make your preference support %s in summary. Override getSummaryValue to customize what to put in.
* Make your preference support %s in summary. Override getSummaryValue to customize what to put in.
* @author Mygod
* @author Mygod
*/
*/
trait
SummaryPreference
extends
Preference
{
trait
SummaryPreference
extends
Preference
{
private
var
mSummary
:
String
=
_
protected
def
initSummary
(
context
:
Context
,
attrs
:
AttributeSet
)
{
val
a
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
SummaryPreference
)
mSummary
=
a
.
getString
(
R
.
styleable
.
SummaryPreference_summary
)
a
.
recycle
}
protected
def
getSummaryValue
:
AnyRef
protected
def
getSummaryValue
:
AnyRef
/**
/**
...
@@ -26,19 +15,5 @@ trait SummaryPreference extends Preference {
...
@@ -26,19 +15,5 @@ trait SummaryPreference extends Preference {
*
*
* @return the summary with appropriate string substitution
* @return the summary with appropriate string substitution
*/
*/
override
def
getSummary
=
{
override
def
getSummary
=
String
.
format
(
super
.
getSummary
.
toString
,
getSummaryValue
)
val
entry
=
getSummaryValue
if
(
mSummary
==
null
||
entry
==
null
)
super
.
getSummary
else
String
.
format
(
mSummary
,
entry
)
}
/**
* Sets the summary for this Preference with a CharSequence. If the summary has a String formatting marker in it
* (i.e. "%s" or "%1$s"), then the current entry value will be substituted in its place when it's retrieved.
*
* @param summary The summary for the preference.
*/
override
def
setSummary
(
summary
:
CharSequence
)
{
super
.
setSummary
(
summary
)
if
(
summary
==
null
&&
mSummary
!=
null
)
mSummary
=
null
else
if
(
summary
!=
null
&&
summary
!=
mSummary
)
mSummary
=
summary
.
toString
}
}
}
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