diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/CalendarAdapter.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/CalendarAdapter.java index b2e58d11..28733ee7 100644 --- a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/CalendarAdapter.java +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/CalendarAdapter.java @@ -34,6 +34,7 @@ */ @SuppressWarnings("UnusedReturnValue") public class CalendarAdapter extends RecyclerView.Adapter implements OnDateClickListener { + public static String DATE_FORMAT = "yyyy年MM月"; private boolean notify = true; private ColorScheme colorScheme = new ColorScheme(); private final List dates = new ArrayList<>(); @@ -198,7 +199,7 @@ public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public void onBindViewHolder(@NonNull VH holder, int position) { holder.titleView.setBackgroundColor(colorScheme.monthTitleBackgroundColor()); holder.titleView.setTextColor(colorScheme.monthTitleTextColor()); - holder.titleView.setText(TimeUtils.dateText(getDateValue(position).getTime(), TimeUtils.YY_M_CN)); + holder.titleView.setText(TimeUtils.dateText(getDateValue(position).getTime(), DATE_FORMAT)); holder.monthView.setOnDayInMonthClickListener(this); holder.monthView.setValue(MonthEntity.obtain(valid, select) .date(dates.get(position)) diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthEntity.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthEntity.java index b858baa8..0e2cc2d6 100644 --- a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthEntity.java +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthEntity.java @@ -22,10 +22,10 @@ * Created by peng on 2017/8/4. */ public class MonthEntity implements Serializable { - public static final int WEEK_DAYS = 7; - public static final int MAX_HORIZONTAL_LINES = 6; - public static final int MAX_DAYS_OF_MONTH = 31; - public static final String STR_TODAY = "今天"; + public static int WEEK_DAYS = 7; + public static int MAX_HORIZONTAL_LINES = 6; + public static int MAX_DAYS_OF_MONTH = 31; + public static String STR_TODAY = "今天"; private final static List pools = new ArrayList<>(); private Date date; private Interval valid; diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/TimeUtils.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/TimeUtils.java index 093eead2..ab5b84e7 100644 --- a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/TimeUtils.java +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/TimeUtils.java @@ -25,9 +25,6 @@ * 时间工具 */ public class TimeUtils { - public final static String YY_M_CN = "yyyy年MM月"; - public final static String YY_MD = "yyyy-MM-dd"; - private final static Map dateMap = new HashMap<>(); private static void ensureDateFormatMap(@NonNull String format) { @@ -45,7 +42,9 @@ public static Date date(String dateText, @NonNull String format) throws Exceptio ensureDateFormatMap(format); if (dateMap.containsKey(format)) { SimpleDateFormat sdf = dateMap.get(format); - return sdf.parse(dateText); + if (sdf != null) { + return sdf.parse(dateText); + } } return null; } @@ -55,7 +54,9 @@ public static String dateText(long date, @NonNull String format) { ensureDateFormatMap(format); if (dateMap.containsKey(format)) { SimpleDateFormat sdf = dateMap.get(format); - value = sdf.format(new Date(date)); + if (sdf != null) { + value = sdf.format(new Date(date)); + } } return value; } diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/WeekAdapter.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/WeekAdapter.java index eefdee37..67cc3aa0 100644 --- a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/WeekAdapter.java +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/WeekAdapter.java @@ -25,7 +25,7 @@ * @since 2021/9/17 14:36 */ public class WeekAdapter extends BaseAdapter { - private static final String[] DATA = new String[]{ + public static String[] DATA = new String[]{ "日", "一", "二", "三", "四", "五", "六" }; private ColorScheme colorScheme = new ColorScheme(); diff --git a/ChangeLog.md b/ChangeLog.md index 32698c4d..271f71a9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,11 @@ # 更新日志 +## 4.0.1 - 2021.10.28 + +- 基于最新版本的 Android Studio Arctic Fox 构建,Gradle 升级到最新的 7.x 版本; +- 文本国际化,支持定制多语言(默认为中文及英文); +- 手机号码前缀选择器数据完善,支持全球的国家及地区; + ## 4.0.0 - 2021.09.18 - 支持设置弹窗样式,内置四种弹窗模式,支持全局弹窗配色,效果请运行Demo; diff --git a/Common/src/main/java/com/github/gzuliyujiang/dialog/ModalDialog.java b/Common/src/main/java/com/github/gzuliyujiang/dialog/ModalDialog.java index d151a2aa..922855cc 100644 --- a/Common/src/main/java/com/github/gzuliyujiang/dialog/ModalDialog.java +++ b/Common/src/main/java/com/github/gzuliyujiang/dialog/ModalDialog.java @@ -30,6 +30,7 @@ import androidx.annotation.IntRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import androidx.annotation.StyleRes; import androidx.core.graphics.ColorUtils; @@ -239,6 +240,24 @@ public void onClick(View v) { protected abstract void onOk(); + @Override + public void setTitle(@Nullable CharSequence title) { + if (titleView == null) { + return; + } + titleView.post(new Runnable() { + @Override + public void run() { + titleView.setText(title); + } + }); + } + + @Override + public void setTitle(@StringRes int titleId) { + setTitle(activity.getString(titleId)); + } + public final void setBodyWidth(@Dimension(unit = Dimension.DP) @IntRange(from = 50) int bodyWidth) { ViewGroup.LayoutParams layoutParams = bodyView.getLayoutParams(); int width = WRAP_CONTENT; diff --git a/Common/src/main/res/layout/dialog_footer_style_1.xml b/Common/src/main/res/layout/dialog_footer_style_1.xml index ec71be05..ee4de15a 100644 --- a/Common/src/main/res/layout/dialog_footer_style_1.xml +++ b/Common/src/main/res/layout/dialog_footer_style_1.xml @@ -27,7 +27,7 @@ android:paddingTop="13dp" android:paddingBottom="13dp" android:singleLine="true" - android:text="@android:string/cancel" + android:text="@string/dialog_modal_cancel" android:textColor="#FF333333" android:textSize="15sp" /> @@ -46,7 +46,7 @@ android:paddingTop="13dp" android:paddingBottom="13dp" android:singleLine="true" - android:text="@android:string/ok" + android:text="@string/dialog_modal_ok" android:textColor="#FF333333" android:textSize="15sp" /> diff --git a/Common/src/main/res/layout/dialog_footer_style_2.xml b/Common/src/main/res/layout/dialog_footer_style_2.xml index 2aa93fa6..0c860ac8 100644 --- a/Common/src/main/res/layout/dialog_footer_style_2.xml +++ b/Common/src/main/res/layout/dialog_footer_style_2.xml @@ -27,7 +27,7 @@ android:paddingTop="13dp" android:paddingBottom="13dp" android:singleLine="true" - android:text="@android:string/ok" + android:text="@string/dialog_modal_ok" android:textColor="#FF333333" android:textSize="15sp" /> diff --git a/Common/src/main/res/layout/dialog_footer_style_3.xml b/Common/src/main/res/layout/dialog_footer_style_3.xml index 0b40cf19..66479b12 100644 --- a/Common/src/main/res/layout/dialog_footer_style_3.xml +++ b/Common/src/main/res/layout/dialog_footer_style_3.xml @@ -25,7 +25,7 @@ android:gravity="center" android:paddingTop="15dp" android:paddingBottom="15dp" - android:text="@android:string/cancel" + android:text="@string/dialog_modal_cancel" android:textColor="#FF333333" android:textSize="14sp" /> @@ -37,7 +37,7 @@ android:gravity="center" android:paddingTop="15dp" android:paddingBottom="15dp" - android:text="@android:string/ok" + android:text="@string/dialog_modal_ok" android:textColor="#FF333333" android:textSize="14sp" /> diff --git a/Common/src/main/res/layout/dialog_header_style_1.xml b/Common/src/main/res/layout/dialog_header_style_1.xml index 981e73a0..812867f6 100644 --- a/Common/src/main/res/layout/dialog_header_style_1.xml +++ b/Common/src/main/res/layout/dialog_header_style_1.xml @@ -22,7 +22,7 @@ android:paddingEnd="25dp" android:paddingBottom="15dp" android:singleLine="true" - android:text="温馨提示" + android:text="@string/dialog_modal_title" android:textColor="#FF666666" android:textSize="15sp" android:textStyle="bold" /> diff --git a/Common/src/main/res/layout/dialog_header_style_2.xml b/Common/src/main/res/layout/dialog_header_style_2.xml index bad50557..707f4ef9 100644 --- a/Common/src/main/res/layout/dialog_header_style_2.xml +++ b/Common/src/main/res/layout/dialog_header_style_2.xml @@ -27,7 +27,7 @@ android:paddingTop="15dp" android:paddingBottom="15dp" android:singleLine="true" - android:text="温馨提示" + android:text="@string/dialog_modal_title" android:textColor="#FF666666" android:textSize="15sp" android:textStyle="bold" /> diff --git a/Common/src/main/res/layout/dialog_header_style_3.xml b/Common/src/main/res/layout/dialog_header_style_3.xml index 981e73a0..812867f6 100644 --- a/Common/src/main/res/layout/dialog_header_style_3.xml +++ b/Common/src/main/res/layout/dialog_header_style_3.xml @@ -22,7 +22,7 @@ android:paddingEnd="25dp" android:paddingBottom="15dp" android:singleLine="true" - android:text="温馨提示" + android:text="@string/dialog_modal_title" android:textColor="#FF666666" android:textSize="15sp" android:textStyle="bold" /> diff --git a/Common/src/main/res/layout/dialog_header_style_default.xml b/Common/src/main/res/layout/dialog_header_style_default.xml index 5ced357c..e8674c39 100644 --- a/Common/src/main/res/layout/dialog_header_style_default.xml +++ b/Common/src/main/res/layout/dialog_header_style_default.xml @@ -25,7 +25,7 @@ android:paddingTop="15dp" android:paddingEnd="20dp" android:paddingBottom="15dp" - android:text="@android:string/cancel" + android:text="@string/dialog_modal_cancel" android:textColor="#FF333333" android:textSize="15sp" /> @@ -54,7 +54,7 @@ android:paddingTop="15dp" android:paddingEnd="20dp" android:paddingBottom="15dp" - android:text="@android:string/ok" + android:text="@string/dialog_modal_ok" android:textColor="#FF0081FF" android:textSize="15sp" /> diff --git a/Common/src/main/res/values-en/dialog_strings.xml b/Common/src/main/res/values-en/dialog_strings.xml new file mode 100644 index 00000000..3acc04c9 --- /dev/null +++ b/Common/src/main/res/values-en/dialog_strings.xml @@ -0,0 +1,20 @@ + + + + + Tips + OK + Cancel + + \ No newline at end of file diff --git a/Common/src/main/res/values/dialog_strings.xml b/Common/src/main/res/values/dialog_strings.xml new file mode 100644 index 00000000..b5b92fc4 --- /dev/null +++ b/Common/src/main/res/values/dialog_strings.xml @@ -0,0 +1,20 @@ + + + + + 温馨提示 + 确定 + 取消 + + \ No newline at end of file diff --git a/README.md b/README.md index 9d36f04d..3ea8a30c 100644 --- a/README.md +++ b/README.md @@ -124,14 +124,12 @@ dependencies { ## 用法示例 -常见用法请参阅 [demo](/app),高级用法请细读[源码](/WheelPicker), -诸如可以重写同名的`assets/china_address.json`来自定义省市区数据, 重写同名的`DialogSheetAnimation`来自定义弹窗动画……。 代码是最好的老师,强烈建议拉取代码运行,尝试修改 demo 对比查看实际效果以便加深理解。 +常见用法请参阅 [demo](/app),高级用法请细读[源码](/WheelPicker), 诸如可以重写同名的`assets/china_address.json`来自定义省市区数据, +重写同名的`DialogSheetAnimation`来自定义弹窗动画……。 代码是最好的老师,强烈建议拉取代码运行,尝试修改 demo 对比查看实际效果以便加深理解。 ### 在 Java 中 ```groovy -DialogConfig.setDialogStyle(DialogStyle.One); -... List data = new ArrayList<>(); data.add(new GoodsCategoryBean(1, "食品生鲜")); data.add(new GoodsCategoryBean(2, "家用电器")); @@ -157,14 +155,13 @@ picker.show(); ``` ```groovy -DialogConfig.setDialogStyle(DialogStyle.Default); -... DatePicker picker = new DatePicker(this); -picker.setBodyWidth(240); +//picker.setBodyWidth(240); DateWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY); -wheelLayout.setDateLabel("年", "月", "日"); -wheelLayout.setRange(DateEntity.today(), DateEntity.yearOnFuture(30), DateEntity.yearOnFuture(10)); +//wheelLayout.setDateLabel("年", "月", "日"); +wheelLayout.setDateFormatter(new UnitDateFormatter()); +wheelLayout.setRange(DateEntity.target(2021, 1, 1), DateEntity.target(2050, 12, 31), DateEntity.today()); wheelLayout.setCurtainEnabled(true); wheelLayout.setCurtainColor(0xFFCC0000); wheelLayout.setIndicatorEnabled(true); @@ -172,16 +169,13 @@ wheelLayout.setIndicatorColor(0xFFFF0000); wheelLayout.setIndicatorSize(view.getResources().getDisplayMetrics().density * 2); wheelLayout.setTextColor(0xCCCC0000); wheelLayout.setSelectedTextColor(0xFFFF0000); -wheelLayout.getYearLabelView().setTextColor(0xFF999999); -wheelLayout.getMonthLabelView().setTextColor(0xFF999999); -wheelLayout.getDayLabelView().setTextColor(0xFF999999); -picker.setOnDatePickedListener(this); +//wheelLayout.getYearLabelView().setTextColor(0xFF999999); +//wheelLayout.getMonthLabelView().setTextColor(0xFF999999); +//picker.setOnDatePickedListener(this); picker.show(); ``` ```groovy -DialogConfig.setDialogStyle(DialogStyle.Three); -... AddressPicker picker = new AddressPicker(this); picker.setAddressMode("city.json", AddressMode.PROVINCE_CITY_COUNTY, new AddressJsonParser.Builder() @@ -199,9 +193,10 @@ picker.setOnAddressPickedListener(this); picker.show(); ``` -### 在 XML 中 +### 在 XML 中 (可选) ```xml + @@ -228,7 +224,7 @@ picker.show(); ``` -### 定制样式 +### 定制样式(可选) #### 全局配置所有选择器样式及配色 @@ -325,6 +321,37 @@ public class AntFortuneLikePicker extends LinkagePicker { } ```` +### 国际化多语言(可选) + +在APP项目中重写以下字符串资源即可,具体名称可查看源代码: + +#### dialog_strings.xml + +```xml + + 温馨提示 + 确定 + 取消 + +``` +#### wheel_strings.xml + +```xml + +   + 日期选择 + 日期时间选择 + 时间选择 + 生日选择 + 车牌选择 +   + 手机号码前缀 + 民族选择 +   + 星座选择 + +``` + ## 效果预览 以下图片显示的效果可能已修改过,实际效果请运行 demo 查看。 diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/BirthdayPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/BirthdayPicker.java index a072003a..8a5dbe93 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/BirthdayPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/BirthdayPicker.java @@ -14,6 +14,7 @@ package com.github.gzuliyujiang.wheelpicker; import android.app.Activity; +import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; @@ -43,10 +44,15 @@ public BirthdayPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } + @Override + protected void initView(@NonNull View contentView) { + super.initView(contentView); + titleView.setText(R.string.wheel_birthday_title); + } + @Override protected void initData() { super.initData(); - titleView.setText("生日选择"); Calendar calendar = Calendar.getInstance(); int currentYear = calendar.get(Calendar.YEAR); int currentMonth = calendar.get(Calendar.MONTH) + 1; diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarNumberPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarPlatePicker.java similarity index 64% rename from WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarNumberPicker.java rename to WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarPlatePicker.java index d7ccc114..cb69ffb1 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarNumberPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarPlatePicker.java @@ -20,9 +20,9 @@ import androidx.annotation.StyleRes; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; -import com.github.gzuliyujiang.wheelpicker.contract.OnCarNumberPickedListener; +import com.github.gzuliyujiang.wheelpicker.contract.OnCarPlatePickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkagePickedListener; -import com.github.gzuliyujiang.wheelpicker.widget.CarNumberWheelLayout; +import com.github.gzuliyujiang.wheelpicker.widget.CarPlateWheelLayout; /** * 中国大陆车牌号滚轮选择 @@ -31,14 +31,14 @@ * @since 2016/12/18 10:47 */ @SuppressWarnings({"unused"}) -public class CarNumberPicker extends LinkagePicker { - private OnCarNumberPickedListener onCarNumberPickedListener; +public class CarPlatePicker extends LinkagePicker { + private OnCarPlatePickedListener onCarPlatePickedListener; - public CarNumberPicker(@NonNull Activity activity) { + public CarPlatePicker(@NonNull Activity activity) { super(activity); } - public CarNumberPicker(@NonNull Activity activity, @StyleRes int themeResId) { + public CarPlatePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @@ -51,34 +51,34 @@ public void setData(@NonNull LinkageProvider data) { @Deprecated @Override public void setOnLinkagePickedListener(OnLinkagePickedListener onLinkagePickedListener) { - throw new UnsupportedOperationException("Use setOnCarNumberPickedListener instead"); + throw new UnsupportedOperationException("Use setOnCarPlatePickedListener instead"); } @NonNull @Override protected View createBodyView() { - wheelLayout = new CarNumberWheelLayout(activity); + wheelLayout = new CarPlateWheelLayout(activity); return wheelLayout; } @Override - protected void initData() { - super.initData(); - titleView.setText("车牌选择"); + protected void initView(@NonNull View contentView) { + super.initView(contentView); + titleView.setText(R.string.wheel_car_plate_title); } @Override protected void onOk() { - if (onCarNumberPickedListener != null) { + if (onCarPlatePickedListener != null) { String province = wheelLayout.getFirstWheelView().getCurrentItem().toString(); String letter = wheelLayout.getSecondWheelView().getCurrentItem().toString(); - onCarNumberPickedListener.onCarNumberPicked(province, letter); + onCarPlatePickedListener.onCarNumberPicked(province, letter); } } - public void setOnCarNumberPickedListener(OnCarNumberPickedListener onCarNumberPickedListener) { - this.onCarNumberPickedListener = onCarNumberPickedListener; + public void setOnCarPlatePickedListener(OnCarPlatePickedListener onCarPlatePickedListener) { + this.onCarPlatePickedListener = onCarPlatePickedListener; } } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java index 057acc85..111f7a54 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import java.util.Locale; /** * 星座选择器 @@ -31,14 +30,6 @@ */ @SuppressWarnings("WeakerAccess") public class ConstellationPicker extends OptionPicker { - public static final List DATA_CN = Arrays.asList( - "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", - "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座" - ); - public static final List DATA_EN = Arrays.asList( - "Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", - "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn" - ); private final boolean includeUnlimited; public ConstellationPicker(Activity activity) { @@ -63,23 +54,15 @@ public ConstellationPicker(Activity activity, boolean includeUnlimited) { @Override protected void initData() { super.initData(); - titleView.setText("星座选择"); + titleView.setText(R.string.wheel_constellation_title); } @Override protected List provideData() { - boolean isChinese = Locale.getDefault().getDisplayLanguage().contains("中文"); - LinkedList data = new LinkedList<>(); - if (isChinese) { - data.addAll(DATA_CN); - if (includeUnlimited) { - data.addFirst("不限"); - } - } else { - data.addAll(DATA_EN); - if (includeUnlimited) { - data.addFirst("Unlimited"); - } + String[] array = activity.getResources().getStringArray(R.array.wheel_constellation_value); + LinkedList data = new LinkedList<>(Arrays.asList(array)); + if (includeUnlimited) { + data.addFirst(activity.getString(R.string.wheel_constellation_secrecy)); } return data; } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatePicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatePicker.java index c00c39df..e663f3e3 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatePicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatePicker.java @@ -57,7 +57,7 @@ protected void initView(@NonNull View contentView) { @Override protected void initData() { super.initData(); - titleView.setText("日期选择"); + titleView.setText(R.string.wheel_date_title); } @Override diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatimePicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatimePicker.java index 12cd0a0d..6790373f 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatimePicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatimePicker.java @@ -52,7 +52,7 @@ protected View createBodyView() { @Override protected void initData() { super.initData(); - titleView.setText("日期时间选择"); + titleView.setText(R.string.wheel_datime_title); } @Override diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java index a01bf544..419ea7b2 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java @@ -36,7 +36,7 @@ */ @SuppressWarnings({"WeakerAccess", "unused"}) public class EthnicPicker extends OptionPicker { - public static final String JSON = "[{\"code\":\"01\",\"name\":\"汉族\",\"spelling\":\"Han\"}," + + public static String JSON = "[{\"code\":\"01\",\"name\":\"汉族\",\"spelling\":\"Han\"}," + "{\"code\":\"02\",\"name\":\"蒙古族\",\"spelling\":\"Mongol\"}," + "{\"code\":\"03\",\"name\":\"回族\",\"spelling\":\"Hui\"}," + "{\"code\":\"04\",\"name\":\"藏族\",\"spelling\":\"Zang\"}," + @@ -105,7 +105,7 @@ public EthnicPicker(@NonNull Activity activity, int themeResId) { @Override protected void initData() { super.initData(); - titleView.setText("民族选择"); + titleView.setText(R.string.wheel_ethnic_title); } public void setEthnicSpec(@EthnicSpec int ethnicSpec) { diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/LinkagePicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/LinkagePicker.java index 737f04a0..82f71caf 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/LinkagePicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/LinkagePicker.java @@ -60,7 +60,7 @@ protected View createBodyView() { @Override protected void initData() { super.initData(); - titleView.setText("请选择"); + titleView.setText(R.string.wheel_linkage_title); } @Override diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/NumberPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/NumberPicker.java index d1ce9e42..c3b115b5 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/NumberPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/NumberPicker.java @@ -53,9 +53,9 @@ protected View createBodyView() { } @Override - protected void initData() { - super.initData(); - titleView.setText("请选择"); + protected void initView(@NonNull View contentView) { + super.initView(contentView); + titleView.setText(R.string.wheel_number_title); } @Override diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/OptionPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/OptionPicker.java index 1b6c8717..f5f1af81 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/OptionPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/OptionPicker.java @@ -77,7 +77,7 @@ protected void onOk() { protected void initData() { super.initData(); initialized = true; - titleView.setText("请选择"); + titleView.setText(R.string.wheel_option_title); if (data == null || data.size() == 0) { data = provideData(); } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java index 5b8d674e..bd5ad7ab 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java @@ -18,8 +18,13 @@ import androidx.annotation.NonNull; import androidx.annotation.StyleRes; +import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.wheelpicker.entity.PhoneCodeEntity; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + import java.util.ArrayList; import java.util.List; @@ -31,6 +36,219 @@ */ @SuppressWarnings("unused") public class PhoneCodePicker extends OptionPicker { + public static String JSON = "[{\"prefix\":\"1\",\"en\":\"USA\",\"cn\":\"美国\"},\n" + + "{\"prefix\":\"1\",\"en\":\"PuertoRico\",\"cn\":\"波多黎各\"},\n" + + "{\"prefix\":\"1\",\"en\":\"Canada\",\"cn\":\"加拿大\"},\n" + + "{\"prefix\":\"7\",\"en\":\"Russia\",\"cn\":\"俄罗斯\"},\n" + + "{\"prefix\":\"7\",\"en\":\"Kazeakhstan\",\"cn\":\"哈萨克斯坦\"},\n" + + "{\"prefix\":\"20\",\"en\":\"Egypt\",\"cn\":\"埃及\"},\n" + + "{\"prefix\":\"27\",\"en\":\"South Africa\",\"cn\":\"南非\"},\n" + + "{\"prefix\":\"30\",\"en\":\"Greece\",\"cn\":\"希腊\"},\n" + + "{\"prefix\":\"31\",\"en\":\"Netherlands\",\"cn\":\"荷兰\"},\n" + + "{\"prefix\":\"32\",\"en\":\"Belgium\",\"cn\":\"比利时\"},\n" + + "{\"prefix\":\"33\",\"en\":\"France\",\"cn\":\"法国\"},\n" + + "{\"prefix\":\"34\",\"en\":\"Spain\",\"cn\":\"西班牙\"},\n" + + "{\"prefix\":\"36\",\"en\":\"Hungary\",\"cn\":\"匈牙利\"},\n" + + "{\"prefix\":\"40\",\"en\":\"Romania\",\"cn\":\"罗马尼亚\"},\n" + + "{\"prefix\":\"41\",\"en\":\"Switzerland\",\"cn\":\"瑞士\"},\n" + + "{\"prefix\":\"43\",\"en\":\"Austria\",\"cn\":\"奥地利\"},\n" + + "{\"prefix\":\"44\",\"en\":\"United Kingdom\",\"cn\":\"英国\"},\n" + + "{\"prefix\":\"44\",\"en\":\"Jersey\",\"cn\":\"泽西岛\"},\n" + + "{\"prefix\":\"44\",\"en\":\"Isle of Man\",\"cn\":\"马恩岛\"},\n" + + "{\"prefix\":\"44\",\"en\":\"Guernsey\",\"cn\":\"根西\"},\n" + + "{\"prefix\":\"45\",\"en\":\"Denmark\",\"cn\":\"丹麦\"},\n" + + "{\"prefix\":\"46\",\"en\":\"Sweden\",\"cn\":\"瑞典\"},\n" + + "{\"prefix\":\"47\",\"en\":\"Norway\",\"cn\":\"挪威\"},\n" + + "{\"prefix\":\"48\",\"en\":\"Poland\",\"cn\":\"波兰\"},\n" + + "{\"prefix\":\"51\",\"en\":\"Peru\",\"cn\":\"秘鲁\"},\n" + + "{\"prefix\":\"52\",\"en\":\"Mexico\",\"cn\":\"墨西哥\"},\n" + + "{\"prefix\":\"53\",\"en\":\"Cuba\",\"cn\":\"古巴\"},\n" + + "{\"prefix\":\"54\",\"en\":\"Argentina\",\"cn\":\"阿根廷\"},\n" + + "{\"prefix\":\"55\",\"en\":\"Brazill\",\"cn\":\"巴西\"},\n" + + "{\"prefix\":\"56\",\"en\":\"Chile\",\"cn\":\"智利\"},\n" + + "{\"prefix\":\"57\",\"en\":\"Colombia\",\"cn\":\"哥伦比亚\"},\n" + + "{\"prefix\":\"58\",\"en\":\"Venezuela\",\"cn\":\"委内瑞拉\"},\n" + + "{\"prefix\":\"60\",\"en\":\"Malaysia\",\"cn\":\"马来西亚\"},\n" + + "{\"prefix\":\"61\",\"en\":\"Australia\",\"cn\":\"澳大利亚\"},\n" + + "{\"prefix\":\"62\",\"en\":\"Indonesia\",\"cn\":\"印度尼西亚\"},\n" + + "{\"prefix\":\"63\",\"en\":\"Philippines\",\"cn\":\"菲律宾\"},\n" + + "{\"prefix\":\"64\",\"en\":\"NewZealand\",\"cn\":\"新西兰\"},\n" + + "{\"prefix\":\"65\",\"en\":\"Singapore\",\"cn\":\"新加坡\"},\n" + + "{\"prefix\":\"66\",\"en\":\"Thailand\",\"cn\":\"泰国\"},\n" + + "{\"prefix\":\"81\",\"en\":\"Japan\",\"cn\":\"日本\"},\n" + + "{\"prefix\":\"82\",\"en\":\"Korea\",\"cn\":\"韩国\"},\n" + + "{\"prefix\":\"84\",\"en\":\"Vietnam\",\"cn\":\"越南\"},\n" + + "{\"prefix\":\"86\",\"en\":\"China\",\"cn\":\"中国\"},\n" + + "{\"prefix\":\"90\",\"en\":\"Turkey\",\"cn\":\"土耳其\"},\n" + + "{\"prefix\":\"91\",\"en\":\"Indea\",\"cn\":\"印度\"},\n" + + "{\"prefix\":\"92\",\"en\":\"Pakistan\",\"cn\":\"巴基斯坦\"},\n" + + "{\"prefix\":\"93\",\"en\":\"Italy\",\"cn\":\"意大利\"},\n" + + "{\"prefix\":\"93\",\"en\":\"Afghanistan\",\"cn\":\"阿富汗\"},\n" + + "{\"prefix\":\"94\",\"en\":\"SriLanka\",\"cn\":\"斯里兰卡\"},\n" + + "{\"prefix\":\"94\",\"en\":\"Germany\",\"cn\":\"德国\"},\n" + + "{\"prefix\":\"95\",\"en\":\"Myanmar\",\"cn\":\"缅甸\"},\n" + + "{\"prefix\":\"98\",\"en\":\"Iran\",\"cn\":\"伊朗\"},\n" + + "{\"prefix\":\"212\",\"en\":\"Morocco\",\"cn\":\"摩洛哥\"},\n" + + "{\"prefix\":\"213\",\"en\":\"Algera\",\"cn\":\"阿尔格拉\"},\n" + + "{\"prefix\":\"216\",\"en\":\"Tunisia\",\"cn\":\"突尼斯\"},\n" + + "{\"prefix\":\"218\",\"en\":\"Libya\",\"cn\":\"利比亚\"},\n" + + "{\"prefix\":\"220\",\"en\":\"Gambia\",\"cn\":\"冈比亚\"},\n" + + "{\"prefix\":\"221\",\"en\":\"Senegal\",\"cn\":\"塞内加尔\"},\n" + + "{\"prefix\":\"222\",\"en\":\"Mauritania\",\"cn\":\"毛里塔尼亚\"},\n" + + "{\"prefix\":\"223\",\"en\":\"Mali\",\"cn\":\"马里\"},\n" + + "{\"prefix\":\"224\",\"en\":\"Guinea\",\"cn\":\"几内亚\"},\n" + + "{\"prefix\":\"225\",\"en\":\"Cote divoire\",\"cn\":\"科特迪沃\"},\n" + + "{\"prefix\":\"226\",\"en\":\"Burkina Faso\",\"cn\":\"布基纳法索\"},\n" + + "{\"prefix\":\"227\",\"en\":\"Niger\",\"cn\":\"尼日尔\"},\n" + + "{\"prefix\":\"228\",\"en\":\"Togo\",\"cn\":\"多哥\"},\n" + + "{\"prefix\":\"229\",\"en\":\"Benin\",\"cn\":\"贝宁\"},\n" + + "{\"prefix\":\"230\",\"en\":\"Mauritius\",\"cn\":\"毛里求斯\"},\n" + + "{\"prefix\":\"231\",\"en\":\"Liberia\",\"cn\":\"利比里亚\"},\n" + + "{\"prefix\":\"232\",\"en\":\"Sierra Leone\",\"cn\":\"塞拉利昂\"},\n" + + "{\"prefix\":\"233\",\"en\":\"Ghana\",\"cn\":\"加纳\"},\n" + + "{\"prefix\":\"234\",\"en\":\"Nigeria\",\"cn\":\"尼日利亚\"},\n" + + "{\"prefix\":\"235\",\"en\":\"Chad\",\"cn\":\"乍得\"},\n" + + "{\"prefix\":\"236\",\"en\":\"Central African Republic\",\"cn\":\"中非共和国\"},\n" + + "{\"prefix\":\"237\",\"en\":\"Cameroon\",\"cn\":\"喀麦隆\"},\n" + + "{\"prefix\":\"238\",\"en\":\"Cape Verde\",\"cn\":\"佛得角\"},\n" + + "{\"prefix\":\"239\",\"en\":\"Sao Tome and Principe\",\"cn\":\"圣多美和普林西比\"},\n" + + "{\"prefix\":\"240\",\"en\":\"Guinea\",\"cn\":\"几内亚\"},\n" + + "{\"prefix\":\"241\",\"en\":\"Gabon\",\"cn\":\"加蓬\"},\n" + + "{\"prefix\":\"242\",\"en\":\"Republic of the Congo\",\"cn\":\"刚果共和国\"},\n" + + "{\"prefix\":\"243\",\"en\":\"Democratic Republic of the Congo\",\"cn\":\"刚果民主共和国\"},\n" + + "{\"prefix\":\"244\",\"en\":\"Angola\",\"cn\":\"安哥拉\"},\n" + + "{\"prefix\":\"247\",\"en\":\"Ascension\",\"cn\":\"阿森松岛\"},\n" + + "{\"prefix\":\"248\",\"en\":\"Seychelles\",\"cn\":\"塞舌尔\"},\n" + + "{\"prefix\":\"249\",\"en\":\"Sudan\",\"cn\":\"苏丹\"},\n" + + "{\"prefix\":\"250\",\"en\":\"Rwanda\",\"cn\":\"卢旺达\"},\n" + + "{\"prefix\":\"251\",\"en\":\"Ethiopia\",\"cn\":\"埃塞俄比亚\"},\n" + + "{\"prefix\":\"253\",\"en\":\"Djibouti\",\"cn\":\"吉布提\"},\n" + + "{\"prefix\":\"254\",\"en\":\"Kenya\",\"cn\":\"肯尼亚\"},\n" + + "{\"prefix\":\"255\",\"en\":\"Tanzania\",\"cn\":\"坦桑尼亚\"},\n" + + "{\"prefix\":\"256\",\"en\":\"Uganda\",\"cn\":\"乌干达\"},\n" + + "{\"prefix\":\"257\",\"en\":\"Burundi\",\"cn\":\"布隆迪\"},\n" + + "{\"prefix\":\"258\",\"en\":\"Mozambique\",\"cn\":\"莫桑比克\"},\n" + + "{\"prefix\":\"260\",\"en\":\"Zambia\",\"cn\":\"赞比亚\"},\n" + + "{\"prefix\":\"261\",\"en\":\"Madagascar\",\"cn\":\"马达加斯加\"},\n" + + "{\"prefix\":\"262\",\"en\":\"Reunion\",\"cn\":\"留尼汪\"},\n" + + "{\"prefix\":\"262\",\"en\":\"Mayotte\",\"cn\":\"马约特\"},\n" + + "{\"prefix\":\"263\",\"en\":\"Zimbabwe\",\"cn\":\"津巴布韦\"},\n" + + "{\"prefix\":\"264\",\"en\":\"Namibia\",\"cn\":\"纳米比亚\"},\n" + + "{\"prefix\":\"265\",\"en\":\"Malawi\",\"cn\":\"马拉维\"},\n" + + "{\"prefix\":\"266\",\"en\":\"Lesotho\",\"cn\":\"莱索托\"},\n" + + "{\"prefix\":\"267\",\"en\":\"Botwana\",\"cn\":\"博茨瓦纳\"},\n" + + "{\"prefix\":\"268\",\"en\":\"Swaziland\",\"cn\":\"斯威士兰\"},\n" + + "{\"prefix\":\"269\",\"en\":\"Comoros\",\"cn\":\"科摩罗\"},\n" + + "{\"prefix\":\"297\",\"en\":\"Aruba\",\"cn\":\"阿鲁巴\"},\n" + + "{\"prefix\":\"298\",\"en\":\"Faroe Islands\",\"cn\":\"法罗群岛\"},\n" + + "{\"prefix\":\"299\",\"en\":\"Greenland\",\"cn\":\"格陵兰\"},\n" + + "{\"prefix\":\"350\",\"en\":\"Gibraltar\",\"cn\":\"直布罗陀\"},\n" + + "{\"prefix\":\"351\",\"en\":\"Portugal\",\"cn\":\"葡萄牙\"},\n" + + "{\"prefix\":\"352\",\"en\":\"Luxembourg\",\"cn\":\"卢森堡\"},\n" + + "{\"prefix\":\"353\",\"en\":\"Ireland\",\"cn\":\"爱尔兰\"},\n" + + "{\"prefix\":\"354\",\"en\":\"Iceland\",\"cn\":\"冰岛\"},\n" + + "{\"prefix\":\"355\",\"en\":\"Albania\",\"cn\":\"阿尔巴尼亚\"},\n" + + "{\"prefix\":\"356\",\"en\":\"Malta\",\"cn\":\"马耳他\"},\n" + + "{\"prefix\":\"357\",\"en\":\"Cyprus\",\"cn\":\"塞浦路斯\"},\n" + + "{\"prefix\":\"358\",\"en\":\"Finland\",\"cn\":\"芬兰\"},\n" + + "{\"prefix\":\"359\",\"en\":\"Bulgaria\",\"cn\":\"保加利亚\"},\n" + + "{\"prefix\":\"370\",\"en\":\"Lithuania\",\"cn\":\"立陶宛\"},\n" + + "{\"prefix\":\"371\",\"en\":\"Latvia\",\"cn\":\"拉脱维亚\"},\n" + + "{\"prefix\":\"372\",\"en\":\"Estonia\",\"cn\":\"爱沙尼亚\"},\n" + + "{\"prefix\":\"373\",\"en\":\"Moldova\",\"cn\":\"摩尔多瓦\"},\n" + + "{\"prefix\":\"374\",\"en\":\"Armenia\",\"cn\":\"亚美尼亚\"},\n" + + "{\"prefix\":\"375\",\"en\":\"Belarus\",\"cn\":\"白俄罗斯\"},\n" + + "{\"prefix\":\"376\",\"en\":\"Andorra\",\"cn\":\"安道尔\"},\n" + + "{\"prefix\":\"377\",\"en\":\"Monaco\",\"cn\":\"摩纳哥\"},\n" + + "{\"prefix\":\"378\",\"en\":\"San Marino\",\"cn\":\"圣马力诺\"},\n" + + "{\"prefix\":\"380\",\"en\":\"Ukraine\",\"cn\":\"乌克兰\"},\n" + + "{\"prefix\":\"381\",\"en\":\"Serbia\",\"cn\":\"塞尔维亚\"},\n" + + "{\"prefix\":\"382\",\"en\":\"Montenegro\",\"cn\":\"黑山\"},\n" + + "{\"prefix\":\"383\",\"en\":\"Kosovo\",\"cn\":\"科索沃\"},\n" + + "{\"prefix\":\"385\",\"en\":\"Croatia\",\"cn\":\"克罗地亚\"},\n" + + "{\"prefix\":\"386\",\"en\":\"Slovenia\",\"cn\":\"斯洛文尼亚\"},\n" + + "{\"prefix\":\"387\",\"en\":\"Bosnia and Herzegovina\",\"cn\":\"波斯尼亚和黑塞哥维那\"},\n" + + "{\"prefix\":\"389\",\"en\":\"Macedonia\",\"cn\":\"马其顿\"},\n" + + "{\"prefix\":\"420\",\"en\":\"Czech Republic\",\"cn\":\"捷克共和国\"},\n" + + "{\"prefix\":\"421\",\"en\":\"Slovakia\",\"cn\":\"斯洛伐克\"},\n" + + "{\"prefix\":\"423\",\"en\":\"Liechtenstein\",\"cn\":\"列支敦士登\"},\n" + + "{\"prefix\":\"501\",\"en\":\"Belize\",\"cn\":\"伯利兹\"},\n" + + "{\"prefix\":\"502\",\"en\":\"Guatemala\",\"cn\":\"危地马拉\"},\n" + + "{\"prefix\":\"503\",\"en\":\"EISalvador\",\"cn\":\"艾萨尔瓦多\"},\n" + + "{\"prefix\":\"504\",\"en\":\"Honduras\",\"cn\":\"洪都拉斯\"},\n" + + "{\"prefix\":\"505\",\"en\":\"Nicaragua\",\"cn\":\"尼加拉瓜\"},\n" + + "{\"prefix\":\"506\",\"en\":\"Costa Rica\",\"cn\":\"哥斯达黎加\"},\n" + + "{\"prefix\":\"507\",\"en\":\"Panama\",\"cn\":\"巴拿马\"},\n" + + "{\"prefix\":\"509\",\"en\":\"Haiti\",\"cn\":\"海地\"},\n" + + "{\"prefix\":\"590\",\"en\":\"Guadeloupe\",\"cn\":\"瓜德罗普\"},\n" + + "{\"prefix\":\"591\",\"en\":\"Bolivia\",\"cn\":\"玻利维亚\"},\n" + + "{\"prefix\":\"592\",\"en\":\"Guyana\",\"cn\":\"圭亚那\"},\n" + + "{\"prefix\":\"593\",\"en\":\"Ecuador\",\"cn\":\"厄瓜多尔\"},\n" + + "{\"prefix\":\"594\",\"en\":\"French Guiana\",\"cn\":\"法属圭亚那\"},\n" + + "{\"prefix\":\"595\",\"en\":\"Paraguay\",\"cn\":\"巴拉圭\"},\n" + + "{\"prefix\":\"596\",\"en\":\"Martinique\",\"cn\":\"马提尼克\"},\n" + + "{\"prefix\":\"597\",\"en\":\"Suriname\",\"cn\":\"苏里南\"},\n" + + "{\"prefix\":\"598\",\"en\":\"Uruguay\",\"cn\":\"乌拉圭\"},\n" + + "{\"prefix\":\"599\",\"en\":\"Netherlands Antillse\",\"cn\":\"荷属安的列斯\"},\n" + + "{\"prefix\":\"670\",\"en\":\"Timor Leste\",\"cn\":\"东帝汶\"},\n" + + "{\"prefix\":\"673\",\"en\":\"Brunei\",\"cn\":\"文莱\"},\n" + + "{\"prefix\":\"675\",\"en\":\"Papua New Guinea\",\"cn\":\"巴布亚新几内亚\"},\n" + + "{\"prefix\":\"676\",\"en\":\"Tonga\",\"cn\":\"汤加\"},\n" + + "{\"prefix\":\"678\",\"en\":\"Vanuatu\",\"cn\":\"瓦努阿图\"},\n" + + "{\"prefix\":\"679\",\"en\":\"Fiji\",\"cn\":\"斐济\"},\n" + + "{\"prefix\":\"682\",\"en\":\"Cook Islands\",\"cn\":\"库克群岛\"},\n" + + "{\"prefix\":\"684\",\"en\":\"Samoa Eastern\",\"cn\":\"萨摩亚东部\"},\n" + + "{\"prefix\":\"685\",\"en\":\"Samoa Western\",\"cn\":\"萨摩亚西部\"},\n" + + "{\"prefix\":\"687\",\"en\":\"New Caledonia\",\"cn\":\"新喀里多尼亚\"},\n" + + "{\"prefix\":\"689\",\"en\":\"French Polynesia\",\"cn\":\"法属波利尼西亚\"},\n" + + "{\"prefix\":\"852\",\"en\":\"Hong Kong\",\"cn\":\"香港\"},\n" + + "{\"prefix\":\"853\",\"en\":\"Macao\",\"cn\":\"澳门\"},\n" + + "{\"prefix\":\"855\",\"en\":\"Cambodia\",\"cn\":\"柬埔寨\"},\n" + + "{\"prefix\":\"856\",\"en\":\"Laos\",\"cn\":\"老挝\"},\n" + + "{\"prefix\":\"880\",\"en\":\"Bangladesh\",\"cn\":\"孟加拉国\"},\n" + + "{\"prefix\":\"886\",\"en\":\"Taiwan\",\"cn\":\"台湾\"},\n" + + "{\"prefix\":\"960\",\"en\":\"Maldives\",\"cn\":\"马尔代夫\"},\n" + + "{\"prefix\":\"961\",\"en\":\"Lebanon\",\"cn\":\"黎巴嫩\"},\n" + + "{\"prefix\":\"962\",\"en\":\"Jordan\",\"cn\":\"约旦\"},\n" + + "{\"prefix\":\"963\",\"en\":\"Syria\",\"cn\":\"叙利亚\"},\n" + + "{\"prefix\":\"964\",\"en\":\"Iraq\",\"cn\":\"伊拉克\"},\n" + + "{\"prefix\":\"965\",\"en\":\"Kuwait\",\"cn\":\"科威特\"},\n" + + "{\"prefix\":\"966\",\"en\":\"Saudi Arabia\",\"cn\":\"沙特阿拉伯\"},\n" + + "{\"prefix\":\"967\",\"en\":\"Yemen\",\"cn\":\"也门\"},\n" + + "{\"prefix\":\"968\",\"en\":\"Oman\",\"cn\":\"阿曼\"},\n" + + "{\"prefix\":\"970\",\"en\":\"Palestinian\",\"cn\":\"巴勒斯坦\"},\n" + + "{\"prefix\":\"971\",\"en\":\"United Arab Emirates\",\"cn\":\"阿拉伯联合酋长国\"},\n" + + "{\"prefix\":\"972\",\"en\":\"Israel\",\"cn\":\"以色列\"},\n" + + "{\"prefix\":\"973\",\"en\":\"Bahrain\",\"cn\":\"巴林\"},\n" + + "{\"prefix\":\"974\",\"en\":\"Qotar\",\"cn\":\"库塔\"},\n" + + "{\"prefix\":\"975\",\"en\":\"Bhutan\",\"cn\":\"不丹\"},\n" + + "{\"prefix\":\"976\",\"en\":\"Mongolia\",\"cn\":\"蒙古\"},\n" + + "{\"prefix\":\"977\",\"en\":\"Nepal\",\"cn\":\"尼泊尔\"},\n" + + "{\"prefix\":\"992\",\"en\":\"Tajikistan\",\"cn\":\"塔吉克斯坦\"},\n" + + "{\"prefix\":\"993\",\"en\":\"Turkmenistan\",\"cn\":\"土库曼斯坦\"},\n" + + "{\"prefix\":\"994\",\"en\":\"Azerbaijan\",\"cn\":\"阿塞拜疆\"},\n" + + "{\"prefix\":\"995\",\"en\":\"Georgia\",\"cn\":\"格鲁吉亚\"},\n" + + "{\"prefix\":\"996\",\"en\":\"Kyrgyzstan\",\"cn\":\"吉尔吉斯斯坦\"},\n" + + "{\"prefix\":\"998\",\"en\":\"Uzbekistan\",\"cn\":\"乌兹别克斯坦\"},\n" + + "{\"prefix\":\"1242\",\"en\":\"Bahamas\",\"cn\":\"巴哈马\"},\n" + + "{\"prefix\":\"1246\",\"en\":\"Barbados\",\"cn\":\"巴巴多斯\"},\n" + + "{\"prefix\":\"1264\",\"en\":\"Anguilla\",\"cn\":\"安圭拉\"},\n" + + "{\"prefix\":\"1268\",\"en\":\"Antigua and Barbuda\",\"cn\":\"安提瓜和巴布达\"},\n" + + "{\"prefix\":\"1340\",\"en\":\"Virgin Islands\",\"cn\":\"维尔京群岛\"},\n" + + "{\"prefix\":\"1345\",\"en\":\"Cayman Islands\",\"cn\":\"开曼群岛\"},\n" + + "{\"prefix\":\"1441\",\"en\":\"Bermuda\",\"cn\":\"百慕大\"},\n" + + "{\"prefix\":\"1473\",\"en\":\"Grenada\",\"cn\":\"格林纳达\"},\n" + + "{\"prefix\":\"1649\",\"en\":\"Turks and Caicos Islands\",\"cn\":\"特克斯和凯科斯群岛\"},\n" + + "{\"prefix\":\"1664\",\"en\":\"Montserrat\",\"cn\":\"蒙特塞拉特\"},\n" + + "{\"prefix\":\"1671\",\"en\":\"Guam\",\"cn\":\"关岛\"},\n" + + "{\"prefix\":\"1758\",\"en\":\"St.Lucia\",\"cn\":\"圣卢西亚\"},\n" + + "{\"prefix\":\"1767\",\"en\":\"Dominica\",\"cn\":\"多米尼加\"},\n" + + "{\"prefix\":\"1784\",\"en\":\"St.Vincent\",\"cn\":\"圣文森特\"},\n" + + "{\"prefix\":\"1809\",\"en\":\"Dominican Republic\",\"cn\":\"多米尼加共和国\"},\n" + + "{\"prefix\":\"1868\",\"en\":\"Trinidad and Tobago\",\"cn\":\"特立尼达和多巴哥\"},\n" + + "{\"prefix\":\"1869\",\"en\":\"St Kitts and Nevis\",\"cn\":\"圣基茨和尼维斯\"},\n" + + "{\"prefix\":\"1876\",\"en\":\"Jamaica\",\"cn\":\"牙买加\"}]"; + private boolean onlyChina = false; public PhoneCodePicker(@NonNull Activity activity) { super(activity); @@ -40,19 +258,74 @@ public PhoneCodePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } + public void setOnlyChina(boolean onlyChina) { + this.onlyChina = onlyChina; + setData(provideData()); + } + + public void setDefaultValueByCode(String code) { + PhoneCodeEntity entity = new PhoneCodeEntity(); + entity.setCode(code); + setDefaultValue(entity); + } + + public void setDefaultValueByName(String name) { + PhoneCodeEntity entity = new PhoneCodeEntity(); + entity.setName(name); + setDefaultValue(entity); + } + + public void setDefaultValueByEnglish(String english) { + PhoneCodeEntity entity = new PhoneCodeEntity(); + entity.setEnglish(english); + setDefaultValue(entity); + } + @Override protected void initData() { super.initData(); - titleView.setText("请选择"); + titleView.setText(R.string.wheel_phone_code_title); } @Override protected List provideData() { List data = new ArrayList<>(); - data.add(new PhoneCodeEntity("大陆+86", "+86")); - data.add(new PhoneCodeEntity("香港+852", "+852")); - data.add(new PhoneCodeEntity("澳门+853", "+853")); - data.add(new PhoneCodeEntity("台湾+886", "+886")); + if (onlyChina) { + PhoneCodeEntity china = new PhoneCodeEntity(); + china.setCode("+86"); + china.setName("中国大陆+86"); + china.setEnglish("Chinese Mainland"); + data.add(china); + PhoneCodeEntity hongKong = new PhoneCodeEntity(); + hongKong.setCode("+852"); + hongKong.setName("香港+852"); + hongKong.setEnglish("Hong Kong"); + data.add(hongKong); + PhoneCodeEntity macao = new PhoneCodeEntity(); + macao.setCode("+853"); + macao.setName("澳门+853"); + macao.setEnglish("Macao"); + data.add(macao); + PhoneCodeEntity taiwan = new PhoneCodeEntity(); + taiwan.setCode("+886"); + taiwan.setName("台湾+886"); + taiwan.setEnglish("Taiwan"); + data.add(taiwan); + } else { + try { + JSONArray jsonArray = new JSONArray(JSON); + for (int i = 0, n = jsonArray.length(); i < n; i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + PhoneCodeEntity entity = new PhoneCodeEntity(); + entity.setCode("+" + jsonObject.getString("prefix")); + entity.setName(jsonObject.getString("cn")); + entity.setEnglish(jsonObject.getString("en")); + data.add(entity); + } + } catch (JSONException e) { + DialogLog.print(e); + } + } return data; } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java index ae028578..cfd046fc 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import java.util.Locale; /** * 性别选择器 @@ -31,12 +30,6 @@ */ @SuppressWarnings("WeakerAccess") public class SexPicker extends OptionPicker { - public static final List DATA_CN = Arrays.asList( - "男", "女" - ); - public static final List DATA_EN = Arrays.asList( - "Male", "Female" - ); private final boolean includeSecrecy; public SexPicker(Activity activity) { @@ -61,23 +54,15 @@ public SexPicker(@NonNull Activity activity, @StyleRes int themeResId, boolean i @Override protected void initData() { super.initData(); - titleView.setText("性别选择"); + titleView.setText(R.string.wheel_sex_title); } @Override protected List provideData() { - boolean isChinese = Locale.getDefault().getDisplayLanguage().contains("中文"); - LinkedList data = new LinkedList<>(); - if (isChinese) { - data.addAll(DATA_CN); - if (includeSecrecy) { - data.addFirst("保密"); - } - } else { - data.addAll(DATA_EN); - if (includeSecrecy) { - data.addFirst("Unlimited"); - } + String[] array = activity.getResources().getStringArray(R.array.wheel_sex_value); + LinkedList data = new LinkedList<>(Arrays.asList(array)); + if (includeSecrecy) { + data.addFirst(activity.getString(R.string.wheel_sex_secrecy)); } return data; } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/TimePicker.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/TimePicker.java index 8e9554c1..afdf7871 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/TimePicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/TimePicker.java @@ -59,7 +59,7 @@ protected void initView(@NonNull View contentView) { @Override protected void initData() { super.initData(); - titleView.setText("时间选择"); + titleView.setText(R.string.wheel_time_title); } @Override diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarNumberPickedListener.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarPlatePickedListener.java similarity index 94% rename from WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarNumberPickedListener.java rename to WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarPlatePickedListener.java index bbd9bf33..7f0a69a1 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarNumberPickedListener.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarPlatePickedListener.java @@ -17,7 +17,7 @@ * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/9 11:53 */ -public interface OnCarNumberPickedListener { +public interface OnCarPlatePickedListener { void onCarNumberPicked(String province, String letter); diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/EthnicEntity.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/EthnicEntity.java index f7ff4250..2dd65eb7 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/EthnicEntity.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/EthnicEntity.java @@ -26,13 +26,13 @@ * @since 2021/6/12 15:05 */ public class EthnicEntity implements TextProvider, Serializable { - private static final boolean CHINESE; + private static final boolean IS_CHINESE; private String code; private String name; private String spelling; static { - CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); + IS_CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); } public String getCode() { @@ -61,7 +61,7 @@ public void setSpelling(String spelling) { @Override public String provideText() { - if (CHINESE) { + if (IS_CHINESE) { return name; } return spelling; diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/PhoneCodeEntity.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/PhoneCodeEntity.java index e05f5787..a1647223 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/PhoneCodeEntity.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/PhoneCodeEntity.java @@ -18,17 +18,28 @@ import com.github.gzuliyujiang.wheelview.contract.TextProvider; import java.io.Serializable; +import java.util.Locale; +import java.util.Objects; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/3 16:27 */ public class PhoneCodeEntity implements TextProvider, Serializable { - private String name; + private static final boolean IS_CHINESE; private String code; + private String name; + private String english; - public PhoneCodeEntity(String name, String code) { - this.name = name; + static { + IS_CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { this.code = code; } @@ -40,25 +51,48 @@ public void setName(String name) { this.name = name; } - public String getCode() { - return code; + public String getEnglish() { + return english; } - public void setCode(String code) { - this.code = code; + public void setEnglish(String english) { + this.english = english; } @Override public String provideText() { - return name; + if (IS_CHINESE) { + return name; + } + return english; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PhoneCodeEntity that = (PhoneCodeEntity) o; + return Objects.equals(code, that.code) || + Objects.equals(name, that.name) || + Objects.equals(english, that.english); + } + + @Override + public int hashCode() { + return Objects.hash(code, name, english); } @NonNull @Override public String toString() { return "PhoneCodeEntity{" + - "name='" + name + '\'' + - ", code='" + code + '\'' + + "code='" + code + '\'' + + ", name='" + name + '\'' + + ", english" + english + '\'' + '}'; } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarNumberProvider.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarPlateProvider.java similarity index 99% rename from WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarNumberProvider.java rename to WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarPlateProvider.java index 81fd2ae8..64b29cbf 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarNumberProvider.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarPlateProvider.java @@ -27,7 +27,7 @@ * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/9 11:31 */ -public class CarNumberProvider implements LinkageProvider { +public class CarPlateProvider implements LinkageProvider { private static final String[] ABBREVIATIONS = { "京", "津", "冀", "晋", "蒙", "辽", "吉", "黑", "沪", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarNumberWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarPlateWheelLayout.java similarity index 73% rename from WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarNumberWheelLayout.java rename to WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarPlateWheelLayout.java index 25645deb..147398b1 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarNumberWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarPlateWheelLayout.java @@ -19,35 +19,35 @@ import androidx.annotation.NonNull; -import com.github.gzuliyujiang.wheelpicker.impl.CarNumberProvider; +import com.github.gzuliyujiang.wheelpicker.impl.CarPlateProvider; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/9 11:57 */ -public class CarNumberWheelLayout extends LinkageWheelLayout { - private CarNumberProvider provider; +public class CarPlateWheelLayout extends LinkageWheelLayout { + private CarPlateProvider provider; - public CarNumberWheelLayout(Context context) { + public CarPlateWheelLayout(Context context) { super(context); } - public CarNumberWheelLayout(Context context, AttributeSet attrs) { + public CarPlateWheelLayout(Context context, AttributeSet attrs) { super(context, attrs); } - public CarNumberWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { + public CarPlateWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } - public CarNumberWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + public CarPlateWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onInit(@NonNull Context context) { super.onInit(context); - provider = new CarNumberProvider(); + provider = new CarPlateProvider(); setData(provider); } diff --git a/WheelPicker/src/main/res/values-en/wheel_strings.xml b/WheelPicker/src/main/res/values-en/wheel_strings.xml new file mode 100644 index 00000000..b7a93b6b --- /dev/null +++ b/WheelPicker/src/main/res/values-en/wheel_strings.xml @@ -0,0 +1,49 @@ + + + + +   +   +   +   + Birthday + Car Plate +   + Phone Code + Ethnic +   + Constellation + + Aquarius + Pisces + Aries + Taurus + Gemini + Cancer + Leo + Virgo + Libra + Scorpio + Sagittarius + Capricorn + + Unlimited + Gender + + Male + Female + + Unlimited + + \ No newline at end of file diff --git a/WheelPicker/src/main/res/values/wheel_strings.xml b/WheelPicker/src/main/res/values/wheel_strings.xml new file mode 100644 index 00000000..2884ae25 --- /dev/null +++ b/WheelPicker/src/main/res/values/wheel_strings.xml @@ -0,0 +1,49 @@ + + + + +   + 日期选择 + 日期时间选择 + 时间选择 + 生日选择 + 车牌选择 +   + 手机号码前缀 + 民族选择 +   + 星座选择 + + 水瓶座 + 双鱼座 + 白羊座 + 金牛座 + 双子座 + 巨蟹座 + 狮子座 + 处女座 + 天秤座 + 天蝎座 + 射手座 + 摩羯座 + + 保密 + 性别选择 + + + + + 保密 + + \ No newline at end of file diff --git a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/DateTimePickerActivity.java b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/DateTimePickerActivity.java index 672390b1..7fc8ac4b 100644 --- a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/DateTimePickerActivity.java +++ b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/DateTimePickerActivity.java @@ -84,11 +84,12 @@ public void onDatimePicked(int year, int month, int day, int hour, int minute, i public void onYearMonthDay(View view) { DatePicker picker = new DatePicker(this); - picker.setBodyWidth(240); + //picker.setBodyWidth(240); DateWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY); - wheelLayout.setDateLabel("年", "月", "日"); - wheelLayout.setRange(DateEntity.today(), DateEntity.yearOnFuture(30), DateEntity.yearOnFuture(10)); + //wheelLayout.setDateLabel("年", "月", "日"); + wheelLayout.setDateFormatter(new UnitDateFormatter()); + wheelLayout.setRange(DateEntity.target(2021, 1, 1), DateEntity.target(2050, 12, 31), DateEntity.today()); wheelLayout.setCurtainEnabled(true); wheelLayout.setCurtainColor(0xFFCC0000); wheelLayout.setIndicatorEnabled(true); @@ -96,10 +97,9 @@ public void onYearMonthDay(View view) { wheelLayout.setIndicatorSize(view.getResources().getDisplayMetrics().density * 2); wheelLayout.setTextColor(0xCCCC0000); wheelLayout.setSelectedTextColor(0xFFFF0000); - wheelLayout.getYearLabelView().setTextColor(0xFF999999); - wheelLayout.getMonthLabelView().setTextColor(0xFF999999); - wheelLayout.getDayLabelView().setTextColor(0xFF999999); - picker.setOnDatePickedListener(this); + //wheelLayout.getYearLabelView().setTextColor(0xFF999999); + //wheelLayout.getMonthLabelView().setTextColor(0xFF999999); + //picker.setOnDatePickedListener(this); picker.show(); } diff --git a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/LinkagePickerActivity.java b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/LinkagePickerActivity.java index c89c786e..6c2a1301 100644 --- a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/LinkagePickerActivity.java +++ b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/LinkagePickerActivity.java @@ -21,15 +21,15 @@ import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.fallback.custom.AntFortuneLikePicker; -import com.github.gzuliyujiang.wheelpicker.CarNumberPicker; -import com.github.gzuliyujiang.wheelpicker.contract.OnCarNumberPickedListener; +import com.github.gzuliyujiang.wheelpicker.CarPlatePicker; +import com.github.gzuliyujiang.wheelpicker.contract.OnCarPlatePickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkagePickedListener; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/4 12:40 */ -public class LinkagePickerActivity extends BackAbleActivity implements OnCarNumberPickedListener, OnLinkagePickedListener { +public class LinkagePickerActivity extends BackAbleActivity implements OnCarPlatePickedListener, OnLinkagePickedListener { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -48,10 +48,10 @@ public void onLinkagePicked(Object first, Object second, Object third) { } public void onCarNumber(View view) { - CarNumberPicker picker = new CarNumberPicker(this); + CarPlatePicker picker = new CarPlatePicker(this); picker.setBodyWidth(90); picker.setDefaultValue("贵", "F", ""); - picker.setOnCarNumberPickedListener(this); + picker.setOnCarPlatePickedListener(this); picker.show(); } diff --git a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/SinglePickerActivity.java b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/SinglePickerActivity.java index 40d1f768..178346c8 100644 --- a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/SinglePickerActivity.java +++ b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/SinglePickerActivity.java @@ -80,7 +80,7 @@ public String formatItem(@NonNull Object item) { }); picker.setRange(140, 200, 1); picker.setDefaultValue(172); - picker.getTitleView().setText("身高选择"); + picker.setTitle("身高选择"); picker.show(); } @@ -197,7 +197,8 @@ public void onOptionSelected(int position, Object item) { public void onPhoneCode(View view) { PhoneCodePicker picker = new PhoneCodePicker(this); picker.setBodyWidth(140); - picker.setDefaultPosition(2); + picker.setOnlyChina(false); + picker.setDefaultValueByCode("+86"); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override diff --git a/app/src/main/res/layout/activity_picker_linkage.xml b/app/src/main/res/layout/activity_picker_linkage.xml index fbf1c2ff..d30875f8 100644 --- a/app/src/main/res/layout/activity_picker_linkage.xml +++ b/app/src/main/res/layout/activity_picker_linkage.xml @@ -36,7 +36,7 @@ android:onClick="onLikeAntFortune" android:text="仿蚂蚁财富定投周期选择"/> -