diff --git a/AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/AddressPicker.java b/AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/AddressPicker.java index a760894d..0b67b6d9 100644 --- a/AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/AddressPicker.java +++ b/AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/AddressPicker.java @@ -14,6 +14,7 @@ package com.github.gzuliyujiang.wheelpicker; import android.app.Activity; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; @@ -33,6 +34,7 @@ import com.github.gzuliyujiang.wheelpicker.impl.AddressProvider; import com.github.gzuliyujiang.wheelpicker.impl.AssetAddressLoader; import com.github.gzuliyujiang.wheelpicker.utility.AddressJsonParser; +import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.List; @@ -139,4 +141,28 @@ public void setAddressMode(@NonNull String assetPath, @AddressMode int addressMo setAddressLoader(new AssetAddressLoader(getContext(), assetPath), jsonParser); } + public final WheelView getProvinceWheelView() { + return wheelLayout.getFirstWheelView(); + } + + public final WheelView getCityWheelView() { + return wheelLayout.getSecondWheelView(); + } + + public final WheelView getCountyWheelView() { + return wheelLayout.getThirdWheelView(); + } + + public final TextView getProvinceLabelView() { + return wheelLayout.getFirstLabelView(); + } + + public final TextView getCityLabelView() { + return wheelLayout.getSecondLabelView(); + } + + public final TextView getCountyLabelView() { + return wheelLayout.getThirdLabelView(); + } + } diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/CalendarPicker.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/CalendarPicker.java index 54180566..138defc8 100644 --- a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/CalendarPicker.java +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/CalendarPicker.java @@ -24,6 +24,7 @@ import com.github.gzuliyujiang.calendarpicker.core.CalendarView; import com.github.gzuliyujiang.calendarpicker.core.ColorScheme; import com.github.gzuliyujiang.calendarpicker.core.DateUtils; +import com.github.gzuliyujiang.calendarpicker.core.FestivalProvider; import com.github.gzuliyujiang.calendarpicker.core.OnDateSelectedListener; import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.dialog.DialogStyle; @@ -45,6 +46,7 @@ public class CalendarPicker extends ModalDialog implements OnDateSelectedListene private CalendarAdapter calendarAdapter; private ColorScheme colorScheme; private boolean singleMode = false; + private FestivalProvider festivalProvider; private Date minDate, maxDate; private Date selectDate, startDate, endDate; private String noteFrom, noteTo; @@ -73,12 +75,8 @@ protected void initView() { setHeight((int) (activity.getResources().getDisplayMetrics().heightPixels * 0.6f)); switch (DialogConfig.getDialogStyle()) { case DialogStyle.Default: - headerView.setVisibility(View.VISIBLE); - titleView.setText(""); - break; case DialogStyle.Two: headerView.setVisibility(View.VISIBLE); - titleView.setText("请选择"); break; default: headerView.setVisibility(View.GONE); @@ -252,10 +250,21 @@ public void setIntervalNotes(String noteFrom, String noteTo) { } } + /** + * 设置是否展示节日文本 + */ + public void setFestivalProvider(FestivalProvider festivalProvider) { + this.festivalProvider = festivalProvider; + if (initialized) { + refreshData(); + } + } + private void refreshData() { calendarView.setColorScheme(colorScheme); calendarAdapter.notify(false); calendarAdapter.single(singleMode); + calendarAdapter.festivalProvider(festivalProvider); if (singleMode) { startDate = selectDate; endDate = selectDate; 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 28733ee7..5ce37c68 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 @@ -28,6 +28,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Locale; /** * Created by peng on 2017/8/3. @@ -42,9 +43,16 @@ public class CalendarAdapter extends RecyclerView.Adapter im private final Interval select = new Interval<>(); private final Interval selectNote = new Interval<>(); private boolean singleMode = false; + private FestivalProvider festivalProvider; private Date lastClickDate = null; private OnDateSelectedListener onDateSelectedListener; + static { + if (!Locale.getDefault().getDisplayLanguage().contains("中文")) { + DATE_FORMAT = "MMM, yyyy"; + } + } + public CalendarAdapter notify(boolean notify) { this.notify = notify; return this; @@ -66,6 +74,14 @@ public CalendarAdapter single(boolean value) { return this; } + public CalendarAdapter festivalProvider(FestivalProvider value) { + festivalProvider = value; + if (notify) { + refresh(); + } + return this; + } + public CalendarAdapter valid(Date from, Date to) { valid.left(from); valid.right(to); @@ -204,6 +220,7 @@ public void onBindViewHolder(@NonNull VH holder, int position) { holder.monthView.setValue(MonthEntity.obtain(valid, select) .date(dates.get(position)) .singleMode(singleMode) + .festivalProvider(festivalProvider) .note(selectNote), colorScheme); } diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/FestivalProvider.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/FestivalProvider.java new file mode 100644 index 00000000..8e46d0f8 --- /dev/null +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/FestivalProvider.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> + * + * The software is licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package com.github.gzuliyujiang.calendarpicker.core; + +import java.util.Date; + +/** + * @author 贵州山野羡民(1032694760@qq.com) + * @since 2021/10/28 9:52 + */ +public interface FestivalProvider { + + String provideText(Date date); + +} 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 0e2cc2d6..8eb26ac6 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 @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Locale; /** * Created by peng on 2017/8/4. @@ -32,6 +33,13 @@ public class MonthEntity implements Serializable { private Interval select; private Interval note; private boolean singleMode = false; + private FestivalProvider festivalProvider; + + static { + if (!Locale.getDefault().getDisplayLanguage().contains("中文")) { + STR_TODAY = "Today"; + } + } public static MonthEntity obtain(Interval valid, Interval select) { MonthEntity entity = pools.size() == 0 ? new MonthEntity() : pools.remove(0); @@ -71,8 +79,8 @@ public MonthEntity select(Interval select) { return this; } - public MonthEntity singleMode(boolean single) { - this.singleMode = single; + public MonthEntity singleMode(boolean singleMode) { + this.singleMode = singleMode; return this; } @@ -80,6 +88,15 @@ public boolean singleMode() { return this.singleMode; } + public MonthEntity festivalProvider(FestivalProvider festivalProvider) { + this.festivalProvider = festivalProvider; + return this; + } + + public FestivalProvider festivalProvider() { + return this.festivalProvider; + } + public Interval note() { return note; } diff --git a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthView.java b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthView.java index e382bb76..bb2b54b1 100644 --- a/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthView.java +++ b/CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthView.java @@ -22,9 +22,7 @@ import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; -import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Locale; /** * 月份控件 @@ -197,41 +195,17 @@ public void onClick(View v) { } @NonNull - private String toDayDesc(int index) { + protected String toDayDesc(int index) { + FestivalProvider festivalProvider = monthEntity.festivalProvider(); + if (festivalProvider == null) { + return ""; + } Date date = DateUtils.specialDayInMonth(monthEntity.date(), index); - String monthDay = new SimpleDateFormat("MMdd", Locale.PRC).format(date); - switch (monthDay) { - case "0101": - return "元旦"; - case "0214": - return "情人节"; - case "0308": - return "妇女节"; - case "0312": - return "植树节"; - case "0401": - return "愚人节"; - case "0501": - return "劳动节"; - case "0504": - return "青年节"; - case "0601": - return "儿童节"; - case "0701": - return "建党节"; - case "0801": - return "建军节"; - case "0910": - return "教师节"; - case "1001": - return "国庆节"; - case "1111": - return "光棍节"; - case "1225": - return "圣诞节"; - default: - return ""; + String festival = festivalProvider.provideText(date); + if (festival == null) { + festival = ""; } + return festival; } public void setValue(@NonNull MonthEntity entity, @NonNull ColorScheme colorScheme) { 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 67cc3aa0..24a16024 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 @@ -20,6 +20,8 @@ import android.widget.BaseAdapter; import android.widget.TextView; +import java.util.Locale; + /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/17 14:36 @@ -30,6 +32,14 @@ public class WeekAdapter extends BaseAdapter { }; private ColorScheme colorScheme = new ColorScheme(); + static { + if (!Locale.getDefault().getDisplayLanguage().contains("中文")) { + DATA = new String[]{ + "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" + }; + } + } + public void setColorScheme(ColorScheme colorScheme) { if (colorScheme == null) { colorScheme = new ColorScheme(); diff --git a/ChangeLog.md b/ChangeLog.md index 09d47648..1fdf1c44 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,10 +1,12 @@ # 更新日志 -## 4.0.2 - 2021.10.28 +## 4.1.0 - 2021.10.28 -- 基于最新版本的 Android Studio Arctic Fox 构建,Gradle 升级到最新的 7.x 版本; -- 文本国际化,支持定制多语言(默认为中文及英文); +- 支持滚轮选择器选中项设置圆角纯色背景; +- 所以选择器文本国际化,内置支持中文及英文; - 手机号码前缀选择器数据完善,支持全球的国家及地区; +- 车牌、星座及性别等选择器调整,民族、星座及性别等默认值设置优化; +- 日历选择器支持自定义节日文本; ## 4.0.1 - 2021.09.26 diff --git a/FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/FilePicker.java b/FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/FilePicker.java index 2540ecd8..e76b5090 100644 --- a/FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/FilePicker.java +++ b/FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/FilePicker.java @@ -62,7 +62,6 @@ protected View createBodyView() { protected void initView() { super.initView(); setHeight((int) (activity.getResources().getDisplayMetrics().heightPixels * 0.6f)); - titleView.setText(explorerMode == ExplorerMode.FILE ? "文件选择" : "目录选择"); if (explorerMode == ExplorerMode.FILE) { okView.setVisibility(View.GONE); } diff --git a/FilePicker/src/main/res/layout/file_picker_content.xml b/FilePicker/src/main/res/layout/file_picker_content.xml index 6994fc3c..c835a723 100644 --- a/FilePicker/src/main/res/layout/file_picker_content.xml +++ b/FilePicker/src/main/res/layout/file_picker_content.xml @@ -47,9 +47,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" - android:text="<Empty>" android:textColor="#FF999999" android:visibility="invisible" + tools:text="<Empty>" tools:visibility="visible" /> diff --git a/README.md b/README.md index 14bef433..41269f41 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ requests 贡献您的代码,大家共同学习【[AndroidPicker 交流群 6042 ## 接入指引 最新版本:[![jitpack](https://jitpack.io/v/gzu-liyujiang/AndroidPicker.svg)](https://jitpack.io/#gzu-liyujiang/AndroidPicker) -([更新日志](/ChangeLog.md)) +(具体历史版本号参见 [更新日志](/ChangeLog.md)) ### 注意事项 @@ -140,18 +140,23 @@ data.add(new GoodsCategoryBean(6, "图书音像")); OptionPicker picker = new OptionPicker(this); picker.setTitle("货物分类"); picker.setBodyWidth(140); -picker.getWheelView().setIndicatorColor(0xFFFF0000); -picker.getWheelView().setTextColor(0xFFFF00FF); -picker.getWheelView().setSelectedTextColor(0xFFFF0000); +picker.setData(data); +picker.setDefaultPosition(2); picker.setOnOptionPickedListener(this); -picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { +OptionWheelLayout wheelLayout = picker.getWheelLayout(); +wheelLayout.setIndicatorEnabled(false); +wheelLayout.setTextColor(0xFFFF00FF); +wheelLayout.setSelectedTextColor(0xFFFF0000); +wheelLayout.setCurtainEnabled(true); +wheelLayout.setCurtainColor(0xEEFF0000); +wheelLayout.setCurtainCorner(CurtainCorner.ALL); +wheelLayout.setCurtainRadius(5 * view.getResources().getDisplayMetrics().density); +wheelLayout.setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); -picker.setData(data); -picker.setDefaultPosition(2); picker.show(); ``` @@ -178,7 +183,7 @@ picker.show(); ```groovy AddressPicker picker = new AddressPicker(this); -picker.setAddressMode("city.json", AddressMode.PROVINCE_CITY_COUNTY, +picker.setAddressMode("china_address_guizhou_city.json", AddressMode.PROVINCE_CITY, new AddressJsonParser.Builder() .provinceCodeField("code") .provinceNameField("name") @@ -189,8 +194,27 @@ picker.setAddressMode("city.json", AddressMode.PROVINCE_CITY_COUNTY, .countyCodeField("code") .countyNameField("name") .build()); -picker.setDefaultValue("贵州省", "毕节地区", "纳雍县"); +picker.setTitle("贵州省地址选择"); +picker.setDefaultValue("贵州省", "毕节市", "纳雍县"); picker.setOnAddressPickedListener(this); +LinkageWheelLayout wheelLayout = picker.getWheelLayout(); +wheelLayout.setIndicatorEnabled(false); +wheelLayout.setCurtainEnabled(true); +wheelLayout.setCurtainColor(0xEE0081FF); +wheelLayout.setCurtainRadius(5 * view.getResources().getDisplayMetrics().density); +int padding = (int) (10 * view.getResources().getDisplayMetrics().density); +wheelLayout.setPadding(padding, 0, padding, 0); +wheelLayout.setOnLinkageSelectedListener(new OnLinkageSelectedListener() { + @Override + public void onLinkageSelected(Object first, Object second, Object third) { + picker.getTitleView().setText(String.format("%s%s%s", + picker.getFirstWheelView().formatItem(first), + picker.getSecondWheelView().formatItem(second), + picker.getThirdWheelView().formatItem(third))); + } +}); +picker.getProvinceWheelView().setCurtainCorner(CurtainCorner.LEFT); +picker.getCityWheelView().setCurtainCorner(CurtainCorner.RIGHT); picker.show(); ``` 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 a9173997..7d374738 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java @@ -18,8 +18,17 @@ import androidx.annotation.NonNull; import androidx.annotation.StyleRes; -import java.util.Arrays; -import java.util.LinkedList; +import com.github.gzuliyujiang.dialog.DialogLog; +import com.github.gzuliyujiang.wheelpicker.entity.ConstellationEntity; +import com.github.gzuliyujiang.wheelpicker.entity.DateEntity; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.List; /** @@ -30,33 +39,137 @@ */ @SuppressWarnings("WeakerAccess") public class ConstellationPicker extends OptionPicker { - private final boolean includeUnlimited; + public static String JSON = "[{\"id\":0,\"name\":\"不限\",\"startDate\":\"\",\"endDate\":\"\",\"english\":\"Unlimited\"},\n" + + "{\"id\":1,\"name\":\"白羊座\",\"startDate\":\"3-21\",\"endDate\":\"4-19\",\"english\":\"Aries\"},\n" + + "{\"id\":2,\"name\":\"金牛座\",\"startDate\":\"4-20\",\"endDate\":\"5-20\",\"english\":\"Taurus\"},\n" + + "{\"id\":3,\"name\":\"双子座\",\"startDate\":\"5-21\",\"endDate\":\"6-21\",\"english\":\"Gemini\"},\n" + + "{\"id\":4,\"name\":\"巨蟹座\",\"startDate\":\"6-22\",\"endDate\":\"7-22\",\"english\":\"Cancer\"},\n" + + "{\"id\":5,\"name\":\"狮子座\",\"startDate\":\"7-23\",\"endDate\":\"8-22\",\"english\":\"Leo\"},\n" + + "{\"id\":6,\"name\":\"处女座\",\"startDate\":\"8-23\",\"endDate\":\"9-22\",\"english\":\"Virgo\"},\n" + + "{\"id\":7,\"name\":\"天秤座\",\"startDate\":\"9-23\",\"endDate\":\"10-23\",\"english\":\"Libra\"},\n" + + "{\"id\":8,\"name\":\"天蝎座\",\"startDate\":\"10-24\",\"endDate\":\"11-22\",\"english\":\"Scorpio\"},\n" + + "{\"id\":9,\"name\":\"射手座\",\"startDate\":\"11-23\",\"endDate\":\"12-21\",\"english\":\"Sagittarius\"},\n" + + "{\"id\":10,\"name\":\"摩羯座\",\"startDate\":\"12-22\",\"endDate\":\"1-19\",\"english\":\"Capricorn\"},\n" + + "{\"id\":11,\"name\":\"水瓶座\",\"startDate\":\"1-20\",\"endDate\":\"2-18\",\"english\":\"Aquarius\"},\n" + + "{\"id\":12,\"name\":\"双鱼座\",\"startDate\":\"2-19\",\"endDate\":\"3-20\",\"english\":\"Pisces\"}]"; + private boolean includeUnlimited = false; public ConstellationPicker(Activity activity) { - this(activity, false); + super(activity); } public ConstellationPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); - this.includeUnlimited = false; } - public ConstellationPicker(@NonNull Activity activity, @StyleRes int themeResId, boolean includeUnlimited) { - super(activity, themeResId); + public void setIncludeUnlimited(boolean includeUnlimited) { this.includeUnlimited = includeUnlimited; + setData(provideData()); } - public ConstellationPicker(Activity activity, boolean includeUnlimited) { - super(activity); - this.includeUnlimited = includeUnlimited; + @Override + public void setDefaultValue(Object item) { + if (item instanceof String) { + setDefaultValueByName(item.toString()); + } else { + super.setDefaultValue(item); + } + } + + public void setDefaultValueById(String id) { + ConstellationEntity entity = new ConstellationEntity(); + entity.setId(id); + super.setDefaultValue(entity); + } + + public void setDefaultValueByName(String name) { + ConstellationEntity entity = new ConstellationEntity(); + entity.setName(name); + super.setDefaultValue(entity); + } + + public void setDefaultValueByDate(DateEntity date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(date.toTimeInMillis()); + setDefaultValueByDate(calendar.getTime()); + } + + public void setDefaultValueByDate(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int month = calendar.get(Calendar.MONTH) + 1; + int day = calendar.get(Calendar.DAY_OF_MONTH); + String name; + switch (month) { + case 1: + name = day < 21 ? "摩羯座" : "水瓶座"; + break; + case 2: + name = day < 20 ? "水瓶座" : "双鱼座"; + break; + case 3: + name = day < 21 ? "双鱼座" : "白羊座"; + break; + case 4: + name = day < 21 ? "白羊座" : "金牛座"; + break; + case 5: + name = day < 22 ? "金牛座" : "双子座"; + break; + case 6: + name = day < 22 ? "双子座" : "巨蟹座"; + break; + case 7: + name = day < 23 ? "巨蟹座" : "狮子座"; + break; + case 8: + name = day < 24 ? "狮子座" : "处女座"; + break; + case 9: + name = day < 24 ? "处女座" : "天秤座"; + break; + case 10: + name = day < 24 ? "天秤座" : "天蝎座"; + break; + case 11: + name = day < 23 ? "天蝎座" : "射手座"; + break; + case 12: + name = day < 22 ? "射手座" : "摩羯座"; + break; + default: + name = "不限"; + break; + } + setDefaultValueByName(name); + } + + public void setDefaultValueByEnglish(String english) { + ConstellationEntity entity = new ConstellationEntity(); + entity.setEnglish(english); + super.setDefaultValue(entity); } @Override protected List provideData() { - 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)); + ArrayList data = new ArrayList<>(); + try { + JSONArray jsonArray = new JSONArray(JSON); + for (int i = 0, n = jsonArray.length(); i < n; i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + ConstellationEntity entity = new ConstellationEntity(); + entity.setId(jsonObject.getString("id")); + entity.setStartDate(jsonObject.getString("startDate")); + entity.setEndDate(jsonObject.getString("endDate")); + entity.setName(jsonObject.getString("name")); + entity.setEnglish(jsonObject.getString("english")); + if (!includeUnlimited && "0".equals(entity.getId())) { + continue; + } + data.add(entity); + } + } catch (JSONException e) { + DialogLog.print(e); } return data; } 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 3c531fa6..84fdcbfd 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java @@ -107,22 +107,31 @@ public void setEthnicSpec(@EthnicSpec int ethnicSpec) { setData(provideData()); } + @Override + public void setDefaultValue(Object item) { + if (item instanceof String) { + setDefaultValueByName(item.toString()); + } else { + super.setDefaultValue(item); + } + } + public void setDefaultValueByCode(String code) { EthnicEntity entity = new EthnicEntity(); entity.setCode(code); - setDefaultValue(entity); + super.setDefaultValue(entity); } public void setDefaultValueByName(String name) { EthnicEntity entity = new EthnicEntity(); entity.setName(name); - setDefaultValue(entity); + super.setDefaultValue(entity); } public void setDefaultValueBySpelling(String spelling) { EthnicEntity entity = new EthnicEntity(); entity.setSpelling(spelling); - setDefaultValue(entity); + super.setDefaultValue(entity); } @Override 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 c5e90ab1..225a2f22 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java @@ -263,22 +263,31 @@ public void setOnlyChina(boolean onlyChina) { setData(provideData()); } + @Override + public void setDefaultValue(Object item) { + if (item instanceof String) { + setDefaultValueByName(item.toString()); + } else { + super.setDefaultValue(item); + } + } + public void setDefaultValueByCode(String code) { PhoneCodeEntity entity = new PhoneCodeEntity(); entity.setCode(code); - setDefaultValue(entity); + super.setDefaultValue(entity); } public void setDefaultValueByName(String name) { PhoneCodeEntity entity = new PhoneCodeEntity(); entity.setName(name); - setDefaultValue(entity); + super.setDefaultValue(entity); } public void setDefaultValueByEnglish(String english) { PhoneCodeEntity entity = new PhoneCodeEntity(); entity.setEnglish(english); - setDefaultValue(entity); + super.setDefaultValue(entity); } @Override 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 758d91f1..401f0726 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java @@ -18,8 +18,14 @@ import androidx.annotation.NonNull; import androidx.annotation.StyleRes; -import java.util.Arrays; -import java.util.LinkedList; +import com.github.gzuliyujiang.dialog.DialogLog; +import com.github.gzuliyujiang.wheelpicker.entity.SexEntity; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; import java.util.List; /** @@ -30,33 +36,63 @@ */ @SuppressWarnings("WeakerAccess") public class SexPicker extends OptionPicker { - private final boolean includeSecrecy; + public static String JSON = "[{\"id\":0,\"name\":\"保密\",\"english\":\"Secrecy\"},\n" + + "{\"id\":1,\"name\":\"男\",\"english\":\"Male\"},\n" + + "{\"id\":2,\"name\":\"女\",\"english\":\"Female\"}]"; + private boolean includeSecrecy; public SexPicker(Activity activity) { - this(activity, false); + super(activity); } public SexPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); - this.includeSecrecy = false; } - public SexPicker(Activity activity, boolean includeSecrecy) { - super(activity); + public void setIncludeSecrecy(boolean includeSecrecy) { this.includeSecrecy = includeSecrecy; + setData(provideData()); } - public SexPicker(@NonNull Activity activity, @StyleRes int themeResId, boolean includeSecrecy) { - super(activity, themeResId); - this.includeSecrecy = includeSecrecy; + @Override + public void setDefaultValue(Object item) { + if (item instanceof String) { + setDefaultValueByName(item.toString()); + } else { + super.setDefaultValue(item); + } + } + + public void setDefaultValueByName(String name) { + SexEntity entity = new SexEntity(); + entity.setName(name); + super.setDefaultValue(entity); + } + + public void setDefaultValueByEnglish(String english) { + SexEntity entity = new SexEntity(); + entity.setEnglish(english); + super.setDefaultValue(entity); } @Override protected List provideData() { - 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)); + ArrayList data = new ArrayList<>(); + try { + JSONArray jsonArray = new JSONArray(JSON); + for (int i = 0, n = jsonArray.length(); i < n; i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + SexEntity entity = new SexEntity(); + entity.setId(jsonObject.getString("id")); + entity.setName(jsonObject.getString("name")); + entity.setEnglish(jsonObject.getString("english")); + if (!includeSecrecy && "0".equals(entity.getId())) { + continue; + } + data.add(entity); + } + } catch (JSONException e) { + DialogLog.print(e); } return data; } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/ConstellationEntity.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/ConstellationEntity.java new file mode 100644 index 00000000..b8ceb1d7 --- /dev/null +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/ConstellationEntity.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> + * + * The software is licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package com.github.gzuliyujiang.wheelpicker.entity; + +import androidx.annotation.NonNull; + +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/10/28 8:37 + */ +public class ConstellationEntity implements TextProvider, Serializable { + private static final boolean IS_CHINESE; + private String id; + private String startDate; + private String endDate; + private String name; + private String english; + + static { + IS_CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEnglish() { + return english; + } + + public void setEnglish(String english) { + this.english = english; + } + + @Override + public String provideText() { + 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; + } + ConstellationEntity that = (ConstellationEntity) o; + return Objects.equals(id, that.id) || + Objects.equals(startDate, that.startDate) || + Objects.equals(endDate, that.endDate) || + Objects.equals(name, that.name) || + Objects.equals(english, that.english); + } + + @Override + public int hashCode() { + return Objects.hash(id, startDate, endDate, name, english); + } + + @NonNull + @Override + public String toString() { + return "ConstellationEntity{" + + "id='" + id + '\'' + + ", startDate='" + startDate + '\'' + + ", endDate='" + endDate + '\'' + + ", name='" + name + '\'' + + ", english" + english + '\'' + + '}'; + } + +} diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/SexEntity.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/SexEntity.java new file mode 100644 index 00000000..d3d96c14 --- /dev/null +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/SexEntity.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> + * + * The software is licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package com.github.gzuliyujiang.wheelpicker.entity; + +import androidx.annotation.NonNull; + +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/10/28 9:17 + */ +public class SexEntity implements TextProvider, Serializable { + private static final boolean IS_CHINESE; + private String id; + private String name; + private String english; + + static { + IS_CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEnglish() { + return english; + } + + public void setEnglish(String english) { + this.english = english; + } + + @Override + public String provideText() { + 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; + } + SexEntity that = (SexEntity) o; + return Objects.equals(id, that.id) || + Objects.equals(name, that.name) || + Objects.equals(english, that.english); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, english); + } + + @NonNull + @Override + public String toString() { + return "SexEntity{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", english" + english + '\'' + + '}'; + } + +} diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/BaseWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/BaseWheelLayout.java index ce7ab84a..0fe0642f 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/BaseWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/BaseWheelLayout.java @@ -27,8 +27,9 @@ import androidx.annotation.StyleRes; import androidx.annotation.StyleableRes; -import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.wheelpicker.R; +import com.github.gzuliyujiang.wheelview.annotation.CurtainCorner; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.contract.OnWheelChangedListener; import com.github.gzuliyujiang.wheelview.widget.WheelView; @@ -125,7 +126,7 @@ public void onWheelScrolled(WheelView view, int offset) { } @Override - public void onWheelScrollStateChanged(WheelView view, int state) { + public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { } @@ -154,6 +155,18 @@ public void setCurtainColor(@ColorInt int color) { } } + public void setCurtainCorner(@CurtainCorner int corner) { + for (WheelView wheelView : wheelViews) { + wheelView.setCurtainCorner(corner); + } + } + + public void setCurtainRadius(@Px float radius) { + for (WheelView wheelView : wheelViews) { + wheelView.setCurtainRadius(radius); + } + } + public void setAtmosphericEnabled(boolean hasAtmospheric) { for (WheelView wheelView : wheelViews) { wheelView.setAtmosphericEnabled(hasAtmospheric); diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DateWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DateWheelLayout.java index c726e764..2f42e632 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DateWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DateWheelLayout.java @@ -28,6 +28,7 @@ import com.github.gzuliyujiang.wheelpicker.entity.DateEntity; import com.github.gzuliyujiang.wheelpicker.impl.SimpleDateFormatter; import com.github.gzuliyujiang.wheelview.annotation.ItemTextAlign; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; import com.github.gzuliyujiang.wheelview.widget.NumberWheelView; import com.github.gzuliyujiang.wheelview.widget.WheelView; @@ -116,6 +117,7 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.DateWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.DateWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.DateWheelLayout_wheel_curtainColor, 0x88FFFFFF)); + setCurtainRadius(typedArray.getDimension(R.styleable.DateWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.DateWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.DateWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.DateWheelLayout_wheel_curvedMaxAngle, 90)); @@ -154,21 +156,21 @@ public void onWheelSelected(WheelView view, int position) { } @Override - public void onWheelScrollStateChanged(WheelView view, int state) { + public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { int id = view.getId(); if (id == R.id.wheel_picker_date_year_wheel) { - monthWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - dayWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + monthWheelView.setEnabled(state == ScrollState.IDLE); + dayWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_date_month_wheel) { - yearWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - dayWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + yearWheelView.setEnabled(state == ScrollState.IDLE); + dayWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_date_day_wheel) { - yearWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - monthWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + yearWheelView.setEnabled(state == ScrollState.IDLE); + monthWheelView.setEnabled(state == ScrollState.IDLE); } } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DatimeWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DatimeWheelLayout.java index 4fbcd5b1..6e61cefc 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DatimeWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DatimeWheelLayout.java @@ -30,6 +30,7 @@ import com.github.gzuliyujiang.wheelpicker.impl.SimpleDateFormatter; import com.github.gzuliyujiang.wheelpicker.impl.SimpleTimeFormatter; import com.github.gzuliyujiang.wheelview.annotation.ItemTextAlign; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.widget.NumberWheelView; import com.github.gzuliyujiang.wheelview.widget.WheelView; @@ -109,6 +110,7 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.DatimeWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.DatimeWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.DatimeWheelLayout_wheel_curtainColor, 0x88FFFFFF)); + setCurtainRadius(typedArray.getDimension(R.styleable.DatimeWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.DatimeWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.DatimeWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.DatimeWheelLayout_wheel_curvedMaxAngle, 90)); @@ -153,7 +155,7 @@ public void onWheelScrolled(WheelView view, int offset) { } @Override - public void onWheelScrollStateChanged(WheelView view, int state) { + public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { dateWheelLayout.onWheelScrollStateChanged(view, state); timeWheelLayout.onWheelScrollStateChanged(view, state); } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/LinkageWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/LinkageWheelLayout.java index 9d460f82..9e134347 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/LinkageWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/LinkageWheelLayout.java @@ -25,6 +25,7 @@ import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkageSelectedListener; import com.github.gzuliyujiang.wheelview.annotation.ItemTextAlign; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; import com.github.gzuliyujiang.wheelview.widget.WheelView; @@ -108,6 +109,7 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.LinkageWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.LinkageWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.LinkageWheelLayout_wheel_curtainColor, 0x88FFFFFF)); + setCurtainRadius(typedArray.getDimension(R.styleable.LinkageWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.LinkageWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.LinkageWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.LinkageWheelLayout_wheel_curvedMaxAngle, 90)); @@ -146,21 +148,21 @@ public void onWheelSelected(WheelView view, int position) { } @Override - public void onWheelScrollStateChanged(WheelView view, int state) { + public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { int id = view.getId(); if (id == R.id.wheel_picker_linkage_first_wheel) { - secondWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - thirdWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + secondWheelView.setEnabled(state == ScrollState.IDLE); + thirdWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_linkage_second_wheel) { - firstWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - thirdWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + firstWheelView.setEnabled(state == ScrollState.IDLE); + thirdWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_linkage_third_wheel) { - firstWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - secondWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + firstWheelView.setEnabled(state == ScrollState.IDLE); + secondWheelView.setEnabled(state == ScrollState.IDLE); } } diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/NumberWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/NumberWheelLayout.java index f46a6b47..5fec4c7e 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/NumberWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/NumberWheelLayout.java @@ -78,6 +78,7 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.NumberWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.NumberWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.NumberWheelLayout_wheel_curtainColor, 0x88FFFFFF)); + setCurtainRadius(typedArray.getDimension(R.styleable.NumberWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.NumberWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.NumberWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.NumberWheelLayout_wheel_curvedMaxAngle, 90)); diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/OptionWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/OptionWheelLayout.java index 44c8b1e7..cf85582a 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/OptionWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/OptionWheelLayout.java @@ -21,7 +21,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionSelectedListener; import com.github.gzuliyujiang.wheelview.annotation.ItemTextAlign; @@ -97,6 +96,7 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.OptionWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.OptionWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.OptionWheelLayout_wheel_curtainColor, 0x88FFFFFF)); + setCurtainRadius(typedArray.getDimension(R.styleable.OptionWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.OptionWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.OptionWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.OptionWheelLayout_wheel_curvedMaxAngle, 90)); diff --git a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/TimeWheelLayout.java b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/TimeWheelLayout.java index f4d8b2e0..6b7c4097 100644 --- a/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/TimeWheelLayout.java +++ b/WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/TimeWheelLayout.java @@ -29,6 +29,7 @@ import com.github.gzuliyujiang.wheelpicker.entity.TimeEntity; import com.github.gzuliyujiang.wheelpicker.impl.SimpleTimeFormatter; import com.github.gzuliyujiang.wheelview.annotation.ItemTextAlign; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; import com.github.gzuliyujiang.wheelview.widget.NumberWheelView; import com.github.gzuliyujiang.wheelview.widget.WheelView; @@ -122,6 +123,7 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.TimeWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.TimeWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.TimeWheelLayout_wheel_curtainColor, 0x88FFFFFF)); + setCurtainRadius(typedArray.getDimension(R.styleable.TimeWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.TimeWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.TimeWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.TimeWheelLayout_wheel_curvedMaxAngle, 90)); @@ -161,21 +163,21 @@ public void onWheelSelected(WheelView view, int position) { } @Override - public void onWheelScrollStateChanged(WheelView view, int state) { + public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { int id = view.getId(); if (id == R.id.wheel_picker_time_hour_wheel) { - minuteWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - secondWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + minuteWheelView.setEnabled(state == ScrollState.IDLE); + secondWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_time_minute_wheel) { - hourWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - secondWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + hourWheelView.setEnabled(state == ScrollState.IDLE); + secondWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_time_second_wheel) { - hourWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); - minuteWheelView.setEnabled(state == WheelView.SCROLL_STATE_IDLE); + hourWheelView.setEnabled(state == ScrollState.IDLE); + minuteWheelView.setEnabled(state == ScrollState.IDLE); } } diff --git a/WheelPicker/src/main/res/values-en/wheel_strings.xml b/WheelPicker/src/main/res/values-en/wheel_strings.xml deleted file mode 100644 index d0ae3976..00000000 --- a/WheelPicker/src/main/res/values-en/wheel_strings.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - Aquarius - Pisces - Aries - Taurus - Gemini - Cancer - Leo - Virgo - Libra - Scorpio - Sagittarius - Capricorn - - Unlimited - - Male - Female - - Unlimited - - \ No newline at end of file diff --git a/WheelPicker/src/main/res/values/wheel_attrs.xml b/WheelPicker/src/main/res/values/wheel_attrs.xml index 669a79ac..55cd890a 100644 --- a/WheelPicker/src/main/res/values/wheel_attrs.xml +++ b/WheelPicker/src/main/res/values/wheel_attrs.xml @@ -58,6 +58,7 @@ + @@ -80,6 +81,7 @@ + @@ -106,6 +108,7 @@ + @@ -131,6 +134,7 @@ + @@ -156,6 +160,7 @@ + @@ -185,6 +190,7 @@ + diff --git a/WheelPicker/src/main/res/values/wheel_strings.xml b/WheelPicker/src/main/res/values/wheel_strings.xml deleted file mode 100644 index e68434ff..00000000 --- a/WheelPicker/src/main/res/values/wheel_strings.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - 水瓶座 - 双鱼座 - 白羊座 - 金牛座 - 双子座 - 巨蟹座 - 狮子座 - 处女座 - 天秤座 - 天蝎座 - 射手座 - 摩羯座 - - 保密 - - - - - 保密 - - \ No newline at end of file diff --git a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/CurtainCorner.java b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/CurtainCorner.java new file mode 100644 index 00000000..ccaafd7c --- /dev/null +++ b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/CurtainCorner.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> + * + * The software is licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package com.github.gzuliyujiang.wheelview.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * @author 贵州山野羡民(1032694760@qq.com) + * @since 2021/10/28 11:27 + */ +@Retention(RetentionPolicy.SOURCE) +public @interface CurtainCorner { + int NONE = 0; + int ALL = 1; + int TOP = 2; + int BOTTOM = 3; + int LEFT = 4; + int RIGHT = 5; +} diff --git a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/ScrollState.java b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/ScrollState.java new file mode 100644 index 00000000..071f249e --- /dev/null +++ b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/ScrollState.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> + * + * The software is licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package com.github.gzuliyujiang.wheelview.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * @author 贵州山野羡民(1032694760@qq.com) + * @since 2021/10/28 11:28 + */ +@Retention(RetentionPolicy.SOURCE) +public @interface ScrollState { + int IDLE = 0; + int DRAGGING = 1; + int SCROLLING = 2; +} diff --git a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/OnWheelChangedListener.java b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/OnWheelChangedListener.java index 1f13a54e..afbc34b2 100644 --- a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/OnWheelChangedListener.java +++ b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/OnWheelChangedListener.java @@ -13,6 +13,7 @@ package com.github.gzuliyujiang.wheelview.contract; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.widget.WheelView; /** @@ -51,19 +52,19 @@ public interface OnWheelChangedListener { * be called when they switch * * @param view wheel view - * @param state {@link WheelView#SCROLL_STATE_IDLE} - * {@link WheelView#SCROLL_STATE_DRAGGING} - * {@link WheelView#SCROLL_STATE_SCROLLING} + * @param state {@link ScrollState#IDLE} + * {@link ScrollState#DRAGGING} + * {@link ScrollState#SCROLLING} *

* State only one of the following - * {@link WheelView#SCROLL_STATE_IDLE} + * {@link ScrollState#IDLE} * Express WheelPicker in state of idle - * {@link WheelView#SCROLL_STATE_DRAGGING} + * {@link ScrollState#DRAGGING} * Express WheelPicker in state of dragging - * {@link WheelView#SCROLL_STATE_SCROLLING} + * {@link ScrollState#SCROLLING} * Express WheelPicker in state of scrolling */ - void onWheelScrollStateChanged(WheelView view, int state); + void onWheelScrollStateChanged(WheelView view, @ScrollState int state); /** * Invoke when loop finished diff --git a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java index 838c6a58..9a8488cf 100644 --- a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java +++ b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java @@ -23,7 +23,9 @@ import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.Rect; +import android.graphics.RectF; import android.graphics.Region; import android.graphics.Typeface; import android.os.Build; @@ -43,7 +45,9 @@ import androidx.annotation.StyleRes; import com.github.gzuliyujiang.wheelview.R; +import com.github.gzuliyujiang.wheelview.annotation.CurtainCorner; import com.github.gzuliyujiang.wheelview.annotation.ItemTextAlign; +import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.contract.OnWheelChangedListener; import com.github.gzuliyujiang.wheelview.contract.TextProvider; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; @@ -61,9 +65,12 @@ */ @SuppressWarnings({"unused"}) public class WheelView extends View implements Runnable { - public static final int SCROLL_STATE_IDLE = 0; - public static final int SCROLL_STATE_DRAGGING = 1; - public static final int SCROLL_STATE_SCROLLING = 2; + @Deprecated + public static final int SCROLL_STATE_IDLE = ScrollState.IDLE; + @Deprecated + public static final int SCROLL_STATE_DRAGGING = ScrollState.DRAGGING; + @Deprecated + public static final int SCROLL_STATE_SCROLLING = ScrollState.SCROLLING; protected List data = new ArrayList<>(); protected WheelFormatter formatter; @@ -77,6 +84,8 @@ public class WheelView extends View implements Runnable { protected float indicatorSize; protected int indicatorColor; protected int curtainColor; + protected int curtainCorner; + protected float curtainRadius; protected int itemSpace; protected int textAlign; protected boolean sameWidthEnabled; @@ -171,6 +180,8 @@ private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr, in curvedIndicatorSpace = (int) (1 * density); curtainEnabled = false; curtainColor = 0xFFFFFFFF; + curtainCorner = CurtainCorner.NONE; + curtainRadius = 0; atmosphericEnabled = false; curvedEnabled = false; curvedMaxAngle = 90; @@ -201,6 +212,8 @@ protected void onAttributeSet(@NonNull Context context, @NonNull TypedArray type curvedIndicatorSpace = typedArray.getDimensionPixelSize(R.styleable.WheelView_wheel_curvedIndicatorSpace, (int) (1 * density)); curtainEnabled = typedArray.getBoolean(R.styleable.WheelView_wheel_curtainEnabled, false); curtainColor = typedArray.getColor(R.styleable.WheelView_wheel_curtainColor, 0xFFFFFFFF); + curtainCorner = CurtainCorner.NONE; + curtainRadius = typedArray.getDimension(R.styleable.WheelView_wheel_curtainRadius, 0); atmosphericEnabled = typedArray.getBoolean(R.styleable.WheelView_wheel_atmosphericEnabled, false); curvedEnabled = typedArray.getBoolean(R.styleable.WheelView_wheel_curvedEnabled, false); curvedMaxAngle = typedArray.getInteger(R.styleable.WheelView_wheel_curvedMaxAngle, 90); @@ -491,6 +504,26 @@ public void setCurtainColor(@ColorInt int color) { invalidate(); } + @CurtainCorner + public int getCurtainCorner() { + return curtainCorner; + } + + public void setCurtainCorner(@CurtainCorner int curtainCorner) { + this.curtainCorner = curtainCorner; + invalidate(); + } + + @Px + public float getCurtainRadius() { + return curtainRadius; + } + + public void setCurtainRadius(@Px float curtainRadius) { + this.curtainRadius = curtainRadius; + invalidate(); + } + public boolean isAtmosphericEnabled() { return atmosphericEnabled; } @@ -857,24 +890,65 @@ private void computeAndSetAtmospheric(int abs) { private void drawCurtain(Canvas canvas) { // Need to draw curtain or not - if (curtainEnabled) { - int red = Color.red(curtainColor); - int green = Color.green(curtainColor); - int blue = Color.blue(curtainColor); - paint.setColor(Color.argb(128, red, green, blue)); - paint.setStyle(Paint.Style.FILL); - canvas.drawRect(rectCurrentItem, paint); + if (!curtainEnabled) { + return; } + int red = Color.red(curtainColor); + int green = Color.green(curtainColor); + int blue = Color.blue(curtainColor); + paint.setColor(Color.argb(128, red, green, blue)); + paint.setStyle(Paint.Style.FILL); + if (curtainRadius > 0) { + //canvas.drawRoundRect(new RectF(rectCurrentItem), curtainRadius, curtainRadius, paint); + Path path = new Path(); + float[] radii; + switch (curtainCorner) { + case CurtainCorner.ALL: + radii = new float[]{ + curtainRadius, curtainRadius, curtainRadius, curtainRadius, + curtainRadius, curtainRadius, curtainRadius, curtainRadius + }; + break; + case CurtainCorner.TOP: + radii = new float[]{ + curtainRadius, curtainRadius, curtainRadius, curtainRadius, 0, 0, 0, 0 + }; + break; + case CurtainCorner.BOTTOM: + radii = new float[]{ + 0, 0, 0, 0, curtainRadius, curtainRadius, curtainRadius, curtainRadius + }; + break; + case CurtainCorner.LEFT: + radii = new float[]{ + curtainRadius, curtainRadius, 0, 0, 0, 0, curtainRadius, curtainRadius + }; + break; + case CurtainCorner.RIGHT: + radii = new float[]{ + 0, 0, curtainRadius, curtainRadius, curtainRadius, curtainRadius, 0, 0 + }; + break; + default: + radii = new float[]{0, 0, 0, 0, 0, 0, 0, 0}; + break; + } + path.addRoundRect(new RectF(rectCurrentItem), radii, Path.Direction.CCW); + canvas.drawPath(path, paint); + return; + } + canvas.drawRect(rectCurrentItem, paint); } private void drawIndicator(Canvas canvas) { // Need to draw indicator or not - if (indicatorEnabled) { - paint.setColor(indicatorColor); - paint.setStyle(Paint.Style.FILL); - canvas.drawRect(rectIndicatorHead, paint); - canvas.drawRect(rectIndicatorFoot, paint); + if (!indicatorEnabled) { + return; } + paint.setColor(indicatorColor); + paint.setStyle(Paint.Style.FILL); + canvas.drawRect(rectIndicatorHead, paint); + canvas.drawRect(rectIndicatorFoot, paint); } private boolean isPositionInRange(int position, int itemCount) { @@ -945,7 +1019,7 @@ private void handleActionMove(MotionEvent event) { tracker.addMovement(event); } if (null != onWheelChangedListener) { - onWheelChangedListener.onWheelScrollStateChanged(this, SCROLL_STATE_DRAGGING); + onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.DRAGGING); } // Scroll WheelPicker's content float move = event.getY() - lastPointYCoordinate; @@ -1041,7 +1115,7 @@ public void run() { int itemCount = getItemCount(); if (itemCount == 0) { if (null != onWheelChangedListener) { - onWheelChangedListener.onWheelScrollStateChanged(this, SCROLL_STATE_IDLE); + onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.IDLE); } return; } @@ -1051,7 +1125,7 @@ public void run() { currentPosition = position; if (null != onWheelChangedListener) { onWheelChangedListener.onWheelSelected(this, position); - onWheelChangedListener.onWheelScrollStateChanged(this, SCROLL_STATE_IDLE); + onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.IDLE); } postInvalidate(); return; @@ -1059,7 +1133,7 @@ public void run() { // Scroll not finished if (scroller.computeScrollOffset()) { if (null != onWheelChangedListener) { - onWheelChangedListener.onWheelScrollStateChanged(this, SCROLL_STATE_SCROLLING); + onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.SCROLLING); } scrollOffsetYCoordinate = scroller.getCurrY(); int position = computePosition(itemCount); diff --git a/WheelView/src/main/res/values/wheel_attrs.xml b/WheelView/src/main/res/values/wheel_attrs.xml index a19a964d..4b6b4273 100644 --- a/WheelView/src/main/res/values/wheel_attrs.xml +++ b/WheelView/src/main/res/values/wheel_attrs.xml @@ -33,6 +33,7 @@ + @@ -53,6 +54,7 @@ + diff --git a/app/src/main/assets/china_address_guizhou.json b/app/src/main/assets/china_address_guizhou.json new file mode 100644 index 00000000..922a3952 --- /dev/null +++ b/app/src/main/assets/china_address_guizhou.json @@ -0,0 +1,722 @@ +[ + { + "id": "2486", + "name": "贵州省", + "code": "520000", + "deep": "1", + "pid": "0", + "city": [ + { + "id": "2487", + "name": "贵阳市", + "code": "520100", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2488", + "name": "南明区", + "code": "520102", + "deep": "3", + "pid": "2487" + }, + { + "id": "2489", + "name": "云岩区", + "code": "520103", + "deep": "3", + "pid": "2487" + }, + { + "id": "2490", + "name": "花溪区", + "code": "520111", + "deep": "3", + "pid": "2487" + }, + { + "id": "2491", + "name": "乌当区", + "code": "520112", + "deep": "3", + "pid": "2487" + }, + { + "id": "2492", + "name": "白云区", + "code": "520113", + "deep": "3", + "pid": "2487" + }, + { + "id": "2493", + "name": "观山湖区", + "code": "520115", + "deep": "3", + "pid": "2487" + }, + { + "id": "2494", + "name": "开阳县", + "code": "520121", + "deep": "3", + "pid": "2487" + }, + { + "id": "2495", + "name": "息烽县", + "code": "520122", + "deep": "3", + "pid": "2487" + }, + { + "id": "2496", + "name": "修文县", + "code": "520123", + "deep": "3", + "pid": "2487" + }, + { + "id": "2497", + "name": "清镇市", + "code": "520181", + "deep": "3", + "pid": "2487" + } + ] + }, + { + "id": "2498", + "name": "六盘水市", + "code": "520200", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2499", + "name": "钟山区", + "code": "520201", + "deep": "3", + "pid": "2498" + }, + { + "id": "2500", + "name": "六枝特区", + "code": "520203", + "deep": "3", + "pid": "2498" + }, + { + "id": "2501", + "name": "水城县", + "code": "520221", + "deep": "3", + "pid": "2498" + }, + { + "id": "2502", + "name": "盘县", + "code": "520222", + "deep": "3", + "pid": "2498" + }, + { + "id": "3368", + "name": "盘州市", + "code": "520281", + "deep": "3", + "pid": "2498" + } + ] + }, + { + "id": "2503", + "name": "遵义市", + "code": "520300", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2504", + "name": "红花岗区", + "code": "520302", + "deep": "3", + "pid": "2503" + }, + { + "id": "2505", + "name": "汇川区", + "code": "520303", + "deep": "3", + "pid": "2503" + }, + { + "id": "2506", + "name": "遵义县", + "code": "520321", + "deep": "3", + "pid": "2503" + }, + { + "id": "2507", + "name": "桐梓县", + "code": "520322", + "deep": "3", + "pid": "2503" + }, + { + "id": "2508", + "name": "绥阳县", + "code": "520323", + "deep": "3", + "pid": "2503" + }, + { + "id": "2509", + "name": "正安县", + "code": "520324", + "deep": "3", + "pid": "2503" + }, + { + "id": "2510", + "name": "道真仡佬族苗族自治县", + "code": "520325", + "deep": "3", + "pid": "2503" + }, + { + "id": "2511", + "name": "务川仡佬族苗族自治县", + "code": "520326", + "deep": "3", + "pid": "2503" + }, + { + "id": "2512", + "name": "凤冈县", + "code": "520327", + "deep": "3", + "pid": "2503" + }, + { + "id": "2513", + "name": "湄潭县", + "code": "520328", + "deep": "3", + "pid": "2503" + }, + { + "id": "2514", + "name": "余庆县", + "code": "520329", + "deep": "3", + "pid": "2503" + }, + { + "id": "2515", + "name": "习水县", + "code": "520330", + "deep": "3", + "pid": "2503" + }, + { + "id": "2516", + "name": "赤水市", + "code": "520381", + "deep": "3", + "pid": "2503" + }, + { + "id": "2517", + "name": "仁怀市", + "code": "520382", + "deep": "3", + "pid": "2503" + }, + { + "id": "3369", + "name": "播州区", + "code": "520304", + "deep": "3", + "pid": "2503" + } + ] + }, + { + "id": "2518", + "name": "安顺市", + "code": "520400", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2519", + "name": "西秀区", + "code": "520402", + "deep": "3", + "pid": "2518" + }, + { + "id": "2520", + "name": "平坝区", + "code": "520403", + "deep": "3", + "pid": "2518" + }, + { + "id": "2521", + "name": "普定县", + "code": "520422", + "deep": "3", + "pid": "2518" + }, + { + "id": "2522", + "name": "镇宁布依族苗族自治县", + "code": "520423", + "deep": "3", + "pid": "2518" + }, + { + "id": "2523", + "name": "关岭布依族苗族自治县", + "code": "520424", + "deep": "3", + "pid": "2518" + }, + { + "id": "2524", + "name": "紫云苗族布依族自治县", + "code": "520425", + "deep": "3", + "pid": "2518" + } + ] + }, + { + "id": "2525", + "name": "毕节市", + "code": "520500", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2526", + "name": "七星关区", + "code": "520502", + "deep": "3", + "pid": "2525" + }, + { + "id": "2527", + "name": "大方县", + "code": "520521", + "deep": "3", + "pid": "2525" + }, + { + "id": "2528", + "name": "黔西县", + "code": "520522", + "deep": "3", + "pid": "2525" + }, + { + "id": "2529", + "name": "金沙县", + "code": "520523", + "deep": "3", + "pid": "2525" + }, + { + "id": "2530", + "name": "织金县", + "code": "520524", + "deep": "3", + "pid": "2525" + }, + { + "id": "2531", + "name": "纳雍县", + "code": "520525", + "deep": "3", + "pid": "2525" + }, + { + "id": "2532", + "name": "威宁彝族回族苗族自治县", + "code": "520526", + "deep": "3", + "pid": "2525" + }, + { + "id": "2533", + "name": "赫章县", + "code": "520527", + "deep": "3", + "pid": "2525" + } + ] + }, + { + "id": "2534", + "name": "铜仁市", + "code": "520600", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2535", + "name": "碧江区", + "code": "520602", + "deep": "3", + "pid": "2534" + }, + { + "id": "2536", + "name": "万山区", + "code": "520603", + "deep": "3", + "pid": "2534" + }, + { + "id": "2537", + "name": "江口县", + "code": "520621", + "deep": "3", + "pid": "2534" + }, + { + "id": "2538", + "name": "玉屏侗族自治县", + "code": "520622", + "deep": "3", + "pid": "2534" + }, + { + "id": "2539", + "name": "石阡县", + "code": "520623", + "deep": "3", + "pid": "2534" + }, + { + "id": "2540", + "name": "思南县", + "code": "520624", + "deep": "3", + "pid": "2534" + }, + { + "id": "2541", + "name": "印江土家族苗族自治县", + "code": "520625", + "deep": "3", + "pid": "2534" + }, + { + "id": "2542", + "name": "德江县", + "code": "520626", + "deep": "3", + "pid": "2534" + }, + { + "id": "2543", + "name": "沿河土家族自治县", + "code": "520627", + "deep": "3", + "pid": "2534" + }, + { + "id": "2544", + "name": "松桃苗族自治县", + "code": "520628", + "deep": "3", + "pid": "2534" + } + ] + }, + { + "id": "2545", + "name": "黔西南布依族苗族自治州", + "code": "522300", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2546", + "name": "兴义市", + "code": "522301", + "deep": "3", + "pid": "2545" + }, + { + "id": "2547", + "name": "兴仁县", + "code": "522322", + "deep": "3", + "pid": "2545" + }, + { + "id": "2548", + "name": "普安县", + "code": "522323", + "deep": "3", + "pid": "2545" + }, + { + "id": "2549", + "name": "晴隆县", + "code": "522324", + "deep": "3", + "pid": "2545" + }, + { + "id": "2550", + "name": "贞丰县", + "code": "522325", + "deep": "3", + "pid": "2545" + }, + { + "id": "2551", + "name": "望谟县", + "code": "522326", + "deep": "3", + "pid": "2545" + }, + { + "id": "2552", + "name": "册亨县", + "code": "522327", + "deep": "3", + "pid": "2545" + }, + { + "id": "2553", + "name": "安龙县", + "code": "522328", + "deep": "3", + "pid": "2545" + } + ] + }, + { + "id": "2554", + "name": "黔东南苗族侗族自治州", + "code": "522600", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2555", + "name": "凯里市", + "code": "522601", + "deep": "3", + "pid": "2554" + }, + { + "id": "2556", + "name": "黄平县", + "code": "522622", + "deep": "3", + "pid": "2554" + }, + { + "id": "2557", + "name": "施秉县", + "code": "522623", + "deep": "3", + "pid": "2554" + }, + { + "id": "2558", + "name": "三穗县", + "code": "522624", + "deep": "3", + "pid": "2554" + }, + { + "id": "2559", + "name": "镇远县", + "code": "522625", + "deep": "3", + "pid": "2554" + }, + { + "id": "2560", + "name": "岑巩县", + "code": "522626", + "deep": "3", + "pid": "2554" + }, + { + "id": "2561", + "name": "天柱县", + "code": "522627", + "deep": "3", + "pid": "2554" + }, + { + "id": "2562", + "name": "锦屏县", + "code": "522628", + "deep": "3", + "pid": "2554" + }, + { + "id": "2563", + "name": "剑河县", + "code": "522629", + "deep": "3", + "pid": "2554" + }, + { + "id": "2564", + "name": "台江县", + "code": "522630", + "deep": "3", + "pid": "2554" + }, + { + "id": "2565", + "name": "黎平县", + "code": "522631", + "deep": "3", + "pid": "2554" + }, + { + "id": "2566", + "name": "榕江县", + "code": "522632", + "deep": "3", + "pid": "2554" + }, + { + "id": "2567", + "name": "从江县", + "code": "522633", + "deep": "3", + "pid": "2554" + }, + { + "id": "2568", + "name": "雷山县", + "code": "522634", + "deep": "3", + "pid": "2554" + }, + { + "id": "2569", + "name": "麻江县", + "code": "522635", + "deep": "3", + "pid": "2554" + }, + { + "id": "2570", + "name": "丹寨县", + "code": "522636", + "deep": "3", + "pid": "2554" + } + ] + }, + { + "id": "2571", + "name": "黔南布依族苗族自治州", + "code": "522700", + "deep": "2", + "pid": "2486", + "area": [ + { + "id": "2572", + "name": "都匀市", + "code": "522701", + "deep": "3", + "pid": "2571" + }, + { + "id": "2573", + "name": "福泉市", + "code": "522702", + "deep": "3", + "pid": "2571" + }, + { + "id": "2574", + "name": "荔波县", + "code": "522722", + "deep": "3", + "pid": "2571" + }, + { + "id": "2575", + "name": "贵定县", + "code": "522723", + "deep": "3", + "pid": "2571" + }, + { + "id": "2576", + "name": "瓮安县", + "code": "522725", + "deep": "3", + "pid": "2571" + }, + { + "id": "2577", + "name": "独山县", + "code": "522726", + "deep": "3", + "pid": "2571" + }, + { + "id": "2578", + "name": "平塘县", + "code": "522727", + "deep": "3", + "pid": "2571" + }, + { + "id": "2579", + "name": "罗甸县", + "code": "522728", + "deep": "3", + "pid": "2571" + }, + { + "id": "2580", + "name": "长顺县", + "code": "522729", + "deep": "3", + "pid": "2571" + }, + { + "id": "2581", + "name": "龙里县", + "code": "522730", + "deep": "3", + "pid": "2571" + }, + { + "id": "2582", + "name": "惠水县", + "code": "522731", + "deep": "3", + "pid": "2571" + }, + { + "id": "2583", + "name": "三都水族自治县", + "code": "522732", + "deep": "3", + "pid": "2571" + } + ] + } + ] + } +] diff --git a/app/src/main/assets/china_address_guizhou_city.json b/app/src/main/assets/china_address_guizhou_city.json new file mode 100644 index 00000000..5d92cc97 --- /dev/null +++ b/app/src/main/assets/china_address_guizhou_city.json @@ -0,0 +1,83 @@ +[ + { + "id": "2486", + "name": "贵州省", + "code": "520000", + "deep": "1", + "pid": "0", + "city": [ + { + "id": "2487", + "name": "贵阳市", + "code": "520100", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2498", + "name": "六盘水市", + "code": "520200", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2503", + "name": "遵义市", + "code": "520300", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2518", + "name": "安顺市", + "code": "520400", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2525", + "name": "毕节市", + "code": "520500", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2534", + "name": "铜仁市", + "code": "520600", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2545", + "name": "黔西南布依族苗族自治州", + "code": "522300", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2554", + "name": "黔东南苗族侗族自治州", + "code": "522600", + "deep": "2", + "pid": "2486", + "area": [] + }, + { + "id": "2571", + "name": "黔南布依族苗族自治州", + "code": "522700", + "deep": "2", + "pid": "2486", + "area": [] + } + ] + } +] diff --git a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/AddressPickerActivity.java b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/AddressPickerActivity.java index 9798d339..29824730 100644 --- a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/AddressPickerActivity.java +++ b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/AddressPickerActivity.java @@ -31,6 +31,8 @@ import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import com.github.gzuliyujiang.wheelpicker.utility.AddressJsonParser; +import com.github.gzuliyujiang.wheelpicker.widget.LinkageWheelLayout; +import com.github.gzuliyujiang.wheelview.annotation.CurtainCorner; /** * 地址滚轮选择器 @@ -70,6 +72,7 @@ public void onLinkageSelected(Object first, Object second, Object third) { public void onProvinceCity(View view) { AddressPicker picker = new AddressPicker(this); + picker.setTitle("省市选择"); picker.setAddressMode(AddressMode.PROVINCE_CITY); picker.setDefaultValue("520000", "520100", ""); picker.setOnAddressPickedListener(this); @@ -82,13 +85,59 @@ public void onLinkageSelected(Object first, Object second, Object third) { picker.getThirdWheelView().formatItem(third))); } }); - picker.getTitleView().setText("省市选择"); + picker.show(); + } + + public void onProvinceCityForGuiZhou(View view) { + AddressPicker picker = new AddressPicker(this); + picker.setAddressMode("china_address_guizhou_city.json", AddressMode.PROVINCE_CITY, + new AddressJsonParser.Builder() + .provinceCodeField("code") + .provinceNameField("name") + .provinceChildField("city") + .cityCodeField("code") + .cityNameField("name") + .cityChildField("area") + .countyCodeField("code") + .countyNameField("name") + .build()); + picker.setTitle("贵州省地址选择"); + picker.setDefaultValue("贵州省", "毕节市", "纳雍县"); + picker.setOnAddressPickedListener(this); + LinkageWheelLayout wheelLayout = picker.getWheelLayout(); + wheelLayout.setIndicatorEnabled(false); + wheelLayout.setCurtainEnabled(true); + wheelLayout.setCurtainColor(0xEE0081FF); + wheelLayout.setCurtainRadius(5 * view.getResources().getDisplayMetrics().density); + int padding = (int) (10 * view.getResources().getDisplayMetrics().density); + wheelLayout.setPadding(padding, 0, padding, 0); + wheelLayout.setOnLinkageSelectedListener(new OnLinkageSelectedListener() { + @Override + public void onLinkageSelected(Object first, Object second, Object third) { + picker.getTitleView().setText(String.format("%s%s%s", + picker.getFirstWheelView().formatItem(first), + picker.getSecondWheelView().formatItem(second), + picker.getThirdWheelView().formatItem(third))); + } + }); + picker.getProvinceWheelView().setCurtainCorner(CurtainCorner.LEFT); + picker.getCityWheelView().setCurtainCorner(CurtainCorner.RIGHT); picker.show(); } public void onCityCounty(View view) { AddressPicker picker = new AddressPicker(this); - picker.setAddressMode(AddressMode.CITY_COUNTY); + picker.setAddressMode("china_address_guizhou.json", AddressMode.CITY_COUNTY, + new AddressJsonParser.Builder() + .provinceCodeField("code") + .provinceNameField("name") + .provinceChildField("city") + .cityCodeField("code") + .cityNameField("name") + .cityChildField("area") + .countyCodeField("code") + .countyNameField("name") + .build()); picker.setTitle("贵州省地址选择"); picker.setDefaultValue("贵州省", "毕节市", "纳雍县"); picker.setOnAddressPickedListener(this); diff --git a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/CalendarPickerActivity.java b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/CalendarPickerActivity.java index 6fb23fc6..c5b6940d 100644 --- a/app/src/main/java/com/github/gzuliyujiang/fallback/activity/CalendarPickerActivity.java +++ b/app/src/main/java/com/github/gzuliyujiang/fallback/activity/CalendarPickerActivity.java @@ -26,11 +26,14 @@ import com.github.gzuliyujiang.calendarpicker.core.CalendarView; import com.github.gzuliyujiang.calendarpicker.core.ColorScheme; import com.github.gzuliyujiang.calendarpicker.core.DateUtils; +import com.github.gzuliyujiang.calendarpicker.core.FestivalProvider; import com.github.gzuliyujiang.fallback.R; import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; /** * 日历日期选择器 @@ -53,6 +56,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { calendarView.getAdapter() .notify(false) .single(false) + .festivalProvider(new MyFestivalProvider()) .valid(minDate, maxDate) .intervalNotes("开始", "结束") .select(minDate.getTime(), minDate.getTime() + 5 * android.text.format.DateUtils.DAY_IN_MILLIS) @@ -120,6 +124,7 @@ public void onCalendarDateSingle(View view) { singleTimeInMillis = System.currentTimeMillis(); } picker.setSelectedDate(singleTimeInMillis); + picker.setFestivalProvider(new MyFestivalProvider()); picker.setOnSingleDatePickListener(new OnSingleDatePickListener() { @Override public void onSingleDatePicked(@NonNull Date date) { @@ -130,5 +135,45 @@ public void onSingleDatePicked(@NonNull Date date) { picker.show(); } + private static class MyFestivalProvider implements FestivalProvider { + @Override + public String provideText(Date date) { + String monthDay = new SimpleDateFormat("MMdd", Locale.PRC).format(date); + switch (monthDay) { + case "0101": + return "元旦节"; + case "0214": + return "情人节"; + case "0308": + return "妇女节"; + case "0312": + return "植树节"; + case "0401": + return "愚人节"; + case "0501": + return "劳动节"; + case "0504": + return "青年节"; + case "0601": + return "儿童节"; + case "0701": + return "建党节"; + case "0801": + return "建军节"; + case "0910": + return "教师节"; + case "1001": + return "国庆节"; + case "1111": + return "光棍节"; + case "1225": + return "圣诞节"; + default: + return ""; + } + } + } + + } 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 b7c9987d..69e454c1 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 @@ -33,10 +33,13 @@ import com.github.gzuliyujiang.wheelpicker.contract.OnNumberSelectedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionPickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionSelectedListener; +import com.github.gzuliyujiang.wheelpicker.widget.OptionWheelLayout; +import com.github.gzuliyujiang.wheelview.annotation.CurtainCorner; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; /** @@ -135,24 +138,30 @@ public void onOptionBean(View view) { OptionPicker picker = new OptionPicker(this); picker.setTitle("货物分类"); picker.setBodyWidth(140); - picker.getWheelView().setIndicatorColor(0xFFFF0000); - picker.getWheelView().setTextColor(0xFFFF00FF); - picker.getWheelView().setSelectedTextColor(0xFFFF0000); + picker.setData(data); + picker.setDefaultPosition(2); picker.setOnOptionPickedListener(this); - picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { + OptionWheelLayout wheelLayout = picker.getWheelLayout(); + wheelLayout.setIndicatorEnabled(false); + wheelLayout.setTextColor(0xFFFF00FF); + wheelLayout.setSelectedTextColor(0xFFFF0000); + wheelLayout.setCurtainEnabled(true); + wheelLayout.setCurtainColor(0xEEFF0000); + wheelLayout.setCurtainCorner(CurtainCorner.ALL); + wheelLayout.setCurtainRadius(5 * view.getResources().getDisplayMetrics().density); + wheelLayout.setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); - picker.setData(data); - picker.setDefaultPosition(2); picker.show(); } public void onSex(View view) { - SexPicker picker = new SexPicker(this, true); + SexPicker picker = new SexPicker(this); picker.setBodyWidth(140); + picker.setIncludeSecrecy(false); picker.setDefaultValue("女"); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @@ -182,9 +191,14 @@ public void onOptionSelected(int position, Object item) { } public void onConstellation(View view) { - ConstellationPicker picker = new ConstellationPicker(this, true); + ConstellationPicker picker = new ConstellationPicker(this); picker.setBodyWidth(140); - picker.setDefaultValue("射手座"); + picker.setIncludeUnlimited(true); + //picker.setDefaultValueByName("射手座"); + //picker.setDefaultValueByDate(DateEntity.target(1991, 12, 9)); + Calendar calendar = Calendar.getInstance(); + calendar.set(1991, 11, 9); + picker.setDefaultValueByDate(calendar.getTime()); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override diff --git a/app/src/main/java/com/github/gzuliyujiang/fallback/custom/CustomAddressPicker.java b/app/src/main/java/com/github/gzuliyujiang/fallback/custom/CustomAddressPicker.java index 50ee0014..aecc123b 100644 --- a/app/src/main/java/com/github/gzuliyujiang/fallback/custom/CustomAddressPicker.java +++ b/app/src/main/java/com/github/gzuliyujiang/fallback/custom/CustomAddressPicker.java @@ -40,7 +40,7 @@ * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 16:03 */ -public class CustomAddressPicker extends BottomDialog implements AddressReceiver { +public class CustomAddressPicker extends BottomDialog implements AddressReceiver, View.OnClickListener { protected LinkageWheelLayout wheelLayout; private OnAddressPickedListener onAddressPickedListener; @@ -48,6 +48,10 @@ public CustomAddressPicker(@NonNull Activity activity) { super(activity); } + public CustomAddressPicker(@NonNull Activity activity, int themeResId) { + super(activity, themeResId); + } + @NonNull @Override protected View createContentView() { @@ -57,24 +61,8 @@ protected View createContentView() { @Override protected void initView() { super.initView(); - contentView.findViewById(R.id.wheel_picker_address_cancel).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dismiss(); - } - }); - contentView.findViewById(R.id.wheel_picker_address_confirm).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (onAddressPickedListener != null) { - ProvinceEntity province = (ProvinceEntity) wheelLayout.getFirstWheelView().getCurrentItem(); - CityEntity city = (CityEntity) wheelLayout.getSecondWheelView().getCurrentItem(); - CountyEntity county = (CountyEntity) wheelLayout.getThirdWheelView().getCurrentItem(); - onAddressPickedListener.onAddressPicked(province, city, county); - } - dismiss(); - } - }); + contentView.findViewById(R.id.wheel_picker_address_cancel).setOnClickListener(this); + contentView.findViewById(R.id.wheel_picker_address_confirm).setOnClickListener(this); wheelLayout = contentView.findViewById(R.id.wheel_picker_address_wheel); } @@ -102,6 +90,24 @@ public void onAddressReceived(@NonNull List data) { wheelLayout.setData(new AddressProvider(data, AddressMode.PROVINCE_CITY_COUNTY)); } + @Override + public void onClick(View v) { + int id = v.getId(); + if (id == R.id.wheel_picker_address_cancel) { + dismiss(); + return; + } + if (id == R.id.wheel_picker_address_confirm) { + if (onAddressPickedListener != null) { + ProvinceEntity province = (ProvinceEntity) wheelLayout.getFirstWheelView().getCurrentItem(); + CityEntity city = (CityEntity) wheelLayout.getSecondWheelView().getCurrentItem(); + CountyEntity county = (CountyEntity) wheelLayout.getThirdWheelView().getCurrentItem(); + onAddressPickedListener.onAddressPicked(province, city, county); + } + dismiss(); + } + } + public void setDefaultValue(String province, String city, String county) { wheelLayout.setDefaultValue(province, city, county); } diff --git a/app/src/main/res/layout/activity_picker_address.xml b/app/src/main/res/layout/activity_picker_address.xml index 55d41f63..7d3218b5 100644 --- a/app/src/main/res/layout/activity_picker_address.xml +++ b/app/src/main/res/layout/activity_picker_address.xml @@ -27,25 +27,31 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="onProvinceCityCounty" - android:text="省市县选择(默认数据源为国家民政局2020年12月)" /> + android:text="省市县选择(数据为国家民政局2020年12月)" />