Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-picker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-picker
Commits
0e39dea0
Commit
0e39dea0
authored
May 15, 2018
by
Ahad Birang
Committed by
zooble
May 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Android custome fontFamily (#301)
parent
ceb20cbd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
0 deletions
+68
-0
README.md
README.md
+1
-0
android/src/main/java/com/beefe/picker/PickerViewModule.java
android/src/main/java/com/beefe/picker/PickerViewModule.java
+34
-0
android/src/main/java/com/beefe/picker/view/LoopView.java
android/src/main/java/com/beefe/picker/view/LoopView.java
+6
-0
android/src/main/java/com/beefe/picker/view/PickerViewAlone.java
.../src/main/java/com/beefe/picker/view/PickerViewAlone.java
+12
-0
android/src/main/java/com/beefe/picker/view/PickerViewLinkage.java
...rc/main/java/com/beefe/picker/view/PickerViewLinkage.java
+15
-0
No files found.
README.md
View file @
0e39dea0
...
...
@@ -25,6 +25,7 @@
|wheelFlex | array | [1, 1, 1] | iOS/Android | |
|pickerFontSize | number | 16 | iOS/Android | |
|pickerFontColor | array | [31, 31, 31, 1] | iOS/Android | |
|pickerFontFamily | string | | Android | |
|pickerRowHeight | number | 24 | iOS | |
|pickerData | array | | iOS/Android | |
|selectedValue | array | | iOS/Android | |
...
...
android/src/main/java/com/beefe/picker/PickerViewModule.java
View file @
0e39dea0
package
com.beefe.picker
;
import
android.content.res.AssetManager
;
import
android.app.Activity
;
import
android.app.Dialog
;
import
android.graphics.Color
;
import
android.graphics.PixelFormat
;
import
android.graphics.Typeface
;
import
android.support.annotation.Nullable
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
...
...
@@ -75,6 +77,10 @@ import static android.graphics.Color.argb;
*/
public
class
PickerViewModule
extends
ReactContextBaseJavaModule
implements
LifecycleEventListener
{
private
static
final
String
FONTS
=
"fonts/"
;
private
static
final
String
OTF
=
".otf"
;
private
static
final
String
TTF
=
".ttf"
;
private
static
final
String
REACT_CLASS
=
"BEEPickerManager"
;
...
...
@@ -104,6 +110,8 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life
private
static
final
String
PICKER_TEXT_SIZE
=
"pickerFontSize"
;
private
static
final
String
PICKER_TEXT_ELLIPSIS_LEN
=
"pickerTextEllipsisLen"
;
private
static
final
String
PICKER_FONT_FAMILY
=
"pickerFontFamily"
;
private
static
final
String
PICKER_EVENT_NAME
=
"pickerEvent"
;
private
static
final
String
EVENT_KEY_CONFIRM
=
"confirm"
;
private
static
final
String
EVENT_KEY_CANCEL
=
"cancel"
;
...
...
@@ -340,6 +348,32 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life
break
;
}
if
(
options
.
hasKey
(
PICKER_FONT_FAMILY
))
{
Typeface
typeface
=
null
;
AssetManager
assetManager
=
activity
.
getApplicationContext
().
getAssets
();
final
String
fontFamily
=
options
.
getString
(
PICKER_FONT_FAMILY
);
try
{
String
path
=
FONTS
+
fontFamily
+
TTF
;
typeface
=
Typeface
.
createFromAsset
(
assetManager
,
path
);
}
catch
(
Exception
ignored
)
{
try
{
String
path
=
FONTS
+
fontFamily
+
OTF
;
typeface
=
Typeface
.
createFromAsset
(
assetManager
,
path
);
}
catch
(
Exception
ignored2
)
{
try
{
typeface
=
Typeface
.
create
(
fontFamily
,
Typeface
.
NORMAL
);
}
catch
(
Exception
ignored3
)
{
}
}
}
cancelTV
.
setTypeface
(
typeface
);
titleTV
.
setTypeface
(
typeface
);
confirmTV
.
setTypeface
(
typeface
);
pickerViewAlone
.
setTypeface
(
typeface
);
pickerViewLinkage
.
setTypeface
(
typeface
);
}
if
(
options
.
hasKey
(
SELECTED_VALUE
))
{
ReadableArray
array
=
options
.
getArray
(
SELECTED_VALUE
);
String
[]
selectedValue
=
getSelectedValue
(
array
);
...
...
android/src/main/java/com/beefe/picker/view/LoopView.java
View file @
0e39dea0
...
...
@@ -203,6 +203,12 @@ public class LoopView extends View {
invalidate
();
}
public
void
setTypeface
(
Typeface
typeface
){
paintOuterText
.
setTypeface
(
typeface
);
paintCenterText
.
setTypeface
(
typeface
);
invalidate
();
}
public
final
void
setNotLoop
()
{
isLoop
=
false
;
}
...
...
android/src/main/java/com/beefe/picker/view/PickerViewAlone.java
View file @
0e39dea0
package
com.beefe.picker.view
;
import
android.content.Context
;
import
android.graphics.Typeface
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.View
;
...
...
@@ -212,6 +213,17 @@ public class PickerViewAlone extends LinearLayout {
}
}
public
void
setTypeface
(
Typeface
typeface
){
int
viewCount
=
pickerViewAloneLayout
.
getChildCount
();
for
(
int
i
=
0
;
i
<
viewCount
;
i
++)
{
View
view
=
pickerViewAloneLayout
.
getChildAt
(
i
);
if
(
view
instanceof
LoopView
)
{
LoopView
loopView
=
(
LoopView
)
view
;
loopView
.
setTypeface
(
typeface
);
}
}
}
public
void
setTextEllipsisLen
(
int
len
){
int
viewCount
=
pickerViewAloneLayout
.
getChildCount
();
for
(
int
i
=
0
;
i
<
viewCount
;
i
++)
{
...
...
android/src/main/java/com/beefe/picker/view/PickerViewLinkage.java
View file @
0e39dea0
package
com.beefe.picker.view
;
import
android.content.Context
;
import
android.graphics.Typeface
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.View
;
...
...
@@ -603,6 +604,20 @@ public class PickerViewLinkage extends LinearLayout {
}
}
public
void
setTypeface
(
Typeface
typeface
){
switch
(
curRow
)
{
case
2
:
loopViewOne
.
setTypeface
(
typeface
);
loopViewTwo
.
setTypeface
(
typeface
);
break
;
case
3
:
loopViewOne
.
setTypeface
(
typeface
);
loopViewTwo
.
setTypeface
(
typeface
);
loopViewThree
.
setTypeface
(
typeface
);
break
;
}
}
public
void
setTextEllipsisLen
(
int
len
){
switch
(
curRow
)
{
case
2
:
...
...
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