Repository: gzu-liyujiang/AndroidPicker Branch: master Commit: e60e1e839318 Files: 290 Total size: 2.1 MB Directory structure: gitextract_q7ux4klz/ ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ ├── gradle-publish.yml │ └── release-apk.yml ├── .gitignore ├── .idea/ │ ├── codeStyles/ │ │ └── Project.xml │ ├── copyright/ │ │ ├── liyujiang_Default.xml │ │ ├── liyujiang_MulanPSL.xml │ │ └── profiles_settings.xml │ └── inspectionProfiles/ │ └── Project_Default.xml ├── .jitpack.yml ├── API.md ├── AddressPicker/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── assets/ │ │ └── china_address.json │ └── java/ │ └── com/ │ └── github/ │ └── gzuliyujiang/ │ └── wheelpicker/ │ ├── AddressPicker.java │ ├── annotation/ │ │ └── AddressMode.java │ ├── contract/ │ │ ├── AddressLoader.java │ │ ├── AddressParser.java │ │ ├── AddressReceiver.java │ │ ├── OnAddressLoadListener.java │ │ └── OnAddressPickedListener.java │ ├── entity/ │ │ ├── AddressEntity.java │ │ ├── CityEntity.java │ │ ├── CountyEntity.java │ │ └── ProvinceEntity.java │ ├── impl/ │ │ ├── AddressProvider.java │ │ └── AssetAddressLoader.java │ └── utility/ │ └── AddressJsonParser.java ├── CalendarPicker/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── calendarpicker/ │ │ ├── CalendarPicker.java │ │ ├── OnRangeDatePickListener.java │ │ ├── OnSingleDatePickListener.java │ │ ├── core/ │ │ │ ├── CalendarAdapter.java │ │ │ ├── CalendarView.java │ │ │ ├── ColorScheme.java │ │ │ ├── DateUtils.java │ │ │ ├── DayEntity.java │ │ │ ├── DayStatus.java │ │ │ ├── DayView.java │ │ │ ├── FestivalProvider.java │ │ │ ├── Interval.java │ │ │ ├── ItemViewProvider.java │ │ │ ├── MonthEntity.java │ │ │ ├── MonthView.java │ │ │ ├── NumInterval.java │ │ │ ├── OnDateClickListener.java │ │ │ ├── OnDateSelectedListener.java │ │ │ ├── TimeUtils.java │ │ │ └── WeekAdapter.java │ │ └── listener/ │ │ ├── OnPageChangeCallback.java │ │ └── ScrollEventAdapter.java │ └── res/ │ └── layout/ │ └── calendar_body.xml ├── ChangeLog.md ├── ColorPicker/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── colorpicker/ │ │ ├── BrightnessGradientView.java │ │ ├── ColorGradientView.java │ │ ├── ColorPicker.java │ │ ├── OnColorChangedListener.java │ │ ├── OnColorPickedListener.java │ │ ├── SavedState.java │ │ └── Utils.java │ └── res/ │ └── layout/ │ └── color_picker_content.xml ├── Common/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── dialog/ │ │ ├── BaseDialog.java │ │ ├── BottomDialog.java │ │ ├── CornerRound.java │ │ ├── DialogColor.java │ │ ├── DialogConfig.java │ │ ├── DialogLog.java │ │ ├── DialogStyle.java │ │ └── ModalDialog.java │ └── res/ │ ├── anim/ │ │ ├── dialog_sheet_enter.xml │ │ └── dialog_sheet_exit.xml │ ├── layout/ │ │ ├── dialog_footer_style_1.xml │ │ ├── dialog_footer_style_2.xml │ │ ├── dialog_footer_style_3.xml │ │ ├── dialog_header_style_1.xml │ │ ├── dialog_header_style_2.xml │ │ ├── dialog_header_style_3.xml │ │ └── dialog_header_style_default.xml │ └── values/ │ ├── dialog_anims.xml │ └── dialog_themes.xml ├── FilePicker/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── filepicker/ │ │ ├── ExplorerConfig.java │ │ ├── FileExplorer.java │ │ ├── FilePicker.java │ │ ├── adapter/ │ │ │ ├── FileAdapter.java │ │ │ ├── FileEntity.java │ │ │ ├── PathAdapter.java │ │ │ └── ViewHolder.java │ │ ├── annotation/ │ │ │ ├── ExplorerMode.java │ │ │ └── FileSort.java │ │ ├── contract/ │ │ │ ├── OnFileClickedListener.java │ │ │ ├── OnFileLoadedListener.java │ │ │ ├── OnFilePickedListener.java │ │ │ └── OnPathClickedListener.java │ │ ├── filter/ │ │ │ ├── PatternFilter.java │ │ │ └── SimpleFilter.java │ │ └── sort/ │ │ ├── SortByExtension.java │ │ ├── SortByName.java │ │ ├── SortBySize.java │ │ └── SortByTime.java │ └── res/ │ └── layout/ │ └── file_picker_content.xml ├── ImagePicker/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── imagepicker/ │ │ ├── ActivityBuilder.java │ │ ├── ActivityResult.java │ │ ├── BitmapCroppingTask.java │ │ ├── BitmapLoadingTask.java │ │ ├── BitmapUtils.java │ │ ├── CropImageActivity.java │ │ ├── CropImageAnimation.java │ │ ├── CropImageConsts.java │ │ ├── CropImageOptions.java │ │ ├── CropImageView.java │ │ ├── CropOverlayView.java │ │ ├── CropWindowHandler.java │ │ ├── CropWindowMoveHandler.java │ │ ├── HybridityUtils.java │ │ ├── ImagePicker.java │ │ ├── ImageProvider.java │ │ └── PickCallback.java │ └── res/ │ ├── layout/ │ │ ├── crop_image_activity.xml │ │ └── crop_image_view.xml │ ├── values/ │ │ └── crop_image_attrs.xml │ └── xml/ │ └── crop_image_paths.xml ├── LICENSE ├── NOTICE ├── README.md ├── WheelPicker/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── wheelpicker/ │ │ ├── BirthdayPicker.java │ │ ├── CarPlatePicker.java │ │ ├── ConstellationPicker.java │ │ ├── DatePicker.java │ │ ├── DatimePicker.java │ │ ├── EthnicPicker.java │ │ ├── LinkagePicker.java │ │ ├── NumberPicker.java │ │ ├── OptionPicker.java │ │ ├── PhoneCodePicker.java │ │ ├── SexPicker.java │ │ ├── TimePicker.java │ │ ├── annotation/ │ │ │ ├── DateMode.java │ │ │ ├── EthnicSpec.java │ │ │ └── TimeMode.java │ │ ├── contract/ │ │ │ ├── DateFormatter.java │ │ │ ├── LinkageProvider.java │ │ │ ├── OnCarPlatePickedListener.java │ │ │ ├── OnDatePickedListener.java │ │ │ ├── OnDateSelectedListener.java │ │ │ ├── OnDatimePickedListener.java │ │ │ ├── OnDatimeSelectedListener.java │ │ │ ├── OnLinkagePickedListener.java │ │ │ ├── OnLinkageSelectedListener.java │ │ │ ├── OnNumberPickedListener.java │ │ │ ├── OnNumberSelectedListener.java │ │ │ ├── OnOptionPickedListener.java │ │ │ ├── OnOptionSelectedListener.java │ │ │ ├── OnTimeMeridiemPickedListener.java │ │ │ ├── OnTimeMeridiemSelectedListener.java │ │ │ ├── OnTimePickedListener.java │ │ │ ├── OnTimeSelectedListener.java │ │ │ └── TimeFormatter.java │ │ ├── entity/ │ │ │ ├── ConstellationEntity.java │ │ │ ├── DateEntity.java │ │ │ ├── DatimeEntity.java │ │ │ ├── EthnicEntity.java │ │ │ ├── PhoneCodeEntity.java │ │ │ ├── SexEntity.java │ │ │ └── TimeEntity.java │ │ ├── impl/ │ │ │ ├── BirthdayFormatter.java │ │ │ ├── CarPlateProvider.java │ │ │ ├── SimpleDateFormatter.java │ │ │ ├── SimpleTimeFormatter.java │ │ │ ├── SimpleWheelFormatter.java │ │ │ ├── UnitDateFormatter.java │ │ │ └── UnitTimeFormatter.java │ │ └── widget/ │ │ ├── BaseWheelLayout.java │ │ ├── CarPlateWheelLayout.java │ │ ├── DateWheelLayout.java │ │ ├── DatimeWheelLayout.java │ │ ├── LinkageWheelLayout.java │ │ ├── NumberWheelLayout.java │ │ ├── OptionWheelLayout.java │ │ └── TimeWheelLayout.java │ └── res/ │ ├── layout/ │ │ ├── wheel_picker_date.xml │ │ ├── wheel_picker_datime.xml │ │ ├── wheel_picker_linkage.xml │ │ ├── wheel_picker_number.xml │ │ ├── wheel_picker_option.xml │ │ └── wheel_picker_time.xml │ └── values/ │ └── wheel_attrs.xml ├── WheelView/ │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── wheelview/ │ │ ├── annotation/ │ │ │ ├── CurtainCorner.java │ │ │ ├── ItemTextAlign.java │ │ │ └── ScrollState.java │ │ ├── contract/ │ │ │ ├── OnWheelChangedListener.java │ │ │ ├── TextProvider.java │ │ │ └── WheelFormatter.java │ │ └── widget/ │ │ ├── NumberWheelView.java │ │ └── WheelView.java │ └── res/ │ └── values/ │ ├── wheel_attrs.xml │ └── wheel_styles.xml ├── _config.yml ├── app/ │ ├── build.gradle │ ├── debug.keystore │ ├── gradle.properties │ ├── proguard-common.pro │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── assets/ │ │ ├── china_address_guizhou.json │ │ ├── china_address_guizhou_city.json │ │ ├── city.json │ │ ├── city.txt │ │ └── pca-code.json │ ├── java/ │ │ └── com/ │ │ └── github/ │ │ └── gzuliyujiang/ │ │ └── fallback/ │ │ ├── DemoApp.java │ │ ├── activity/ │ │ │ ├── AddressPickerActivity.java │ │ │ ├── BackAbleActivity.java │ │ │ ├── CalendarPickerActivity.java │ │ │ ├── ColorPickerActivity.java │ │ │ ├── DateTimePickerActivity.java │ │ │ ├── FileExplorerFragment.java │ │ │ ├── FilePickerActivity.java │ │ │ ├── ImagePickerActivity.java │ │ │ ├── LinkagePickerActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── OptionPickerFragment.java │ │ │ └── SinglePickerActivity.java │ │ ├── bean/ │ │ │ └── GoodsCategoryBean.java │ │ └── custom/ │ │ ├── AntFortuneLikePicker.java │ │ ├── AntFortuneLikeProvider.java │ │ ├── CustomAddressPicker.java │ │ ├── TextAddressLoader.java │ │ └── TextAddressParser.java │ └── res/ │ ├── layout/ │ │ ├── activity_picker_address.xml │ │ ├── activity_picker_calendar.xml │ │ ├── activity_picker_color.xml │ │ ├── activity_picker_date_time.xml │ │ ├── activity_picker_file.xml │ │ ├── activity_picker_image.xml │ │ ├── activity_picker_linkage.xml │ │ ├── activity_picker_main.xml │ │ ├── activity_picker_single.xml │ │ ├── fragment_file_explorer.xml │ │ ├── layout_title_bar.xml │ │ └── wheel_picker_custom_ui_address.xml │ └── values/ │ ├── colors.xml │ ├── strings.xml │ ├── styles.xml │ └── themes.xml ├── build.gradle ├── buildAPK.bat ├── demo.apk ├── gradle/ │ ├── app.gradle │ ├── common.gradle │ ├── config.gradle │ ├── dependency.gradle │ ├── git.gradle │ ├── init.d/ │ │ └── init.gradle │ ├── library.gradle │ ├── publish.gradle │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── publishAAR.bat └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms custom: [ 'https://gitee.com/li_yu_jiang' ] ================================================ FILE: .github/workflows/gradle-publish.yml ================================================ # This workflow will build a package using Gradle and then publish it to maven local when a release is created # See https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle # and https://github.com/actions/starter-workflows/blob/master/ci/gradle-publish.yml name: Gradle Package on: release: types: [ created ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout source code uses: actions/checkout@v2 - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 11 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - name: Publish to mavenLocal() run: ./gradlew publishToMavenLocal --info --warning-mode all - name: Auto send a request to JitPack uses: badasintended/autojitpack@v0 ================================================ FILE: .github/workflows/release-apk.yml ================================================ # This workflow will build a Java/Android project with Gradle # See https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle # and https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts name: Release APK on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout source code uses: actions/checkout@v2 - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 11 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle run: ./gradlew clean assembleRelease --info --warning-mode all - name: Store android package uses: actions/upload-artifact@v4 with: name: artifact path: app/build/outputs/apk/pub/release/*.apk if-no-files-found: warn retention-days: 7 ================================================ FILE: .gitignore ================================================ # Miscellaneous **/*.class **/*.lock **/*.log **/*.pyc **/*.swp **/.atom/ **/.buildlog/ **/.history **/.svn/ **/.git-rewrite/ **/.thumbs.db # IntelliJ related (Intellij IDEA, Android Studio, etc.) **/*.iml **/*.ipr **/*.iws **/build **/local.properties !**/.idea/codeStyles/** !**/.idea/copyright/** **/.idea/caches **/.idea/libraries **/.idea/modules **/.idea/runConfigurations **/.idea/*.xml **/.idea/.name # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ !**/android/gradlew !**/android/gradlew.bat **/android/local.properties **/proguard **/resource_mapping.txt **/gen **/debug **/release **/*.apk !**/demo.apk **/归档 # NDK related **/.externalNativeBuild **/.cxx # Gradle **/.gradle **/gradle-app.setting **/.gradletasknamecache !**/gradle/wrapper/** # VS/VS Code **/.vs **/.suo **/.vscode !**/.vscode/*.json **/.project **/.classpath **/.settings # Flutter/Dart/Pub related **/doc/api/ **/.dart_tool/ **/.flutter-plugins **/.flutter-plugins-dependencies **/.packages **/.pub-cache/ **/.pub/ **/build/ **/lib/generated **/lib/generated_plugin_registrant.dart **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/.DS_Store **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* **/ios/Flutter/flutter_export_environment.sh !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages # Node related **/node_modules **/dist **/package-lock.json **/npm-debug.log* **/yarn-debug.log* **/yarn-error.log* ================================================ FILE: .idea/codeStyles/Project.xml ================================================
xmlns:android ^$
xmlns:.* ^$ BY_NAME
.*:id http://schemas.android.com/apk/res/android
.*:name http://schemas.android.com/apk/res/android
name ^$
style ^$
.* ^$ BY_NAME
.* http://schemas.android.com/apk/res/android ANDROID_ATTRIBUTE_ORDER
.* .* BY_NAME
================================================ FILE: .idea/copyright/liyujiang_Default.xml ================================================ ================================================ FILE: .idea/copyright/liyujiang_MulanPSL.xml ================================================ ================================================ FILE: .idea/copyright/profiles_settings.xml ================================================ ================================================ FILE: .idea/inspectionProfiles/Project_Default.xml ================================================ ================================================ FILE: .jitpack.yml ================================================ jdk: openjdk11 ================================================ FILE: API.md ================================================ # API 说明 ## 窗体 ### BaseDialog | 方法 | 说明 | | ---- | ---- | | disableCancel | 禁止按返回键取消窗体 | | setBackgroundColor | 设置窗体背景色(`CornerRound`可指定圆角类型) | | setBackgroundResource | 设置窗体背景 | | setBackgroundDrawable | 设置窗体背景 | | setLayout | 设置窗体宽高 | | setWidth | 设置窗体宽 | | setHeight | 设置窗体高 | | setGravity | 设置窗体对齐方式(居中、居底) | | setDimAmount | 设置窗体蒙层透明度 | | setAnimationStyle | 设置窗体动画 | | setOnShowListener | 设置窗体显示监听器 | | setOnDismissListener | 设置窗体关闭监听器 | ### ModalDialog | 方法 | 说明 | | ---- | ---- | | setTitle | 设置窗体标题 | | setBodyWidth | 设置窗体主体内容宽度 | | setBodyHeight | 设置窗体主体内容高度 | | getHeaderView | 设置窗体头部内容视图 | | getTopLineView | 设置窗体顶部分割线视图 | | getBodyView | 设置窗体主体内容视图 | | getFooterView | 设置窗体脚部内容视图 | | getCancelView | 设置窗体取消按钮视图 | | getTitleView | 设置窗体标题视图 | | getOkView | 设置窗体确定按钮视图 | ### DialogConfig | 方法 | 说明 | | ---- | ---- | | setDialogStyle | 设置全局的窗体样式(`DialogStyle`内置了四种样式) | | getDialogStyle | 获取已设置的全局窗体样式 | | setDialogColor | 设置全局的窗体配色(`DialogColor`) | | getDialogColor | 获取已设置的全局窗体配色 | ### DialogColor | 方法 | 说明 | | ---- | ---- | | contentBackgroundColor | 全局的窗体内容背景色 | | topLineColor | 全局的窗体顶部分隔线颜色 | | titleTextColor | 全局的窗体标题文字颜色 | | cancelTextColor | 全局的窗体取消按钮文字颜色 | | okTextColor | 全局的窗体确定按钮文字颜色 | | cancelEllipseColor | 全局的窗体取消按钮椭圆颜色 | | okEllipseColor | 全局的窗体确定按钮椭圆颜色 | ## 滚轮 ### WheelView/WheelLayout | 方法 | 说明 | | ---- | ---- | | scrollTo | 滚动到指定位置 | | setStyle | 通过XML属性设置样式 | | setAtmosphericEnabled | 设置是否启用透明度渐变效果 | | setCurtainEnabled | 设置是否启用选中条目的背景 | | setCurtainColor | 设置选中条目的背景色 | | setCurtainCorner | 设置选中条目的圆角类型 | | setCurtainRadius | 设置选中条目的圆角大小 | | setCurvedEnabled | 设置是否启用弯曲效果 | | setCurvedIndicatorSpace | 设置弯曲效果情况下条目指示器双横线的间距 | | setCurvedMaxAngle | 设置弯曲效果情况下最大弯曲角度 | | setCyclicEnabled | 设置是否启用无限循环滚动 | | setData | 设置数据 | | setDefaultPosition | 设置默认选中的位置 | | setDefaultValue | 设置默认值 | | setFormatter | 设置条目的格式化显示 | | setIndicatorEnabled | 设置是否启用条目指示器双横线 | | setIndicatorColor | 设置条目指示器双横线的颜色 | | setIndicatorSize | 设置条目指示器双横线的大小 | | setItemSpace | 设置条目的间距 | | setMaxWidthText | 指定条目中最长的文本,便于快速计算条目宽度 | | setOnWheelChangedListener | 设置条目滚动监听器 | | setSameWidthEnabled | 指定条目中所有文本长度一致,便于快速计算条目宽度 | | setSelectedTextBold | 设置条目选中项文本加粗 | | setSelectedTextColor | 设置条目选中项文本颜色 | | setSelectedTextSize | 设置条目选中项文本字号 | | setTextAlign | 设置条目文本对齐方式(`ItemTextAlign`) | | setTextColor | 设置条目未选中时的文本颜色 | | setTextSize | 设置条目未选中时的文本字号 | | setTypeface | 设置条目文本字体(`Typeface`) | | setVisibleItemCount | 设置条目可见条数,只能是奇数 | ### XXXPicker | 方法 | 说明 | | ---- | ---- | | setDefaultValue | 设置默认值 | | setDefaultPosition | 设置默认选中位置 | | setOnXXXPickedListener | 设置选择回调监听器 | | getWheelLayout | 获取滚轮布局 | | getWheelView | 获取滚轮视图 | | getLabelView | 获取文本标签视图 | ### FilePicker | 方法 | 说明 | | ---- | ---- | | setExplorerConfig | 设置文件管理器配置 | | getFileExplorer | 获取文件管理器对象 | | …… | 更多项参见源码及相应的注释 | ================================================ FILE: AddressPicker/README.md ================================================ # 地址选择器 省市区县地址联动选择器,含省市县、省区及市县。 ================================================ FILE: AddressPicker/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation api project(':Common') api project(':WheelView') api project(':WheelPicker') } ================================================ FILE: AddressPicker/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 # 若通过FastJSON、GSON等对省市区县的数据实体进行序列化及反序列化,则不能混淆Province、City等实体类。 #-keep class com.github.gzuliyujiang.wheelpicker.entity.AddressEntity { *;} #-keep class * extends com.github.gzuliyujiang.wheelpicker.entity.AddressEntity { *;} ================================================ FILE: AddressPicker/src/main/AndroidManifest.xml ================================================ ================================================ FILE: AddressPicker/src/main/assets/china_address.json ================================================ [ { "code": "110000", "name": "北京市", "cityList": [ { "code": "110000", "name": "北京市", "areaList": [ { "code": "110101", "name": "东城区" }, { "code": "110102", "name": "西城区" }, { "code": "110105", "name": "朝阳区" }, { "code": "110106", "name": "丰台区" }, { "code": "110107", "name": "石景山区" }, { "code": "110108", "name": "海淀区" }, { "code": "110109", "name": "门头沟区" }, { "code": "110111", "name": "房山区" }, { "code": "110112", "name": "通州区" }, { "code": "110113", "name": "顺义区" }, { "code": "110114", "name": "昌平区" }, { "code": "110115", "name": "大兴区" }, { "code": "110116", "name": "怀柔区" }, { "code": "110117", "name": "平谷区" }, { "code": "110118", "name": "密云区" }, { "code": "110119", "name": "延庆区" } ] } ] }, { "code": "120000", "name": "天津市", "cityList": [ { "code": "120000", "name": "天津市", "areaList": [ { "code": "120101", "name": "和平区" }, { "code": "120102", "name": "河东区" }, { "code": "120103", "name": "河西区" }, { "code": "120104", "name": "南开区" }, { "code": "120105", "name": "河北区" }, { "code": "120106", "name": "红桥区" }, { "code": "120110", "name": "东丽区" }, { "code": "120111", "name": "西青区" }, { "code": "120112", "name": "津南区" }, { "code": "120113", "name": "北辰区" }, { "code": "120114", "name": "武清区" }, { "code": "120115", "name": "宝坻区" }, { "code": "120116", "name": "滨海新区" }, { "code": "120117", "name": "宁河区" }, { "code": "120118", "name": "静海区" }, { "code": "120119", "name": "蓟州区" } ] } ] }, { "code": "130000", "name": "河北省", "cityList": [ { "code": "130100", "name": "石家庄市", "areaList": [ { "code": "130102", "name": "长安区" }, { "code": "130104", "name": "桥西区" }, { "code": "130105", "name": "新华区" }, { "code": "130107", "name": "井陉矿区" }, { "code": "130108", "name": "裕华区" }, { "code": "130109", "name": "藁城区" }, { "code": "130110", "name": "鹿泉区" }, { "code": "130111", "name": "栾城区" }, { "code": "130121", "name": "井陉县" }, { "code": "130123", "name": "正定县" }, { "code": "130125", "name": "行唐县" }, { "code": "130126", "name": "灵寿县" }, { "code": "130127", "name": "高邑县" }, { "code": "130128", "name": "深泽县" }, { "code": "130129", "name": "赞皇县" }, { "code": "130130", "name": "无极县" }, { "code": "130131", "name": "平山县" }, { "code": "130132", "name": "元氏县" }, { "code": "130133", "name": "赵县" }, { "code": "130181", "name": "辛集市" }, { "code": "130183", "name": "晋州市" }, { "code": "130184", "name": "新乐市" } ] }, { "code": "130200", "name": "唐山市", "areaList": [ { "code": "130202", "name": "路南区" }, { "code": "130203", "name": "路北区" }, { "code": "130204", "name": "古冶区" }, { "code": "130205", "name": "开平区" }, { "code": "130207", "name": "丰南区" }, { "code": "130208", "name": "丰润区" }, { "code": "130209", "name": "曹妃甸区" }, { "code": "130224", "name": "滦南县" }, { "code": "130225", "name": "乐亭县" }, { "code": "130227", "name": "迁西县" }, { "code": "130229", "name": "玉田县" }, { "code": "130281", "name": "遵化市" }, { "code": "130283", "name": "迁安市" }, { "code": "130284", "name": "滦州市" } ] }, { "code": "130300", "name": "秦皇岛市", "areaList": [ { "code": "130302", "name": "海港区" }, { "code": "130303", "name": "山海关区" }, { "code": "130304", "name": "北戴河区" }, { "code": "130306", "name": "抚宁区" }, { "code": "130321", "name": "青龙满族自治县" }, { "code": "130322", "name": "昌黎县" }, { "code": "130324", "name": "卢龙县" } ] }, { "code": "130400", "name": "邯郸市", "areaList": [ { "code": "130402", "name": "邯山区" }, { "code": "130403", "name": "丛台区" }, { "code": "130404", "name": "复兴区" }, { "code": "130406", "name": "峰峰矿区" }, { "code": "130407", "name": "肥乡区" }, { "code": "130408", "name": "永年区" }, { "code": "130423", "name": "临漳县" }, { "code": "130424", "name": "成安县" }, { "code": "130425", "name": "大名县" }, { "code": "130426", "name": "涉县" }, { "code": "130427", "name": "磁县" }, { "code": "130430", "name": "邱县" }, { "code": "130431", "name": "鸡泽县" }, { "code": "130432", "name": "广平县" }, { "code": "130433", "name": "馆陶县" }, { "code": "130434", "name": "魏县" }, { "code": "130435", "name": "曲周县" }, { "code": "130481", "name": "武安市" } ] }, { "code": "130500", "name": "邢台市", "areaList": [ { "code": "130502", "name": "襄都区" }, { "code": "130503", "name": "信都区" }, { "code": "130505", "name": "任泽区" }, { "code": "130506", "name": "南和区" }, { "code": "130522", "name": "临城县" }, { "code": "130523", "name": "内丘县" }, { "code": "130524", "name": "柏乡县" }, { "code": "130525", "name": "隆尧县" }, { "code": "130528", "name": "宁晋县" }, { "code": "130529", "name": "巨鹿县" }, { "code": "130530", "name": "新河县" }, { "code": "130531", "name": "广宗县" }, { "code": "130532", "name": "平乡县" }, { "code": "130533", "name": "威县" }, { "code": "130534", "name": "清河县" }, { "code": "130535", "name": "临西县" }, { "code": "130581", "name": "南宫市" }, { "code": "130582", "name": "沙河市" } ] }, { "code": "130600", "name": "保定市", "areaList": [ { "code": "130602", "name": "竞秀区" }, { "code": "130606", "name": "莲池区" }, { "code": "130607", "name": "满城区" }, { "code": "130608", "name": "清苑区" }, { "code": "130609", "name": "徐水区" }, { "code": "130623", "name": "涞水县" }, { "code": "130624", "name": "阜平县" }, { "code": "130626", "name": "定兴县" }, { "code": "130627", "name": "唐县" }, { "code": "130628", "name": "高阳县" }, { "code": "130629", "name": "容城县" }, { "code": "130630", "name": "涞源县" }, { "code": "130631", "name": "望都县" }, { "code": "130632", "name": "安新县" }, { "code": "130633", "name": "易县" }, { "code": "130634", "name": "曲阳县" }, { "code": "130635", "name": "蠡县" }, { "code": "130636", "name": "顺平县" }, { "code": "130637", "name": "博野县" }, { "code": "130638", "name": "雄县" }, { "code": "130681", "name": "涿州市" }, { "code": "130682", "name": "定州市" }, { "code": "130683", "name": "安国市" }, { "code": "130684", "name": "高碑店市" } ] }, { "code": "130700", "name": "张家口市", "areaList": [ { "code": "130702", "name": "桥东区" }, { "code": "130703", "name": "桥西区" }, { "code": "130705", "name": "宣化区" }, { "code": "130706", "name": "下花园区" }, { "code": "130708", "name": "万全区" }, { "code": "130709", "name": "崇礼区" }, { "code": "130722", "name": "张北县" }, { "code": "130723", "name": "康保县" }, { "code": "130724", "name": "沽源县" }, { "code": "130725", "name": "尚义县" }, { "code": "130726", "name": "蔚县" }, { "code": "130727", "name": "阳原县" }, { "code": "130728", "name": "怀安县" }, { "code": "130730", "name": "怀来县" }, { "code": "130731", "name": "涿鹿县" }, { "code": "130732", "name": "赤城县" } ] }, { "code": "130800", "name": "承德市", "areaList": [ { "code": "130802", "name": "双桥区" }, { "code": "130803", "name": "双滦区" }, { "code": "130804", "name": "鹰手营子矿区" }, { "code": "130821", "name": "承德县" }, { "code": "130822", "name": "兴隆县" }, { "code": "130824", "name": "滦平县" }, { "code": "130825", "name": "隆化县" }, { "code": "130826", "name": "丰宁满族自治县" }, { "code": "130827", "name": "宽城满族自治县" }, { "code": "130828", "name": "围场满族蒙古族自治县" }, { "code": "130881", "name": "平泉市" } ] }, { "code": "130900", "name": "沧州市", "areaList": [ { "code": "130902", "name": "新华区" }, { "code": "130903", "name": "运河区" }, { "code": "130921", "name": "沧县" }, { "code": "130922", "name": "青县" }, { "code": "130923", "name": "东光县" }, { "code": "130924", "name": "海兴县" }, { "code": "130925", "name": "盐山县" }, { "code": "130926", "name": "肃宁县" }, { "code": "130927", "name": "南皮县" }, { "code": "130928", "name": "吴桥县" }, { "code": "130929", "name": "献县" }, { "code": "130930", "name": "孟村回族自治县" }, { "code": "130981", "name": "泊头市" }, { "code": "130982", "name": "任丘市" }, { "code": "130983", "name": "黄骅市" }, { "code": "130984", "name": "河间市" } ] }, { "code": "131000", "name": "廊坊市", "areaList": [ { "code": "131002", "name": "安次区" }, { "code": "131003", "name": "广阳区" }, { "code": "131022", "name": "固安县" }, { "code": "131023", "name": "永清县" }, { "code": "131024", "name": "香河县" }, { "code": "131025", "name": "大城县" }, { "code": "131026", "name": "文安县" }, { "code": "131028", "name": "大厂回族自治县" }, { "code": "131081", "name": "霸州市" }, { "code": "131082", "name": "三河市" } ] }, { "code": "131100", "name": "衡水市", "areaList": [ { "code": "131102", "name": "桃城区" }, { "code": "131103", "name": "冀州区" }, { "code": "131121", "name": "枣强县" }, { "code": "131122", "name": "武邑县" }, { "code": "131123", "name": "武强县" }, { "code": "131124", "name": "饶阳县" }, { "code": "131125", "name": "安平县" }, { "code": "131126", "name": "故城县" }, { "code": "131127", "name": "景县" }, { "code": "131128", "name": "阜城县" }, { "code": "131182", "name": "深州市" } ] } ] }, { "code": "140000", "name": "山西省", "cityList": [ { "code": "140100", "name": "太原市", "areaList": [ { "code": "140105", "name": "小店区" }, { "code": "140106", "name": "迎泽区" }, { "code": "140107", "name": "杏花岭区" }, { "code": "140108", "name": "尖草坪区" }, { "code": "140109", "name": "万柏林区" }, { "code": "140110", "name": "晋源区" }, { "code": "140121", "name": "清徐县" }, { "code": "140122", "name": "阳曲县" }, { "code": "140123", "name": "娄烦县" }, { "code": "140181", "name": "古交市" } ] }, { "code": "140200", "name": "大同市", "areaList": [ { "code": "140212", "name": "新荣区" }, { "code": "140213", "name": "平城区" }, { "code": "140214", "name": "云冈区" }, { "code": "140215", "name": "云州区" }, { "code": "140221", "name": "阳高县" }, { "code": "140222", "name": "天镇县" }, { "code": "140223", "name": "广灵县" }, { "code": "140224", "name": "灵丘县" }, { "code": "140225", "name": "浑源县" }, { "code": "140226", "name": "左云县" } ] }, { "code": "140300", "name": "阳泉市", "areaList": [ { "code": "140302", "name": "城区" }, { "code": "140303", "name": "矿区" }, { "code": "140311", "name": "郊区" }, { "code": "140321", "name": "平定县" }, { "code": "140322", "name": "盂县" } ] }, { "code": "140400", "name": "长治市", "areaList": [ { "code": "140403", "name": "潞州区" }, { "code": "140404", "name": "上党区" }, { "code": "140405", "name": "屯留区" }, { "code": "140406", "name": "潞城区" }, { "code": "140423", "name": "襄垣县" }, { "code": "140425", "name": "平顺县" }, { "code": "140426", "name": "黎城县" }, { "code": "140427", "name": "壶关县" }, { "code": "140428", "name": "长子县" }, { "code": "140429", "name": "武乡县" }, { "code": "140430", "name": "沁县" }, { "code": "140431", "name": "沁源县" } ] }, { "code": "140500", "name": "晋城市", "areaList": [ { "code": "140502", "name": "城区" }, { "code": "140521", "name": "沁水县" }, { "code": "140522", "name": "阳城县" }, { "code": "140524", "name": "陵川县" }, { "code": "140525", "name": "泽州县" }, { "code": "140581", "name": "高平市" } ] }, { "code": "140600", "name": "朔州市", "areaList": [ { "code": "140602", "name": "朔城区" }, { "code": "140603", "name": "平鲁区" }, { "code": "140621", "name": "山阴县" }, { "code": "140622", "name": "应县" }, { "code": "140623", "name": "右玉县" }, { "code": "140681", "name": "怀仁市" } ] }, { "code": "140700", "name": "晋中市", "areaList": [ { "code": "140702", "name": "榆次区" }, { "code": "140703", "name": "太谷区" }, { "code": "140721", "name": "榆社县" }, { "code": "140722", "name": "左权县" }, { "code": "140723", "name": "和顺县" }, { "code": "140724", "name": "昔阳县" }, { "code": "140725", "name": "寿阳县" }, { "code": "140727", "name": "祁县" }, { "code": "140728", "name": "平遥县" }, { "code": "140729", "name": "灵石县" }, { "code": "140781", "name": "介休市" } ] }, { "code": "140800", "name": "运城市", "areaList": [ { "code": "140802", "name": "盐湖区" }, { "code": "140821", "name": "临猗县" }, { "code": "140822", "name": "万荣县" }, { "code": "140823", "name": "闻喜县" }, { "code": "140824", "name": "稷山县" }, { "code": "140825", "name": "新绛县" }, { "code": "140826", "name": "绛县" }, { "code": "140827", "name": "垣曲县" }, { "code": "140828", "name": "夏县" }, { "code": "140829", "name": "平陆县" }, { "code": "140830", "name": "芮城县" }, { "code": "140881", "name": "永济市" }, { "code": "140882", "name": "河津市" } ] }, { "code": "140900", "name": "忻州市", "areaList": [ { "code": "140902", "name": "忻府区" }, { "code": "140921", "name": "定襄县" }, { "code": "140922", "name": "五台县" }, { "code": "140923", "name": "代县" }, { "code": "140924", "name": "繁峙县" }, { "code": "140925", "name": "宁武县" }, { "code": "140926", "name": "静乐县" }, { "code": "140927", "name": "神池县" }, { "code": "140928", "name": "五寨县" }, { "code": "140929", "name": "岢岚县" }, { "code": "140930", "name": "河曲县" }, { "code": "140931", "name": "保德县" }, { "code": "140932", "name": "偏关县" }, { "code": "140981", "name": "原平市" } ] }, { "code": "141000", "name": "临汾市", "areaList": [ { "code": "141002", "name": "尧都区" }, { "code": "141021", "name": "曲沃县" }, { "code": "141022", "name": "翼城县" }, { "code": "141023", "name": "襄汾县" }, { "code": "141024", "name": "洪洞县" }, { "code": "141025", "name": "古县" }, { "code": "141026", "name": "安泽县" }, { "code": "141027", "name": "浮山县" }, { "code": "141028", "name": "吉县" }, { "code": "141029", "name": "乡宁县" }, { "code": "141030", "name": "大宁县" }, { "code": "141031", "name": "隰县" }, { "code": "141032", "name": "永和县" }, { "code": "141033", "name": "蒲县" }, { "code": "141034", "name": "汾西县" }, { "code": "141081", "name": "侯马市" }, { "code": "141082", "name": "霍州市" } ] }, { "code": "141100", "name": "吕梁市", "areaList": [ { "code": "141102", "name": "离石区" }, { "code": "141121", "name": "文水县" }, { "code": "141122", "name": "交城县" }, { "code": "141123", "name": "兴县" }, { "code": "141124", "name": "临县" }, { "code": "141125", "name": "柳林县" }, { "code": "141126", "name": "石楼县" }, { "code": "141127", "name": "岚县" }, { "code": "141128", "name": "方山县" }, { "code": "141129", "name": "中阳县" }, { "code": "141130", "name": "交口县" }, { "code": "141181", "name": "孝义市" }, { "code": "141182", "name": "汾阳市" } ] } ] }, { "code": "150000", "name": "内蒙古自治区", "cityList": [ { "code": "150100", "name": "呼和浩特市", "areaList": [ { "code": "150102", "name": "新城区" }, { "code": "150103", "name": "回民区" }, { "code": "150104", "name": "玉泉区" }, { "code": "150105", "name": "赛罕区" }, { "code": "150121", "name": "土默特左旗" }, { "code": "150122", "name": "托克托县" }, { "code": "150123", "name": "和林格尔县" }, { "code": "150124", "name": "清水河县" }, { "code": "150125", "name": "武川县" } ] }, { "code": "150200", "name": "包头市", "areaList": [ { "code": "150202", "name": "东河区" }, { "code": "150203", "name": "昆都仑区" }, { "code": "150204", "name": "青山区" }, { "code": "150205", "name": "石拐区" }, { "code": "150206", "name": "白云鄂博矿区" }, { "code": "150207", "name": "九原区" }, { "code": "150221", "name": "土默特右旗" }, { "code": "150222", "name": "固阳县" }, { "code": "150223", "name": "达尔罕茂明安联合旗" } ] }, { "code": "150300", "name": "乌海市", "areaList": [ { "code": "150302", "name": "海勃湾区" }, { "code": "150303", "name": "海南区" }, { "code": "150304", "name": "乌达区" } ] }, { "code": "150400", "name": "赤峰市", "areaList": [ { "code": "150402", "name": "红山区" }, { "code": "150403", "name": "元宝山区" }, { "code": "150404", "name": "松山区" }, { "code": "150421", "name": "阿鲁科尔沁旗" }, { "code": "150422", "name": "巴林左旗" }, { "code": "150423", "name": "巴林右旗" }, { "code": "150424", "name": "林西县" }, { "code": "150425", "name": "克什克腾旗" }, { "code": "150426", "name": "翁牛特旗" }, { "code": "150428", "name": "喀喇沁旗" }, { "code": "150429", "name": "宁城县" }, { "code": "150430", "name": "敖汉旗" } ] }, { "code": "150500", "name": "通辽市", "areaList": [ { "code": "150502", "name": "科尔沁区" }, { "code": "150521", "name": "科尔沁左翼中旗" }, { "code": "150522", "name": "科尔沁左翼后旗" }, { "code": "150523", "name": "开鲁县" }, { "code": "150524", "name": "库伦旗" }, { "code": "150525", "name": "奈曼旗" }, { "code": "150526", "name": "扎鲁特旗" }, { "code": "150581", "name": "霍林郭勒市" } ] }, { "code": "150600", "name": "鄂尔多斯市", "areaList": [ { "code": "150602", "name": "东胜区" }, { "code": "150603", "name": "康巴什区" }, { "code": "150621", "name": "达拉特旗" }, { "code": "150622", "name": "准格尔旗" }, { "code": "150623", "name": "鄂托克前旗" }, { "code": "150624", "name": "鄂托克旗" }, { "code": "150625", "name": "杭锦旗" }, { "code": "150626", "name": "乌审旗" }, { "code": "150627", "name": "伊金霍洛旗" } ] }, { "code": "150700", "name": "呼伦贝尔市", "areaList": [ { "code": "150702", "name": "海拉尔区" }, { "code": "150703", "name": "扎赉诺尔区" }, { "code": "150721", "name": "阿荣旗" }, { "code": "150722", "name": "莫力达瓦达斡尔族自治旗" }, { "code": "150723", "name": "鄂伦春自治旗" }, { "code": "150724", "name": "鄂温克族自治旗" }, { "code": "150725", "name": "陈巴尔虎旗" }, { "code": "150726", "name": "新巴尔虎左旗" }, { "code": "150727", "name": "新巴尔虎右旗" }, { "code": "150781", "name": "满洲里市" }, { "code": "150782", "name": "牙克石市" }, { "code": "150783", "name": "扎兰屯市" }, { "code": "150784", "name": "额尔古纳市" }, { "code": "150785", "name": "根河市" } ] }, { "code": "150800", "name": "巴彦淖尔市", "areaList": [ { "code": "150802", "name": "临河区" }, { "code": "150821", "name": "五原县" }, { "code": "150822", "name": "磴口县" }, { "code": "150823", "name": "乌拉特前旗" }, { "code": "150824", "name": "乌拉特中旗" }, { "code": "150825", "name": "乌拉特后旗" }, { "code": "150826", "name": "杭锦后旗" } ] }, { "code": "150900", "name": "乌兰察布市", "areaList": [ { "code": "150902", "name": "集宁区" }, { "code": "150921", "name": "卓资县" }, { "code": "150922", "name": "化德县" }, { "code": "150923", "name": "商都县" }, { "code": "150924", "name": "兴和县" }, { "code": "150925", "name": "凉城县" }, { "code": "150926", "name": "察哈尔右翼前旗" }, { "code": "150927", "name": "察哈尔右翼中旗" }, { "code": "150928", "name": "察哈尔右翼后旗" }, { "code": "150929", "name": "四子王旗" }, { "code": "150981", "name": "丰镇市" } ] }, { "code": "152200", "name": "兴安盟", "areaList": [ { "code": "152201", "name": "乌兰浩特市" }, { "code": "152202", "name": "阿尔山市" }, { "code": "152221", "name": "科尔沁右翼前旗" }, { "code": "152222", "name": "科尔沁右翼中旗" }, { "code": "152223", "name": "扎赉特旗" }, { "code": "152224", "name": "突泉县" } ] }, { "code": "152500", "name": "锡林郭勒盟", "areaList": [ { "code": "152501", "name": "二连浩特市" }, { "code": "152502", "name": "锡林浩特市" }, { "code": "152522", "name": "阿巴嘎旗" }, { "code": "152523", "name": "苏尼特左旗" }, { "code": "152524", "name": "苏尼特右旗" }, { "code": "152525", "name": "东乌珠穆沁旗" }, { "code": "152526", "name": "西乌珠穆沁旗" }, { "code": "152527", "name": "太仆寺旗" }, { "code": "152528", "name": "镶黄旗" }, { "code": "152529", "name": "正镶白旗" }, { "code": "152530", "name": "正蓝旗" }, { "code": "152531", "name": "多伦县" } ] }, { "code": "152900", "name": "阿拉善盟", "areaList": [ { "code": "152921", "name": "阿拉善左旗" }, { "code": "152922", "name": "阿拉善右旗" }, { "code": "152923", "name": "额济纳旗" } ] } ] }, { "code": "210000", "name": "辽宁省", "cityList": [ { "code": "210100", "name": "沈阳市", "areaList": [ { "code": "210102", "name": "和平区" }, { "code": "210103", "name": "沈河区" }, { "code": "210104", "name": "大东区" }, { "code": "210105", "name": "皇姑区" }, { "code": "210106", "name": "铁西区" }, { "code": "210111", "name": "苏家屯区" }, { "code": "210112", "name": "浑南区" }, { "code": "210113", "name": "沈北新区" }, { "code": "210114", "name": "于洪区" }, { "code": "210115", "name": "辽中区" }, { "code": "210123", "name": "康平县" }, { "code": "210124", "name": "法库县" }, { "code": "210181", "name": "新民市" } ] }, { "code": "210200", "name": "大连市", "areaList": [ { "code": "210202", "name": "中山区" }, { "code": "210203", "name": "西岗区" }, { "code": "210204", "name": "沙河口区" }, { "code": "210211", "name": "甘井子区" }, { "code": "210212", "name": "旅顺口区" }, { "code": "210213", "name": "金州区" }, { "code": "210214", "name": "普兰店区" }, { "code": "210224", "name": "长海县" }, { "code": "210281", "name": "瓦房店市" }, { "code": "210283", "name": "庄河市" } ] }, { "code": "210300", "name": "鞍山市", "areaList": [ { "code": "210302", "name": "铁东区" }, { "code": "210303", "name": "铁西区" }, { "code": "210304", "name": "立山区" }, { "code": "210311", "name": "千山区" }, { "code": "210321", "name": "台安县" }, { "code": "210323", "name": "岫岩满族自治县" }, { "code": "210381", "name": "海城市" } ] }, { "code": "210400", "name": "抚顺市", "areaList": [ { "code": "210402", "name": "新抚区" }, { "code": "210403", "name": "东洲区" }, { "code": "210404", "name": "望花区" }, { "code": "210411", "name": "顺城区" }, { "code": "210421", "name": "抚顺县" }, { "code": "210422", "name": "新宾满族自治县" }, { "code": "210423", "name": "清原满族自治县" } ] }, { "code": "210500", "name": "本溪市", "areaList": [ { "code": "210502", "name": "平山区" }, { "code": "210503", "name": "溪湖区" }, { "code": "210504", "name": "明山区" }, { "code": "210505", "name": "南芬区" }, { "code": "210521", "name": "本溪满族自治县" }, { "code": "210522", "name": "桓仁满族自治县" } ] }, { "code": "210600", "name": "丹东市", "areaList": [ { "code": "210602", "name": "元宝区" }, { "code": "210603", "name": "振兴区" }, { "code": "210604", "name": "振安区" }, { "code": "210624", "name": "宽甸满族自治县" }, { "code": "210681", "name": "东港市" }, { "code": "210682", "name": "凤城市" } ] }, { "code": "210700", "name": "锦州市", "areaList": [ { "code": "210702", "name": "古塔区" }, { "code": "210703", "name": "凌河区" }, { "code": "210711", "name": "太和区" }, { "code": "210726", "name": "黑山县" }, { "code": "210727", "name": "义县" }, { "code": "210781", "name": "凌海市" }, { "code": "210782", "name": "北镇市" } ] }, { "code": "210800", "name": "营口市", "areaList": [ { "code": "210802", "name": "站前区" }, { "code": "210803", "name": "西市区" }, { "code": "210804", "name": "鲅鱼圈区" }, { "code": "210811", "name": "老边区" }, { "code": "210881", "name": "盖州市" }, { "code": "210882", "name": "大石桥市" } ] }, { "code": "210900", "name": "阜新市", "areaList": [ { "code": "210902", "name": "海州区" }, { "code": "210903", "name": "新邱区" }, { "code": "210904", "name": "太平区" }, { "code": "210905", "name": "清河门区" }, { "code": "210911", "name": "细河区" }, { "code": "210921", "name": "阜新蒙古族自治县" }, { "code": "210922", "name": "彰武县" } ] }, { "code": "211000", "name": "辽阳市", "areaList": [ { "code": "211002", "name": "白塔区" }, { "code": "211003", "name": "文圣区" }, { "code": "211004", "name": "宏伟区" }, { "code": "211005", "name": "弓长岭区" }, { "code": "211011", "name": "太子河区" }, { "code": "211021", "name": "辽阳县" }, { "code": "211081", "name": "灯塔市" } ] }, { "code": "211100", "name": "盘锦市", "areaList": [ { "code": "211102", "name": "双台子区" }, { "code": "211103", "name": "兴隆台区" }, { "code": "211104", "name": "大洼区" }, { "code": "211122", "name": "盘山县" } ] }, { "code": "211200", "name": "铁岭市", "areaList": [ { "code": "211202", "name": "银州区" }, { "code": "211204", "name": "清河区" }, { "code": "211221", "name": "铁岭县" }, { "code": "211223", "name": "西丰县" }, { "code": "211224", "name": "昌图县" }, { "code": "211281", "name": "调兵山市" }, { "code": "211282", "name": "开原市" } ] }, { "code": "211300", "name": "朝阳市", "areaList": [ { "code": "211302", "name": "双塔区" }, { "code": "211303", "name": "龙城区" }, { "code": "211321", "name": "朝阳县" }, { "code": "211322", "name": "建平县" }, { "code": "211324", "name": "喀喇沁左翼蒙古族自治县" }, { "code": "211381", "name": "北票市" }, { "code": "211382", "name": "凌源市" } ] }, { "code": "211400", "name": "葫芦岛市", "areaList": [ { "code": "211402", "name": "连山区" }, { "code": "211403", "name": "龙港区" }, { "code": "211404", "name": "南票区" }, { "code": "211421", "name": "绥中县" }, { "code": "211422", "name": "建昌县" }, { "code": "211481", "name": "兴城市" } ] } ] }, { "code": "220000", "name": "吉林省", "cityList": [ { "code": "220100", "name": "长春市", "areaList": [ { "code": "220102", "name": "南关区" }, { "code": "220103", "name": "宽城区" }, { "code": "220104", "name": "朝阳区" }, { "code": "220105", "name": "二道区" }, { "code": "220106", "name": "绿园区" }, { "code": "220112", "name": "双阳区" }, { "code": "220113", "name": "九台区" }, { "code": "220122", "name": "农安县" }, { "code": "220182", "name": "榆树市" }, { "code": "220183", "name": "德惠市" }, { "code": "220184", "name": "公主岭市" } ] }, { "code": "220200", "name": "吉林市", "areaList": [ { "code": "220202", "name": "昌邑区" }, { "code": "220203", "name": "龙潭区" }, { "code": "220204", "name": "船营区" }, { "code": "220211", "name": "丰满区" }, { "code": "220221", "name": "永吉县" }, { "code": "220281", "name": "蛟河市" }, { "code": "220282", "name": "桦甸市" }, { "code": "220283", "name": "舒兰市" }, { "code": "220284", "name": "磐石市" } ] }, { "code": "220300", "name": "四平市", "areaList": [ { "code": "220302", "name": "铁西区" }, { "code": "220303", "name": "铁东区" }, { "code": "220322", "name": "梨树县" }, { "code": "220323", "name": "伊通满族自治县" }, { "code": "220382", "name": "双辽市" } ] }, { "code": "220400", "name": "辽源市", "areaList": [ { "code": "220402", "name": "龙山区" }, { "code": "220403", "name": "西安区" }, { "code": "220421", "name": "东丰县" }, { "code": "220422", "name": "东辽县" } ] }, { "code": "220500", "name": "通化市", "areaList": [ { "code": "220502", "name": "东昌区" }, { "code": "220503", "name": "二道江区" }, { "code": "220521", "name": "通化县" }, { "code": "220523", "name": "辉南县" }, { "code": "220524", "name": "柳河县" }, { "code": "220581", "name": "梅河口市" }, { "code": "220582", "name": "集安市" } ] }, { "code": "220600", "name": "白山市", "areaList": [ { "code": "220602", "name": "浑江区" }, { "code": "220605", "name": "江源区" }, { "code": "220621", "name": "抚松县" }, { "code": "220622", "name": "靖宇县" }, { "code": "220623", "name": "长白朝鲜族自治县" }, { "code": "220681", "name": "临江市" } ] }, { "code": "220700", "name": "松原市", "areaList": [ { "code": "220702", "name": "宁江区" }, { "code": "220721", "name": "前郭尔罗斯蒙古族自治县" }, { "code": "220722", "name": "长岭县" }, { "code": "220723", "name": "乾安县" }, { "code": "220781", "name": "扶余市" } ] }, { "code": "220800", "name": "白城市", "areaList": [ { "code": "220802", "name": "洮北区" }, { "code": "220821", "name": "镇赉县" }, { "code": "220822", "name": "通榆县" }, { "code": "220881", "name": "洮南市" }, { "code": "220882", "name": "大安市" } ] }, { "code": "222400", "name": "延边朝鲜族自治州", "areaList": [ { "code": "222401", "name": "延吉市" }, { "code": "222402", "name": "图们市" }, { "code": "222403", "name": "敦化市" }, { "code": "222404", "name": "珲春市" }, { "code": "222405", "name": "龙井市" }, { "code": "222406", "name": "和龙市" }, { "code": "222424", "name": "汪清县" }, { "code": "222426", "name": "安图县" } ] } ] }, { "code": "230000", "name": "黑龙江省", "cityList": [ { "code": "230100", "name": "哈尔滨市", "areaList": [ { "code": "230102", "name": "道里区" }, { "code": "230103", "name": "南岗区" }, { "code": "230104", "name": "道外区" }, { "code": "230108", "name": "平房区" }, { "code": "230109", "name": "松北区" }, { "code": "230110", "name": "香坊区" }, { "code": "230111", "name": "呼兰区" }, { "code": "230112", "name": "阿城区" }, { "code": "230113", "name": "双城区" }, { "code": "230123", "name": "依兰县" }, { "code": "230124", "name": "方正县" }, { "code": "230125", "name": "宾县" }, { "code": "230126", "name": "巴彦县" }, { "code": "230127", "name": "木兰县" }, { "code": "230128", "name": "通河县" }, { "code": "230129", "name": "延寿县" }, { "code": "230183", "name": "尚志市" }, { "code": "230184", "name": "五常市" } ] }, { "code": "230200", "name": "齐齐哈尔市", "areaList": [ { "code": "230202", "name": "龙沙区" }, { "code": "230203", "name": "建华区" }, { "code": "230204", "name": "铁锋区" }, { "code": "230205", "name": "昂昂溪区" }, { "code": "230206", "name": "富拉尔基区" }, { "code": "230207", "name": "碾子山区" }, { "code": "230208", "name": "梅里斯达斡尔族区" }, { "code": "230221", "name": "龙江县" }, { "code": "230223", "name": "依安县" }, { "code": "230224", "name": "泰来县" }, { "code": "230225", "name": "甘南县" }, { "code": "230227", "name": "富裕县" }, { "code": "230229", "name": "克山县" }, { "code": "230230", "name": "克东县" }, { "code": "230231", "name": "拜泉县" }, { "code": "230281", "name": "讷河市" } ] }, { "code": "230300", "name": "鸡西市", "areaList": [ { "code": "230302", "name": "鸡冠区" }, { "code": "230303", "name": "恒山区" }, { "code": "230304", "name": "滴道区" }, { "code": "230305", "name": "梨树区" }, { "code": "230306", "name": "城子河区" }, { "code": "230307", "name": "麻山区" }, { "code": "230321", "name": "鸡东县" }, { "code": "230381", "name": "虎林市" }, { "code": "230382", "name": "密山市" } ] }, { "code": "230400", "name": "鹤岗市", "areaList": [ { "code": "230402", "name": "向阳区" }, { "code": "230403", "name": "工农区" }, { "code": "230404", "name": "南山区" }, { "code": "230405", "name": "兴安区" }, { "code": "230406", "name": "东山区" }, { "code": "230407", "name": "兴山区" }, { "code": "230421", "name": "萝北县" }, { "code": "230422", "name": "绥滨县" } ] }, { "code": "230500", "name": "双鸭山市", "areaList": [ { "code": "230502", "name": "尖山区" }, { "code": "230503", "name": "岭东区" }, { "code": "230505", "name": "四方台区" }, { "code": "230506", "name": "宝山区" }, { "code": "230521", "name": "集贤县" }, { "code": "230522", "name": "友谊县" }, { "code": "230523", "name": "宝清县" }, { "code": "230524", "name": "饶河县" } ] }, { "code": "230600", "name": "大庆市", "areaList": [ { "code": "230602", "name": "萨尔图区" }, { "code": "230603", "name": "龙凤区" }, { "code": "230604", "name": "让胡路区" }, { "code": "230605", "name": "红岗区" }, { "code": "230606", "name": "大同区" }, { "code": "230621", "name": "肇州县" }, { "code": "230622", "name": "肇源县" }, { "code": "230623", "name": "林甸县" }, { "code": "230624", "name": "杜尔伯特蒙古族自治县" } ] }, { "code": "230700", "name": "伊春市", "areaList": [ { "code": "230717", "name": "伊美区" }, { "code": "230718", "name": "乌翠区" }, { "code": "230719", "name": "友好区" }, { "code": "230722", "name": "嘉荫县" }, { "code": "230723", "name": "汤旺县" }, { "code": "230724", "name": "丰林县" }, { "code": "230725", "name": "大箐山县" }, { "code": "230726", "name": "南岔县" }, { "code": "230751", "name": "金林区" }, { "code": "230781", "name": "铁力市" } ] }, { "code": "230800", "name": "佳木斯市", "areaList": [ { "code": "230803", "name": "向阳区" }, { "code": "230804", "name": "前进区" }, { "code": "230805", "name": "东风区" }, { "code": "230811", "name": "郊区" }, { "code": "230822", "name": "桦南县" }, { "code": "230826", "name": "桦川县" }, { "code": "230828", "name": "汤原县" }, { "code": "230881", "name": "同江市" }, { "code": "230882", "name": "富锦市" }, { "code": "230883", "name": "抚远市" } ] }, { "code": "230900", "name": "七台河市", "areaList": [ { "code": "230902", "name": "新兴区" }, { "code": "230903", "name": "桃山区" }, { "code": "230904", "name": "茄子河区" }, { "code": "230921", "name": "勃利县" } ] }, { "code": "231000", "name": "牡丹江市", "areaList": [ { "code": "231002", "name": "东安区" }, { "code": "231003", "name": "阳明区" }, { "code": "231004", "name": "爱民区" }, { "code": "231005", "name": "西安区" }, { "code": "231025", "name": "林口县" }, { "code": "231081", "name": "绥芬河市" }, { "code": "231083", "name": "海林市" }, { "code": "231084", "name": "宁安市" }, { "code": "231085", "name": "穆棱市" }, { "code": "231086", "name": "东宁市" } ] }, { "code": "231100", "name": "黑河市", "areaList": [ { "code": "231102", "name": "爱辉区" }, { "code": "231123", "name": "逊克县" }, { "code": "231124", "name": "孙吴县" }, { "code": "231181", "name": "北安市" }, { "code": "231182", "name": "五大连池市" }, { "code": "231183", "name": "嫩江市" } ] }, { "code": "231200", "name": "绥化市", "areaList": [ { "code": "231202", "name": "北林区" }, { "code": "231221", "name": "望奎县" }, { "code": "231222", "name": "兰西县" }, { "code": "231223", "name": "青冈县" }, { "code": "231224", "name": "庆安县" }, { "code": "231225", "name": "明水县" }, { "code": "231226", "name": "绥棱县" }, { "code": "231281", "name": "安达市" }, { "code": "231282", "name": "肇东市" }, { "code": "231283", "name": "海伦市" } ] }, { "code": "232700", "name": "大兴安岭地区", "areaList": [ { "code": "232701", "name": "漠河市" }, { "code": "232718", "name": "加格达奇区" }, { "code": "232721", "name": "呼玛县" }, { "code": "232722", "name": "塔河县" } ] } ] }, { "code": "310000", "name": "上海市", "cityList": [ { "code": "310000", "name": "上海市", "areaList": [ { "code": "310101", "name": "黄浦区" }, { "code": "310104", "name": "徐汇区" }, { "code": "310105", "name": "长宁区" }, { "code": "310106", "name": "静安区" }, { "code": "310107", "name": "普陀区" }, { "code": "310109", "name": "虹口区" }, { "code": "310110", "name": "杨浦区" }, { "code": "310112", "name": "闵行区" }, { "code": "310113", "name": "宝山区" }, { "code": "310114", "name": "嘉定区" }, { "code": "310115", "name": "浦东新区" }, { "code": "310116", "name": "金山区" }, { "code": "310117", "name": "松江区" }, { "code": "310118", "name": "青浦区" }, { "code": "310120", "name": "奉贤区" }, { "code": "310151", "name": "崇明区" } ] } ] }, { "code": "320000", "name": "江苏省", "cityList": [ { "code": "320100", "name": "南京市", "areaList": [ { "code": "320102", "name": "玄武区" }, { "code": "320104", "name": "秦淮区" }, { "code": "320105", "name": "建邺区" }, { "code": "320106", "name": "鼓楼区" }, { "code": "320111", "name": "浦口区" }, { "code": "320113", "name": "栖霞区" }, { "code": "320114", "name": "雨花台区" }, { "code": "320115", "name": "江宁区" }, { "code": "320116", "name": "六合区" }, { "code": "320117", "name": "溧水区" }, { "code": "320118", "name": "高淳区" } ] }, { "code": "320200", "name": "无锡市", "areaList": [ { "code": "320205", "name": "锡山区" }, { "code": "320206", "name": "惠山区" }, { "code": "320211", "name": "滨湖区" }, { "code": "320213", "name": "梁溪区" }, { "code": "320214", "name": "新吴区" }, { "code": "320281", "name": "江阴市" }, { "code": "320282", "name": "宜兴市" } ] }, { "code": "320300", "name": "徐州市", "areaList": [ { "code": "320302", "name": "鼓楼区" }, { "code": "320303", "name": "云龙区" }, { "code": "320305", "name": "贾汪区" }, { "code": "320311", "name": "泉山区" }, { "code": "320312", "name": "铜山区" }, { "code": "320321", "name": "丰县" }, { "code": "320322", "name": "沛县" }, { "code": "320324", "name": "睢宁县" }, { "code": "320381", "name": "新沂市" }, { "code": "320382", "name": "邳州市" } ] }, { "code": "320400", "name": "常州市", "areaList": [ { "code": "320402", "name": "天宁区" }, { "code": "320404", "name": "钟楼区" }, { "code": "320411", "name": "新北区" }, { "code": "320412", "name": "武进区" }, { "code": "320413", "name": "金坛区" }, { "code": "320481", "name": "溧阳市" } ] }, { "code": "320500", "name": "苏州市", "areaList": [ { "code": "320505", "name": "虎丘区" }, { "code": "320506", "name": "吴中区" }, { "code": "320507", "name": "相城区" }, { "code": "320508", "name": "姑苏区" }, { "code": "320509", "name": "吴江区" }, { "code": "320581", "name": "常熟市" }, { "code": "320582", "name": "张家港市" }, { "code": "320583", "name": "昆山市" }, { "code": "320585", "name": "太仓市" } ] }, { "code": "320600", "name": "南通市", "areaList": [ { "code": "320612", "name": "通州区" }, { "code": "320613", "name": "崇川区" }, { "code": "320614", "name": "海门区" }, { "code": "320623", "name": "如东县" }, { "code": "320681", "name": "启东市" }, { "code": "320682", "name": "如皋市" }, { "code": "320685", "name": "海安市" } ] }, { "code": "320700", "name": "连云港市", "areaList": [ { "code": "320703", "name": "连云区" }, { "code": "320706", "name": "海州区" }, { "code": "320707", "name": "赣榆区" }, { "code": "320722", "name": "东海县" }, { "code": "320723", "name": "灌云县" }, { "code": "320724", "name": "灌南县" } ] }, { "code": "320800", "name": "淮安市", "areaList": [ { "code": "320803", "name": "淮安区" }, { "code": "320804", "name": "淮阴区" }, { "code": "320812", "name": "清江浦区" }, { "code": "320813", "name": "洪泽区" }, { "code": "320826", "name": "涟水县" }, { "code": "320830", "name": "盱眙县" }, { "code": "320831", "name": "金湖县" } ] }, { "code": "320900", "name": "盐城市", "areaList": [ { "code": "320902", "name": "亭湖区" }, { "code": "320903", "name": "盐都区" }, { "code": "320904", "name": "大丰区" }, { "code": "320921", "name": "响水县" }, { "code": "320922", "name": "滨海县" }, { "code": "320923", "name": "阜宁县" }, { "code": "320924", "name": "射阳县" }, { "code": "320925", "name": "建湖县" }, { "code": "320981", "name": "东台市" } ] }, { "code": "321000", "name": "扬州市", "areaList": [ { "code": "321002", "name": "广陵区" }, { "code": "321003", "name": "邗江区" }, { "code": "321012", "name": "江都区" }, { "code": "321023", "name": "宝应县" }, { "code": "321081", "name": "仪征市" }, { "code": "321084", "name": "高邮市" } ] }, { "code": "321100", "name": "镇江市", "areaList": [ { "code": "321102", "name": "京口区" }, { "code": "321111", "name": "润州区" }, { "code": "321112", "name": "丹徒区" }, { "code": "321181", "name": "丹阳市" }, { "code": "321182", "name": "扬中市" }, { "code": "321183", "name": "句容市" } ] }, { "code": "321200", "name": "泰州市", "areaList": [ { "code": "321202", "name": "海陵区" }, { "code": "321203", "name": "高港区" }, { "code": "321204", "name": "姜堰区" }, { "code": "321281", "name": "兴化市" }, { "code": "321282", "name": "靖江市" }, { "code": "321283", "name": "泰兴市" } ] }, { "code": "321300", "name": "宿迁市", "areaList": [ { "code": "321302", "name": "宿城区" }, { "code": "321311", "name": "宿豫区" }, { "code": "321322", "name": "沭阳县" }, { "code": "321323", "name": "泗阳县" }, { "code": "321324", "name": "泗洪县" } ] } ] }, { "code": "330000", "name": "浙江省", "cityList": [ { "code": "330100", "name": "杭州市", "areaList": [ { "code": "330102", "name": "上城区" }, { "code": "330105", "name": "拱墅区" }, { "code": "330106", "name": "西湖区" }, { "code": "330108", "name": "滨江区" }, { "code": "330109", "name": "萧山区" }, { "code": "330110", "name": "余杭区" }, { "code": "330111", "name": "富阳区" }, { "code": "330112", "name": "临安区" }, { "code": "330113", "name": "临平区" }, { "code": "330114", "name": "钱塘区" }, { "code": "330122", "name": "桐庐县" }, { "code": "330127", "name": "淳安县" }, { "code": "330182", "name": "建德市" } ] }, { "code": "330200", "name": "宁波市", "areaList": [ { "code": "330203", "name": "海曙区" }, { "code": "330205", "name": "江北区" }, { "code": "330206", "name": "北仑区" }, { "code": "330211", "name": "镇海区" }, { "code": "330212", "name": "鄞州区" }, { "code": "330213", "name": "奉化区" }, { "code": "330225", "name": "象山县" }, { "code": "330226", "name": "宁海县" }, { "code": "330281", "name": "余姚市" }, { "code": "330282", "name": "慈溪市" } ] }, { "code": "330300", "name": "温州市", "areaList": [ { "code": "330302", "name": "鹿城区" }, { "code": "330303", "name": "龙湾区" }, { "code": "330304", "name": "瓯海区" }, { "code": "330305", "name": "洞头区" }, { "code": "330324", "name": "永嘉县" }, { "code": "330326", "name": "平阳县" }, { "code": "330327", "name": "苍南县" }, { "code": "330328", "name": "文成县" }, { "code": "330329", "name": "泰顺县" }, { "code": "330381", "name": "瑞安市" }, { "code": "330382", "name": "乐清市" }, { "code": "330383", "name": "龙港市" } ] }, { "code": "330400", "name": "嘉兴市", "areaList": [ { "code": "330402", "name": "南湖区" }, { "code": "330411", "name": "秀洲区" }, { "code": "330421", "name": "嘉善县" }, { "code": "330424", "name": "海盐县" }, { "code": "330481", "name": "海宁市" }, { "code": "330482", "name": "平湖市" }, { "code": "330483", "name": "桐乡市" } ] }, { "code": "330500", "name": "湖州市", "areaList": [ { "code": "330502", "name": "吴兴区" }, { "code": "330503", "name": "南浔区" }, { "code": "330521", "name": "德清县" }, { "code": "330522", "name": "长兴县" }, { "code": "330523", "name": "安吉县" } ] }, { "code": "330600", "name": "绍兴市", "areaList": [ { "code": "330602", "name": "越城区" }, { "code": "330603", "name": "柯桥区" }, { "code": "330604", "name": "上虞区" }, { "code": "330624", "name": "新昌县" }, { "code": "330681", "name": "诸暨市" }, { "code": "330683", "name": "嵊州市" } ] }, { "code": "330700", "name": "金华市", "areaList": [ { "code": "330702", "name": "婺城区" }, { "code": "330703", "name": "金东区" }, { "code": "330723", "name": "武义县" }, { "code": "330726", "name": "浦江县" }, { "code": "330727", "name": "磐安县" }, { "code": "330781", "name": "兰溪市" }, { "code": "330782", "name": "义乌市" }, { "code": "330783", "name": "东阳市" }, { "code": "330784", "name": "永康市" } ] }, { "code": "330800", "name": "衢州市", "areaList": [ { "code": "330802", "name": "柯城区" }, { "code": "330803", "name": "衢江区" }, { "code": "330822", "name": "常山县" }, { "code": "330824", "name": "开化县" }, { "code": "330825", "name": "龙游县" }, { "code": "330881", "name": "江山市" } ] }, { "code": "330900", "name": "舟山市", "areaList": [ { "code": "330902", "name": "定海区" }, { "code": "330903", "name": "普陀区" }, { "code": "330921", "name": "岱山县" }, { "code": "330922", "name": "嵊泗县" } ] }, { "code": "331000", "name": "台州市", "areaList": [ { "code": "331002", "name": "椒江区" }, { "code": "331003", "name": "黄岩区" }, { "code": "331004", "name": "路桥区" }, { "code": "331022", "name": "三门县" }, { "code": "331023", "name": "天台县" }, { "code": "331024", "name": "仙居县" }, { "code": "331081", "name": "温岭市" }, { "code": "331082", "name": "临海市" }, { "code": "331083", "name": "玉环市" } ] }, { "code": "331100", "name": "丽水市", "areaList": [ { "code": "331102", "name": "莲都区" }, { "code": "331121", "name": "青田县" }, { "code": "331122", "name": "缙云县" }, { "code": "331123", "name": "遂昌县" }, { "code": "331124", "name": "松阳县" }, { "code": "331125", "name": "云和县" }, { "code": "331126", "name": "庆元县" }, { "code": "331127", "name": "景宁畲族自治县" }, { "code": "331181", "name": "龙泉市" } ] } ] }, { "code": "340000", "name": "安徽省", "cityList": [ { "code": "340100", "name": "合肥市", "areaList": [ { "code": "340102", "name": "瑶海区" }, { "code": "340103", "name": "庐阳区" }, { "code": "340104", "name": "蜀山区" }, { "code": "340111", "name": "包河区" }, { "code": "340121", "name": "长丰县" }, { "code": "340122", "name": "肥东县" }, { "code": "340123", "name": "肥西县" }, { "code": "340124", "name": "庐江县" }, { "code": "340181", "name": "巢湖市" } ] }, { "code": "340200", "name": "芜湖市", "areaList": [ { "code": "340202", "name": "镜湖区" }, { "code": "340207", "name": "鸠江区" }, { "code": "340209", "name": "弋江区" }, { "code": "340210", "name": "湾沚区" }, { "code": "340212", "name": "繁昌区" }, { "code": "340223", "name": "南陵县" }, { "code": "340281", "name": "无为市" } ] }, { "code": "340300", "name": "蚌埠市", "areaList": [ { "code": "340302", "name": "龙子湖区" }, { "code": "340303", "name": "蚌山区" }, { "code": "340304", "name": "禹会区" }, { "code": "340311", "name": "淮上区" }, { "code": "340321", "name": "怀远县" }, { "code": "340322", "name": "五河县" }, { "code": "340323", "name": "固镇县" } ] }, { "code": "340400", "name": "淮南市", "areaList": [ { "code": "340402", "name": "大通区" }, { "code": "340403", "name": "田家庵区" }, { "code": "340404", "name": "谢家集区" }, { "code": "340405", "name": "八公山区" }, { "code": "340406", "name": "潘集区" }, { "code": "340421", "name": "凤台县" }, { "code": "340422", "name": "寿县" } ] }, { "code": "340500", "name": "马鞍山市", "areaList": [ { "code": "340503", "name": "花山区" }, { "code": "340504", "name": "雨山区" }, { "code": "340506", "name": "博望区" }, { "code": "340521", "name": "当涂县" }, { "code": "340522", "name": "含山县" }, { "code": "340523", "name": "和县" } ] }, { "code": "340600", "name": "淮北市", "areaList": [ { "code": "340602", "name": "杜集区" }, { "code": "340603", "name": "相山区" }, { "code": "340604", "name": "烈山区" }, { "code": "340621", "name": "濉溪县" } ] }, { "code": "340700", "name": "铜陵市", "areaList": [ { "code": "340705", "name": "铜官区" }, { "code": "340706", "name": "义安区" }, { "code": "340711", "name": "郊区" }, { "code": "340722", "name": "枞阳县" } ] }, { "code": "340800", "name": "安庆市", "areaList": [ { "code": "340802", "name": "迎江区" }, { "code": "340803", "name": "大观区" }, { "code": "340811", "name": "宜秀区" }, { "code": "340822", "name": "怀宁县" }, { "code": "340825", "name": "太湖县" }, { "code": "340826", "name": "宿松县" }, { "code": "340827", "name": "望江县" }, { "code": "340828", "name": "岳西县" }, { "code": "340881", "name": "桐城市" }, { "code": "340882", "name": "潜山市" } ] }, { "code": "341000", "name": "黄山市", "areaList": [ { "code": "341002", "name": "屯溪区" }, { "code": "341003", "name": "黄山区" }, { "code": "341004", "name": "徽州区" }, { "code": "341021", "name": "歙县" }, { "code": "341022", "name": "休宁县" }, { "code": "341023", "name": "黟县" }, { "code": "341024", "name": "祁门县" } ] }, { "code": "341100", "name": "滁州市", "areaList": [ { "code": "341102", "name": "琅琊区" }, { "code": "341103", "name": "南谯区" }, { "code": "341122", "name": "来安县" }, { "code": "341124", "name": "全椒县" }, { "code": "341125", "name": "定远县" }, { "code": "341126", "name": "凤阳县" }, { "code": "341181", "name": "天长市" }, { "code": "341182", "name": "明光市" } ] }, { "code": "341200", "name": "阜阳市", "areaList": [ { "code": "341202", "name": "颍州区" }, { "code": "341203", "name": "颍东区" }, { "code": "341204", "name": "颍泉区" }, { "code": "341221", "name": "临泉县" }, { "code": "341222", "name": "太和县" }, { "code": "341225", "name": "阜南县" }, { "code": "341226", "name": "颍上县" }, { "code": "341282", "name": "界首市" } ] }, { "code": "341300", "name": "宿州市", "areaList": [ { "code": "341302", "name": "埇桥区" }, { "code": "341321", "name": "砀山县" }, { "code": "341322", "name": "萧县" }, { "code": "341323", "name": "灵璧县" }, { "code": "341324", "name": "泗县" } ] }, { "code": "341500", "name": "六安市", "areaList": [ { "code": "341502", "name": "金安区" }, { "code": "341503", "name": "裕安区" }, { "code": "341504", "name": "叶集区" }, { "code": "341522", "name": "霍邱县" }, { "code": "341523", "name": "舒城县" }, { "code": "341524", "name": "金寨县" }, { "code": "341525", "name": "霍山县" } ] }, { "code": "341600", "name": "亳州市", "areaList": [ { "code": "341602", "name": "谯城区" }, { "code": "341621", "name": "涡阳县" }, { "code": "341622", "name": "蒙城县" }, { "code": "341623", "name": "利辛县" } ] }, { "code": "341700", "name": "池州市", "areaList": [ { "code": "341702", "name": "贵池区" }, { "code": "341721", "name": "东至县" }, { "code": "341722", "name": "石台县" }, { "code": "341723", "name": "青阳县" } ] }, { "code": "341800", "name": "宣城市", "areaList": [ { "code": "341802", "name": "宣州区" }, { "code": "341821", "name": "郎溪县" }, { "code": "341823", "name": "泾县" }, { "code": "341824", "name": "绩溪县" }, { "code": "341825", "name": "旌德县" }, { "code": "341881", "name": "宁国市" }, { "code": "341882", "name": "广德市" } ] } ] }, { "code": "350000", "name": "福建省", "cityList": [ { "code": "350100", "name": "福州市", "areaList": [ { "code": "350102", "name": "鼓楼区" }, { "code": "350103", "name": "台江区" }, { "code": "350104", "name": "仓山区" }, { "code": "350105", "name": "马尾区" }, { "code": "350111", "name": "晋安区" }, { "code": "350112", "name": "长乐区" }, { "code": "350121", "name": "闽侯县" }, { "code": "350122", "name": "连江县" }, { "code": "350123", "name": "罗源县" }, { "code": "350124", "name": "闽清县" }, { "code": "350125", "name": "永泰县" }, { "code": "350128", "name": "平潭县" }, { "code": "350181", "name": "福清市" } ] }, { "code": "350200", "name": "厦门市", "areaList": [ { "code": "350203", "name": "思明区" }, { "code": "350205", "name": "海沧区" }, { "code": "350206", "name": "湖里区" }, { "code": "350211", "name": "集美区" }, { "code": "350212", "name": "同安区" }, { "code": "350213", "name": "翔安区" } ] }, { "code": "350300", "name": "莆田市", "areaList": [ { "code": "350302", "name": "城厢区" }, { "code": "350303", "name": "涵江区" }, { "code": "350304", "name": "荔城区" }, { "code": "350305", "name": "秀屿区" }, { "code": "350322", "name": "仙游县" } ] }, { "code": "350400", "name": "三明市", "areaList": [ { "code": "350404", "name": "三元区" }, { "code": "350405", "name": "沙县区" }, { "code": "350421", "name": "明溪县" }, { "code": "350423", "name": "清流县" }, { "code": "350424", "name": "宁化县" }, { "code": "350425", "name": "大田县" }, { "code": "350426", "name": "尤溪县" }, { "code": "350428", "name": "将乐县" }, { "code": "350429", "name": "泰宁县" }, { "code": "350430", "name": "建宁县" }, { "code": "350481", "name": "永安市" } ] }, { "code": "350500", "name": "泉州市", "areaList": [ { "code": "350502", "name": "鲤城区" }, { "code": "350503", "name": "丰泽区" }, { "code": "350504", "name": "洛江区" }, { "code": "350505", "name": "泉港区" }, { "code": "350521", "name": "惠安县" }, { "code": "350524", "name": "安溪县" }, { "code": "350525", "name": "永春县" }, { "code": "350526", "name": "德化县" }, { "code": "350527", "name": "金门县" }, { "code": "350581", "name": "石狮市" }, { "code": "350582", "name": "晋江市" }, { "code": "350583", "name": "南安市" } ] }, { "code": "350600", "name": "漳州市", "areaList": [ { "code": "350602", "name": "芗城区" }, { "code": "350603", "name": "龙文区" }, { "code": "350604", "name": "龙海区" }, { "code": "350605", "name": "长泰区" }, { "code": "350622", "name": "云霄县" }, { "code": "350623", "name": "漳浦县" }, { "code": "350624", "name": "诏安县" }, { "code": "350626", "name": "东山县" }, { "code": "350627", "name": "南靖县" }, { "code": "350628", "name": "平和县" }, { "code": "350629", "name": "华安县" } ] }, { "code": "350700", "name": "南平市", "areaList": [ { "code": "350702", "name": "延平区" }, { "code": "350703", "name": "建阳区" }, { "code": "350721", "name": "顺昌县" }, { "code": "350722", "name": "浦城县" }, { "code": "350723", "name": "光泽县" }, { "code": "350724", "name": "松溪县" }, { "code": "350725", "name": "政和县" }, { "code": "350781", "name": "邵武市" }, { "code": "350782", "name": "武夷山市" }, { "code": "350783", "name": "建瓯市" } ] }, { "code": "350800", "name": "龙岩市", "areaList": [ { "code": "350802", "name": "新罗区" }, { "code": "350803", "name": "永定区" }, { "code": "350821", "name": "长汀县" }, { "code": "350823", "name": "上杭县" }, { "code": "350824", "name": "武平县" }, { "code": "350825", "name": "连城县" }, { "code": "350881", "name": "漳平市" } ] }, { "code": "350900", "name": "宁德市", "areaList": [ { "code": "350902", "name": "蕉城区" }, { "code": "350921", "name": "霞浦县" }, { "code": "350922", "name": "古田县" }, { "code": "350923", "name": "屏南县" }, { "code": "350924", "name": "寿宁县" }, { "code": "350925", "name": "周宁县" }, { "code": "350926", "name": "柘荣县" }, { "code": "350981", "name": "福安市" }, { "code": "350982", "name": "福鼎市" } ] } ] }, { "code": "360000", "name": "江西省", "cityList": [ { "code": "360100", "name": "南昌市", "areaList": [ { "code": "360102", "name": "东湖区" }, { "code": "360103", "name": "西湖区" }, { "code": "360104", "name": "青云谱区" }, { "code": "360111", "name": "青山湖区" }, { "code": "360112", "name": "新建区" }, { "code": "360113", "name": "红谷滩区" }, { "code": "360121", "name": "南昌县" }, { "code": "360123", "name": "安义县" }, { "code": "360124", "name": "进贤县" } ] }, { "code": "360200", "name": "景德镇市", "areaList": [ { "code": "360202", "name": "昌江区" }, { "code": "360203", "name": "珠山区" }, { "code": "360222", "name": "浮梁县" }, { "code": "360281", "name": "乐平市" } ] }, { "code": "360300", "name": "萍乡市", "areaList": [ { "code": "360302", "name": "安源区" }, { "code": "360313", "name": "湘东区" }, { "code": "360321", "name": "莲花县" }, { "code": "360322", "name": "上栗县" }, { "code": "360323", "name": "芦溪县" } ] }, { "code": "360400", "name": "九江市", "areaList": [ { "code": "360402", "name": "濂溪区" }, { "code": "360403", "name": "浔阳区" }, { "code": "360404", "name": "柴桑区" }, { "code": "360423", "name": "武宁县" }, { "code": "360424", "name": "修水县" }, { "code": "360425", "name": "永修县" }, { "code": "360426", "name": "德安县" }, { "code": "360428", "name": "都昌县" }, { "code": "360429", "name": "湖口县" }, { "code": "360430", "name": "彭泽县" }, { "code": "360481", "name": "瑞昌市" }, { "code": "360482", "name": "共青城市" }, { "code": "360483", "name": "庐山市" } ] }, { "code": "360500", "name": "新余市", "areaList": [ { "code": "360502", "name": "渝水区" }, { "code": "360521", "name": "分宜县" } ] }, { "code": "360600", "name": "鹰潭市", "areaList": [ { "code": "360602", "name": "月湖区" }, { "code": "360603", "name": "余江区" }, { "code": "360681", "name": "贵溪市" } ] }, { "code": "360700", "name": "赣州市", "areaList": [ { "code": "360702", "name": "章贡区" }, { "code": "360703", "name": "南康区" }, { "code": "360704", "name": "赣县区" }, { "code": "360722", "name": "信丰县" }, { "code": "360723", "name": "大余县" }, { "code": "360724", "name": "上犹县" }, { "code": "360725", "name": "崇义县" }, { "code": "360726", "name": "安远县" }, { "code": "360728", "name": "定南县" }, { "code": "360729", "name": "全南县" }, { "code": "360730", "name": "宁都县" }, { "code": "360731", "name": "于都县" }, { "code": "360732", "name": "兴国县" }, { "code": "360733", "name": "会昌县" }, { "code": "360734", "name": "寻乌县" }, { "code": "360735", "name": "石城县" }, { "code": "360781", "name": "瑞金市" }, { "code": "360783", "name": "龙南市" } ] }, { "code": "360800", "name": "吉安市", "areaList": [ { "code": "360802", "name": "吉州区" }, { "code": "360803", "name": "青原区" }, { "code": "360821", "name": "吉安县" }, { "code": "360822", "name": "吉水县" }, { "code": "360823", "name": "峡江县" }, { "code": "360824", "name": "新干县" }, { "code": "360825", "name": "永丰县" }, { "code": "360826", "name": "泰和县" }, { "code": "360827", "name": "遂川县" }, { "code": "360828", "name": "万安县" }, { "code": "360829", "name": "安福县" }, { "code": "360830", "name": "永新县" }, { "code": "360881", "name": "井冈山市" } ] }, { "code": "360900", "name": "宜春市", "areaList": [ { "code": "360902", "name": "袁州区" }, { "code": "360921", "name": "奉新县" }, { "code": "360922", "name": "万载县" }, { "code": "360923", "name": "上高县" }, { "code": "360924", "name": "宜丰县" }, { "code": "360925", "name": "靖安县" }, { "code": "360926", "name": "铜鼓县" }, { "code": "360981", "name": "丰城市" }, { "code": "360982", "name": "樟树市" }, { "code": "360983", "name": "高安市" } ] }, { "code": "361000", "name": "抚州市", "areaList": [ { "code": "361002", "name": "临川区" }, { "code": "361003", "name": "东乡区" }, { "code": "361021", "name": "南城县" }, { "code": "361022", "name": "黎川县" }, { "code": "361023", "name": "南丰县" }, { "code": "361024", "name": "崇仁县" }, { "code": "361025", "name": "乐安县" }, { "code": "361026", "name": "宜黄县" }, { "code": "361027", "name": "金溪县" }, { "code": "361028", "name": "资溪县" }, { "code": "361030", "name": "广昌县" } ] }, { "code": "361100", "name": "上饶市", "areaList": [ { "code": "361102", "name": "信州区" }, { "code": "361103", "name": "广丰区" }, { "code": "361104", "name": "广信区" }, { "code": "361123", "name": "玉山县" }, { "code": "361124", "name": "铅山县" }, { "code": "361125", "name": "横峰县" }, { "code": "361126", "name": "弋阳县" }, { "code": "361127", "name": "余干县" }, { "code": "361128", "name": "鄱阳县" }, { "code": "361129", "name": "万年县" }, { "code": "361130", "name": "婺源县" }, { "code": "361181", "name": "德兴市" } ] } ] }, { "code": "370000", "name": "山东省", "cityList": [ { "code": "370100", "name": "济南市", "areaList": [ { "code": "370102", "name": "历下区" }, { "code": "370103", "name": "市中区" }, { "code": "370104", "name": "槐荫区" }, { "code": "370105", "name": "天桥区" }, { "code": "370112", "name": "历城区" }, { "code": "370113", "name": "长清区" }, { "code": "370114", "name": "章丘区" }, { "code": "370115", "name": "济阳区" }, { "code": "370116", "name": "莱芜区" }, { "code": "370117", "name": "钢城区" }, { "code": "370124", "name": "平阴县" }, { "code": "370126", "name": "商河县" } ] }, { "code": "370200", "name": "青岛市", "areaList": [ { "code": "370202", "name": "市南区" }, { "code": "370203", "name": "市北区" }, { "code": "370211", "name": "黄岛区" }, { "code": "370212", "name": "崂山区" }, { "code": "370213", "name": "李沧区" }, { "code": "370214", "name": "城阳区" }, { "code": "370215", "name": "即墨区" }, { "code": "370281", "name": "胶州市" }, { "code": "370283", "name": "平度市" }, { "code": "370285", "name": "莱西市" } ] }, { "code": "370300", "name": "淄博市", "areaList": [ { "code": "370302", "name": "淄川区" }, { "code": "370303", "name": "张店区" }, { "code": "370304", "name": "博山区" }, { "code": "370305", "name": "临淄区" }, { "code": "370306", "name": "周村区" }, { "code": "370321", "name": "桓台县" }, { "code": "370322", "name": "高青县" }, { "code": "370323", "name": "沂源县" } ] }, { "code": "370400", "name": "枣庄市", "areaList": [ { "code": "370402", "name": "市中区" }, { "code": "370403", "name": "薛城区" }, { "code": "370404", "name": "峄城区" }, { "code": "370405", "name": "台儿庄区" }, { "code": "370406", "name": "山亭区" }, { "code": "370481", "name": "滕州市" } ] }, { "code": "370500", "name": "东营市", "areaList": [ { "code": "370502", "name": "东营区" }, { "code": "370503", "name": "河口区" }, { "code": "370505", "name": "垦利区" }, { "code": "370522", "name": "利津县" }, { "code": "370523", "name": "广饶县" } ] }, { "code": "370600", "name": "烟台市", "areaList": [ { "code": "370602", "name": "芝罘区" }, { "code": "370611", "name": "福山区" }, { "code": "370612", "name": "牟平区" }, { "code": "370613", "name": "莱山区" }, { "code": "370614", "name": "蓬莱区" }, { "code": "370681", "name": "龙口市" }, { "code": "370682", "name": "莱阳市" }, { "code": "370683", "name": "莱州市" }, { "code": "370685", "name": "招远市" }, { "code": "370686", "name": "栖霞市" }, { "code": "370687", "name": "海阳市" } ] }, { "code": "370700", "name": "潍坊市", "areaList": [ { "code": "370702", "name": "潍城区" }, { "code": "370703", "name": "寒亭区" }, { "code": "370704", "name": "坊子区" }, { "code": "370705", "name": "奎文区" }, { "code": "370724", "name": "临朐县" }, { "code": "370725", "name": "昌乐县" }, { "code": "370781", "name": "青州市" }, { "code": "370782", "name": "诸城市" }, { "code": "370783", "name": "寿光市" }, { "code": "370784", "name": "安丘市" }, { "code": "370785", "name": "高密市" }, { "code": "370786", "name": "昌邑市" } ] }, { "code": "370800", "name": "济宁市", "areaList": [ { "code": "370811", "name": "任城区" }, { "code": "370812", "name": "兖州区" }, { "code": "370826", "name": "微山县" }, { "code": "370827", "name": "鱼台县" }, { "code": "370828", "name": "金乡县" }, { "code": "370829", "name": "嘉祥县" }, { "code": "370830", "name": "汶上县" }, { "code": "370831", "name": "泗水县" }, { "code": "370832", "name": "梁山县" }, { "code": "370881", "name": "曲阜市" }, { "code": "370883", "name": "邹城市" } ] }, { "code": "370900", "name": "泰安市", "areaList": [ { "code": "370902", "name": "泰山区" }, { "code": "370911", "name": "岱岳区" }, { "code": "370921", "name": "宁阳县" }, { "code": "370923", "name": "东平县" }, { "code": "370982", "name": "新泰市" }, { "code": "370983", "name": "肥城市" } ] }, { "code": "371000", "name": "威海市", "areaList": [ { "code": "371002", "name": "环翠区" }, { "code": "371003", "name": "文登区" }, { "code": "371082", "name": "荣成市" }, { "code": "371083", "name": "乳山市" } ] }, { "code": "371100", "name": "日照市", "areaList": [ { "code": "371102", "name": "东港区" }, { "code": "371103", "name": "岚山区" }, { "code": "371121", "name": "五莲县" }, { "code": "371122", "name": "莒县" } ] }, { "code": "371300", "name": "临沂市", "areaList": [ { "code": "371302", "name": "兰山区" }, { "code": "371311", "name": "罗庄区" }, { "code": "371312", "name": "河东区" }, { "code": "371321", "name": "沂南县" }, { "code": "371322", "name": "郯城县" }, { "code": "371323", "name": "沂水县" }, { "code": "371324", "name": "兰陵县" }, { "code": "371325", "name": "费县" }, { "code": "371326", "name": "平邑县" }, { "code": "371327", "name": "莒南县" }, { "code": "371328", "name": "蒙阴县" }, { "code": "371329", "name": "临沭县" } ] }, { "code": "371400", "name": "德州市", "areaList": [ { "code": "371402", "name": "德城区" }, { "code": "371403", "name": "陵城区" }, { "code": "371422", "name": "宁津县" }, { "code": "371423", "name": "庆云县" }, { "code": "371424", "name": "临邑县" }, { "code": "371425", "name": "齐河县" }, { "code": "371426", "name": "平原县" }, { "code": "371427", "name": "夏津县" }, { "code": "371428", "name": "武城县" }, { "code": "371481", "name": "乐陵市" }, { "code": "371482", "name": "禹城市" } ] }, { "code": "371500", "name": "聊城市", "areaList": [ { "code": "371502", "name": "东昌府区" }, { "code": "371503", "name": "茌平区" }, { "code": "371521", "name": "阳谷县" }, { "code": "371522", "name": "莘县" }, { "code": "371524", "name": "东阿县" }, { "code": "371525", "name": "冠县" }, { "code": "371526", "name": "高唐县" }, { "code": "371581", "name": "临清市" } ] }, { "code": "371600", "name": "滨州市", "areaList": [ { "code": "371602", "name": "滨城区" }, { "code": "371603", "name": "沾化区" }, { "code": "371621", "name": "惠民县" }, { "code": "371622", "name": "阳信县" }, { "code": "371623", "name": "无棣县" }, { "code": "371625", "name": "博兴县" }, { "code": "371681", "name": "邹平市" } ] }, { "code": "371700", "name": "菏泽市", "areaList": [ { "code": "371702", "name": "牡丹区" }, { "code": "371703", "name": "定陶区" }, { "code": "371721", "name": "曹县" }, { "code": "371722", "name": "单县" }, { "code": "371723", "name": "成武县" }, { "code": "371724", "name": "巨野县" }, { "code": "371725", "name": "郓城县" }, { "code": "371726", "name": "鄄城县" }, { "code": "371728", "name": "东明县" } ] } ] }, { "code": "410000", "name": "河南省", "cityList": [ { "code": "410100", "name": "郑州市", "areaList": [ { "code": "410102", "name": "中原区" }, { "code": "410103", "name": "二七区" }, { "code": "410104", "name": "管城回族区" }, { "code": "410105", "name": "金水区" }, { "code": "410106", "name": "上街区" }, { "code": "410108", "name": "惠济区" }, { "code": "410122", "name": "中牟县" }, { "code": "410181", "name": "巩义市" }, { "code": "410182", "name": "荥阳市" }, { "code": "410183", "name": "新密市" }, { "code": "410184", "name": "新郑市" }, { "code": "410185", "name": "登封市" } ] }, { "code": "410200", "name": "开封市", "areaList": [ { "code": "410202", "name": "龙亭区" }, { "code": "410203", "name": "顺河回族区" }, { "code": "410204", "name": "鼓楼区" }, { "code": "410205", "name": "禹王台区" }, { "code": "410212", "name": "祥符区" }, { "code": "410221", "name": "杞县" }, { "code": "410222", "name": "通许县" }, { "code": "410223", "name": "尉氏县" }, { "code": "410225", "name": "兰考县" } ] }, { "code": "410300", "name": "洛阳市", "areaList": [ { "code": "410302", "name": "老城区" }, { "code": "410303", "name": "西工区" }, { "code": "410304", "name": "瀍河回族区" }, { "code": "410305", "name": "涧西区" }, { "code": "410307", "name": "偃师区" }, { "code": "410308", "name": "孟津区" }, { "code": "410311", "name": "洛龙区" }, { "code": "410323", "name": "新安县" }, { "code": "410324", "name": "栾川县" }, { "code": "410325", "name": "嵩县" }, { "code": "410326", "name": "汝阳县" }, { "code": "410327", "name": "宜阳县" }, { "code": "410328", "name": "洛宁县" }, { "code": "410329", "name": "伊川县" } ] }, { "code": "410400", "name": "平顶山市", "areaList": [ { "code": "410402", "name": "新华区" }, { "code": "410403", "name": "卫东区" }, { "code": "410404", "name": "石龙区" }, { "code": "410411", "name": "湛河区" }, { "code": "410421", "name": "宝丰县" }, { "code": "410422", "name": "叶县" }, { "code": "410423", "name": "鲁山县" }, { "code": "410425", "name": "郏县" }, { "code": "410481", "name": "舞钢市" }, { "code": "410482", "name": "汝州市" } ] }, { "code": "410500", "name": "安阳市", "areaList": [ { "code": "410502", "name": "文峰区" }, { "code": "410503", "name": "北关区" }, { "code": "410505", "name": "殷都区" }, { "code": "410506", "name": "龙安区" }, { "code": "410522", "name": "安阳县" }, { "code": "410523", "name": "汤阴县" }, { "code": "410526", "name": "滑县" }, { "code": "410527", "name": "内黄县" }, { "code": "410581", "name": "林州市" } ] }, { "code": "410600", "name": "鹤壁市", "areaList": [ { "code": "410602", "name": "鹤山区" }, { "code": "410603", "name": "山城区" }, { "code": "410611", "name": "淇滨区" }, { "code": "410621", "name": "浚县" }, { "code": "410622", "name": "淇县" } ] }, { "code": "410700", "name": "新乡市", "areaList": [ { "code": "410702", "name": "红旗区" }, { "code": "410703", "name": "卫滨区" }, { "code": "410704", "name": "凤泉区" }, { "code": "410711", "name": "牧野区" }, { "code": "410721", "name": "新乡县" }, { "code": "410724", "name": "获嘉县" }, { "code": "410725", "name": "原阳县" }, { "code": "410726", "name": "延津县" }, { "code": "410727", "name": "封丘县" }, { "code": "410781", "name": "卫辉市" }, { "code": "410782", "name": "辉县市" }, { "code": "410783", "name": "长垣市" } ] }, { "code": "410800", "name": "焦作市", "areaList": [ { "code": "410802", "name": "解放区" }, { "code": "410803", "name": "中站区" }, { "code": "410804", "name": "马村区" }, { "code": "410811", "name": "山阳区" }, { "code": "410821", "name": "修武县" }, { "code": "410822", "name": "博爱县" }, { "code": "410823", "name": "武陟县" }, { "code": "410825", "name": "温县" }, { "code": "410882", "name": "沁阳市" }, { "code": "410883", "name": "孟州市" } ] }, { "code": "410900", "name": "濮阳市", "areaList": [ { "code": "410902", "name": "华龙区" }, { "code": "410922", "name": "清丰县" }, { "code": "410923", "name": "南乐县" }, { "code": "410926", "name": "范县" }, { "code": "410927", "name": "台前县" }, { "code": "410928", "name": "濮阳县" } ] }, { "code": "411000", "name": "许昌市", "areaList": [ { "code": "411002", "name": "魏都区" }, { "code": "411003", "name": "建安区" }, { "code": "411024", "name": "鄢陵县" }, { "code": "411025", "name": "襄城县" }, { "code": "411081", "name": "禹州市" }, { "code": "411082", "name": "长葛市" } ] }, { "code": "411100", "name": "漯河市", "areaList": [ { "code": "411102", "name": "源汇区" }, { "code": "411103", "name": "郾城区" }, { "code": "411104", "name": "召陵区" }, { "code": "411121", "name": "舞阳县" }, { "code": "411122", "name": "临颍县" } ] }, { "code": "411200", "name": "三门峡市", "areaList": [ { "code": "411202", "name": "湖滨区" }, { "code": "411203", "name": "陕州区" }, { "code": "411221", "name": "渑池县" }, { "code": "411224", "name": "卢氏县" }, { "code": "411281", "name": "义马市" }, { "code": "411282", "name": "灵宝市" } ] }, { "code": "411300", "name": "南阳市", "areaList": [ { "code": "411302", "name": "宛城区" }, { "code": "411303", "name": "卧龙区" }, { "code": "411321", "name": "南召县" }, { "code": "411322", "name": "方城县" }, { "code": "411323", "name": "西峡县" }, { "code": "411324", "name": "镇平县" }, { "code": "411325", "name": "内乡县" }, { "code": "411326", "name": "淅川县" }, { "code": "411327", "name": "社旗县" }, { "code": "411328", "name": "唐河县" }, { "code": "411329", "name": "新野县" }, { "code": "411330", "name": "桐柏县" }, { "code": "411381", "name": "邓州市" } ] }, { "code": "411400", "name": "商丘市", "areaList": [ { "code": "411402", "name": "梁园区" }, { "code": "411403", "name": "睢阳区" }, { "code": "411421", "name": "民权县" }, { "code": "411422", "name": "睢县" }, { "code": "411423", "name": "宁陵县" }, { "code": "411424", "name": "柘城县" }, { "code": "411425", "name": "虞城县" }, { "code": "411426", "name": "夏邑县" }, { "code": "411481", "name": "永城市" } ] }, { "code": "411500", "name": "信阳市", "areaList": [ { "code": "411502", "name": "浉河区" }, { "code": "411503", "name": "平桥区" }, { "code": "411521", "name": "罗山县" }, { "code": "411522", "name": "光山县" }, { "code": "411523", "name": "新县" }, { "code": "411524", "name": "商城县" }, { "code": "411525", "name": "固始县" }, { "code": "411526", "name": "潢川县" }, { "code": "411527", "name": "淮滨县" }, { "code": "411528", "name": "息县" } ] }, { "code": "411600", "name": "周口市", "areaList": [ { "code": "411602", "name": "川汇区" }, { "code": "411603", "name": "淮阳区" }, { "code": "411621", "name": "扶沟县" }, { "code": "411622", "name": "西华县" }, { "code": "411623", "name": "商水县" }, { "code": "411624", "name": "沈丘县" }, { "code": "411625", "name": "郸城县" }, { "code": "411627", "name": "太康县" }, { "code": "411628", "name": "鹿邑县" }, { "code": "411681", "name": "项城市" } ] }, { "code": "411700", "name": "驻马店市", "areaList": [ { "code": "411702", "name": "驿城区" }, { "code": "411721", "name": "西平县" }, { "code": "411722", "name": "上蔡县" }, { "code": "411723", "name": "平舆县" }, { "code": "411724", "name": "正阳县" }, { "code": "411725", "name": "确山县" }, { "code": "411726", "name": "泌阳县" }, { "code": "411727", "name": "汝南县" }, { "code": "411728", "name": "遂平县" }, { "code": "411729", "name": "新蔡县" } ] }, { "code": "419001", "name": "济源市", "areaList": [ { "code": "419001", "name": "济源市" } ] } ] }, { "code": "420000", "name": "湖北省", "cityList": [ { "code": "420100", "name": "武汉市", "areaList": [ { "code": "420102", "name": "江岸区" }, { "code": "420103", "name": "江汉区" }, { "code": "420104", "name": "硚口区" }, { "code": "420105", "name": "汉阳区" }, { "code": "420106", "name": "武昌区" }, { "code": "420107", "name": "青山区" }, { "code": "420111", "name": "洪山区" }, { "code": "420112", "name": "东西湖区" }, { "code": "420113", "name": "汉南区" }, { "code": "420114", "name": "蔡甸区" }, { "code": "420115", "name": "江夏区" }, { "code": "420116", "name": "黄陂区" }, { "code": "420117", "name": "新洲区" } ] }, { "code": "420200", "name": "黄石市", "areaList": [ { "code": "420202", "name": "黄石港区" }, { "code": "420203", "name": "西塞山区" }, { "code": "420204", "name": "下陆区" }, { "code": "420205", "name": "铁山区" }, { "code": "420222", "name": "阳新县" }, { "code": "420281", "name": "大冶市" } ] }, { "code": "420300", "name": "十堰市", "areaList": [ { "code": "420302", "name": "茅箭区" }, { "code": "420303", "name": "张湾区" }, { "code": "420304", "name": "郧阳区" }, { "code": "420322", "name": "郧西县" }, { "code": "420323", "name": "竹山县" }, { "code": "420324", "name": "竹溪县" }, { "code": "420325", "name": "房县" }, { "code": "420381", "name": "丹江口市" } ] }, { "code": "420500", "name": "宜昌市", "areaList": [ { "code": "420502", "name": "西陵区" }, { "code": "420503", "name": "伍家岗区" }, { "code": "420504", "name": "点军区" }, { "code": "420505", "name": "猇亭区" }, { "code": "420506", "name": "夷陵区" }, { "code": "420525", "name": "远安县" }, { "code": "420526", "name": "兴山县" }, { "code": "420527", "name": "秭归县" }, { "code": "420528", "name": "长阳土家族自治县" }, { "code": "420529", "name": "五峰土家族自治县" }, { "code": "420581", "name": "宜都市" }, { "code": "420582", "name": "当阳市" }, { "code": "420583", "name": "枝江市" } ] }, { "code": "420600", "name": "襄阳市", "areaList": [ { "code": "420602", "name": "襄城区" }, { "code": "420606", "name": "樊城区" }, { "code": "420607", "name": "襄州区" }, { "code": "420624", "name": "南漳县" }, { "code": "420625", "name": "谷城县" }, { "code": "420626", "name": "保康县" }, { "code": "420682", "name": "老河口市" }, { "code": "420683", "name": "枣阳市" }, { "code": "420684", "name": "宜城市" } ] }, { "code": "420700", "name": "鄂州市", "areaList": [ { "code": "420702", "name": "梁子湖区" }, { "code": "420703", "name": "华容区" }, { "code": "420704", "name": "鄂城区" } ] }, { "code": "420800", "name": "荆门市", "areaList": [ { "code": "420802", "name": "东宝区" }, { "code": "420804", "name": "掇刀区" }, { "code": "420822", "name": "沙洋县" }, { "code": "420881", "name": "钟祥市" }, { "code": "420882", "name": "京山市" } ] }, { "code": "420900", "name": "孝感市", "areaList": [ { "code": "420902", "name": "孝南区" }, { "code": "420921", "name": "孝昌县" }, { "code": "420922", "name": "大悟县" }, { "code": "420923", "name": "云梦县" }, { "code": "420981", "name": "应城市" }, { "code": "420982", "name": "安陆市" }, { "code": "420984", "name": "汉川市" } ] }, { "code": "421000", "name": "荆州市", "areaList": [ { "code": "421002", "name": "沙市区" }, { "code": "421003", "name": "荆州区" }, { "code": "421022", "name": "公安县" }, { "code": "421024", "name": "江陵县" }, { "code": "421081", "name": "石首市" }, { "code": "421083", "name": "洪湖市" }, { "code": "421087", "name": "松滋市" }, { "code": "421088", "name": "监利市" } ] }, { "code": "421100", "name": "黄冈市", "areaList": [ { "code": "421102", "name": "黄州区" }, { "code": "421121", "name": "团风县" }, { "code": "421122", "name": "红安县" }, { "code": "421123", "name": "罗田县" }, { "code": "421124", "name": "英山县" }, { "code": "421125", "name": "浠水县" }, { "code": "421126", "name": "蕲春县" }, { "code": "421127", "name": "黄梅县" }, { "code": "421181", "name": "麻城市" }, { "code": "421182", "name": "武穴市" } ] }, { "code": "421200", "name": "咸宁市", "areaList": [ { "code": "421202", "name": "咸安区" }, { "code": "421221", "name": "嘉鱼县" }, { "code": "421222", "name": "通城县" }, { "code": "421223", "name": "崇阳县" }, { "code": "421224", "name": "通山县" }, { "code": "421281", "name": "赤壁市" } ] }, { "code": "421300", "name": "随州市", "areaList": [ { "code": "421303", "name": "曾都区" }, { "code": "421321", "name": "随县" }, { "code": "421381", "name": "广水市" } ] }, { "code": "422800", "name": "恩施土家族苗族自治州", "areaList": [ { "code": "422801", "name": "恩施市" }, { "code": "422802", "name": "利川市" }, { "code": "422822", "name": "建始县" }, { "code": "422823", "name": "巴东县" }, { "code": "422825", "name": "宣恩县" }, { "code": "422826", "name": "咸丰县" }, { "code": "422827", "name": "来凤县" }, { "code": "422828", "name": "鹤峰县" } ] }, { "code": "429004", "name": "仙桃市", "areaList": [ { "code": "429004", "name": "仙桃市" } ] }, { "code": "429005", "name": "潜江市", "areaList": [ { "code": "429005", "name": "潜江市" } ] }, { "code": "429006", "name": "天门市", "areaList": [ { "code": "429006", "name": "天门市" } ] }, { "code": "429021", "name": "神农架林区", "areaList": [ { "code": "429021", "name": "神农架林区" } ] } ] }, { "code": "430000", "name": "湖南省", "cityList": [ { "code": "430100", "name": "长沙市", "areaList": [ { "code": "430102", "name": "芙蓉区" }, { "code": "430103", "name": "天心区" }, { "code": "430104", "name": "岳麓区" }, { "code": "430105", "name": "开福区" }, { "code": "430111", "name": "雨花区" }, { "code": "430112", "name": "望城区" }, { "code": "430121", "name": "长沙县" }, { "code": "430181", "name": "浏阳市" }, { "code": "430182", "name": "宁乡市" } ] }, { "code": "430200", "name": "株洲市", "areaList": [ { "code": "430202", "name": "荷塘区" }, { "code": "430203", "name": "芦淞区" }, { "code": "430204", "name": "石峰区" }, { "code": "430211", "name": "天元区" }, { "code": "430212", "name": "渌口区" }, { "code": "430223", "name": "攸县" }, { "code": "430224", "name": "茶陵县" }, { "code": "430225", "name": "炎陵县" }, { "code": "430281", "name": "醴陵市" } ] }, { "code": "430300", "name": "湘潭市", "areaList": [ { "code": "430302", "name": "雨湖区" }, { "code": "430304", "name": "岳塘区" }, { "code": "430321", "name": "湘潭县" }, { "code": "430381", "name": "湘乡市" }, { "code": "430382", "name": "韶山市" } ] }, { "code": "430400", "name": "衡阳市", "areaList": [ { "code": "430405", "name": "珠晖区" }, { "code": "430406", "name": "雁峰区" }, { "code": "430407", "name": "石鼓区" }, { "code": "430408", "name": "蒸湘区" }, { "code": "430412", "name": "南岳区" }, { "code": "430421", "name": "衡阳县" }, { "code": "430422", "name": "衡南县" }, { "code": "430423", "name": "衡山县" }, { "code": "430424", "name": "衡东县" }, { "code": "430426", "name": "祁东县" }, { "code": "430481", "name": "耒阳市" }, { "code": "430482", "name": "常宁市" } ] }, { "code": "430500", "name": "邵阳市", "areaList": [ { "code": "430502", "name": "双清区" }, { "code": "430503", "name": "大祥区" }, { "code": "430511", "name": "北塔区" }, { "code": "430522", "name": "新邵县" }, { "code": "430523", "name": "邵阳县" }, { "code": "430524", "name": "隆回县" }, { "code": "430525", "name": "洞口县" }, { "code": "430527", "name": "绥宁县" }, { "code": "430528", "name": "新宁县" }, { "code": "430529", "name": "城步苗族自治县" }, { "code": "430581", "name": "武冈市" }, { "code": "430582", "name": "邵东市" } ] }, { "code": "430600", "name": "岳阳市", "areaList": [ { "code": "430602", "name": "岳阳楼区" }, { "code": "430603", "name": "云溪区" }, { "code": "430611", "name": "君山区" }, { "code": "430621", "name": "岳阳县" }, { "code": "430623", "name": "华容县" }, { "code": "430624", "name": "湘阴县" }, { "code": "430626", "name": "平江县" }, { "code": "430681", "name": "汨罗市" }, { "code": "430682", "name": "临湘市" } ] }, { "code": "430700", "name": "常德市", "areaList": [ { "code": "430702", "name": "武陵区" }, { "code": "430703", "name": "鼎城区" }, { "code": "430721", "name": "安乡县" }, { "code": "430722", "name": "汉寿县" }, { "code": "430723", "name": "澧县" }, { "code": "430724", "name": "临澧县" }, { "code": "430725", "name": "桃源县" }, { "code": "430726", "name": "石门县" }, { "code": "430781", "name": "津市市" } ] }, { "code": "430800", "name": "张家界市", "areaList": [ { "code": "430802", "name": "永定区" }, { "code": "430811", "name": "武陵源区" }, { "code": "430821", "name": "慈利县" }, { "code": "430822", "name": "桑植县" } ] }, { "code": "430900", "name": "益阳市", "areaList": [ { "code": "430902", "name": "资阳区" }, { "code": "430903", "name": "赫山区" }, { "code": "430921", "name": "南县" }, { "code": "430922", "name": "桃江县" }, { "code": "430923", "name": "安化县" }, { "code": "430981", "name": "沅江市" } ] }, { "code": "431000", "name": "郴州市", "areaList": [ { "code": "431002", "name": "北湖区" }, { "code": "431003", "name": "苏仙区" }, { "code": "431021", "name": "桂阳县" }, { "code": "431022", "name": "宜章县" }, { "code": "431023", "name": "永兴县" }, { "code": "431024", "name": "嘉禾县" }, { "code": "431025", "name": "临武县" }, { "code": "431026", "name": "汝城县" }, { "code": "431027", "name": "桂东县" }, { "code": "431028", "name": "安仁县" }, { "code": "431081", "name": "资兴市" } ] }, { "code": "431100", "name": "永州市", "areaList": [ { "code": "431102", "name": "零陵区" }, { "code": "431103", "name": "冷水滩区" }, { "code": "431122", "name": "东安县" }, { "code": "431123", "name": "双牌县" }, { "code": "431124", "name": "道县" }, { "code": "431125", "name": "江永县" }, { "code": "431126", "name": "宁远县" }, { "code": "431127", "name": "蓝山县" }, { "code": "431128", "name": "新田县" }, { "code": "431129", "name": "江华瑶族自治县" }, { "code": "431181", "name": "祁阳市" } ] }, { "code": "431200", "name": "怀化市", "areaList": [ { "code": "431202", "name": "鹤城区" }, { "code": "431221", "name": "中方县" }, { "code": "431222", "name": "沅陵县" }, { "code": "431223", "name": "辰溪县" }, { "code": "431224", "name": "溆浦县" }, { "code": "431225", "name": "会同县" }, { "code": "431226", "name": "麻阳苗族自治县" }, { "code": "431227", "name": "新晃侗族自治县" }, { "code": "431228", "name": "芷江侗族自治县" }, { "code": "431229", "name": "靖州苗族侗族自治县" }, { "code": "431230", "name": "通道侗族自治县" }, { "code": "431281", "name": "洪江市" } ] }, { "code": "431300", "name": "娄底市", "areaList": [ { "code": "431302", "name": "娄星区" }, { "code": "431321", "name": "双峰县" }, { "code": "431322", "name": "新化县" }, { "code": "431381", "name": "冷水江市" }, { "code": "431382", "name": "涟源市" } ] }, { "code": "433100", "name": "湘西土家族苗族自治州", "areaList": [ { "code": "433101", "name": "吉首市" }, { "code": "433122", "name": "泸溪县" }, { "code": "433123", "name": "凤凰县" }, { "code": "433124", "name": "花垣县" }, { "code": "433125", "name": "保靖县" }, { "code": "433126", "name": "古丈县" }, { "code": "433127", "name": "永顺县" }, { "code": "433130", "name": "龙山县" } ] } ] }, { "code": "440000", "name": "广东省", "cityList": [ { "code": "440100", "name": "广州市", "areaList": [ { "code": "440103", "name": "荔湾区" }, { "code": "440104", "name": "越秀区" }, { "code": "440105", "name": "海珠区" }, { "code": "440106", "name": "天河区" }, { "code": "440111", "name": "白云区" }, { "code": "440112", "name": "黄埔区" }, { "code": "440113", "name": "番禺区" }, { "code": "440114", "name": "花都区" }, { "code": "440115", "name": "南沙区" }, { "code": "440117", "name": "从化区" }, { "code": "440118", "name": "增城区" } ] }, { "code": "440200", "name": "韶关市", "areaList": [ { "code": "440203", "name": "武江区" }, { "code": "440204", "name": "浈江区" }, { "code": "440205", "name": "曲江区" }, { "code": "440222", "name": "始兴县" }, { "code": "440224", "name": "仁化县" }, { "code": "440229", "name": "翁源县" }, { "code": "440232", "name": "乳源瑶族自治县" }, { "code": "440233", "name": "新丰县" }, { "code": "440281", "name": "乐昌市" }, { "code": "440282", "name": "南雄市" } ] }, { "code": "440300", "name": "深圳市", "areaList": [ { "code": "440303", "name": "罗湖区" }, { "code": "440304", "name": "福田区" }, { "code": "440305", "name": "南山区" }, { "code": "440306", "name": "宝安区" }, { "code": "440307", "name": "龙岗区" }, { "code": "440308", "name": "盐田区" }, { "code": "440309", "name": "龙华区" }, { "code": "440310", "name": "坪山区" }, { "code": "440311", "name": "光明区" } ] }, { "code": "440400", "name": "珠海市", "areaList": [ { "code": "440402", "name": "香洲区" }, { "code": "440403", "name": "斗门区" }, { "code": "440404", "name": "金湾区" } ] }, { "code": "440500", "name": "汕头市", "areaList": [ { "code": "440507", "name": "龙湖区" }, { "code": "440511", "name": "金平区" }, { "code": "440512", "name": "濠江区" }, { "code": "440513", "name": "潮阳区" }, { "code": "440514", "name": "潮南区" }, { "code": "440515", "name": "澄海区" }, { "code": "440523", "name": "南澳县" } ] }, { "code": "440600", "name": "佛山市", "areaList": [ { "code": "440604", "name": "禅城区" }, { "code": "440605", "name": "南海区" }, { "code": "440606", "name": "顺德区" }, { "code": "440607", "name": "三水区" }, { "code": "440608", "name": "高明区" } ] }, { "code": "440700", "name": "江门市", "areaList": [ { "code": "440703", "name": "蓬江区" }, { "code": "440704", "name": "江海区" }, { "code": "440705", "name": "新会区" }, { "code": "440781", "name": "台山市" }, { "code": "440783", "name": "开平市" }, { "code": "440784", "name": "鹤山市" }, { "code": "440785", "name": "恩平市" } ] }, { "code": "440800", "name": "湛江市", "areaList": [ { "code": "440802", "name": "赤坎区" }, { "code": "440803", "name": "霞山区" }, { "code": "440804", "name": "坡头区" }, { "code": "440811", "name": "麻章区" }, { "code": "440823", "name": "遂溪县" }, { "code": "440825", "name": "徐闻县" }, { "code": "440881", "name": "廉江市" }, { "code": "440882", "name": "雷州市" }, { "code": "440883", "name": "吴川市" } ] }, { "code": "440900", "name": "茂名市", "areaList": [ { "code": "440902", "name": "茂南区" }, { "code": "440904", "name": "电白区" }, { "code": "440981", "name": "高州市" }, { "code": "440982", "name": "化州市" }, { "code": "440983", "name": "信宜市" } ] }, { "code": "441200", "name": "肇庆市", "areaList": [ { "code": "441202", "name": "端州区" }, { "code": "441203", "name": "鼎湖区" }, { "code": "441204", "name": "高要区" }, { "code": "441223", "name": "广宁县" }, { "code": "441224", "name": "怀集县" }, { "code": "441225", "name": "封开县" }, { "code": "441226", "name": "德庆县" }, { "code": "441284", "name": "四会市" } ] }, { "code": "441300", "name": "惠州市", "areaList": [ { "code": "441302", "name": "惠城区" }, { "code": "441303", "name": "惠阳区" }, { "code": "441322", "name": "博罗县" }, { "code": "441323", "name": "惠东县" }, { "code": "441324", "name": "龙门县" } ] }, { "code": "441400", "name": "梅州市", "areaList": [ { "code": "441402", "name": "梅江区" }, { "code": "441403", "name": "梅县区" }, { "code": "441422", "name": "大埔县" }, { "code": "441423", "name": "丰顺县" }, { "code": "441424", "name": "五华县" }, { "code": "441426", "name": "平远县" }, { "code": "441427", "name": "蕉岭县" }, { "code": "441481", "name": "兴宁市" } ] }, { "code": "441500", "name": "汕尾市", "areaList": [ { "code": "441502", "name": "城区" }, { "code": "441521", "name": "海丰县" }, { "code": "441523", "name": "陆河县" }, { "code": "441581", "name": "陆丰市" } ] }, { "code": "441600", "name": "河源市", "areaList": [ { "code": "441602", "name": "源城区" }, { "code": "441621", "name": "紫金县" }, { "code": "441622", "name": "龙川县" }, { "code": "441623", "name": "连平县" }, { "code": "441624", "name": "和平县" }, { "code": "441625", "name": "东源县" } ] }, { "code": "441700", "name": "阳江市", "areaList": [ { "code": "441702", "name": "江城区" }, { "code": "441704", "name": "阳东区" }, { "code": "441721", "name": "阳西县" }, { "code": "441781", "name": "阳春市" } ] }, { "code": "441800", "name": "清远市", "areaList": [ { "code": "441802", "name": "清城区" }, { "code": "441803", "name": "清新区" }, { "code": "441821", "name": "佛冈县" }, { "code": "441823", "name": "阳山县" }, { "code": "441825", "name": "连山壮族瑶族自治县" }, { "code": "441826", "name": "连南瑶族自治县" }, { "code": "441881", "name": "英德市" }, { "code": "441882", "name": "连州市" } ] }, { "code": "441900", "name": "东莞市", "areaList": [ { "code": "441900", "name": "东莞市" } ] }, { "code": "442000", "name": "中山市", "areaList": [ { "code": "442000", "name": "中山市" } ] }, { "code": "445100", "name": "潮州市", "areaList": [ { "code": "445102", "name": "湘桥区" }, { "code": "445103", "name": "潮安区" }, { "code": "445122", "name": "饶平县" } ] }, { "code": "445200", "name": "揭阳市", "areaList": [ { "code": "445202", "name": "榕城区" }, { "code": "445203", "name": "揭东区" }, { "code": "445222", "name": "揭西县" }, { "code": "445224", "name": "惠来县" }, { "code": "445281", "name": "普宁市" } ] }, { "code": "445300", "name": "云浮市", "areaList": [ { "code": "445302", "name": "云城区" }, { "code": "445303", "name": "云安区" }, { "code": "445321", "name": "新兴县" }, { "code": "445322", "name": "郁南县" }, { "code": "445381", "name": "罗定市" } ] } ] }, { "code": "450000", "name": "广西壮族自治区", "cityList": [ { "code": "450100", "name": "南宁市", "areaList": [ { "code": "450102", "name": "兴宁区" }, { "code": "450103", "name": "青秀区" }, { "code": "450105", "name": "江南区" }, { "code": "450107", "name": "西乡塘区" }, { "code": "450108", "name": "良庆区" }, { "code": "450109", "name": "邕宁区" }, { "code": "450110", "name": "武鸣区" }, { "code": "450123", "name": "隆安县" }, { "code": "450124", "name": "马山县" }, { "code": "450125", "name": "上林县" }, { "code": "450126", "name": "宾阳县" }, { "code": "450181", "name": "横州市" } ] }, { "code": "450200", "name": "柳州市", "areaList": [ { "code": "450202", "name": "城中区" }, { "code": "450203", "name": "鱼峰区" }, { "code": "450204", "name": "柳南区" }, { "code": "450205", "name": "柳北区" }, { "code": "450206", "name": "柳江区" }, { "code": "450222", "name": "柳城县" }, { "code": "450223", "name": "鹿寨县" }, { "code": "450224", "name": "融安县" }, { "code": "450225", "name": "融水苗族自治县" }, { "code": "450226", "name": "三江侗族自治县" } ] }, { "code": "450300", "name": "桂林市", "areaList": [ { "code": "450302", "name": "秀峰区" }, { "code": "450303", "name": "叠彩区" }, { "code": "450304", "name": "象山区" }, { "code": "450305", "name": "七星区" }, { "code": "450311", "name": "雁山区" }, { "code": "450312", "name": "临桂区" }, { "code": "450321", "name": "阳朔县" }, { "code": "450323", "name": "灵川县" }, { "code": "450324", "name": "全州县" }, { "code": "450325", "name": "兴安县" }, { "code": "450326", "name": "永福县" }, { "code": "450327", "name": "灌阳县" }, { "code": "450328", "name": "龙胜各族自治县" }, { "code": "450329", "name": "资源县" }, { "code": "450330", "name": "平乐县" }, { "code": "450332", "name": "恭城瑶族自治县" }, { "code": "450381", "name": "荔浦市" } ] }, { "code": "450400", "name": "梧州市", "areaList": [ { "code": "450403", "name": "万秀区" }, { "code": "450405", "name": "长洲区" }, { "code": "450406", "name": "龙圩区" }, { "code": "450421", "name": "苍梧县" }, { "code": "450422", "name": "藤县" }, { "code": "450423", "name": "蒙山县" }, { "code": "450481", "name": "岑溪市" } ] }, { "code": "450500", "name": "北海市", "areaList": [ { "code": "450502", "name": "海城区" }, { "code": "450503", "name": "银海区" }, { "code": "450512", "name": "铁山港区" }, { "code": "450521", "name": "合浦县" } ] }, { "code": "450600", "name": "防城港市", "areaList": [ { "code": "450602", "name": "港口区" }, { "code": "450603", "name": "防城区" }, { "code": "450621", "name": "上思县" }, { "code": "450681", "name": "东兴市" } ] }, { "code": "450700", "name": "钦州市", "areaList": [ { "code": "450702", "name": "钦南区" }, { "code": "450703", "name": "钦北区" }, { "code": "450721", "name": "灵山县" }, { "code": "450722", "name": "浦北县" } ] }, { "code": "450800", "name": "贵港市", "areaList": [ { "code": "450802", "name": "港北区" }, { "code": "450803", "name": "港南区" }, { "code": "450804", "name": "覃塘区" }, { "code": "450821", "name": "平南县" }, { "code": "450881", "name": "桂平市" } ] }, { "code": "450900", "name": "玉林市", "areaList": [ { "code": "450902", "name": "玉州区" }, { "code": "450903", "name": "福绵区" }, { "code": "450921", "name": "容县" }, { "code": "450922", "name": "陆川县" }, { "code": "450923", "name": "博白县" }, { "code": "450924", "name": "兴业县" }, { "code": "450981", "name": "北流市" } ] }, { "code": "451000", "name": "百色市", "areaList": [ { "code": "451002", "name": "右江区" }, { "code": "451003", "name": "田阳区" }, { "code": "451022", "name": "田东县" }, { "code": "451024", "name": "德保县" }, { "code": "451026", "name": "那坡县" }, { "code": "451027", "name": "凌云县" }, { "code": "451028", "name": "乐业县" }, { "code": "451029", "name": "田林县" }, { "code": "451030", "name": "西林县" }, { "code": "451031", "name": "隆林各族自治县" }, { "code": "451081", "name": "靖西市" }, { "code": "451082", "name": "平果市" } ] }, { "code": "451100", "name": "贺州市", "areaList": [ { "code": "451102", "name": "八步区" }, { "code": "451103", "name": "平桂区" }, { "code": "451121", "name": "昭平县" }, { "code": "451122", "name": "钟山县" }, { "code": "451123", "name": "富川瑶族自治县" } ] }, { "code": "451200", "name": "河池市", "areaList": [ { "code": "451202", "name": "金城江区" }, { "code": "451203", "name": "宜州区" }, { "code": "451221", "name": "南丹县" }, { "code": "451222", "name": "天峨县" }, { "code": "451223", "name": "凤山县" }, { "code": "451224", "name": "东兰县" }, { "code": "451225", "name": "罗城仫佬族自治县" }, { "code": "451226", "name": "环江毛南族自治县" }, { "code": "451227", "name": "巴马瑶族自治县" }, { "code": "451228", "name": "都安瑶族自治县" }, { "code": "451229", "name": "大化瑶族自治县" } ] }, { "code": "451300", "name": "来宾市", "areaList": [ { "code": "451302", "name": "兴宾区" }, { "code": "451321", "name": "忻城县" }, { "code": "451322", "name": "象州县" }, { "code": "451323", "name": "武宣县" }, { "code": "451324", "name": "金秀瑶族自治县" }, { "code": "451381", "name": "合山市" } ] }, { "code": "451400", "name": "崇左市", "areaList": [ { "code": "451402", "name": "江州区" }, { "code": "451421", "name": "扶绥县" }, { "code": "451422", "name": "宁明县" }, { "code": "451423", "name": "龙州县" }, { "code": "451424", "name": "大新县" }, { "code": "451425", "name": "天等县" }, { "code": "451481", "name": "凭祥市" } ] } ] }, { "code": "460000", "name": "海南省", "cityList": [ { "code": "460100", "name": "海口市", "areaList": [ { "code": "460105", "name": "秀英区" }, { "code": "460106", "name": "龙华区" }, { "code": "460107", "name": "琼山区" }, { "code": "460108", "name": "美兰区" } ] }, { "code": "460200", "name": "三亚市", "areaList": [ { "code": "460202", "name": "海棠区" }, { "code": "460203", "name": "吉阳区" }, { "code": "460204", "name": "天涯区" }, { "code": "460205", "name": "崖州区" } ] }, { "code": "460300", "name": "三沙市", "areaList": [ { "code": "460301", "name": "西沙区" }, { "code": "460302", "name": "南沙区" } ] }, { "code": "460400", "name": "儋州市", "areaList": [ { "code": "460400", "name": "儋州市" } ] }, { "code": "469001", "name": "五指山市", "areaList": [ { "code": "469001", "name": "五指山市" } ] }, { "code": "469002", "name": "琼海市", "areaList": [ { "code": "469002", "name": "琼海市" } ] }, { "code": "469005", "name": "文昌市", "areaList": [ { "code": "469005", "name": "文昌市" } ] }, { "code": "469006", "name": "万宁市", "areaList": [ { "code": "469006", "name": "万宁市" } ] }, { "code": "469007", "name": "东方市", "areaList": [ { "code": "469007", "name": "东方市" } ] }, { "code": "469021", "name": "定安县", "areaList": [ { "code": "469021", "name": "定安县" } ] }, { "code": "469022", "name": "屯昌县", "areaList": [ { "code": "469022", "name": "屯昌县" } ] }, { "code": "469023", "name": "澄迈县", "areaList": [ { "code": "469023", "name": "澄迈县" } ] }, { "code": "469024", "name": "临高县", "areaList": [ { "code": "469024", "name": "临高县" } ] }, { "code": "469025", "name": "白沙黎族自治县", "areaList": [ { "code": "469025", "name": "白沙黎族自治县" } ] }, { "code": "469026", "name": "昌江黎族自治县", "areaList": [ { "code": "469026", "name": "昌江黎族自治县" } ] }, { "code": "469027", "name": "乐东黎族自治县", "areaList": [ { "code": "469027", "name": "乐东黎族自治县" } ] }, { "code": "469028", "name": "陵水黎族自治县", "areaList": [ { "code": "469028", "name": "陵水黎族自治县" } ] }, { "code": "469029", "name": "保亭黎族苗族自治县", "areaList": [ { "code": "469029", "name": "保亭黎族苗族自治县" } ] }, { "code": "469030", "name": "琼中黎族苗族自治县", "areaList": [ { "code": "469030", "name": "琼中黎族苗族自治县" } ] } ] }, { "code": "500000", "name": "重庆市", "cityList": [ { "code": "500000", "name": "重庆市", "areaList": [ { "code": "500101", "name": "万州区" }, { "code": "500102", "name": "涪陵区" }, { "code": "500103", "name": "渝中区" }, { "code": "500104", "name": "大渡口区" }, { "code": "500105", "name": "江北区" }, { "code": "500106", "name": "沙坪坝区" }, { "code": "500107", "name": "九龙坡区" }, { "code": "500108", "name": "南岸区" }, { "code": "500109", "name": "北碚区" }, { "code": "500110", "name": "綦江区" }, { "code": "500111", "name": "大足区" }, { "code": "500112", "name": "渝北区" }, { "code": "500113", "name": "巴南区" }, { "code": "500114", "name": "黔江区" }, { "code": "500115", "name": "长寿区" }, { "code": "500116", "name": "江津区" }, { "code": "500117", "name": "合川区" }, { "code": "500118", "name": "永川区" }, { "code": "500119", "name": "南川区" }, { "code": "500120", "name": "璧山区" }, { "code": "500151", "name": "铜梁区" }, { "code": "500152", "name": "潼南区" }, { "code": "500153", "name": "荣昌区" }, { "code": "500154", "name": "开州区" }, { "code": "500155", "name": "梁平区" }, { "code": "500156", "name": "武隆区" }, { "code": "500229", "name": "城口县" }, { "code": "500230", "name": "丰都县" }, { "code": "500231", "name": "垫江县" }, { "code": "500233", "name": "忠县" }, { "code": "500235", "name": "云阳县" }, { "code": "500236", "name": "奉节县" }, { "code": "500237", "name": "巫山县" }, { "code": "500238", "name": "巫溪县" }, { "code": "500240", "name": "石柱土家族自治县" }, { "code": "500241", "name": "秀山土家族苗族自治县" }, { "code": "500242", "name": "酉阳土家族苗族自治县" }, { "code": "500243", "name": "彭水苗族土家族自治县" } ] } ] }, { "code": "510000", "name": "四川省", "cityList": [ { "code": "510100", "name": "成都市", "areaList": [ { "code": "510104", "name": "锦江区" }, { "code": "510105", "name": "青羊区" }, { "code": "510106", "name": "金牛区" }, { "code": "510107", "name": "武侯区" }, { "code": "510108", "name": "成华区" }, { "code": "510112", "name": "龙泉驿区" }, { "code": "510113", "name": "青白江区" }, { "code": "510114", "name": "新都区" }, { "code": "510115", "name": "温江区" }, { "code": "510116", "name": "双流区" }, { "code": "510117", "name": "郫都区" }, { "code": "510118", "name": "新津区" }, { "code": "510121", "name": "金堂县" }, { "code": "510129", "name": "大邑县" }, { "code": "510131", "name": "蒲江县" }, { "code": "510181", "name": "都江堰市" }, { "code": "510182", "name": "彭州市" }, { "code": "510183", "name": "邛崃市" }, { "code": "510184", "name": "崇州市" }, { "code": "510185", "name": "简阳市" } ] }, { "code": "510300", "name": "自贡市", "areaList": [ { "code": "510302", "name": "自流井区" }, { "code": "510303", "name": "贡井区" }, { "code": "510304", "name": "大安区" }, { "code": "510311", "name": "沿滩区" }, { "code": "510321", "name": "荣县" }, { "code": "510322", "name": "富顺县" } ] }, { "code": "510400", "name": "攀枝花市", "areaList": [ { "code": "510402", "name": "东区" }, { "code": "510403", "name": "西区" }, { "code": "510411", "name": "仁和区" }, { "code": "510421", "name": "米易县" }, { "code": "510422", "name": "盐边县" } ] }, { "code": "510500", "name": "泸州市", "areaList": [ { "code": "510502", "name": "江阳区" }, { "code": "510503", "name": "纳溪区" }, { "code": "510504", "name": "龙马潭区" }, { "code": "510521", "name": "泸县" }, { "code": "510522", "name": "合江县" }, { "code": "510524", "name": "叙永县" }, { "code": "510525", "name": "古蔺县" } ] }, { "code": "510600", "name": "德阳市", "areaList": [ { "code": "510603", "name": "旌阳区" }, { "code": "510604", "name": "罗江区" }, { "code": "510623", "name": "中江县" }, { "code": "510681", "name": "广汉市" }, { "code": "510682", "name": "什邡市" }, { "code": "510683", "name": "绵竹市" } ] }, { "code": "510700", "name": "绵阳市", "areaList": [ { "code": "510703", "name": "涪城区" }, { "code": "510704", "name": "游仙区" }, { "code": "510705", "name": "安州区" }, { "code": "510722", "name": "三台县" }, { "code": "510723", "name": "盐亭县" }, { "code": "510725", "name": "梓潼县" }, { "code": "510726", "name": "北川羌族自治县" }, { "code": "510727", "name": "平武县" }, { "code": "510781", "name": "江油市" } ] }, { "code": "510800", "name": "广元市", "areaList": [ { "code": "510802", "name": "利州区" }, { "code": "510811", "name": "昭化区" }, { "code": "510812", "name": "朝天区" }, { "code": "510821", "name": "旺苍县" }, { "code": "510822", "name": "青川县" }, { "code": "510823", "name": "剑阁县" }, { "code": "510824", "name": "苍溪县" } ] }, { "code": "510900", "name": "遂宁市", "areaList": [ { "code": "510903", "name": "船山区" }, { "code": "510904", "name": "安居区" }, { "code": "510921", "name": "蓬溪县" }, { "code": "510923", "name": "大英县" }, { "code": "510981", "name": "射洪市" } ] }, { "code": "511000", "name": "内江市", "areaList": [ { "code": "511002", "name": "市中区" }, { "code": "511011", "name": "东兴区" }, { "code": "511024", "name": "威远县" }, { "code": "511025", "name": "资中县" }, { "code": "511083", "name": "隆昌市" } ] }, { "code": "511100", "name": "乐山市", "areaList": [ { "code": "511102", "name": "市中区" }, { "code": "511111", "name": "沙湾区" }, { "code": "511112", "name": "五通桥区" }, { "code": "511113", "name": "金口河区" }, { "code": "511123", "name": "犍为县" }, { "code": "511124", "name": "井研县" }, { "code": "511126", "name": "夹江县" }, { "code": "511129", "name": "沐川县" }, { "code": "511132", "name": "峨边彝族自治县" }, { "code": "511133", "name": "马边彝族自治县" }, { "code": "511181", "name": "峨眉山市" } ] }, { "code": "511300", "name": "南充市", "areaList": [ { "code": "511302", "name": "顺庆区" }, { "code": "511303", "name": "高坪区" }, { "code": "511304", "name": "嘉陵区" }, { "code": "511321", "name": "南部县" }, { "code": "511322", "name": "营山县" }, { "code": "511323", "name": "蓬安县" }, { "code": "511324", "name": "仪陇县" }, { "code": "511325", "name": "西充县" }, { "code": "511381", "name": "阆中市" } ] }, { "code": "511400", "name": "眉山市", "areaList": [ { "code": "511402", "name": "东坡区" }, { "code": "511403", "name": "彭山区" }, { "code": "511421", "name": "仁寿县" }, { "code": "511423", "name": "洪雅县" }, { "code": "511424", "name": "丹棱县" }, { "code": "511425", "name": "青神县" } ] }, { "code": "511500", "name": "宜宾市", "areaList": [ { "code": "511502", "name": "翠屏区" }, { "code": "511503", "name": "南溪区" }, { "code": "511504", "name": "叙州区" }, { "code": "511523", "name": "江安县" }, { "code": "511524", "name": "长宁县" }, { "code": "511525", "name": "高县" }, { "code": "511526", "name": "珙县" }, { "code": "511527", "name": "筠连县" }, { "code": "511528", "name": "兴文县" }, { "code": "511529", "name": "屏山县" } ] }, { "code": "511600", "name": "广安市", "areaList": [ { "code": "511602", "name": "广安区" }, { "code": "511603", "name": "前锋区" }, { "code": "511621", "name": "岳池县" }, { "code": "511622", "name": "武胜县" }, { "code": "511623", "name": "邻水县" }, { "code": "511681", "name": "华蓥市" } ] }, { "code": "511700", "name": "达州市", "areaList": [ { "code": "511702", "name": "通川区" }, { "code": "511703", "name": "达川区" }, { "code": "511722", "name": "宣汉县" }, { "code": "511723", "name": "开江县" }, { "code": "511724", "name": "大竹县" }, { "code": "511725", "name": "渠县" }, { "code": "511781", "name": "万源市" } ] }, { "code": "511800", "name": "雅安市", "areaList": [ { "code": "511802", "name": "雨城区" }, { "code": "511803", "name": "名山区" }, { "code": "511822", "name": "荥经县" }, { "code": "511823", "name": "汉源县" }, { "code": "511824", "name": "石棉县" }, { "code": "511825", "name": "天全县" }, { "code": "511826", "name": "芦山县" }, { "code": "511827", "name": "宝兴县" } ] }, { "code": "511900", "name": "巴中市", "areaList": [ { "code": "511902", "name": "巴州区" }, { "code": "511903", "name": "恩阳区" }, { "code": "511921", "name": "通江县" }, { "code": "511922", "name": "南江县" }, { "code": "511923", "name": "平昌县" } ] }, { "code": "512000", "name": "资阳市", "areaList": [ { "code": "512002", "name": "雁江区" }, { "code": "512021", "name": "安岳县" }, { "code": "512022", "name": "乐至县" } ] }, { "code": "513200", "name": "阿坝藏族羌族自治州", "areaList": [ { "code": "513201", "name": "马尔康市" }, { "code": "513221", "name": "汶川县" }, { "code": "513222", "name": "理县" }, { "code": "513223", "name": "茂县" }, { "code": "513224", "name": "松潘县" }, { "code": "513225", "name": "九寨沟县" }, { "code": "513226", "name": "金川县" }, { "code": "513227", "name": "小金县" }, { "code": "513228", "name": "黑水县" }, { "code": "513230", "name": "壤塘县" }, { "code": "513231", "name": "阿坝县" }, { "code": "513232", "name": "若尔盖县" }, { "code": "513233", "name": "红原县" } ] }, { "code": "513300", "name": "甘孜藏族自治州", "areaList": [ { "code": "513301", "name": "康定市" }, { "code": "513322", "name": "泸定县" }, { "code": "513323", "name": "丹巴县" }, { "code": "513324", "name": "九龙县" }, { "code": "513325", "name": "雅江县" }, { "code": "513326", "name": "道孚县" }, { "code": "513327", "name": "炉霍县" }, { "code": "513328", "name": "甘孜县" }, { "code": "513329", "name": "新龙县" }, { "code": "513330", "name": "德格县" }, { "code": "513331", "name": "白玉县" }, { "code": "513332", "name": "石渠县" }, { "code": "513333", "name": "色达县" }, { "code": "513334", "name": "理塘县" }, { "code": "513335", "name": "巴塘县" }, { "code": "513336", "name": "乡城县" }, { "code": "513337", "name": "稻城县" }, { "code": "513338", "name": "得荣县" } ] }, { "code": "513400", "name": "凉山彝族自治州", "areaList": [ { "code": "513401", "name": "西昌市" }, { "code": "513402", "name": "会理市" }, { "code": "513422", "name": "木里藏族自治县" }, { "code": "513423", "name": "盐源县" }, { "code": "513424", "name": "德昌县" }, { "code": "513426", "name": "会东县" }, { "code": "513427", "name": "宁南县" }, { "code": "513428", "name": "普格县" }, { "code": "513429", "name": "布拖县" }, { "code": "513430", "name": "金阳县" }, { "code": "513431", "name": "昭觉县" }, { "code": "513432", "name": "喜德县" }, { "code": "513433", "name": "冕宁县" }, { "code": "513434", "name": "越西县" }, { "code": "513435", "name": "甘洛县" }, { "code": "513436", "name": "美姑县" }, { "code": "513437", "name": "雷波县" } ] } ] }, { "code": "520000", "name": "贵州省", "cityList": [ { "code": "520100", "name": "贵阳市", "areaList": [ { "code": "520102", "name": "南明区" }, { "code": "520103", "name": "云岩区" }, { "code": "520111", "name": "花溪区" }, { "code": "520112", "name": "乌当区" }, { "code": "520113", "name": "白云区" }, { "code": "520115", "name": "观山湖区" }, { "code": "520121", "name": "开阳县" }, { "code": "520122", "name": "息烽县" }, { "code": "520123", "name": "修文县" }, { "code": "520181", "name": "清镇市" } ] }, { "code": "520200", "name": "六盘水市", "areaList": [ { "code": "520201", "name": "钟山区" }, { "code": "520203", "name": "六枝特区" }, { "code": "520204", "name": "水城区" }, { "code": "520281", "name": "盘州市" } ] }, { "code": "520300", "name": "遵义市", "areaList": [ { "code": "520302", "name": "红花岗区" }, { "code": "520303", "name": "汇川区" }, { "code": "520304", "name": "播州区" }, { "code": "520322", "name": "桐梓县" }, { "code": "520323", "name": "绥阳县" }, { "code": "520324", "name": "正安县" }, { "code": "520325", "name": "道真仡佬族苗族自治县" }, { "code": "520326", "name": "务川仡佬族苗族自治县" }, { "code": "520327", "name": "凤冈县" }, { "code": "520328", "name": "湄潭县" }, { "code": "520329", "name": "余庆县" }, { "code": "520330", "name": "习水县" }, { "code": "520381", "name": "赤水市" }, { "code": "520382", "name": "仁怀市" } ] }, { "code": "520400", "name": "安顺市", "areaList": [ { "code": "520402", "name": "西秀区" }, { "code": "520403", "name": "平坝区" }, { "code": "520422", "name": "普定县" }, { "code": "520423", "name": "镇宁布依族苗族自治县" }, { "code": "520424", "name": "关岭布依族苗族自治县" }, { "code": "520425", "name": "紫云苗族布依族自治县" } ] }, { "code": "520500", "name": "毕节市", "areaList": [ { "code": "520502", "name": "七星关区" }, { "code": "520521", "name": "大方县" }, { "code": "520523", "name": "金沙县" }, { "code": "520524", "name": "织金县" }, { "code": "520525", "name": "纳雍县" }, { "code": "520526", "name": "威宁彝族回族苗族自治县" }, { "code": "520527", "name": "赫章县" }, { "code": "520581", "name": "黔西市" } ] }, { "code": "520600", "name": "铜仁市", "areaList": [ { "code": "520602", "name": "碧江区" }, { "code": "520603", "name": "万山区" }, { "code": "520621", "name": "江口县" }, { "code": "520622", "name": "玉屏侗族自治县" }, { "code": "520623", "name": "石阡县" }, { "code": "520624", "name": "思南县" }, { "code": "520625", "name": "印江土家族苗族自治县" }, { "code": "520626", "name": "德江县" }, { "code": "520627", "name": "沿河土家族自治县" }, { "code": "520628", "name": "松桃苗族自治县" } ] }, { "code": "522300", "name": "黔西南布依族苗族自治州", "areaList": [ { "code": "522301", "name": "兴义市" }, { "code": "522302", "name": "兴仁市" }, { "code": "522323", "name": "普安县" }, { "code": "522324", "name": "晴隆县" }, { "code": "522325", "name": "贞丰县" }, { "code": "522326", "name": "望谟县" }, { "code": "522327", "name": "册亨县" }, { "code": "522328", "name": "安龙县" } ] }, { "code": "522600", "name": "黔东南苗族侗族自治州", "areaList": [ { "code": "522601", "name": "凯里市" }, { "code": "522622", "name": "黄平县" }, { "code": "522623", "name": "施秉县" }, { "code": "522624", "name": "三穗县" }, { "code": "522625", "name": "镇远县" }, { "code": "522626", "name": "岑巩县" }, { "code": "522627", "name": "天柱县" }, { "code": "522628", "name": "锦屏县" }, { "code": "522629", "name": "剑河县" }, { "code": "522630", "name": "台江县" }, { "code": "522631", "name": "黎平县" }, { "code": "522632", "name": "榕江县" }, { "code": "522633", "name": "从江县" }, { "code": "522634", "name": "雷山县" }, { "code": "522635", "name": "麻江县" }, { "code": "522636", "name": "丹寨县" } ] }, { "code": "522700", "name": "黔南布依族苗族自治州", "areaList": [ { "code": "522701", "name": "都匀市" }, { "code": "522702", "name": "福泉市" }, { "code": "522722", "name": "荔波县" }, { "code": "522723", "name": "贵定县" }, { "code": "522725", "name": "瓮安县" }, { "code": "522726", "name": "独山县" }, { "code": "522727", "name": "平塘县" }, { "code": "522728", "name": "罗甸县" }, { "code": "522729", "name": "长顺县" }, { "code": "522730", "name": "龙里县" }, { "code": "522731", "name": "惠水县" }, { "code": "522732", "name": "三都水族自治县" } ] } ] }, { "code": "530000", "name": "云南省", "cityList": [ { "code": "530100", "name": "昆明市", "areaList": [ { "code": "530102", "name": "五华区" }, { "code": "530103", "name": "盘龙区" }, { "code": "530111", "name": "官渡区" }, { "code": "530112", "name": "西山区" }, { "code": "530113", "name": "东川区" }, { "code": "530114", "name": "呈贡区" }, { "code": "530115", "name": "晋宁区" }, { "code": "530124", "name": "富民县" }, { "code": "530125", "name": "宜良县" }, { "code": "530126", "name": "石林彝族自治县" }, { "code": "530127", "name": "嵩明县" }, { "code": "530128", "name": "禄劝彝族苗族自治县" }, { "code": "530129", "name": "寻甸回族彝族自治县" }, { "code": "530181", "name": "安宁市" } ] }, { "code": "530300", "name": "曲靖市", "areaList": [ { "code": "530302", "name": "麒麟区" }, { "code": "530303", "name": "沾益区" }, { "code": "530304", "name": "马龙区" }, { "code": "530322", "name": "陆良县" }, { "code": "530323", "name": "师宗县" }, { "code": "530324", "name": "罗平县" }, { "code": "530325", "name": "富源县" }, { "code": "530326", "name": "会泽县" }, { "code": "530381", "name": "宣威市" } ] }, { "code": "530400", "name": "玉溪市", "areaList": [ { "code": "530402", "name": "红塔区" }, { "code": "530403", "name": "江川区" }, { "code": "530423", "name": "通海县" }, { "code": "530424", "name": "华宁县" }, { "code": "530425", "name": "易门县" }, { "code": "530426", "name": "峨山彝族自治县" }, { "code": "530427", "name": "新平彝族傣族自治县" }, { "code": "530428", "name": "元江哈尼族彝族傣族自治县" }, { "code": "530481", "name": "澄江市" } ] }, { "code": "530500", "name": "保山市", "areaList": [ { "code": "530502", "name": "隆阳区" }, { "code": "530521", "name": "施甸县" }, { "code": "530523", "name": "龙陵县" }, { "code": "530524", "name": "昌宁县" }, { "code": "530581", "name": "腾冲市" } ] }, { "code": "530600", "name": "昭通市", "areaList": [ { "code": "530602", "name": "昭阳区" }, { "code": "530621", "name": "鲁甸县" }, { "code": "530622", "name": "巧家县" }, { "code": "530623", "name": "盐津县" }, { "code": "530624", "name": "大关县" }, { "code": "530625", "name": "永善县" }, { "code": "530626", "name": "绥江县" }, { "code": "530627", "name": "镇雄县" }, { "code": "530628", "name": "彝良县" }, { "code": "530629", "name": "威信县" }, { "code": "530681", "name": "水富市" } ] }, { "code": "530700", "name": "丽江市", "areaList": [ { "code": "530702", "name": "古城区" }, { "code": "530721", "name": "玉龙纳西族自治县" }, { "code": "530722", "name": "永胜县" }, { "code": "530723", "name": "华坪县" }, { "code": "530724", "name": "宁蒗彝族自治县" } ] }, { "code": "530800", "name": "普洱市", "areaList": [ { "code": "530802", "name": "思茅区" }, { "code": "530821", "name": "宁洱哈尼族彝族自治县" }, { "code": "530822", "name": "墨江哈尼族自治县" }, { "code": "530823", "name": "景东彝族自治县" }, { "code": "530824", "name": "景谷傣族彝族自治县" }, { "code": "530825", "name": "镇沅彝族哈尼族拉祜族自治县" }, { "code": "530826", "name": "江城哈尼族彝族自治县" }, { "code": "530827", "name": "孟连傣族拉祜族佤族自治县" }, { "code": "530828", "name": "澜沧拉祜族自治县" }, { "code": "530829", "name": "西盟佤族自治县" } ] }, { "code": "530900", "name": "临沧市", "areaList": [ { "code": "530902", "name": "临翔区" }, { "code": "530921", "name": "凤庆县" }, { "code": "530922", "name": "云县" }, { "code": "530923", "name": "永德县" }, { "code": "530924", "name": "镇康县" }, { "code": "530925", "name": "双江拉祜族佤族布朗族傣族自治县" }, { "code": "530926", "name": "耿马傣族佤族自治县" }, { "code": "530927", "name": "沧源佤族自治县" } ] }, { "code": "532300", "name": "楚雄彝族自治州", "areaList": [ { "code": "532301", "name": "楚雄市" }, { "code": "532302", "name": "禄丰市" }, { "code": "532322", "name": "双柏县" }, { "code": "532323", "name": "牟定县" }, { "code": "532324", "name": "南华县" }, { "code": "532325", "name": "姚安县" }, { "code": "532326", "name": "大姚县" }, { "code": "532327", "name": "永仁县" }, { "code": "532328", "name": "元谋县" }, { "code": "532329", "name": "武定县" } ] }, { "code": "532500", "name": "红河哈尼族彝族自治州", "areaList": [ { "code": "532501", "name": "个旧市" }, { "code": "532502", "name": "开远市" }, { "code": "532503", "name": "蒙自市" }, { "code": "532504", "name": "弥勒市" }, { "code": "532523", "name": "屏边苗族自治县" }, { "code": "532524", "name": "建水县" }, { "code": "532525", "name": "石屏县" }, { "code": "532527", "name": "泸西县" }, { "code": "532528", "name": "元阳县" }, { "code": "532529", "name": "红河县" }, { "code": "532530", "name": "金平苗族瑶族傣族自治县" }, { "code": "532531", "name": "绿春县" }, { "code": "532532", "name": "河口瑶族自治县" } ] }, { "code": "532600", "name": "文山壮族苗族自治州", "areaList": [ { "code": "532601", "name": "文山市" }, { "code": "532622", "name": "砚山县" }, { "code": "532623", "name": "西畴县" }, { "code": "532624", "name": "麻栗坡县" }, { "code": "532625", "name": "马关县" }, { "code": "532626", "name": "丘北县" }, { "code": "532627", "name": "广南县" }, { "code": "532628", "name": "富宁县" } ] }, { "code": "532800", "name": "西双版纳傣族自治州", "areaList": [ { "code": "532801", "name": "景洪市" }, { "code": "532822", "name": "勐海县" }, { "code": "532823", "name": "勐腊县" } ] }, { "code": "532900", "name": "大理白族自治州", "areaList": [ { "code": "532901", "name": "大理市" }, { "code": "532922", "name": "漾濞彝族自治县" }, { "code": "532923", "name": "祥云县" }, { "code": "532924", "name": "宾川县" }, { "code": "532925", "name": "弥渡县" }, { "code": "532926", "name": "南涧彝族自治县" }, { "code": "532927", "name": "巍山彝族回族自治县" }, { "code": "532928", "name": "永平县" }, { "code": "532929", "name": "云龙县" }, { "code": "532930", "name": "洱源县" }, { "code": "532931", "name": "剑川县" }, { "code": "532932", "name": "鹤庆县" } ] }, { "code": "533100", "name": "德宏傣族景颇族自治州", "areaList": [ { "code": "533102", "name": "瑞丽市" }, { "code": "533103", "name": "芒市" }, { "code": "533122", "name": "梁河县" }, { "code": "533123", "name": "盈江县" }, { "code": "533124", "name": "陇川县" } ] }, { "code": "533300", "name": "怒江傈僳族自治州", "areaList": [ { "code": "533301", "name": "泸水市" }, { "code": "533323", "name": "福贡县" }, { "code": "533324", "name": "贡山独龙族怒族自治县" }, { "code": "533325", "name": "兰坪白族普米族自治县" } ] }, { "code": "533400", "name": "迪庆藏族自治州", "areaList": [ { "code": "533401", "name": "香格里拉市" }, { "code": "533422", "name": "德钦县" }, { "code": "533423", "name": "维西傈僳族自治县" } ] } ] }, { "code": "540000", "name": "西藏自治区", "cityList": [ { "code": "540100", "name": "拉萨市", "areaList": [ { "code": "540102", "name": "城关区" }, { "code": "540103", "name": "堆龙德庆区" }, { "code": "540104", "name": "达孜区" }, { "code": "540121", "name": "林周县" }, { "code": "540122", "name": "当雄县" }, { "code": "540123", "name": "尼木县" }, { "code": "540124", "name": "曲水县" }, { "code": "540127", "name": "墨竹工卡县" } ] }, { "code": "540200", "name": "日喀则市", "areaList": [ { "code": "540202", "name": "桑珠孜区" }, { "code": "540221", "name": "南木林县" }, { "code": "540222", "name": "江孜县" }, { "code": "540223", "name": "定日县" }, { "code": "540224", "name": "萨迦县" }, { "code": "540225", "name": "拉孜县" }, { "code": "540226", "name": "昂仁县" }, { "code": "540227", "name": "谢通门县" }, { "code": "540228", "name": "白朗县" }, { "code": "540229", "name": "仁布县" }, { "code": "540230", "name": "康马县" }, { "code": "540231", "name": "定结县" }, { "code": "540232", "name": "仲巴县" }, { "code": "540233", "name": "亚东县" }, { "code": "540234", "name": "吉隆县" }, { "code": "540235", "name": "聂拉木县" }, { "code": "540236", "name": "萨嘎县" }, { "code": "540237", "name": "岗巴县" } ] }, { "code": "540300", "name": "昌都市", "areaList": [ { "code": "540302", "name": "卡若区" }, { "code": "540321", "name": "江达县" }, { "code": "540322", "name": "贡觉县" }, { "code": "540323", "name": "类乌齐县" }, { "code": "540324", "name": "丁青县" }, { "code": "540325", "name": "察雅县" }, { "code": "540326", "name": "八宿县" }, { "code": "540327", "name": "左贡县" }, { "code": "540328", "name": "芒康县" }, { "code": "540329", "name": "洛隆县" }, { "code": "540330", "name": "边坝县" } ] }, { "code": "540400", "name": "林芝市", "areaList": [ { "code": "540402", "name": "巴宜区" }, { "code": "540421", "name": "工布江达县" }, { "code": "540422", "name": "米林县" }, { "code": "540423", "name": "墨脱县" }, { "code": "540424", "name": "波密县" }, { "code": "540425", "name": "察隅县" }, { "code": "540426", "name": "朗县" } ] }, { "code": "540500", "name": "山南市", "areaList": [ { "code": "540502", "name": "乃东区" }, { "code": "540521", "name": "扎囊县" }, { "code": "540522", "name": "贡嘎县" }, { "code": "540523", "name": "桑日县" }, { "code": "540524", "name": "琼结县" }, { "code": "540525", "name": "曲松县" }, { "code": "540526", "name": "措美县" }, { "code": "540527", "name": "洛扎县" }, { "code": "540528", "name": "加查县" }, { "code": "540529", "name": "隆子县" }, { "code": "540530", "name": "错那县" }, { "code": "540531", "name": "浪卡子县" } ] }, { "code": "540600", "name": "那曲市", "areaList": [ { "code": "540602", "name": "色尼区" }, { "code": "540621", "name": "嘉黎县" }, { "code": "540622", "name": "比如县" }, { "code": "540623", "name": "聂荣县" }, { "code": "540624", "name": "安多县" }, { "code": "540625", "name": "申扎县" }, { "code": "540626", "name": "索县" }, { "code": "540627", "name": "班戈县" }, { "code": "540628", "name": "巴青县" }, { "code": "540629", "name": "尼玛县" }, { "code": "540630", "name": "双湖县" } ] }, { "code": "542500", "name": "阿里地区", "areaList": [ { "code": "542521", "name": "普兰县" }, { "code": "542522", "name": "札达县" }, { "code": "542523", "name": "噶尔县" }, { "code": "542524", "name": "日土县" }, { "code": "542525", "name": "革吉县" }, { "code": "542526", "name": "改则县" }, { "code": "542527", "name": "措勤县" } ] } ] }, { "code": "610000", "name": "陕西省", "cityList": [ { "code": "610100", "name": "西安市", "areaList": [ { "code": "610102", "name": "新城区" }, { "code": "610103", "name": "碑林区" }, { "code": "610104", "name": "莲湖区" }, { "code": "610111", "name": "灞桥区" }, { "code": "610112", "name": "未央区" }, { "code": "610113", "name": "雁塔区" }, { "code": "610114", "name": "阎良区" }, { "code": "610115", "name": "临潼区" }, { "code": "610116", "name": "长安区" }, { "code": "610117", "name": "高陵区" }, { "code": "610118", "name": "鄠邑区" }, { "code": "610122", "name": "蓝田县" }, { "code": "610124", "name": "周至县" } ] }, { "code": "610200", "name": "铜川市", "areaList": [ { "code": "610202", "name": "王益区" }, { "code": "610203", "name": "印台区" }, { "code": "610204", "name": "耀州区" }, { "code": "610222", "name": "宜君县" } ] }, { "code": "610300", "name": "宝鸡市", "areaList": [ { "code": "610302", "name": "渭滨区" }, { "code": "610303", "name": "金台区" }, { "code": "610304", "name": "陈仓区" }, { "code": "610305", "name": "凤翔区" }, { "code": "610323", "name": "岐山县" }, { "code": "610324", "name": "扶风县" }, { "code": "610326", "name": "眉县" }, { "code": "610327", "name": "陇县" }, { "code": "610328", "name": "千阳县" }, { "code": "610329", "name": "麟游县" }, { "code": "610330", "name": "凤县" }, { "code": "610331", "name": "太白县" } ] }, { "code": "610400", "name": "咸阳市", "areaList": [ { "code": "610402", "name": "秦都区" }, { "code": "610403", "name": "杨陵区" }, { "code": "610404", "name": "渭城区" }, { "code": "610422", "name": "三原县" }, { "code": "610423", "name": "泾阳县" }, { "code": "610424", "name": "乾县" }, { "code": "610425", "name": "礼泉县" }, { "code": "610426", "name": "永寿县" }, { "code": "610428", "name": "长武县" }, { "code": "610429", "name": "旬邑县" }, { "code": "610430", "name": "淳化县" }, { "code": "610431", "name": "武功县" }, { "code": "610481", "name": "兴平市" }, { "code": "610482", "name": "彬州市" } ] }, { "code": "610500", "name": "渭南市", "areaList": [ { "code": "610502", "name": "临渭区" }, { "code": "610503", "name": "华州区" }, { "code": "610522", "name": "潼关县" }, { "code": "610523", "name": "大荔县" }, { "code": "610524", "name": "合阳县" }, { "code": "610525", "name": "澄城县" }, { "code": "610526", "name": "蒲城县" }, { "code": "610527", "name": "白水县" }, { "code": "610528", "name": "富平县" }, { "code": "610581", "name": "韩城市" }, { "code": "610582", "name": "华阴市" } ] }, { "code": "610600", "name": "延安市", "areaList": [ { "code": "610602", "name": "宝塔区" }, { "code": "610603", "name": "安塞区" }, { "code": "610621", "name": "延长县" }, { "code": "610622", "name": "延川县" }, { "code": "610625", "name": "志丹县" }, { "code": "610626", "name": "吴起县" }, { "code": "610627", "name": "甘泉县" }, { "code": "610628", "name": "富县" }, { "code": "610629", "name": "洛川县" }, { "code": "610630", "name": "宜川县" }, { "code": "610631", "name": "黄龙县" }, { "code": "610632", "name": "黄陵县" }, { "code": "610681", "name": "子长市" } ] }, { "code": "610700", "name": "汉中市", "areaList": [ { "code": "610702", "name": "汉台区" }, { "code": "610703", "name": "南郑区" }, { "code": "610722", "name": "城固县" }, { "code": "610723", "name": "洋县" }, { "code": "610724", "name": "西乡县" }, { "code": "610725", "name": "勉县" }, { "code": "610726", "name": "宁强县" }, { "code": "610727", "name": "略阳县" }, { "code": "610728", "name": "镇巴县" }, { "code": "610729", "name": "留坝县" }, { "code": "610730", "name": "佛坪县" } ] }, { "code": "610800", "name": "榆林市", "areaList": [ { "code": "610802", "name": "榆阳区" }, { "code": "610803", "name": "横山区" }, { "code": "610822", "name": "府谷县" }, { "code": "610824", "name": "靖边县" }, { "code": "610825", "name": "定边县" }, { "code": "610826", "name": "绥德县" }, { "code": "610827", "name": "米脂县" }, { "code": "610828", "name": "佳县" }, { "code": "610829", "name": "吴堡县" }, { "code": "610830", "name": "清涧县" }, { "code": "610831", "name": "子洲县" }, { "code": "610881", "name": "神木市" } ] }, { "code": "610900", "name": "安康市", "areaList": [ { "code": "610902", "name": "汉滨区" }, { "code": "610921", "name": "汉阴县" }, { "code": "610922", "name": "石泉县" }, { "code": "610923", "name": "宁陕县" }, { "code": "610924", "name": "紫阳县" }, { "code": "610925", "name": "岚皋县" }, { "code": "610926", "name": "平利县" }, { "code": "610927", "name": "镇坪县" }, { "code": "610929", "name": "白河县" }, { "code": "610981", "name": "旬阳市" } ] }, { "code": "611000", "name": "商洛市", "areaList": [ { "code": "611002", "name": "商州区" }, { "code": "611021", "name": "洛南县" }, { "code": "611022", "name": "丹凤县" }, { "code": "611023", "name": "商南县" }, { "code": "611024", "name": "山阳县" }, { "code": "611025", "name": "镇安县" }, { "code": "611026", "name": "柞水县" } ] } ] }, { "code": "620000", "name": "甘肃省", "cityList": [ { "code": "620100", "name": "兰州市", "areaList": [ { "code": "620102", "name": "城关区" }, { "code": "620103", "name": "七里河区" }, { "code": "620104", "name": "西固区" }, { "code": "620105", "name": "安宁区" }, { "code": "620111", "name": "红古区" }, { "code": "620121", "name": "永登县" }, { "code": "620122", "name": "皋兰县" }, { "code": "620123", "name": "榆中县" } ] }, { "code": "620200", "name": "嘉峪关市", "areaList": [ { "code": "620200", "name": "嘉峪关市" } ] }, { "code": "620300", "name": "金昌市", "areaList": [ { "code": "620302", "name": "金川区" }, { "code": "620321", "name": "永昌县" } ] }, { "code": "620400", "name": "白银市", "areaList": [ { "code": "620402", "name": "白银区" }, { "code": "620403", "name": "平川区" }, { "code": "620421", "name": "靖远县" }, { "code": "620422", "name": "会宁县" }, { "code": "620423", "name": "景泰县" } ] }, { "code": "620500", "name": "天水市", "areaList": [ { "code": "620502", "name": "秦州区" }, { "code": "620503", "name": "麦积区" }, { "code": "620521", "name": "清水县" }, { "code": "620522", "name": "秦安县" }, { "code": "620523", "name": "甘谷县" }, { "code": "620524", "name": "武山县" }, { "code": "620525", "name": "张家川回族自治县" } ] }, { "code": "620600", "name": "武威市", "areaList": [ { "code": "620602", "name": "凉州区" }, { "code": "620621", "name": "民勤县" }, { "code": "620622", "name": "古浪县" }, { "code": "620623", "name": "天祝藏族自治县" } ] }, { "code": "620700", "name": "张掖市", "areaList": [ { "code": "620702", "name": "甘州区" }, { "code": "620721", "name": "肃南裕固族自治县" }, { "code": "620722", "name": "民乐县" }, { "code": "620723", "name": "临泽县" }, { "code": "620724", "name": "高台县" }, { "code": "620725", "name": "山丹县" } ] }, { "code": "620800", "name": "平凉市", "areaList": [ { "code": "620802", "name": "崆峒区" }, { "code": "620821", "name": "泾川县" }, { "code": "620822", "name": "灵台县" }, { "code": "620823", "name": "崇信县" }, { "code": "620825", "name": "庄浪县" }, { "code": "620826", "name": "静宁县" }, { "code": "620881", "name": "华亭市" } ] }, { "code": "620900", "name": "酒泉市", "areaList": [ { "code": "620902", "name": "肃州区" }, { "code": "620921", "name": "金塔县" }, { "code": "620922", "name": "瓜州县" }, { "code": "620923", "name": "肃北蒙古族自治县" }, { "code": "620924", "name": "阿克塞哈萨克族自治县" }, { "code": "620981", "name": "玉门市" }, { "code": "620982", "name": "敦煌市" } ] }, { "code": "621000", "name": "庆阳市", "areaList": [ { "code": "621002", "name": "西峰区" }, { "code": "621021", "name": "庆城县" }, { "code": "621022", "name": "环县" }, { "code": "621023", "name": "华池县" }, { "code": "621024", "name": "合水县" }, { "code": "621025", "name": "正宁县" }, { "code": "621026", "name": "宁县" }, { "code": "621027", "name": "镇原县" } ] }, { "code": "621100", "name": "定西市", "areaList": [ { "code": "621102", "name": "安定区" }, { "code": "621121", "name": "通渭县" }, { "code": "621122", "name": "陇西县" }, { "code": "621123", "name": "渭源县" }, { "code": "621124", "name": "临洮县" }, { "code": "621125", "name": "漳县" }, { "code": "621126", "name": "岷县" } ] }, { "code": "621200", "name": "陇南市", "areaList": [ { "code": "621202", "name": "武都区" }, { "code": "621221", "name": "成县" }, { "code": "621222", "name": "文县" }, { "code": "621223", "name": "宕昌县" }, { "code": "621224", "name": "康县" }, { "code": "621225", "name": "西和县" }, { "code": "621226", "name": "礼县" }, { "code": "621227", "name": "徽县" }, { "code": "621228", "name": "两当县" } ] }, { "code": "622900", "name": "临夏回族自治州", "areaList": [ { "code": "622901", "name": "临夏市" }, { "code": "622921", "name": "临夏县" }, { "code": "622922", "name": "康乐县" }, { "code": "622923", "name": "永靖县" }, { "code": "622924", "name": "广河县" }, { "code": "622925", "name": "和政县" }, { "code": "622926", "name": "东乡族自治县" }, { "code": "622927", "name": "积石山保安族东乡族撒拉族自治县" } ] }, { "code": "623000", "name": "甘南藏族自治州", "areaList": [ { "code": "623001", "name": "合作市" }, { "code": "623021", "name": "临潭县" }, { "code": "623022", "name": "卓尼县" }, { "code": "623023", "name": "舟曲县" }, { "code": "623024", "name": "迭部县" }, { "code": "623025", "name": "玛曲县" }, { "code": "623026", "name": "碌曲县" }, { "code": "623027", "name": "夏河县" } ] } ] }, { "code": "630000", "name": "青海省", "cityList": [ { "code": "630100", "name": "西宁市", "areaList": [ { "code": "630102", "name": "城东区" }, { "code": "630103", "name": "城中区" }, { "code": "630104", "name": "城西区" }, { "code": "630105", "name": "城北区" }, { "code": "630106", "name": "湟中区" }, { "code": "630121", "name": "大通回族土族自治县" }, { "code": "630123", "name": "湟源县" } ] }, { "code": "630200", "name": "海东市", "areaList": [ { "code": "630202", "name": "乐都区" }, { "code": "630203", "name": "平安区" }, { "code": "630222", "name": "民和回族土族自治县" }, { "code": "630223", "name": "互助土族自治县" }, { "code": "630224", "name": "化隆回族自治县" }, { "code": "630225", "name": "循化撒拉族自治县" } ] }, { "code": "632200", "name": "海北藏族自治州", "areaList": [ { "code": "632221", "name": "门源回族自治县" }, { "code": "632222", "name": "祁连县" }, { "code": "632223", "name": "海晏县" }, { "code": "632224", "name": "刚察县" } ] }, { "code": "632300", "name": "黄南藏族自治州", "areaList": [ { "code": "632301", "name": "同仁市" }, { "code": "632322", "name": "尖扎县" }, { "code": "632323", "name": "泽库县" }, { "code": "632324", "name": "河南蒙古族自治县" } ] }, { "code": "632500", "name": "海南藏族自治州", "areaList": [ { "code": "632521", "name": "共和县" }, { "code": "632522", "name": "同德县" }, { "code": "632523", "name": "贵德县" }, { "code": "632524", "name": "兴海县" }, { "code": "632525", "name": "贵南县" } ] }, { "code": "632600", "name": "果洛藏族自治州", "areaList": [ { "code": "632621", "name": "玛沁县" }, { "code": "632622", "name": "班玛县" }, { "code": "632623", "name": "甘德县" }, { "code": "632624", "name": "达日县" }, { "code": "632625", "name": "久治县" }, { "code": "632626", "name": "玛多县" } ] }, { "code": "632700", "name": "玉树藏族自治州", "areaList": [ { "code": "632701", "name": "玉树市" }, { "code": "632722", "name": "杂多县" }, { "code": "632723", "name": "称多县" }, { "code": "632724", "name": "治多县" }, { "code": "632725", "name": "囊谦县" }, { "code": "632726", "name": "曲麻莱县" } ] }, { "code": "632800", "name": "海西蒙古族藏族自治州", "areaList": [ { "code": "632801", "name": "格尔木市" }, { "code": "632802", "name": "德令哈市" }, { "code": "632803", "name": "茫崖市" }, { "code": "632821", "name": "乌兰县" }, { "code": "632822", "name": "都兰县" }, { "code": "632823", "name": "天峻县" }, { "code": "632825", "name": "大柴旦行政委员会" } ] } ] }, { "code": "640000", "name": "宁夏回族自治区", "cityList": [ { "code": "640100", "name": "银川市", "areaList": [ { "code": "640104", "name": "兴庆区" }, { "code": "640105", "name": "西夏区" }, { "code": "640106", "name": "金凤区" }, { "code": "640121", "name": "永宁县" }, { "code": "640122", "name": "贺兰县" }, { "code": "640181", "name": "灵武市" } ] }, { "code": "640200", "name": "石嘴山市", "areaList": [ { "code": "640202", "name": "大武口区" }, { "code": "640205", "name": "惠农区" }, { "code": "640221", "name": "平罗县" } ] }, { "code": "640300", "name": "吴忠市", "areaList": [ { "code": "640302", "name": "利通区" }, { "code": "640303", "name": "红寺堡区" }, { "code": "640323", "name": "盐池县" }, { "code": "640324", "name": "同心县" }, { "code": "640381", "name": "青铜峡市" } ] }, { "code": "640400", "name": "固原市", "areaList": [ { "code": "640402", "name": "原州区" }, { "code": "640422", "name": "西吉县" }, { "code": "640423", "name": "隆德县" }, { "code": "640424", "name": "泾源县" }, { "code": "640425", "name": "彭阳县" } ] }, { "code": "640500", "name": "中卫市", "areaList": [ { "code": "640502", "name": "沙坡头区" }, { "code": "640521", "name": "中宁县" }, { "code": "640522", "name": "海原县" } ] } ] }, { "code": "650000", "name": "新疆维吾尔自治区", "cityList": [ { "code": "650100", "name": "乌鲁木齐市", "areaList": [ { "code": "650102", "name": "天山区" }, { "code": "650103", "name": "沙依巴克区" }, { "code": "650104", "name": "新市区" }, { "code": "650105", "name": "水磨沟区" }, { "code": "650106", "name": "头屯河区" }, { "code": "650107", "name": "达坂城区" }, { "code": "650109", "name": "米东区" }, { "code": "650121", "name": "乌鲁木齐县" } ] }, { "code": "650200", "name": "克拉玛依市", "areaList": [ { "code": "650202", "name": "独山子区" }, { "code": "650203", "name": "克拉玛依区" }, { "code": "650204", "name": "白碱滩区" }, { "code": "650205", "name": "乌尔禾区" } ] }, { "code": "650400", "name": "吐鲁番市", "areaList": [ { "code": "650402", "name": "高昌区" }, { "code": "650421", "name": "鄯善县" }, { "code": "650422", "name": "托克逊县" } ] }, { "code": "650500", "name": "哈密市", "areaList": [ { "code": "650502", "name": "伊州区" }, { "code": "650521", "name": "巴里坤哈萨克自治县" }, { "code": "650522", "name": "伊吾县" } ] }, { "code": "652300", "name": "昌吉回族自治州", "areaList": [ { "code": "652301", "name": "昌吉市" }, { "code": "652302", "name": "阜康市" }, { "code": "652323", "name": "呼图壁县" }, { "code": "652324", "name": "玛纳斯县" }, { "code": "652325", "name": "奇台县" }, { "code": "652327", "name": "吉木萨尔县" }, { "code": "652328", "name": "木垒哈萨克自治县" } ] }, { "code": "652700", "name": "博尔塔拉蒙古自治州", "areaList": [ { "code": "652701", "name": "博乐市" }, { "code": "652702", "name": "阿拉山口市" }, { "code": "652722", "name": "精河县" }, { "code": "652723", "name": "温泉县" } ] }, { "code": "652800", "name": "巴音郭楞蒙古自治州", "areaList": [ { "code": "652801", "name": "库尔勒市" }, { "code": "652822", "name": "轮台县" }, { "code": "652823", "name": "尉犁县" }, { "code": "652824", "name": "若羌县" }, { "code": "652825", "name": "且末县" }, { "code": "652826", "name": "焉耆回族自治县" }, { "code": "652827", "name": "和静县" }, { "code": "652828", "name": "和硕县" }, { "code": "652829", "name": "博湖县" } ] }, { "code": "652900", "name": "阿克苏地区", "areaList": [ { "code": "652901", "name": "阿克苏市" }, { "code": "652902", "name": "库车市" }, { "code": "652922", "name": "温宿县" }, { "code": "652924", "name": "沙雅县" }, { "code": "652925", "name": "新和县" }, { "code": "652926", "name": "拜城县" }, { "code": "652927", "name": "乌什县" }, { "code": "652928", "name": "阿瓦提县" }, { "code": "652929", "name": "柯坪县" } ] }, { "code": "653000", "name": "克孜勒苏柯尔克孜自治州", "areaList": [ { "code": "653001", "name": "阿图什市" }, { "code": "653022", "name": "阿克陶县" }, { "code": "653023", "name": "阿合奇县" }, { "code": "653024", "name": "乌恰县" } ] }, { "code": "653100", "name": "喀什地区", "areaList": [ { "code": "653101", "name": "喀什市" }, { "code": "653121", "name": "疏附县" }, { "code": "653122", "name": "疏勒县" }, { "code": "653123", "name": "英吉沙县" }, { "code": "653124", "name": "泽普县" }, { "code": "653125", "name": "莎车县" }, { "code": "653126", "name": "叶城县" }, { "code": "653127", "name": "麦盖提县" }, { "code": "653128", "name": "岳普湖县" }, { "code": "653129", "name": "伽师县" }, { "code": "653130", "name": "巴楚县" }, { "code": "653131", "name": "塔什库尔干塔吉克自治县" } ] }, { "code": "653200", "name": "和田地区", "areaList": [ { "code": "653201", "name": "和田市" }, { "code": "653221", "name": "和田县" }, { "code": "653222", "name": "墨玉县" }, { "code": "653223", "name": "皮山县" }, { "code": "653224", "name": "洛浦县" }, { "code": "653225", "name": "策勒县" }, { "code": "653226", "name": "于田县" }, { "code": "653227", "name": "民丰县" } ] }, { "code": "654000", "name": "伊犁哈萨克自治州", "areaList": [ { "code": "654002", "name": "伊宁市" }, { "code": "654003", "name": "奎屯市" }, { "code": "654004", "name": "霍尔果斯市" }, { "code": "654021", "name": "伊宁县" }, { "code": "654022", "name": "察布查尔锡伯自治县" }, { "code": "654023", "name": "霍城县" }, { "code": "654024", "name": "巩留县" }, { "code": "654025", "name": "新源县" }, { "code": "654026", "name": "昭苏县" }, { "code": "654027", "name": "特克斯县" }, { "code": "654028", "name": "尼勒克县" } ] }, { "code": "654200", "name": "塔城地区", "areaList": [ { "code": "654201", "name": "塔城市" }, { "code": "654202", "name": "乌苏市" }, { "code": "654203", "name": "沙湾市" }, { "code": "654221", "name": "额敏县" }, { "code": "654224", "name": "托里县" }, { "code": "654225", "name": "裕民县" }, { "code": "654226", "name": "和布克赛尔蒙古自治县" } ] }, { "code": "654300", "name": "阿勒泰地区", "areaList": [ { "code": "654301", "name": "阿勒泰市" }, { "code": "654321", "name": "布尔津县" }, { "code": "654322", "name": "富蕴县" }, { "code": "654323", "name": "福海县" }, { "code": "654324", "name": "哈巴河县" }, { "code": "654325", "name": "青河县" }, { "code": "654326", "name": "吉木乃县" } ] }, { "code": "659001", "name": "石河子市", "areaList": [ { "code": "659001", "name": "石河子市" } ] }, { "code": "659002", "name": "阿拉尔市", "areaList": [ { "code": "659002", "name": "阿拉尔市" } ] }, { "code": "659003", "name": "图木舒克市", "areaList": [ { "code": "659003", "name": "图木舒克市" } ] }, { "code": "659004", "name": "五家渠市", "areaList": [ { "code": "659004", "name": "五家渠市" } ] }, { "code": "659005", "name": "北屯市", "areaList": [ { "code": "659005", "name": "北屯市" } ] }, { "code": "659006", "name": "铁门关市", "areaList": [ { "code": "659006", "name": "铁门关市" } ] }, { "code": "659007", "name": "双河市", "areaList": [ { "code": "659007", "name": "双河市" } ] }, { "code": "659008", "name": "可克达拉市", "areaList": [ { "code": "659008", "name": "可克达拉市" } ] }, { "code": "659009", "name": "昆玉市", "areaList": [ { "code": "659009", "name": "昆玉市" } ] }, { "code": "659010", "name": "胡杨河市", "areaList": [ { "code": "659010", "name": "胡杨河市" } ] }, { "code": "659011", "name": "新星市", "areaList": [ { "code": "659011", "name": "新星市" } ] } ] }, { "code": "710000", "name": "台湾省", "cityList": [ { "code": "710100", "name": "台北市", "areaList": [ { "code": "710101", "name": "中正区" }, { "code": "710102", "name": "大同区" }, { "code": "710103", "name": "中山区" }, { "code": "710104", "name": "松山区" }, { "code": "710105", "name": "大安区" }, { "code": "710106", "name": "万华区" }, { "code": "710107", "name": "信义区" }, { "code": "710108", "name": "士林区" }, { "code": "710109", "name": "北投区" }, { "code": "710110", "name": "内湖区" }, { "code": "710111", "name": "南港区" }, { "code": "710112", "name": "文山区" } ] }, { "code": "710200", "name": "高雄市", "areaList": [ { "code": "710201", "name": "新兴区" }, { "code": "710202", "name": "前金区" }, { "code": "710203", "name": "苓雅区" }, { "code": "710204", "name": "盐埕区" }, { "code": "710205", "name": "鼓山区" }, { "code": "710206", "name": "旗津区" }, { "code": "710207", "name": "前镇区" }, { "code": "710208", "name": "三民区" }, { "code": "710209", "name": "左营区" }, { "code": "710210", "name": "楠梓区" }, { "code": "710211", "name": "小港区" }, { "code": "710242", "name": "仁武区" }, { "code": "710243", "name": "大社区" }, { "code": "710244", "name": "冈山区" }, { "code": "710245", "name": "路竹区" }, { "code": "710246", "name": "阿莲区" }, { "code": "710247", "name": "田寮区" }, { "code": "710248", "name": "燕巢区" }, { "code": "710249", "name": "桥头区" }, { "code": "710250", "name": "梓官区" }, { "code": "710251", "name": "弥陀区" }, { "code": "710252", "name": "永安区" }, { "code": "710253", "name": "湖内区" }, { "code": "710254", "name": "凤山区" }, { "code": "710255", "name": "大寮区" }, { "code": "710256", "name": "林园区" }, { "code": "710257", "name": "鸟松区" }, { "code": "710258", "name": "大树区" }, { "code": "710259", "name": "旗山区" }, { "code": "710260", "name": "美浓区" }, { "code": "710261", "name": "六龟区" }, { "code": "710262", "name": "内门区" }, { "code": "710263", "name": "杉林区" }, { "code": "710264", "name": "甲仙区" }, { "code": "710265", "name": "桃源区" }, { "code": "710266", "name": "那玛夏区" }, { "code": "710267", "name": "茂林区" }, { "code": "710268", "name": "茄萣区" } ] }, { "code": "710300", "name": "台南市", "areaList": [ { "code": "710301", "name": "中西区" }, { "code": "710302", "name": "东区" }, { "code": "710303", "name": "南区" }, { "code": "710304", "name": "北区" }, { "code": "710305", "name": "安平区" }, { "code": "710306", "name": "安南区" }, { "code": "710339", "name": "永康区" }, { "code": "710340", "name": "归仁区" }, { "code": "710341", "name": "新化区" }, { "code": "710342", "name": "左镇区" }, { "code": "710343", "name": "玉井区" }, { "code": "710344", "name": "楠西区" }, { "code": "710345", "name": "南化区" }, { "code": "710346", "name": "仁德区" }, { "code": "710347", "name": "关庙区" }, { "code": "710348", "name": "龙崎区" }, { "code": "710349", "name": "官田区" }, { "code": "710350", "name": "麻豆区" }, { "code": "710351", "name": "佳里区" }, { "code": "710352", "name": "西港区" }, { "code": "710353", "name": "七股区" }, { "code": "710354", "name": "将军区" }, { "code": "710355", "name": "学甲区" }, { "code": "710356", "name": "北门区" }, { "code": "710357", "name": "新营区" }, { "code": "710358", "name": "后壁区" }, { "code": "710359", "name": "白河区" }, { "code": "710360", "name": "东山区" }, { "code": "710361", "name": "六甲区" }, { "code": "710362", "name": "下营区" }, { "code": "710363", "name": "柳营区" }, { "code": "710364", "name": "盐水区" }, { "code": "710365", "name": "善化区" }, { "code": "710366", "name": "大内区" }, { "code": "710367", "name": "山上区" }, { "code": "710368", "name": "新市区" }, { "code": "710369", "name": "安定区" } ] }, { "code": "710400", "name": "台中市", "areaList": [ { "code": "710401", "name": "中区" }, { "code": "710402", "name": "东区" }, { "code": "710403", "name": "南区" }, { "code": "710404", "name": "西区" }, { "code": "710405", "name": "北区" }, { "code": "710406", "name": "北屯区" }, { "code": "710407", "name": "西屯区" }, { "code": "710408", "name": "南屯区" }, { "code": "710431", "name": "太平区" }, { "code": "710432", "name": "大里区" }, { "code": "710433", "name": "雾峰区" }, { "code": "710434", "name": "乌日区" }, { "code": "710435", "name": "丰原区" }, { "code": "710436", "name": "后里区" }, { "code": "710437", "name": "石冈区" }, { "code": "710438", "name": "东势区" }, { "code": "710439", "name": "和平区" }, { "code": "710440", "name": "新社区" }, { "code": "710441", "name": "潭子区" }, { "code": "710442", "name": "大雅区" }, { "code": "710443", "name": "神冈区" }, { "code": "710444", "name": "大肚区" }, { "code": "710445", "name": "沙鹿区" }, { "code": "710446", "name": "龙井区" }, { "code": "710447", "name": "梧栖区" }, { "code": "710448", "name": "清水区" }, { "code": "710449", "name": "大甲区" }, { "code": "710450", "name": "外埔区" }, { "code": "710451", "name": "大安区" } ] }, { "code": "710600", "name": "南投县", "areaList": [ { "code": "710600", "name": "南投县" } ] }, { "code": "710700", "name": "基隆市", "areaList": [ { "code": "710701", "name": "仁爱区" }, { "code": "710702", "name": "信义区" }, { "code": "710703", "name": "中正区" }, { "code": "710704", "name": "中山区" }, { "code": "710705", "name": "安乐区" }, { "code": "710706", "name": "暖暖区" }, { "code": "710707", "name": "七堵区" } ] }, { "code": "710800", "name": "新竹市", "areaList": [ { "code": "710801", "name": "东区" }, { "code": "710802", "name": "北区" }, { "code": "710803", "name": "香山区" } ] }, { "code": "710900", "name": "嘉义市", "areaList": [ { "code": "710901", "name": "东区" }, { "code": "710902", "name": "西区" } ] }, { "code": "711100", "name": "新北市", "areaList": [ { "code": "711130", "name": "万里区" }, { "code": "711131", "name": "金山区" }, { "code": "711132", "name": "板桥区" }, { "code": "711133", "name": "汐止区" }, { "code": "711134", "name": "深坑区" }, { "code": "711135", "name": "石碇区" }, { "code": "711136", "name": "瑞芳区" }, { "code": "711137", "name": "平溪区" }, { "code": "711138", "name": "双溪区" }, { "code": "711139", "name": "贡寮区" }, { "code": "711140", "name": "新店区" }, { "code": "711141", "name": "坪林区" }, { "code": "711142", "name": "乌来区" }, { "code": "711143", "name": "永和区" }, { "code": "711144", "name": "中和区" }, { "code": "711145", "name": "土城区" }, { "code": "711146", "name": "三峡区" }, { "code": "711147", "name": "树林区" }, { "code": "711148", "name": "莺歌区" }, { "code": "711149", "name": "三重区" }, { "code": "711150", "name": "新庄区" }, { "code": "711151", "name": "泰山区" }, { "code": "711152", "name": "林口区" }, { "code": "711153", "name": "芦洲区" }, { "code": "711154", "name": "五股区" }, { "code": "711155", "name": "八里区" }, { "code": "711156", "name": "淡水区" }, { "code": "711157", "name": "三芝区" }, { "code": "711158", "name": "石门区" } ] }, { "code": "711200", "name": "宜兰县", "areaList": [ { "code": "711200", "name": "宜兰县" } ] }, { "code": "711300", "name": "新竹县", "areaList": [ { "code": "711300", "name": "新竹县" } ] }, { "code": "711400", "name": "桃园市", "areaList": [ { "code": "711414", "name": "中坜区" }, { "code": "711415", "name": "平镇区" }, { "code": "711416", "name": "龙潭区" }, { "code": "711417", "name": "杨梅区" }, { "code": "711418", "name": "新屋区" }, { "code": "711419", "name": "观音区" }, { "code": "711420", "name": "桃园区" }, { "code": "711421", "name": "龟山区" }, { "code": "711422", "name": "八德区" }, { "code": "711423", "name": "大溪区" }, { "code": "711424", "name": "复兴区" }, { "code": "711425", "name": "大园区" }, { "code": "711426", "name": "芦竹区" } ] }, { "code": "711500", "name": "苗栗县", "areaList": [ { "code": "711500", "name": "苗栗县" } ] }, { "code": "711700", "name": "彰化县", "areaList": [ { "code": "711700", "name": "彰化县" } ] }, { "code": "711900", "name": "嘉义县", "areaList": [ { "code": "711900", "name": "嘉义县" } ] }, { "code": "712100", "name": "云林县", "areaList": [ { "code": "712100", "name": "云林县" } ] }, { "code": "712400", "name": "屏东县", "areaList": [ { "code": "712400", "name": "屏东县" } ] }, { "code": "712500", "name": "台东县", "areaList": [ { "code": "712500", "name": "台东县" } ] }, { "code": "712600", "name": "花莲县", "areaList": [ { "code": "712600", "name": "花莲县" } ] }, { "code": "712700", "name": "澎湖县", "areaList": [ { "code": "712700", "name": "澎湖县" } ] } ] }, { "code": "810000", "name": "香港特别行政区", "cityList": [ { "code": "810000", "name": "香港特别行政区", "areaList": [ { "code": "810000", "name": "香港特别行政区" } ] } ] }, { "code": "820000", "name": "澳门特别行政区", "cityList": [ { "code": "820000", "name": "澳门特别行政区", "areaList": [ { "code": "820000", "name": "澳门特别行政区" } ] } ] } ] ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/AddressPicker.java ================================================ /* * 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; import android.app.Activity; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.wheelpicker.annotation.AddressMode; import com.github.gzuliyujiang.wheelpicker.contract.AddressLoader; import com.github.gzuliyujiang.wheelpicker.contract.AddressParser; import com.github.gzuliyujiang.wheelpicker.contract.AddressReceiver; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import com.github.gzuliyujiang.wheelpicker.contract.OnAddressLoadListener; import com.github.gzuliyujiang.wheelpicker.contract.OnAddressPickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkagePickedListener; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; 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; /** * 省市区县滚轮选择 *

* 数据来源: * 1、国家民政局:http://www.mca.gov.cn/article/sj/xzqh * 2、国家统计局:http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm * 3、台湾维基数据:https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码_(7区) * 4、港澳维基数据:https://zh.wikipedia.org/wiki/中华人民共和国行政区划代码_(8区) * 5、数据抓取转化:https://github.com/small-dream/China_Province_City * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/15 12:17 */ @SuppressWarnings({"unused"}) public class AddressPicker extends LinkagePicker implements AddressReceiver { private AddressLoader addressLoader; private AddressParser addressParser; private int addressMode; private OnAddressPickedListener onAddressPickedListener; private OnAddressLoadListener onAddressLoadListener; public AddressPicker(@NonNull Activity activity) { super(activity); } public AddressPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @Override protected void initData() { super.initData(); if (addressLoader == null || addressParser == null) { return; } wheelLayout.showLoading(); if (onAddressLoadListener != null) { onAddressLoadListener.onAddressLoadStarted(); } DialogLog.print("Address data loading"); addressLoader.loadJson(this, addressParser); } @Override public void onAddressReceived(@NonNull List data) { DialogLog.print("Address data received"); wheelLayout.hideLoading(); if (onAddressLoadListener != null) { onAddressLoadListener.onAddressLoadFinished(data); } wheelLayout.setData(new AddressProvider(data, addressMode)); } @Deprecated @Override public void setData(@NonNull LinkageProvider data) { throw new UnsupportedOperationException("Use setAddressMode or setAddressLoader instead"); } @Deprecated @Override public void setOnLinkagePickedListener(OnLinkagePickedListener onLinkagePickedListener) { throw new UnsupportedOperationException("Use setOnAddressPickedListener instead"); } @Override protected void onOk() { if (onAddressPickedListener != null) { ProvinceEntity province = wheelLayout.getFirstWheelView().getCurrentItem(); CityEntity city = wheelLayout.getSecondWheelView().getCurrentItem(); CountyEntity county = wheelLayout.getThirdWheelView().getCurrentItem(); onAddressPickedListener.onAddressPicked(province, city, county); } } public void setOnAddressPickedListener(@NonNull OnAddressPickedListener onAddressPickedListener) { this.onAddressPickedListener = onAddressPickedListener; } public void setOnAddressLoadListener(@NonNull OnAddressLoadListener onAddressLoadListener) { this.onAddressLoadListener = onAddressLoadListener; } public void setAddressLoader(@NonNull AddressLoader loader, @NonNull AddressParser parser) { this.addressLoader = loader; this.addressParser = parser; } public void setAddressMode(@AddressMode int addressMode) { setAddressMode("china_address.json", addressMode); } public void setAddressMode(@NonNull String assetPath, @AddressMode int addressMode) { setAddressMode(assetPath, addressMode, new AddressJsonParser()); } public void setAddressMode(@NonNull String assetPath, @AddressMode int addressMode, @NonNull AddressJsonParser jsonParser) { this.addressMode = addressMode; 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(); } } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/annotation/AddressMode.java ================================================ /* * 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.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * 地址模式 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/15 12:19 */ @Retention(RetentionPolicy.SOURCE) public @interface AddressMode { /** * 省级、市级、县级 */ int PROVINCE_CITY_COUNTY = 0; /** * 省级、市级 */ int PROVINCE_CITY = 1; /** * 市级、县级 */ int CITY_COUNTY = 2; } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/AddressLoader.java ================================================ /* * 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.contract; import androidx.annotation.MainThread; import androidx.annotation.NonNull; /** * 地址数据加载器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 16:42 */ public interface AddressLoader { @MainThread void loadJson(@NonNull AddressReceiver receiver, @NonNull AddressParser parser); } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/AddressParser.java ================================================ /* * 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.contract; import androidx.annotation.NonNull; import androidx.annotation.WorkerThread; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.util.List; /** * 地址数据解析器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/12 16:53 */ public interface AddressParser { @WorkerThread @NonNull List parseData(@NonNull String text); } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/AddressReceiver.java ================================================ /* * 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.contract; import androidx.annotation.MainThread; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.util.List; /** * 地址数据接收器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 16:42 */ public interface AddressReceiver { @MainThread void onAddressReceived(@NonNull List data); } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnAddressLoadListener.java ================================================ /* * 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.contract; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.util.List; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/30 15:20 */ public interface OnAddressLoadListener { void onAddressLoadStarted(); void onAddressLoadFinished(@NonNull List data); } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnAddressPickedListener.java ================================================ /* * 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.contract; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; /** * 地址选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 18:23 */ public interface OnAddressPickedListener { /** * 联动选择回调 * * @param province 选中的省/直辖市/自治区 * @param city 选中的地级市/自治州 * @param county 选中的区/县/县级市 */ void onAddressPicked(ProvinceEntity province, CityEntity city, CountyEntity county); } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/AddressEntity.java ================================================ /* * 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.Objects; /** * 地址数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 11:47 */ class AddressEntity implements TextProvider, Serializable { private String code; private String name; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String provideText() { return name; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AddressEntity that = (AddressEntity) o; return Objects.equals(code, that.code) && Objects.equals(name, that.name); } @Override public int hashCode() { return Objects.hash(code, name); } @NonNull @Override public String toString() { return "AddressEntity{" + "code='" + code + '\'' + ", name='" + name + '\'' + '}'; } } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/CityEntity.java ================================================ /* * 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 java.util.ArrayList; import java.util.List; /** * 市级数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 11:47 */ public class CityEntity extends AddressEntity { private List countyList; @NonNull public List getCountyList() { if (countyList == null) { countyList = new ArrayList<>(); } return countyList; } public void setCountyList(List countyList) { this.countyList = countyList; } } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/CountyEntity.java ================================================ /* * 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; /** * 县级数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 11:47 */ public class CountyEntity extends AddressEntity { } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/ProvinceEntity.java ================================================ /* * 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 java.util.ArrayList; import java.util.List; /** * 省级数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 11:47 */ public class ProvinceEntity extends AddressEntity { private List cityList; @NonNull public List getCityList() { if (cityList == null) { cityList = new ArrayList<>(); } return cityList; } public void setCityList(List cityList) { this.cityList = cityList; } } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/AddressProvider.java ================================================ /* * 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.impl; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.annotation.AddressMode; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.util.ArrayList; import java.util.List; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 11:55 */ public class AddressProvider implements LinkageProvider { private final List data; private final int mode; public AddressProvider(@NonNull List data, int mode) { this.data = data; this.mode = mode; } @Override public boolean firstLevelVisible() { return mode == AddressMode.PROVINCE_CITY_COUNTY || mode == AddressMode.PROVINCE_CITY; } @Override public boolean thirdLevelVisible() { return mode == AddressMode.PROVINCE_CITY_COUNTY || mode == AddressMode.CITY_COUNTY; } @NonNull @Override public List provideFirstData() { return data; } @NonNull @Override public List linkageSecondData(int firstIndex) { if (data.size() == 0) { return new ArrayList<>(); } if (firstIndex == INDEX_NO_FOUND) { firstIndex = 0; } return data.get(firstIndex).getCityList(); } @NonNull @Override public List linkageThirdData(int firstIndex, int secondIndex) { List data = linkageSecondData(firstIndex); if (data.size() == 0) { return new ArrayList<>(); } if (secondIndex == INDEX_NO_FOUND) { secondIndex = 0; } return data.get(secondIndex).getCountyList(); } @Override public int findFirstIndex(Object firstValue) { if (firstValue == null) { return INDEX_NO_FOUND; } if (firstValue instanceof ProvinceEntity) { return data.indexOf(firstValue); } for (int i = 0, n = data.size(); i < n; i++) { ProvinceEntity entity = data.get(i); if (entity.getCode().equals(firstValue.toString()) || entity.getName().contains(firstValue.toString())) { return i; } } return INDEX_NO_FOUND; } @Override public int findSecondIndex(int firstIndex, Object secondValue) { if (secondValue == null) { return INDEX_NO_FOUND; } List cityList = linkageSecondData(firstIndex); if (secondValue instanceof CityEntity) { return cityList.indexOf(secondValue); } for (int i = 0, n = cityList.size(); i < n; i++) { CityEntity entity = cityList.get(i); if (entity.getCode().equals(secondValue.toString()) || entity.getName().contains(secondValue.toString())) { return i; } } return INDEX_NO_FOUND; } @Override public int findThirdIndex(int firstIndex, int secondIndex, Object thirdValue) { if (thirdValue == null) { return INDEX_NO_FOUND; } List countyList = linkageThirdData(firstIndex, secondIndex); if (thirdValue instanceof CountyEntity) { return countyList.indexOf(thirdValue); } for (int i = 0, n = countyList.size(); i < n; i++) { CountyEntity entity = countyList.get(i); if (entity.getCode().equals(thirdValue.toString()) || entity.getName().contains(thirdValue.toString())) { return i; } } return INDEX_NO_FOUND; } } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/AssetAddressLoader.java ================================================ /* * 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.impl; import android.content.Context; import android.content.res.AssetManager; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.WorkerThread; import com.github.gzuliyujiang.wheelpicker.contract.AddressLoader; import com.github.gzuliyujiang.wheelpicker.contract.AddressParser; import com.github.gzuliyujiang.wheelpicker.contract.AddressReceiver; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executors; /** * 从APK包中的“assets”目录下加载地址数据 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 17:15 */ @SuppressWarnings("unused") public class AssetAddressLoader implements AddressLoader { private final Context context; private final String path; public AssetAddressLoader(@NonNull Context context, @NonNull String path) { this.context = context; this.path = path; } @Override public void loadJson(@NonNull final AddressReceiver receiver, @NonNull final AddressParser parser) { Executors.newSingleThreadExecutor().execute(new Runnable() { @Override public void run() { String text = loadFromAssets(); final List data; if (TextUtils.isEmpty(text)) { data = new ArrayList<>(); } else { data = parser.parseData(text); } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { receiver.onAddressReceived(data); } }); } }); } @WorkerThread private String loadFromAssets() { StringBuilder stringBuilder = new StringBuilder(); AssetManager am = context.getAssets(); try (BufferedReader bf = new BufferedReader(new InputStreamReader(am.open(path)))) { String line; while ((line = bf.readLine()) != null) { stringBuilder.append(line); } } catch (IOException e) { return ""; } return stringBuilder.toString(); } } ================================================ FILE: AddressPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/utility/AddressJsonParser.java ================================================ /* * 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.utility; import android.text.TextUtils; import androidx.annotation.NonNull; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.wheelpicker.contract.AddressParser; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; /** * 使用系统自带的“org.json”包转换地址数据 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 17:15 */ public class AddressJsonParser implements AddressParser { private final Builder builder; public AddressJsonParser() { this(new Builder()); } public AddressJsonParser(Builder builder) { this.builder = builder; } @NonNull @Override public List parseData(@NonNull String text) { try { JSONArray provinceArray = new JSONArray(text); return parseProvince(provinceArray); } catch (JSONException e) { DialogLog.print(e); } return new ArrayList<>(); } private List parseProvince(JSONArray provinceArray) { List data = new ArrayList<>(); for (int i = 0, x = provinceArray.length(); i < x; i++) { ProvinceEntity provinceEntity = new ProvinceEntity(); JSONObject provinceObject = provinceArray.optJSONObject(i); provinceEntity.setCode(provinceObject.optString(builder.provinceCodeField)); provinceEntity.setName(provinceObject.optString(builder.provinceNameField)); provinceEntity.setCityList(new ArrayList<>()); JSONArray cityArray = provinceObject.optJSONArray(builder.provinceChildField); parseCity(provinceEntity, cityArray); data.add(provinceEntity); } return data; } private void parseCity(ProvinceEntity provinceEntity, JSONArray cityArray) { //台湾的第二级可能没数据 if (cityArray == null || cityArray.length() == 0) { return; } for (int j = 0, y = cityArray.length(); j < y; j++) { CityEntity cityEntity = new CityEntity(); JSONObject cityObject = cityArray.optJSONObject(j); cityEntity.setCode(cityObject.optString(builder.cityCodeField)); cityEntity.setName(cityObject.optString(builder.cityNameField)); cityEntity.setCountyList(new ArrayList<>()); provinceEntity.getCityList().add(cityEntity); JSONArray countyArray = cityObject.optJSONArray(builder.cityChildField); parseCounty(cityEntity, countyArray); } } private void parseCounty(CityEntity cityEntity, JSONArray countyArray) { //港澳台的第三级可能没数据 if (countyArray == null || countyArray.length() == 0) { return; } for (int k = 0, z = countyArray.length(); k < z; k++) { CountyEntity countyEntity = new CountyEntity(); JSONObject countyObject = countyArray.optJSONObject(k); countyEntity.setCode(countyObject.optString(builder.countyCodeField)); countyEntity.setName(countyObject.optString(builder.countyNameField)); cityEntity.getCountyList().add(countyEntity); } } @SuppressWarnings("unused") public static class Builder { private String provinceCodeField = "code"; private String provinceNameField = "name"; private String provinceChildField = "cityList"; private String cityCodeField = "code"; private String cityNameField = "name"; private String cityChildField = "areaList"; private String countyCodeField = "code"; private String countyNameField = "name"; public Builder provinceCodeField(String provinceCodeField) { if (TextUtils.isEmpty(provinceCodeField)) { return this; } this.provinceCodeField = provinceCodeField; return this; } public Builder provinceNameField(String provinceNameField) { if (TextUtils.isEmpty(provinceNameField)) { return this; } this.provinceNameField = provinceNameField; return this; } public Builder provinceChildField(String provinceChildField) { if (TextUtils.isEmpty(provinceChildField)) { return this; } this.provinceChildField = provinceChildField; return this; } public Builder cityCodeField(String cityCodeField) { if (TextUtils.isEmpty(cityCodeField)) { return this; } this.cityCodeField = cityCodeField; return this; } public Builder cityNameField(String cityNameField) { if (TextUtils.isEmpty(cityNameField)) { return this; } this.cityNameField = cityNameField; return this; } public Builder cityChildField(String cityChildField) { if (TextUtils.isEmpty(cityChildField)) { return this; } this.cityChildField = cityChildField; return this; } public Builder countyCodeField(String countyCodeField) { if (TextUtils.isEmpty(countyCodeField)) { return this; } this.countyCodeField = countyCodeField; return this; } public Builder countyNameField(String countyNameField) { if (TextUtils.isEmpty(countyNameField)) { return this; } this.countyNameField = countyNameField; return this; } public AddressJsonParser build() { return new AddressJsonParser(this); } } } ================================================ FILE: CalendarPicker/README.md ================================================ # 日历选择器 基于 [双向日期选择日历控件](https://github.com/oxsource/calendar) 开发。 ## 示例 ```groovy CalendarPicker picker = new CalendarPicker(this); picker.setRangeDateOnFuture(3); if (singleTimeInMillis == 0) { singleTimeInMillis = System.currentTimeMillis(); } picker.setSelectedDate(singleTimeInMillis); picker.setOnSingleDatePickListener(new OnSingleDatePickListener() { @Override public void onSingleDatePicked(@NonNull Date date) { singleTimeInMillis = date.getTime(); } }); picker.show(); ``` ## 配色 ```groovy CalendarPicker picker = new CalendarPicker(this); picker.setColorScheme(new ColorScheme() .daySelectBackgroundColor(0xFF0000FF) .dayStressTextColor(0xFF0000DD)); picker.show(); ``` ================================================ FILE: CalendarPicker/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation implementation androidxLibrary.core implementation androidxLibrary.recyclerview api project(':Common') } ================================================ FILE: CalendarPicker/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: CalendarPicker/src/main/AndroidManifest.xml ================================================ ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/CalendarPicker.java ================================================ /* * 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; import android.annotation.SuppressLint; import android.app.Activity; import android.text.TextUtils; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.calendarpicker.core.CalendarAdapter; 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.ItemViewProvider; import com.github.gzuliyujiang.calendarpicker.core.OnDateSelectedListener; import com.github.gzuliyujiang.calendarpicker.listener.OnPageChangeCallback; import com.github.gzuliyujiang.calendarpicker.listener.ScrollEventAdapter; import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.dialog.DialogStyle; import com.github.gzuliyujiang.dialog.ModalDialog; import java.util.Calendar; import java.util.Date; import java.util.Locale; /** * 日历日期选择器,基于`https://github.com/oxsource/calendar` * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/4/30 13:36 */ @SuppressWarnings({"unused", "deprecation"}) public class CalendarPicker extends ModalDialog implements OnDateSelectedListener { private CalendarView calendarView; private CalendarAdapter calendarAdapter; private ScrollEventAdapter mScrollEventAdapter; private ColorScheme colorScheme; private boolean singleMode = false; private FestivalProvider festivalProvider; private ItemViewProvider itemViewProvider; private Date minDate, maxDate; private Date selectDate, startDate, endDate; private String noteFrom, noteTo; private OnSingleDatePickListener onSingleDatePickListener; private OnRangeDatePickListener onRangeDatePickListener; private boolean initialized = false; public CalendarPicker(Activity activity) { super(activity); } public CalendarPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { calendarView = new CalendarView(activity); return calendarView; } @Override protected void initView() { super.initView(); setHeight((int) (activity.getResources().getDisplayMetrics().heightPixels * 0.6f)); switch (DialogConfig.getDialogStyle()) { case DialogStyle.Default: case DialogStyle.Two: headerView.setVisibility(View.VISIBLE); break; default: headerView.setVisibility(View.GONE); break; } } @Override protected void initData() { super.initData(); initialized = true; if (minDate == null && maxDate == null) { Date currentDate = new Date(System.currentTimeMillis()); Calendar minCalendar = DateUtils.calendar(currentDate); minCalendar.add(Calendar.MONTH, -12); minCalendar.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(minCalendar.getTime())); minDate = minCalendar.getTime(); Calendar maxCalendar = DateUtils.calendar(currentDate); maxCalendar.setTime(currentDate); maxCalendar.add(Calendar.MONTH, 12); maxCalendar.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(maxCalendar.getTime())); maxDate = maxCalendar.getTime(); } if (mScrollEventAdapter == null) { mScrollEventAdapter = new ScrollEventAdapter(calendarView.getBodyView()); calendarView.getBodyView().addOnScrollListener(mScrollEventAdapter); } calendarAdapter = calendarView.getAdapter(); calendarAdapter.setOnCalendarSelectedListener(this); mScrollEventAdapter.setOnPageChangeCallback(new OnPageChangeCallback() { @Override public void onPageSelected(int position) { if (calendarAdapter != null) { Date cDate = calendarAdapter.getDateValue(position); if (onSingleDatePickListener != null) { onSingleDatePickListener.onMonthChanged(cDate); } if (onRangeDatePickListener != null) { onRangeDatePickListener.onMonthChanged(cDate); } } } }); refreshData(); } @Override protected void onCancel() { } @Override protected void onOk() { if (singleMode && selectDate == null) { return; } boolean rangeNotSelected = startDate == null || endDate == null; if (!singleMode && rangeNotSelected) { return; } dismiss(); if (onSingleDatePickListener != null) { onSingleDatePickListener.onSingleDatePicked(selectDate); } if (onRangeDatePickListener != null) { onRangeDatePickListener.onRangeDatePicked(startDate, endDate); } } @Override public void onSingleSelected(@NonNull Date date) { selectDate = date; } @Override public void onRangeSelected(@NonNull Date start, @NonNull Date end) { startDate = start; endDate = end; } /** * 启用横向滑动模式 */ public void enablePagerSnap() { setHeight(WRAP_CONTENT); calendarView.enablePagerSnap(); calendarView.getBodyView().addOnScrollListener(new RecyclerView.OnScrollListener() { @SuppressLint("NotifyDataSetChanged") @Override public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { if (newState != RecyclerView.SCROLL_STATE_IDLE) { return; } calendarView.getAdapter().notifyDataSetChanged(); } }); } /** * 设置配色方案 */ public void setColorScheme(ColorScheme colorScheme) { if (colorScheme == null) { colorScheme = new ColorScheme(); } this.colorScheme = colorScheme; if (initialized) { refreshData(); } } /** * 设置日期范围选择回调 */ public void setOnRangeDatePickListener(OnRangeDatePickListener onRangeDatePickListener) { this.singleMode = false; this.onRangeDatePickListener = onRangeDatePickListener; if (initialized) { refreshData(); } } /** * 设置单个日期选择回调 */ public void setOnSingleDatePickListener(OnSingleDatePickListener onSingleDatePickListener) { this.singleMode = true; this.onSingleDatePickListener = onSingleDatePickListener; if (initialized) { refreshData(); } } /** * 设置日期范围 */ public void setRangeDate(Date minDate, Date maxDate) { this.minDate = DateUtils.min(minDate, maxDate); this.maxDate = DateUtils.max(minDate, maxDate); if (initialized) { refreshData(); } } /** * 设置日期范围为当前年月之后的几个月 */ public void setRangeDateOnFuture(int offsetMonth) { if (offsetMonth < 0) { offsetMonth = 0; } minDate = new Date(System.currentTimeMillis()); Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.MONTH, offsetMonth); calendar.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(calendar.getTime())); maxDate = calendar.getTime(); if (initialized) { refreshData(); } } /** * 设置默认选择的日期时间戳(单个日期选择模式) */ public void setSelectedDate(long timeInMillis) { setSelectedDate(new Date(timeInMillis)); } /** * 设置默认选择的日期(单个日期选择模式) */ public void setSelectedDate(Date date) { this.selectDate = date; if (initialized) { refreshData(); } } /** * 设置默认选择的日期时间戳(日期范围选择模式) */ public void setSelectedDate(long timeInMillisStart, long timeInMillisEnd) { setSelectedDate(new Date(Math.min(timeInMillisStart, timeInMillisEnd)), new Date(Math.max(timeInMillisStart, timeInMillisEnd))); } /** * 设置默认选择的日期(日期范围选择模式) */ public void setSelectedDate(Date startDate, Date endDate) { this.startDate = startDate; this.endDate = endDate; if (initialized) { refreshData(); } } /** * 设置选择区间提示语 */ public void setIntervalNotes(String noteFrom, String noteTo) { this.noteFrom = noteFrom; this.noteTo = noteTo; if (initialized) { refreshData(); } } /** * 设置节日文本提供者 */ public void setFestivalProvider(FestivalProvider festivalProvider) { this.festivalProvider = festivalProvider; if (initialized) { refreshData(); } } /** * 设置条目视图提供者 */ public void setItemViewProvider(ItemViewProvider itemViewProvider) { this.itemViewProvider = itemViewProvider; if (initialized) { refreshData(); } } private void refreshData() { calendarView.setColorScheme(colorScheme); calendarAdapter.notify(false); calendarAdapter.single(singleMode); calendarAdapter.festivalProvider(festivalProvider); calendarAdapter.itemViewProvider(itemViewProvider); if (singleMode) { startDate = selectDate; endDate = selectDate; } calendarAdapter.valid(minDate, maxDate); calendarAdapter.select(startDate, endDate); calendarAdapter.range(minDate, maxDate); if (!TextUtils.isEmpty(noteFrom) && !TextUtils.isEmpty(noteTo)) { calendarAdapter.intervalNotes(noteFrom, noteTo); } calendarAdapter.refresh(); scrollToSelectedPosition(); } private void scrollToSelectedPosition() { calendarView.post(new Runnable() { @Override public void run() { int position = calendarAdapter.getDatePosition(startDate); position = Math.max(position, 0); position = Math.min(position, calendarAdapter.getItemCount() - 1); calendarView.getLayoutManager().scrollToPositionWithOffset(position, 0); } }); } /** * 获取日历视图 */ public final CalendarView getCalendarView() { return calendarView; } @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); if (mScrollEventAdapter != null && calendarView != null) { mScrollEventAdapter.setOnPageChangeCallback(null); calendarView.getBodyView().removeOnScrollListener(mScrollEventAdapter); mScrollEventAdapter = null; } } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/OnRangeDatePickListener.java ================================================ /* * 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; import androidx.annotation.NonNull; import java.util.Date; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/4/30 13:36 */ public interface OnRangeDatePickListener { void onRangeDatePicked(@NonNull Date startDate, @NonNull Date endDate); void onMonthChanged(Date date); } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/OnSingleDatePickListener.java ================================================ /* * 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; import androidx.annotation.NonNull; import java.util.Date; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/4/30 13:36 */ public interface OnSingleDatePickListener { void onSingleDatePicked(@NonNull Date date); void onMonthChanged(Date date); } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/CalendarAdapter.java ================================================ /* * 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 android.annotation.SuppressLint; import android.content.Context; import android.graphics.Typeface; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; /** * Created by peng on 2017/8/3. */ @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<>(); private final Interval valid = new Interval<>(); private final Interval select = new Interval<>(); private final Interval selectNote = new Interval<>(); private boolean singleMode = false; private FestivalProvider festivalProvider; private ItemViewProvider itemViewProvider; 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; } public CalendarAdapter colorScheme(ColorScheme colorScheme) { if (colorScheme == null) { colorScheme = new ColorScheme(); } this.colorScheme = colorScheme; return this; } public CalendarAdapter single(boolean value) { singleMode = value; if (notify) { refresh(); } return this; } public CalendarAdapter festivalProvider(FestivalProvider value) { festivalProvider = value; if (notify) { refresh(); } return this; } public CalendarAdapter itemViewProvider(ItemViewProvider value) { itemViewProvider = value; if (notify) { refresh(); } return this; } public CalendarAdapter valid(Date from, Date to) { valid.left(from); valid.right(to); if (notify) { refresh(); } return this; } /** * 选择区间提示语 * * @param noteFrom 开始日期提示语 * @param noteTo 结束日期提示语 */ public CalendarAdapter intervalNotes(String noteFrom, String noteTo) { selectNote.left(noteFrom); selectNote.right(noteTo); if (notify) { refresh(); } return this; } /** * 设置选择范围 * * @param fromInMillis 开始日期 * @param toInMillis 结束日期 */ public CalendarAdapter select(long fromInMillis, long toInMillis) { return select(new Date(fromInMillis), new Date(toInMillis)); } /** * 设置选择范围 * * @param from 开始日期 * @param to 结束日期 */ public CalendarAdapter select(Date from, Date to) { select.left(from); select.right(to); if (notify) { refresh(); } return this; } /** * 设置选择日期范围 * * @param startDate 开始时间 * @param endDate 结束时间 */ public CalendarAdapter range(Date startDate, Date endDate) { return range(startDate, endDate, true); } public CalendarAdapter range(Date startDate, Date endDate, boolean clear) { List dates = DateUtils.fillDates(startDate, endDate); return range(dates, clear); } public CalendarAdapter range(List list, boolean clear) { if (clear) { dates.clear(); } if (null != list && list.size() > 0) { dates.addAll(list); } if (notify) { refresh(); } return this; } /** * @deprecated 使用 {@link #notify(boolean)} 及 {@link #range(Date, Date, boolean)} 代替 */ @Deprecated public CalendarAdapter setRange(Date startDate, Date endDate, boolean clear, boolean notify) { List dates = DateUtils.fillDates(startDate, endDate); this.notify = notify; return range(dates, clear); } /** * @deprecated 使用 {@link #notify(boolean)} 及 {@link #range(List, boolean)} 代替 */ @Deprecated public CalendarAdapter setRange(List list, boolean clear, boolean notify) { this.notify = notify; return range(list, clear); } @SuppressLint("NotifyDataSetChanged") public void refresh() { notifyDataSetChanged(); } public void setOnCalendarSelectedListener(OnDateSelectedListener onDateSelectedListener) { this.onDateSelectedListener = onDateSelectedListener; } @NonNull @Override public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { Context context = parent.getContext(); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TextView titleView = itemViewProvider == null ? null : itemViewProvider.provideTitleView(context); if (titleView == null) { titleView = new TextView(context); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(14); titleView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); int padding = (int) (parent.getResources().getDisplayMetrics().density * 10); titleView.setPadding(padding, padding, padding, padding); } linearLayout.addView(titleView, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); MonthView monthView = itemViewProvider == null ? null : itemViewProvider.provideMonthView(context); if (monthView == null) { monthView = new MonthView(context); } monthView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.addView(monthView); return new VH(linearLayout, titleView, monthView); } @Override 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(), DATE_FORMAT)); holder.monthView.setOnDayInMonthClickListener(this); holder.monthView.setValue(MonthEntity.obtain(valid, select) .date(dates.get(position)) .singleMode(singleMode) .festivalProvider(festivalProvider) .note(selectNote), colorScheme); } @Override public int getItemCount() { return dates.size(); } public final int getDatePosition(Date date) { int size = dates.size(); if (size <= 1) { return 0; } if (date == null) { return 0; } long time = date.getTime(); if (time <= dates.get(0).getTime()) { return 0; } int lastPosition = size - 1; if (time >= dates.get(lastPosition).getTime()) { return lastPosition; } for (int i = 0; i <= lastPosition; i++) { Calendar minDate = DateUtils.calendar(dates.get(i).getTime()); minDate.set(Calendar.DAY_OF_MONTH, 1); minDate.set(Calendar.HOUR_OF_DAY, 0); minDate.set(Calendar.MINUTE, 0); minDate.set(Calendar.SECOND, 0); minDate.set(Calendar.MILLISECOND, 0); Calendar maxDate = DateUtils.calendar(dates.get(i).getTime()); maxDate.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(maxDate.getTime())); maxDate.set(Calendar.HOUR_OF_DAY, 23); maxDate.set(Calendar.MINUTE, 59); maxDate.set(Calendar.SECOND, 59); maxDate.set(Calendar.MILLISECOND, 999); if (time >= minDate.getTime().getTime() && time <= maxDate.getTime().getTime()) { return i; } } return -1; } public Date getDateValue(int position) { if (position >= 0 && position < dates.size()) { return dates.get(position); } return new Date(0); } @Override public void onCalendarDayClick(Date date) { if (null == date) { return; } if (singleMode || null == lastClickDate || lastClickDate.getTime() >= date.getTime()) { lastClickDate = date; select(date, date).refresh(); if (null != onDateSelectedListener) { onDateSelectedListener.onSingleSelected(date); } if (!singleMode && null != onDateSelectedListener) { onDateSelectedListener.onRangeSelected(date, date); } return; } select(lastClickDate, date).refresh(); if (null != onDateSelectedListener) { onDateSelectedListener.onRangeSelected(lastClickDate, date); } lastClickDate = null; } static class VH extends RecyclerView.ViewHolder { TextView titleView; MonthView monthView; VH(View itemView, TextView titleView, MonthView monthView) { super(itemView); this.titleView = titleView; this.monthView = monthView; } } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/CalendarView.java ================================================ /* * 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 android.content.Context; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.util.AttributeSet; import android.widget.GridView; import android.widget.LinearLayout; import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.PagerSnapHelper; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.calendarpicker.R; /** * 日历控件 * Created by peng on 2017/8/3. */ @SuppressWarnings("unused") public class CalendarView extends LinearLayout { private final CalendarAdapter calendarAdapter = new CalendarAdapter(); private final WeekAdapter weekAdapter = new WeekAdapter(); private final GridView weekView; private final RecyclerView bodyView; public CalendarView(Context context) { this(context, null); } public CalendarView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public CalendarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setOrientation(VERTICAL); inflate(context, R.layout.calendar_body, this); weekView = findViewById(R.id.calendar_body_week); weekView.setNumColumns(weekAdapter.getCount()); weekView.setAdapter(weekAdapter); weekView.setSelector(new ColorDrawable(Color.TRANSPARENT)); bodyView = findViewById(R.id.calendar_body_content); bodyView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); bodyView.setAdapter(calendarAdapter); } public void enablePagerSnap() { bodyView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false)); new PagerSnapHelper().attachToRecyclerView(bodyView); } public void setColorScheme(ColorScheme colorScheme) { weekAdapter.setColorScheme(colorScheme); calendarAdapter.colorScheme(colorScheme); } public final GridView getWeekView() { return weekView; } public final RecyclerView getBodyView() { return bodyView; } public final LinearLayoutManager getLayoutManager() { RecyclerView.LayoutManager layoutManager = bodyView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager) { return (LinearLayoutManager) layoutManager; } throw new IllegalArgumentException("Layout manager must instance of LinearLayoutManager"); } public final CalendarAdapter getAdapter() { return calendarAdapter; } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/ColorScheme.java ================================================ /* * 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 android.graphics.Color; import androidx.annotation.ColorInt; import java.io.Serializable; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/17 12:28 */ public class ColorScheme implements Serializable { private int weekTextColor = 0xFF343434; private int weekBackgroundColor = Color.TRANSPARENT; private int monthTitleTextColor = 0xFF343434; private int monthTitleBackgroundColor = Color.TRANSPARENT; private int monthBackgroundColor = Color.TRANSPARENT; private int monthDividerColor = Color.TRANSPARENT; private int dayNormalTextColor = 0xFF343434; private int dayInvalidTextColor = 0xFFCCCCCC; private int dayStressTextColor = 0xFFFF6600; private int daySelectTextColor = 0xFFFFFFFF; private int dayNormalBackgroundColor = Color.TRANSPARENT; private int dayInvalidBackgroundColor = Color.TRANSPARENT; private int daySelectBackgroundColor = 0xFFE75051; public ColorScheme weekTextColor(@ColorInt int color) { this.weekTextColor = color; return this; } @ColorInt public int weekTextColor() { return weekTextColor; } public ColorScheme weekBackgroundColor(@ColorInt int color) { this.weekBackgroundColor = color; return this; } @ColorInt public int weekBackgroundColor() { return weekBackgroundColor; } public ColorScheme monthTitleTextColor(@ColorInt int color) { this.monthTitleTextColor = color; return this; } @ColorInt public int monthTitleTextColor() { return monthTitleTextColor; } public ColorScheme monthTitleBackgroundColor(@ColorInt int color) { this.monthTitleBackgroundColor = color; return this; } @ColorInt public int monthTitleBackgroundColor() { return monthTitleBackgroundColor; } public ColorScheme monthBackgroundColor(@ColorInt int color) { this.monthBackgroundColor = color; return this; } @ColorInt public int monthBackgroundColor() { return monthBackgroundColor; } public ColorScheme monthDividerColor(@ColorInt int color) { this.monthDividerColor = color; return this; } @ColorInt public int monthDividerColor() { return monthDividerColor; } public ColorScheme dayNormalTextColor(@ColorInt int color) { this.dayNormalTextColor = color; return this; } @ColorInt public int dayNormalTextColor() { return dayNormalTextColor; } public ColorScheme dayInvalidTextColor(@ColorInt int color) { this.dayInvalidTextColor = color; return this; } @ColorInt public int dayInvalidTextColor() { return dayInvalidTextColor; } public ColorScheme dayStressTextColor(@ColorInt int color) { this.dayStressTextColor = color; return this; } @ColorInt public int dayStressTextColor() { return dayStressTextColor; } public ColorScheme daySelectTextColor(@ColorInt int color) { this.daySelectTextColor = color; return this; } @ColorInt public int daySelectTextColor() { return daySelectTextColor; } public ColorScheme dayNormalBackgroundColor(@ColorInt int color) { this.dayNormalBackgroundColor = color; return this; } @ColorInt public int dayNormalBackgroundColor() { return dayNormalBackgroundColor; } public ColorScheme dayInvalidBackgroundColor(@ColorInt int color) { this.dayInvalidBackgroundColor = color; return this; } @ColorInt public int dayInvalidBackgroundColor() { return dayInvalidBackgroundColor; } public ColorScheme daySelectBackgroundColor(@ColorInt int color) { this.daySelectBackgroundColor = color; return this; } @ColorInt public int daySelectBackgroundColor() { return daySelectBackgroundColor; } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/DateUtils.java ================================================ /* * 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.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; /** * Created by peng on 2017/8/2. */ public class DateUtils { public static Calendar calendar(long timeInMillis) { return calendar(new Date(timeInMillis)); } public static Calendar calendar(Date date) { Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.setTime(date); return calendar; } /** * @param date 日期 * @return 当月最大天数 */ public static int maxDaysOfMonth(Date date) { return calendar(date).getActualMaximum(Calendar.DATE); } /** * @param date 日期 * @return 当月第一天在月份表中的索引 */ public static int firstDayOfMonthIndex(Date date) { Calendar calendar = calendar(date); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.get(Calendar.DAY_OF_WEEK) - 1; } /** * 给定日期是否是今天所在的月份 * * @param date 日期 * @return 今天是当月几号 */ public static int isTodayOfMonth(Date date) { Calendar current = calendar(new Date()); Calendar calendar = calendar(date); if (diverse(current, calendar, Calendar.YEAR)) { return -1; } if (diverse(current, calendar, Calendar.MONTH)) { return -1; } return current.get(Calendar.DAY_OF_MONTH) - 1; } /** * @param calendarA 开始日历 * @param calendarB 结束日历 * @param field 字段 * @return 是否相同:不相--true,相同--false */ public static boolean diverse(Calendar calendarA, Calendar calendarB, int field) { boolean same; try { same = calendarA.get(field) == calendarB.get(field); } catch (Exception e) { same = false; } return !same; } /** * 区间内有多少个月 * * @param sDate 开始日期 * @param eDate 结束日期 * @return 月数 */ public static int months(Date sDate, Date eDate) { Calendar before = calendar(min(sDate, eDate)); Calendar after = calendar(max(sDate, eDate)); int diffYear = after.get(Calendar.YEAR) - before.get(Calendar.YEAR); int diffMonth = after.get(Calendar.MONTH) - before.get(Calendar.MONTH); return diffYear * 12 + diffMonth; } public static Date max(Date sDate, Date eDate) { return sDate.getTime() > eDate.getTime() ? sDate : eDate; } public static Date min(Date sDate, Date eDate) { return sDate.getTime() > eDate.getTime() ? eDate : sDate; } /** * 获取区间内各月的Date * * @param sDate 开始日期 * @param eDate 结束日期 * @return 区间内各月的Date */ public static List fillDates(Date sDate, Date eDate) { List dates = new ArrayList<>(); if (null == sDate || null == eDate) { dates.add(new Date()); } else { Calendar calendar = calendar(min(sDate, eDate)); int months = months(sDate, eDate); for (int i = 0; i <= months; i++) { dates.add(calendar.getTime()); calendar.add(Calendar.MONTH, 1); } } return dates; } /** * 目标月份有哪些天在区间内,返回索引值区间 * 不在范围内时返回(-1,-1) * * @param month 目标月份 * @param dateInterval 开始,结束日期区间 * @return 起始位置区间 */ public static NumInterval daysInterval(Date month, Interval dateInterval) { final NumInterval range = new NumInterval(); if (null == month || null == dateInterval) { return range; } final int maxDaysOfMonth = maxDaysOfMonth(month); Date sDay; Date eDay; //保证sDay和eDay不为空 if (null == dateInterval.left()) { Calendar safeCalendar = calendar(month); safeCalendar.set(Calendar.DAY_OF_MONTH, 1); sDay = safeCalendar.getTime(); } else { sDay = new Date(dateInterval.left().getTime()); } if (null == dateInterval.right()) { Date date = max(sDay, month); Calendar safeCalendar = calendar(date); safeCalendar.set(Calendar.DAY_OF_MONTH, maxDaysOfMonth); eDay = safeCalendar.getTime(); } else { eDay = new Date(dateInterval.right().getTime()); } //保证日期顺序 sDay = min(sDay, eDay); eDay = max(sDay, eDay); //以最小年份为基础 Calendar[] calendars = new Calendar[]{calendar(month), calendar(sDay), calendar(eDay)}; Calendar miniYearCalendar = calendars[0]; for (int i = 1; i < calendars.length; i++) { if (miniYearCalendar.get(Calendar.YEAR) > calendars[i].get(Calendar.YEAR)) { miniYearCalendar = calendars[i]; } } final long miniDate = miniYearCalendar.getTime().getTime(); long[] diffDays = new long[calendars.length]; for (int i = 0; i < calendars.length; i++) { Calendar cal = calendar(new Date(miniDate)); int diffYear = calendars[i].get(Calendar.YEAR) - cal.get(Calendar.YEAR); for (int j = 0; j < diffYear; j++) { diffDays[i] += cal.getActualMaximum(Calendar.DAY_OF_YEAR); cal.add(Calendar.YEAR, 1); } } calendars[0].set(Calendar.DAY_OF_MONTH, 1); final long dayIndex = diffDays[0] + calendars[0].get(Calendar.DAY_OF_YEAR); final long limitA = diffDays[1] + calendars[1].get(Calendar.DAY_OF_YEAR); final long limitB = diffDays[2] + calendars[2].get(Calendar.DAY_OF_YEAR); long temp; for (int i = 0; i < maxDaysOfMonth; i++) { temp = dayIndex + i; boolean contain = (temp >= limitA) && (temp <= limitB); if (!contain) { continue; } if (range.left() < 0) { range.left(i); } range.right(i); if (limitA == temp) { range.lBound(i); } if (limitB == temp) { range.rBound(i); } } return range; } /** * @param month 月份 * @param index 索引 * @return 根据月份及日期索引计算出指定日期 */ public static Date specialDayInMonth(Date month, int index) { Calendar calendar = calendar(month); calendar.set(Calendar.DAY_OF_MONTH, index + 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return calendar.getTime(); } /** * 获取某月最后一天日期 * * @param date 月份 * @return date月最后一天日期 */ public static Date getLastDayFromMonth(Date date) { Calendar calendar = calendar(date); calendar.set(Calendar.DAY_OF_MONTH, maxDaysOfMonth(date)); return calendar.getTime(); } /** * 获取指定Date一年前的某月第一天日期 * * @param date 制定日期 * @return 指定Date一年前的某月第一天日期 */ public static Date getDayYearAgo(Date date) { Calendar calendar = calendar(date); calendar.add(Calendar.MONTH, -11); calendar.set(Calendar.DAY_OF_MONTH, 0); return calendar.getTime(); } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/DayEntity.java ================================================ /* * 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.io.Serializable; import java.util.ArrayList; import java.util.List; /** * Created by peng on 2017/8/4. */ public class DayEntity implements Serializable { private static final List pools = new ArrayList<>(); @DayStatus private int status; private int value; @DayStatus private int valueStatus; private String desc; @DayStatus private int descStatus; private String note; private DayEntity() { super(); } @DayStatus public int status() { return status; } public DayEntity status(@DayStatus int status) { this.status = status; return this; } public DayEntity value(int value) { this.value = value; return this; } public String value() { return value < 0 || value > MonthEntity.MAX_DAYS_OF_MONTH ? "" : String.valueOf(value + 1); } public int intValue() { return value; } @DayStatus public int valueStatus() { return valueStatus; } public DayEntity valueStatus(@DayStatus int valueStatus) { this.valueStatus = valueStatus; return this; } public String desc() { return null == desc ? "" : desc; } public DayEntity desc(String desc) { this.desc = desc; return this; } @DayStatus public int descStatus() { return descStatus; } public DayEntity descStatus(@DayStatus int descStatus) { this.descStatus = descStatus; return this; } public String note() { return null == note ? "" : note; } public DayEntity note(String note) { this.note = note; return this; } public void recycle() { if (!pools.contains(this)) { this.status = DayStatus.NORMAL; this.value = -1; this.valueStatus = DayStatus.NORMAL; this.descStatus = DayStatus.NORMAL; this.desc = ""; pools.add(this); } } public static DayEntity obtain(@DayStatus int status, int value, String desc) { DayEntity entity = 0 == pools.size() ? new DayEntity() : pools.remove(0); entity.status = status; entity.value = value; entity.valueStatus = status; entity.descStatus = status; entity.desc = desc; return entity; } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/DayStatus.java ================================================ /* * 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.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Created by peng on 2017/8/2. */ @Retention(RetentionPolicy.SOURCE) public @interface DayStatus { //正常 int NORMAL = 0; //不可用 int INVALID = 1; //范围内 int RANGE = 2; //左边界 int BOUND_L = 3; //单选 int BOUND_M = 4; //右边界 int BOUND_R = 5; //强调 int STRESS = 6; } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/DayView.java ================================================ /* * 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 android.content.Context; import android.os.Build; import android.util.AttributeSet; import android.view.Gravity; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.graphics.ColorUtils; /** * 日期控件 * Created by peng on 2017/8/2. */ public final class DayView extends LinearLayout { private TextView tvDesc; private TextView tvDay; private DayEntity entity; public DayView(@NonNull Context context) { super(context); initialize(context); } public DayView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); initialize(context); } public DayView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initialize(context); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public DayView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initialize(context); } private void initialize(Context context) { setOrientation(VERTICAL); setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); int padding = (int) (getResources().getDisplayMetrics().density * 3); setPadding(0, padding, 0, padding); tvDay = new TextView(context); tvDay.setGravity(Gravity.CENTER); tvDay.setTextSize(15); addView(tvDay, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); tvDesc = new TextView(context); tvDesc.setGravity(Gravity.CENTER); tvDesc.setTextSize(12); addView(tvDesc, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } public void setValue(DayEntity entity, ColorScheme scheme) { if (null != getValue()) { getValue().recycle(); } this.entity = entity; //内容 tvDay.setText(entity.value()); setTextStatusColor(tvDay, entity.valueStatus(), scheme); //描述 tvDesc.setText(entity.desc()); setTextStatusColor(tvDesc, entity.descStatus(), scheme); //背景 setBackgroundStatus(entity, scheme); } public DayEntity getValue() { return entity; } private void setTextStatusColor(TextView tv, @DayStatus int status, ColorScheme scheme) { switch (status) { //正常 case DayStatus.NORMAL: tv.setTextColor(scheme.dayNormalTextColor()); break; //不可用 case DayStatus.INVALID: tv.setTextColor(scheme.dayInvalidTextColor()); break; //强调 case DayStatus.STRESS: tv.setTextColor(scheme.dayStressTextColor()); break; //范围内、左边界 case DayStatus.RANGE: case DayStatus.BOUND_L: case DayStatus.BOUND_M: case DayStatus.BOUND_R: tv.setTextColor(scheme.daySelectTextColor()); break; default: break; } } private void setBackgroundStatus(DayEntity entity, ColorScheme scheme) { switch (entity.status()) { //正常、强调 case DayStatus.NORMAL: case DayStatus.STRESS: setBackgroundColor(scheme.dayNormalBackgroundColor()); setEnabled(true); break; //不可用 case DayStatus.INVALID: tvDay.setTextColor(scheme.dayInvalidTextColor()); setBackgroundColor(scheme.dayInvalidBackgroundColor()); setEnabled(false); break; //范围内 case DayStatus.RANGE: setBackgroundColor(ColorUtils.setAlphaComponent(scheme.daySelectBackgroundColor(), 200)); setEnabled(true); break; //左边界、单选、右边界 case DayStatus.BOUND_L: case DayStatus.BOUND_M: case DayStatus.BOUND_R: tvDay.setTextColor(scheme.daySelectTextColor()); tvDesc.setTextColor(scheme.daySelectTextColor()); tvDesc.setText(entity.note()); setBackgroundColor(scheme.daySelectBackgroundColor()); break; default: break; } } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/FestivalProvider.java ================================================ /* * 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); } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/Interval.java ================================================ /* * 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; /** * Created by peng on 2017/8/4. */ public class Interval { private int lBound; private T left; private int rBound; private T right; public int lBound() { return lBound; } public void lBound(int lBound) { this.lBound = lBound; } public T left() { return left; } public Interval left(T left) { this.left = left; return this; } public int rBound() { return rBound; } public void rBound(int rBound) { this.rBound = rBound; } public T right() { return right; } public Interval right(T right) { this.right = right; return this; } public boolean bothNoNull() { return null != left() && null != right(); } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/ItemViewProvider.java ================================================ /* * 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 android.content.Context; import android.widget.TextView; /** * @author liyuj * @since 2022/1/5 16:03 */ public interface ItemViewProvider { TextView provideTitleView(Context context); MonthView provideMonthView(Context context); } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthEntity.java ================================================ /* * 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.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Locale; /** * Created by peng on 2017/8/4. */ public class MonthEntity implements Serializable { 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; 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); entity.valid = valid; entity.select = select; return entity; } private MonthEntity() { super(); } public Date date() { return date; } public MonthEntity date(Date date) { this.date = date; return this; } public Interval valid() { return valid; } public MonthEntity valid(Interval valid) { this.valid = valid; return this; } public Interval select() { return select; } public MonthEntity select(Interval select) { this.select = select; return this; } public MonthEntity singleMode(boolean singleMode) { this.singleMode = singleMode; return this; } 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; } public MonthEntity note(Interval note) { this.note = note; return this; } public void recycle() { if (!pools.contains(this)) { date = null; valid = null; select = null; note = null; pools.add(this); } } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/MonthView.java ================================================ /* * 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 android.content.Context; import android.os.Build; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import java.util.Date; /** * 月份控件 * Created by peng on 2017/8/2. */ public class MonthView extends ViewGroup { private ColorScheme colorScheme = new ColorScheme(); private final DayView[] dayViews = new DayView[MonthEntity.MAX_DAYS_OF_MONTH]; private final View[] dividerViews = new View[MonthEntity.MAX_HORIZONTAL_LINES]; private int dividerHeight; private DividerLayoutControl dividerLayoutControl; private MonthEntity monthEntity; private int isTodayOfMonth = -1; //location private int position = 0; private int offset = 0; //child width and height private int childWidth = 0; private int childHeight = 0; private OnDateClickListener onDayInMonthClickListener; public MonthView(Context context) { super(context); initialize(context); } public MonthView(Context context, AttributeSet attrs) { super(context, attrs); initialize(context); } public MonthView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initialize(context); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public MonthView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initialize(context); } private void initialize(Context context) { for (int i = 0, m = dayViews.length; i < m; i++) { dayViews[i] = new DayView(context); addView(dayViews[i]); } dividerHeight = (int) (getResources().getDisplayMetrics().density * 0.5f); for (int j = 0, n = dividerViews.length; j < n; j++) { View view = new View(getContext()); addView(view); dividerViews[j] = view; } dividerLayoutControl = new DividerLayoutControl(dividerViews); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (null == getValue()) { return; } int totalWidth = MeasureSpec.getSize(widthMeasureSpec); dayViews[0].measure(widthMeasureSpec, heightMeasureSpec); int childrenHeight = 0; //calc need rows int amount = position + offset; int dayRows = (amount / MonthEntity.WEEK_DAYS) + (((amount % MonthEntity.WEEK_DAYS) != 0) ? 1 : 0); //measure container childrenHeight += dayViews[0].getMeasuredHeight() * dayRows; childrenHeight += (dayRows) * dividerHeight; setMeasuredDimension(totalWidth, childrenHeight); //measure DayViews childWidth = totalWidth / MonthEntity.WEEK_DAYS; childHeight = dayViews[0].getMeasuredHeight(); int childWidthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY); int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY); for (DayView dayView : dayViews) { dayView.measure(childWidthSpec, childHeightSpec); } //measure horizontal lines for (View line : dividerViews) { line.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(dividerHeight, MeasureSpec.EXACTLY)); } } @Override protected void onLayout(boolean b, int left, int top, int right, int bottom) { if (null == getValue()) { return; } int offsetX = 0, offsetY = 0; for (int i = 0; i < position; i++) { offsetX += childWidth; } int childBottom = offsetY + childHeight; boolean lastIsRightBound = false;//上一个是否是右边界 NumInterval validRange = DateUtils.daysInterval(monthEntity.date(), monthEntity.valid()); NumInterval selectRange = null; if (monthEntity.select().bothNoNull()) { selectRange = DateUtils.daysInterval(monthEntity.date(), monthEntity.select()); } for (int index = 0, move = position + 1; index < dayViews.length; index++, move++) { boolean rightBound = move % MonthEntity.WEEK_DAYS == 0; DayEntity dayEntity; if (index < offset) { //set state boolean isToday = index == isTodayOfMonth; dayEntity = DayEntity.obtain(DayStatus.NORMAL, index, isToday ? MonthEntity.STR_TODAY : toDayDesc(index)) .valueStatus((lastIsRightBound || rightBound) ? DayStatus.STRESS : DayStatus.NORMAL) .descStatus(isToday ? DayStatus.STRESS : DayStatus.NORMAL); //valid if (validRange.contain(index)) { if (null != selectRange && selectRange.contain(index)) { if (index == selectRange.lBound()) { if (monthEntity.singleMode()) { dayEntity.status(DayStatus.BOUND_M).note(monthEntity.note().left()); } else { dayEntity.status(DayStatus.BOUND_L).note(monthEntity.note().left()); } } else if (index == selectRange.rBound()) { dayEntity.status(DayStatus.BOUND_R).note(monthEntity.note().right()); } else { dayEntity.status(DayStatus.RANGE); dayEntity.valueStatus(DayStatus.RANGE); dayEntity.descStatus(DayStatus.RANGE); } } } else { //不响应选择事件 dayEntity.status(DayStatus.INVALID) .valueStatus(DayStatus.INVALID) .descStatus(DayStatus.INVALID); } dayViews[index].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!(v instanceof DayView)) { return; } if (null == onDayInMonthClickListener) { return; } try { DayEntity entity = ((DayView) v).getValue(); Date dayDate = DateUtils.specialDayInMonth(monthEntity.date(), entity.intValue()); onDayInMonthClickListener.onCalendarDayClick(dayDate); } catch (Exception e) { e.printStackTrace(); } } }); } else { dayEntity = DayEntity.obtain(DayStatus.INVALID, -1, ""); dayViews[index].setOnClickListener(null); } dayViews[index].setValue(dayEntity, colorScheme); dayViews[index].layout(offsetX, offsetY, offsetX + childWidth, childBottom); if (rightBound) { offsetX = 0; offsetY += childHeight; //draw horizontal line offsetY = dividerLayoutControl.layout(offsetY); childBottom = offsetY + childHeight; } else { offsetX += childWidth; } lastIsRightBound = rightBound; } dividerLayoutControl.layout(offsetY + childHeight); } @NonNull protected String toDayDesc(int index) { FestivalProvider festivalProvider = monthEntity.festivalProvider(); if (festivalProvider == null) { return ""; } Date date = DateUtils.specialDayInMonth(monthEntity.date(), index); String festival = festivalProvider.provideText(date); if (festival == null) { festival = ""; } return festival; } public void setValue(@NonNull MonthEntity entity, @NonNull ColorScheme colorScheme) { if (null != monthEntity) { monthEntity.recycle(); } this.monthEntity = entity; position = DateUtils.firstDayOfMonthIndex(entity.date()); offset = DateUtils.maxDaysOfMonth(entity.date()); isTodayOfMonth = DateUtils.isTodayOfMonth(entity.date()); setBackgroundColor(colorScheme.monthBackgroundColor()); for (View view : dividerViews) { view.setBackgroundColor(colorScheme.monthDividerColor()); } this.colorScheme = colorScheme; requestLayout(); } public MonthEntity getValue() { return monthEntity; } public void setOnDayInMonthClickListener(OnDateClickListener listener) { onDayInMonthClickListener = listener; } /** * 分割线布局控制器 */ private static class DividerLayoutControl { private final int width; private final int height; private final View[] view; private int count = 0; DividerLayoutControl(@NonNull View[] views) { this.view = views; width = views[0].getMeasuredWidth(); height = views[0].getMeasuredHeight(); } public int layout(int offsetY) { if (count >= view.length) { return offsetY; } int bottom = offsetY + height; view[count].layout(0, offsetY, width, bottom); count += 1; return bottom; } } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/NumInterval.java ================================================ /* * 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; /** * Created by peng on 2017/8/4. */ public class NumInterval extends Interval { public NumInterval() { left(-1); lBound(-1); right(-1); rBound(-1); } public boolean contain(int index) { return index >= left() && index <= right(); } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/OnDateClickListener.java ================================================ /* * 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; /** * Created by peng on 2017/8/4. */ public interface OnDateClickListener { void onCalendarDayClick(Date date); } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/OnDateSelectedListener.java ================================================ /* * 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 androidx.annotation.NonNull; import java.util.Date; /** * Created by peng on 2017/8/4. */ public interface OnDateSelectedListener { void onSingleSelected(@NonNull Date date); void onRangeSelected(@NonNull Date start, @NonNull Date end); } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/TimeUtils.java ================================================ /* * 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 androidx.annotation.NonNull; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Locale; import java.util.Map; /** * 时间工具 */ public class TimeUtils { private final static Map dateMap = new HashMap<>(); private static void ensureDateFormatMap(@NonNull String format) { if (!dateMap.containsKey(format)) { try { SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.getDefault()); dateMap.put(format, sdf); } catch (Exception e) { e.printStackTrace(); } } } public static Date date(String dateText, @NonNull String format) throws Exception { ensureDateFormatMap(format); if (dateMap.containsKey(format)) { SimpleDateFormat sdf = dateMap.get(format); if (sdf != null) { return sdf.parse(dateText); } } return null; } public static String dateText(long date, @NonNull String format) { String value = ""; ensureDateFormatMap(format); if (dateMap.containsKey(format)) { SimpleDateFormat sdf = dateMap.get(format); if (sdf != null) { value = sdf.format(new Date(date)); } } return value; } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/core/WeekAdapter.java ================================================ /* * 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 android.graphics.Typeface; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import java.util.Locale; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/17 14:36 */ public class WeekAdapter extends BaseAdapter { public static String[] DATA = new String[]{ "日", "一", "二", "三", "四", "五", "六" }; 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(); } this.colorScheme = colorScheme; notifyDataSetChanged(); } @Override public int getCount() { return DATA.length; } @Override public Object getItem(int position) { return DATA[position]; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { TextView textView = new TextView(parent.getContext()); textView.setGravity(Gravity.CENTER); textView.setTextSize(15); textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); int padding = (int) (parent.getResources().getDisplayMetrics().density * 10); textView.setPadding(0, padding, 0, padding); textView.setText(DATA[position]); textView.setBackgroundColor(colorScheme.weekBackgroundColor()); textView.setTextColor(colorScheme.weekTextColor()); return textView; } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/listener/OnPageChangeCallback.java ================================================ package com.github.gzuliyujiang.calendarpicker.listener; import androidx.annotation.Px; public abstract class OnPageChangeCallback { /** * This method will be invoked when the current page is scrolled, either as part * of a programmatically initiated smooth scroll or a user initiated touch scroll. * * @param position Position index of the first page currently being displayed. * Page position+1 will be visible if positionOffset is nonzero. * @param positionOffset Value from [0, 1) indicating the offset from the page at position. * @param positionOffsetPixels Value in pixels indicating the offset from position. */ public void onPageScrolled(int position, float positionOffset, @Px int positionOffsetPixels) { } /** * This method will be invoked when a new page becomes selected. Animation is not * necessarily complete. * * @param position Position index of the new selected page. */ public void onPageSelected(int position) { } /** * Called when the scroll state changes. Useful for discovering when the user begins * dragging, when a fake drag is started, when the pager is automatically settling to the * current page, or when it is fully stopped/idle. {@code state} can be one of {@link */ public void onPageScrollStateChanged(int state) { } } ================================================ FILE: CalendarPicker/src/main/java/com/github/gzuliyujiang/calendarpicker/listener/ScrollEventAdapter.java ================================================ /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.github.gzuliyujiang.calendarpicker.listener; import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING; import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE; import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_SETTLING; import static java.lang.annotation.RetentionPolicy.SOURCE; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.MarginLayoutParams; import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.core.view.ViewCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import java.lang.annotation.Retention; import java.util.Locale; /** * Recy页面滑动的监控 *

* 改自ViewPager2 *

*/ public final class ScrollEventAdapter extends RecyclerView.OnScrollListener { @Retention(SOURCE) @IntDef({STATE_IDLE, STATE_IN_PROGRESS_MANUAL_DRAG, STATE_IN_PROGRESS_SMOOTH_SCROLL, STATE_IN_PROGRESS_IMMEDIATE_SCROLL, STATE_IN_PROGRESS_FAKE_DRAG}) private @interface AdapterState { } private static final int STATE_IDLE = 0; private static final int STATE_IN_PROGRESS_MANUAL_DRAG = 1; private static final int STATE_IN_PROGRESS_SMOOTH_SCROLL = 2; private static final int STATE_IN_PROGRESS_IMMEDIATE_SCROLL = 3; private static final int STATE_IN_PROGRESS_FAKE_DRAG = 4; private static final int NO_POSITION = -1; private OnPageChangeCallback mCallback; private final @NonNull RecyclerView mRecyclerView; private final @NonNull LinearLayoutManager mLayoutManager; // state related fields private @AdapterState int mAdapterState; private int mScrollState; private ScrollEventValues mScrollValues; private int mDragStartPosition; private int mTarget; private boolean mDispatchSelected; private boolean mScrollHappened; private boolean mDataSetChangeHappened; private boolean mFakeDragging; public ScrollEventAdapter(@NonNull RecyclerView recyclerView) { mRecyclerView = recyclerView; if (mRecyclerView.getLayoutManager() instanceof LinearLayoutManager) { mLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager(); } else { throw new RuntimeException("need RecyclerView use LinearLayoutManager!!!!!!!!!!!!"); } mScrollValues = new ScrollEventValues(); resetState(); } private void resetState() { mAdapterState = STATE_IDLE; mScrollState = SCROLL_STATE_IDLE; mScrollValues.reset(); mDragStartPosition = NO_POSITION; mTarget = NO_POSITION; mDispatchSelected = false; mScrollHappened = false; mFakeDragging = false; mDataSetChangeHappened = false; } /** * This method only deals with some cases of {@link AdapterState} transitions. The rest of * the state transition implementation is in the {@link #onScrolled} method. */ @Override public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { // User started a drag (not dragging -> dragging) if ((mAdapterState != STATE_IN_PROGRESS_MANUAL_DRAG || mScrollState != SCROLL_STATE_DRAGGING) && newState == SCROLL_STATE_DRAGGING) { startDrag(false); return; } // Drag is released, RecyclerView is snapping to page (dragging -> settling) // Note that mAdapterState is not updated, to remember we were dragging when settling if (isInAnyDraggingState() && newState == SCROLL_STATE_SETTLING) { // Only go through the settling phase if the drag actually moved the page if (mScrollHappened) { dispatchStateChanged(SCROLL_STATE_SETTLING); // Determine target page and dispatch onPageSelected on next scroll event mDispatchSelected = true; } return; } // Drag is finished (dragging || settling -> idle) if (isInAnyDraggingState() && newState == SCROLL_STATE_IDLE) { boolean dispatchIdle = false; updateScrollEventValues(); if (!mScrollHappened) { // Pages didn't move during drag, so either we're at the start or end of the list, // or there are no pages at all. // In the first case, ViewPager's contract requires at least one scroll event. // In the second case, don't send that scroll event if (mScrollValues.mPosition != RecyclerView.NO_POSITION) { dispatchScrolled(mScrollValues.mPosition, 0f, 0); } dispatchIdle = true; } else if (mScrollValues.mOffsetPx == 0) { // Normally we dispatch the selected page and go to idle in onScrolled when // mOffsetPx == 0, but in this case the drag was still ongoing when onScrolled was // called, so that didn't happen. And since mOffsetPx == 0, there will be no further // scroll events, so fire the onPageSelected event and go to idle now. // Note that if we _did_ go to idle in that last onScrolled event, this code will // not be executed because mAdapterState has been reset to STATE_IDLE. dispatchIdle = true; if (mDragStartPosition != mScrollValues.mPosition) { dispatchSelected(mScrollValues.mPosition); } } if (dispatchIdle) { // Normally idle is fired in last onScrolled call, but either onScrolled was never // called, or we were still dragging when the last onScrolled was called dispatchStateChanged(SCROLL_STATE_IDLE); resetState(); } } if (mAdapterState == STATE_IN_PROGRESS_SMOOTH_SCROLL && newState == SCROLL_STATE_IDLE && mDataSetChangeHappened) { updateScrollEventValues(); if (mScrollValues.mOffsetPx == 0) { if (mTarget != mScrollValues.mPosition) { dispatchSelected( mScrollValues.mPosition == NO_POSITION ? 0 : mScrollValues.mPosition); } dispatchStateChanged(SCROLL_STATE_IDLE); resetState(); } } } /** * This method only deals with some cases of {@link AdapterState} transitions. The rest of * the state transition implementation is in the {@link #onScrollStateChanged} method. */ @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { mScrollHappened = true; updateScrollEventValues(); if (mDispatchSelected) { // Drag started settling, need to calculate target page and dispatch onPageSelected now mDispatchSelected = false; boolean scrollingForward = dy > 0 || (dy == 0 && dx < 0 == (mLayoutManager.getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL)); // "&& values.mOffsetPx != 0": filters special case where we're scrolling forward and // the first scroll event after settling already got us at the target mTarget = scrollingForward && mScrollValues.mOffsetPx != 0 ? mScrollValues.mPosition + 1 : mScrollValues.mPosition; if (mDragStartPosition != mTarget) { dispatchSelected(mTarget); } } else if (mAdapterState == STATE_IDLE) { // onScrolled while IDLE means RV has just been populated after an adapter has been set. // Contract requires us to fire onPageSelected as well. int position = mScrollValues.mPosition; // Contract forbids us to send position = -1 though dispatchSelected(position == NO_POSITION ? 0 : position); } // If position = -1, there are no items. Contract says to send position = 0 instead. dispatchScrolled(mScrollValues.mPosition == NO_POSITION ? 0 : mScrollValues.mPosition, mScrollValues.mOffset, mScrollValues.mOffsetPx); // Dispatch idle in onScrolled instead of in onScrollStateChanged because RecyclerView // doesn't send IDLE event when using setCurrentItem(x, false) if ((mScrollValues.mPosition == mTarget || mTarget == NO_POSITION) && mScrollValues.mOffsetPx == 0 && !(mScrollState == SCROLL_STATE_DRAGGING)) { // When the target page is reached and the user is not dragging anymore, we're settled, // so go to idle. // Special case and a bit of a hack when mTarget == NO_POSITION: RecyclerView is being // initialized and fires a single scroll event. This flags mScrollHappened, so we need // to reset our state. However, we don't want to dispatch idle. But that won't happen; // because we were already idle. dispatchStateChanged(SCROLL_STATE_IDLE); resetState(); } } /** * Calculates the current position and the offset (as a percentage and in pixels) of that * position from the center. */ private void updateScrollEventValues() { ScrollEventValues values = mScrollValues; values.mPosition = mLayoutManager.findFirstVisibleItemPosition(); if (values.mPosition == RecyclerView.NO_POSITION) { values.reset(); return; } View firstVisibleView = mLayoutManager.findViewByPosition(values.mPosition); if (firstVisibleView == null) { values.reset(); return; } int leftDecorations = mLayoutManager.getLeftDecorationWidth(firstVisibleView); int rightDecorations = mLayoutManager.getRightDecorationWidth(firstVisibleView); int topDecorations = mLayoutManager.getTopDecorationHeight(firstVisibleView); int bottomDecorations = mLayoutManager.getBottomDecorationHeight(firstVisibleView); LayoutParams params = firstVisibleView.getLayoutParams(); if (params instanceof MarginLayoutParams) { MarginLayoutParams margin = (MarginLayoutParams) params; leftDecorations += margin.leftMargin; rightDecorations += margin.rightMargin; topDecorations += margin.topMargin; bottomDecorations += margin.bottomMargin; } int decoratedHeight = firstVisibleView.getHeight() + topDecorations + bottomDecorations; int decoratedWidth = firstVisibleView.getWidth() + leftDecorations + rightDecorations; boolean isHorizontal = mLayoutManager.getOrientation() == RecyclerView.HORIZONTAL; int start, sizePx; if (isHorizontal) { sizePx = decoratedWidth; start = firstVisibleView.getLeft() - leftDecorations - mRecyclerView.getPaddingLeft(); if (mLayoutManager.getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL) { start = -start; } } else { sizePx = decoratedHeight; start = firstVisibleView.getTop() - topDecorations - mRecyclerView.getPaddingTop(); } values.mOffsetPx = -start; if (values.mOffsetPx < 0) { /* // We're in an error state. Figure out if this might have been caused // by animateLayoutChanges and throw a descriptive exception if so if (new AnimateLayoutChangeDetector(mLayoutManager).mayHaveInterferingAnimations()) { throw new IllegalStateException("Page(s) contain a ViewGroup with a " + "LayoutTransition (or animateLayoutChanges=\"true\"), which interferes " + "with the scrolling animation. Make sure to call getLayoutTransition()" + ".setAnimateParentHierarchy(false) on all ViewGroups with a " + "LayoutTransition before an animation is started."); }*/ // Throw a generic exception otherwise throw new IllegalStateException(String.format(Locale.US, "Page can only be offset by a " + "positive amount, not by %d", values.mOffsetPx)); } values.mOffset = sizePx == 0 ? 0 : (float) values.mOffsetPx / sizePx; } private void startDrag(boolean isFakeDrag) { mFakeDragging = isFakeDrag; mAdapterState = isFakeDrag ? STATE_IN_PROGRESS_FAKE_DRAG : STATE_IN_PROGRESS_MANUAL_DRAG; if (mTarget != NO_POSITION) { // Target was set means we were settling to that target // Update "drag start page" to reflect the page that ViewPager2 thinks it is at mDragStartPosition = mTarget; // Reset target because drags have no target until released mTarget = NO_POSITION; } else if (mDragStartPosition == NO_POSITION) { // ViewPager2 was at rest, set "drag start page" to current page mDragStartPosition = getPosition(); } dispatchStateChanged(SCROLL_STATE_DRAGGING); } void notifyDataSetChangeHappened() { mDataSetChangeHappened = true; } /** * Let the adapter know a programmatic scroll was initiated. */ void notifyProgrammaticScroll(int target, boolean smooth) { mAdapterState = smooth ? STATE_IN_PROGRESS_SMOOTH_SCROLL : STATE_IN_PROGRESS_IMMEDIATE_SCROLL; // mFakeDragging is true when a fake drag is interrupted by an a11y command // set it to false so endFakeDrag won't fling the RecyclerView mFakeDragging = false; boolean hasNewTarget = mTarget != target; mTarget = target; dispatchStateChanged(SCROLL_STATE_SETTLING); if (hasNewTarget) { dispatchSelected(target); } } /** * Let the adapter know that a fake drag has started. */ void notifyBeginFakeDrag() { mAdapterState = STATE_IN_PROGRESS_FAKE_DRAG; startDrag(true); } /** * Let the adapter know that a fake drag has ended. */ void notifyEndFakeDrag() { if (isDragging() && !mFakeDragging) { // Real drag has already taken over, no need to post process the fake drag return; } mFakeDragging = false; updateScrollEventValues(); if (mScrollValues.mOffsetPx == 0) { // We're snapped, so dispatch an IDLE event if (mScrollValues.mPosition != mDragStartPosition) { dispatchSelected(mScrollValues.mPosition); } dispatchStateChanged(SCROLL_STATE_IDLE); resetState(); } else { // We're not snapped, so dispatch a SETTLING event dispatchStateChanged(SCROLL_STATE_SETTLING); } } public void setOnPageChangeCallback(OnPageChangeCallback callback) { mCallback = callback; } int getScrollState() { return mScrollState; } /** * @return {@code true} if there is no known scroll in progress */ boolean isIdle() { return mScrollState == SCROLL_STATE_IDLE; } /** * @return {@code true} if the ViewPager2 is being dragged. Returns {@code false} from the * moment the ViewPager2 starts settling or goes idle. */ boolean isDragging() { return mScrollState == SCROLL_STATE_DRAGGING; } boolean isFakeDragging() { return mFakeDragging; } /** * Checks if the adapter state (not the scroll state) is in the manual or fake dragging state. * * @return {@code true} if {@link #mAdapterState} is either {@link * #STATE_IN_PROGRESS_MANUAL_DRAG} or {@link #STATE_IN_PROGRESS_FAKE_DRAG} */ private boolean isInAnyDraggingState() { return mAdapterState == STATE_IN_PROGRESS_MANUAL_DRAG || mAdapterState == STATE_IN_PROGRESS_FAKE_DRAG; } /** * Calculates the scroll position of the currently visible item of the ViewPager relative to its * width. Calculated by adding the fraction by which the first visible item is off screen to its * adapter position. E.g., if the ViewPager is currently scrolling from the second to the third * page, the returned value will be between 1 and 2. Thus, non-integral values mean that the * the ViewPager is settling towards its {ViewPager2#getCurrentItem() current item}, or * the user may be dragging it. * * @return The current scroll position of the ViewPager, relative to its width */ double getRelativeScrollPosition() { updateScrollEventValues(); return mScrollValues.mPosition + (double) mScrollValues.mOffset; } private void dispatchStateChanged(int state) { // Callback contract for immediate-scroll requires not having state change notifications, // but only when there was no smooth scroll in progress. // By putting a suppress statement in here (rather than next to dispatch calls) we are // simplifying the code of the class and enforcing the contract in one place. if (mAdapterState == STATE_IN_PROGRESS_IMMEDIATE_SCROLL && mScrollState == SCROLL_STATE_IDLE) { return; } if (mScrollState == state) { return; } mScrollState = state; if (mCallback != null) { mCallback.onPageScrollStateChanged(state); } } private void dispatchSelected(int target) { if (mCallback != null) { mCallback.onPageSelected(target); } } private void dispatchScrolled(int position, float offset, int offsetPx) { if (mCallback != null) { mCallback.onPageScrolled(position, offset, offsetPx); } } private int getPosition() { return mLayoutManager.findFirstVisibleItemPosition(); } private static final class ScrollEventValues { int mPosition; float mOffset; int mOffsetPx; // to avoid a synthetic accessor ScrollEventValues() { } void reset() { mPosition = RecyclerView.NO_POSITION; mOffset = 0f; mOffsetPx = 0; } } } ================================================ FILE: CalendarPicker/src/main/res/layout/calendar_body.xml ================================================ ================================================ FILE: ChangeLog.md ================================================ # 更新日志 ## 4.1.12 - 2023.07.22 - 避免内存泄露,参阅 [issues#337](https://github.com/gzu-liyujiang/AndroidPicker/issues/337) 。 - 地址选择器内置的省市区数据更新(2022版)。 ## 4.1.11 - 2022.11.09 - Fix [issues#322](https://github.com/gzu-liyujiang/AndroidPicker/issues/322) 。 ## 4.1.10 - 2022.11.04 - Fix [issues#324](https://github.com/gzu-liyujiang/AndroidPicker/issues/324) 。 - Opt [issues#294](https://github.com/gzu-liyujiang/AndroidPicker/issues/294) [issues#296](https://github.com/gzu-liyujiang/AndroidPicker/issues/296) 。 - `XXXPicker`和`DialogFragment`结合使用示例。 ## 4.1.9 - 2022.08.31 - Fix [issues#292](https://github.com/gzu-liyujiang/AndroidPicker/issues/292) 。 - Fix [issues#290](https://github.com/gzu-liyujiang/AndroidPicker/issues/290) 。 - 增加 API 说明文档。 ## 4.1.8 - 2022.07.12 - Fix [issues#313](https://github.com/gzu-liyujiang/AndroidPicker/issues/313) 。 - Fix [issues#304](https://github.com/gzu-liyujiang/AndroidPicker/issues/304) 。 - Fix `setStyle`只能在其他设置项之前调用,否则会导致其他设置项失效。 - Fix [issues#293](https://github.com/gzu-liyujiang/AndroidPicker/issues/293) 。 ## 4.1.7 - 2022.01.21 - 添加可直接安卓体验的 demo.apk ,参阅 [gitee#note_7765234](https://gitee.com/li_yu_jiang/AndroidPicker#note_7765234)。 - 修复时间选择器未来小时数计算错误问题。 - 日历选择器支持启用左右翻页,参阅 [issues#288](https://github.com/gzu-liyujiang/AndroidPicker/issues/288) 。 - 时间选择器上午下午联动优化,参阅 [issues#284](https://github.com/gzu-liyujiang/AndroidPicker/issues/284) 。 ## 4.1.6 - 2021.12.20 - 修复滚轮选择器部分XML属性设置无效问题,参阅 [issues#281](https://github.com/gzu-liyujiang/AndroidPicker/issues/281); - 修复滚轮选择器设置了选中项文字加大加粗时滑动会导致其他条目错位问题,参阅 [issues#279](https://github.com/gzu-liyujiang/AndroidPicker/issues/279); ## 4.1.5 - 2021.12.05 - 修复日期时间选择器未来日期时间计算错误问题,参阅 [issues#276](https://github.com/gzu-liyujiang/AndroidPicker/issues/276); - 修复滚轮无法设置白色背景及选中项加粗属性可能无效问题,参阅 [issues#274](https://github.com/gzu-liyujiang/AndroidPicker/issues/274) [issues#268](https://github.com/gzu-liyujiang/AndroidPicker/issues/268); - 日历日期选择器范围选择允许选择单个日期,参阅 [issues#271](https://github.com/gzu-liyujiang/AndroidPicker/issues/271); ## 4.1.4 - 2021.11.16 - 时间选择器支持设置时分秒间隔,参阅 [issues#270](https://github.com/gzu-liyujiang/AndroidPicker/issues/270); - 修复滚轮选择器设置选中项文字加大加粗可能导致错乱问题(注:建议通过`setStyle`定制样式设置文字加大,若通过`setSelectedTextSize`设置,该解决方案会导致选择器展示时跳动一下); - 代码精简,移除`declare-styleable`冗余; ## 4.1.3 - 2021.11.07 - 滚轮选择器条目文字过长截取优化; - 日期时间选择器支持滚动联动不重置开关; - 滚轮选择器条目滚动展示效果优化; ## 4.1.2 - 2021.11.01 - 修复 Android 7.x 上滚轮选择器选中项重叠问题; ## 4.1.1 - 2021.10.28 - 滚轮选择器选中项文字支持加大加粗; - 部分细节优化,部分效果图更新; ## 4.1.0 - 2021.10.28 - 支持滚轮选择器选中项设置圆角纯色背景; - 所以选择器文本国际化,内置支持中文及英文; - 手机号码前缀选择器数据完善,支持全球的国家及地区; - 车牌、星座及性别等选择器调整,民族、星座及性别等默认值设置优化; - 日历选择器支持自定义节日文本; ## 4.0.1 - 2021.09.26 - 优化选择器标题设置,避免设置不生效问题; ## 4.0.0 - 2021.09.18 - 支持设置弹窗样式,内置四种弹窗模式,支持全局弹窗配色,效果请运行Demo; - 日历日期选择器重构,日历默认选中项展示到当前可见位置,Demo日历日期选择器自定义配色示例; - 滚轮选择器滚动变化监听器优化,Demo滚轮选择器实时滚动变化监听示例; - 二三级联动选择器默认值设置优化; - 文件目录选择器优化及界面调整; - 颜色选择器优化及界面调整; - 其他已知的小缺陷修复及代码优化; ## 3.1.2 - 2021.09.13 - 选择器弹窗效果优化,支持启用顶部圆角背景; - 修正联动选择器当第二三级数据为空时滑动一下会导致滑动失效问题,参阅 [issues#263](https://github.com/gzu-liyujiang/AndroidPicker/issues/263); - 日历日期选择器默认选中项设置优化,参阅 [CSDN#comments_18122565](https://blog.csdn.net/waplyj/article/details/117857191#comments_18122565); ## 3.1.1 - 2021.08.31 - 图片选择器增加自定义文件类型选择及取消回调; - 默认值选中设置优化; - 修复日历日期选择器月份可能缺失问题,参阅 [issues#262](https://github.com/gzu-liyujiang/AndroidPicker/issues/262); - 日期时间选择器联动滚动优化; ## 3.1.0 - 2021.07.30 - 新增图片选择器(相机+相册+裁剪),可用于头像选择裁剪; - 修复个别已知的可能的异常; - 改进12小时制的上下午选择,参阅 [252#issuecomment-888115423](https://github.com/gzu-liyujiang/AndroidPicker/issues/252#issuecomment-888115423); - 民族选择器支持按民族代码、民族中文名及罗马拼写设置默认值; ## 3.0.8 - 2021.07.21 - 联动/日期/时间选择器有滚轮在滑动中时不允许另外的滚轮滑动,参阅 [issues#251](https://github.com/gzu-liyujiang/AndroidPicker/issues/251); - 修复日期/时间选择器模式设置可能不生效问题; - 修复时间选择器12小时制时间显示不正确问题,参阅 [issues#252](https://github.com/gzu-liyujiang/AndroidPicker/issues/252); ## 3.0.7 - 2021.07.15 - 时间选择器设置显示秒无效问题,参阅 [issues#249](https://github.com/gzu-liyujiang/AndroidPicker/issues/249); ## 3.0.6 - 2021.07.08 - 滚轮控件弯曲模式增加指示线间隔控制; ## 3.0.5 - 2021.07.02 - 日期/时间选择器确保设置的日期时间范围有效,参阅 [issues#244](https://github.com/gzu-liyujiang/AndroidPicker/issues/244); ## 3.0.4 - 2021.06.30 - 联动选择器增加初始数据加载进度控制,地址选择器数据加载过程避免卡顿感; - 以日期选择器为例示范选择器界面个性化用法,参阅 [issues#243](https://github.com/gzu-liyujiang/AndroidPicker/issues/243); - 地址选择器新增国家统计局省市区数据示例; ## 3.0.3 - 2021.06.25 - 滚轮控件默认值设置优化; - 小数选择器格式化示例; ## 3.0.2 - 2021.06.12 - 发布遗漏了的地址选择器模块; ## 3.0.1 - 2021.06.12 - 增加民族选择器; - 抽取地址选择器模块,默认附带来源于国家统计局的省市区数据; - 地址选择器演示添加新的省市区JSON数据; ## 3.0.0 - 2021.06.11 - 时隔两年,大刀阔斧的重构回归,全新的滚轮选择器、文件选择器、颜色选择器、日历选择器; ## 2.0.0 - 2020.10.20 - 从 Support v4/v7 迁移到 AndroidX ; ## 1.5.6.20181018 - 2018.10.18 - 兼容 Android 9.0(COMPILE_SDK_VERSION=28); ## ~~1.5.6 - 2018.06.01~~ - 避免因 Android9.0 导致的编译问题; - WheelView 优化…… ## ~~1.5.5 - 2017.09.01~~ - 代码优化,新增一些设置方法; ## ~~1.5.4 - 2017.08.19~~ - 修复时间选择器 bug; - 联动选择器支持设置宽度填充; ## ~~1.5.3 - 2017.07.01~~ - 修复默认无法选中第一项的问题; - 新增日期时间选择器联动时是否重置下一级的索引的控制方法; - 修复日期选择器 setSelectedItem 传值错误可能导致的奔溃问题; - 新增多项选择器; ## ~~1.5.2 - 2017.05.14~~ - 有童鞋反应动画太慢,移除选择器默认的动画; - DoublePicker 支持设置前缀及后缀标签; - 修复联动选择器不滑动(使用默认项)就确定时的奔溃问题; - 修复 setXXRangeStart()及 setXXRangeEnd()二者调用顺序颠倒出现的问题; ## ~~1.5.1 - 2017.05.03~~ - 日期时间选择器支持设置各项平分布局; - 顶部按钮文字颜色默认调整为青蓝风格; - 修复日期时间选择联动适时取值不对问题; - 支持设置选中项的背景色及透明度; - 增加港澳台的县级城市数据; - 添加双项选择器,选择两项,数据不联动; ## ~~1.5.0 - 2017.05.01~~ - 基于 View 重构 WheelView; - 联动选择器支持直接传入对象; - 动画默认为 500 毫秒,应该不会太慢了; ## ~~1.4.6 - 2017.04.10~~ - 弹窗内部部分代码重构; - 使用透明渐变位移动画,缓解初始化时默认选中项显示跳动问题; - 日期时间选择联动时重置联动项的索引为 0; ## ~~1.4.5 - 2017.03.19~~ - - 解决选择器部分选项概率性不显示问题,感谢亮亮同学; ## ~~1.4.4 - 2017.03.8~~ - 解决滑动选项闪烁问题;修复已知的数组越界异常问题; ## ~~1.4.3 - 2017.01.16~~ - 解决默认选项选中失效问题; ## ~~1.4.2 - 2017.01.09~~ - 滑轮选择器默认禁用循环滚动; - 日期时间选择器宽度兼容 480x800; - demo 的地址选择器重构,方便回调; ## ~~1.4.1 - 2017.01.08~~ - 修复选择器在 Android4.X 版本上奔溃问题; - 改进文件目录选择器的路径指示效果; ## ~~1.4.0 - 2017.01.07~~ - 重构 WheelView,大批量数据时滑动性能显著提升; - 改进颜色选择器的颜色选择预览效果; - 滑轮选择器可设置阴影效果; ## ~~1.3.5 - 2017.01.04~~ - 选择器引用的图片改成字节数组形式; - 解决默认主题设置为 Material 时顶部按钮内边距过宽问题; - demo 添加沉浸式状态栏功能 ## ~~1.3.4 - 2017.01.01~~ - 重构日期时间选择器,默认选中当前日期时间; - 支持设置顶部的左右边距; - 优化多级选择器的数据联动; - 支持将库打包为纯 jar 包,通过 jar 依赖; ## ~~1.3.3 - 2016.12.21~~ - 修复日期选择器月份范围设置可能无效的 bug; - 支持设置顶部按钮按下状态的文字颜色; - 选择器条目默认显示由 3 条改为 5 条,并修改条目文字的内边距; ## ~~1.3.2 - 2016.12.19~~ - 支持设置选中项分割线的宽比例、透明度、粗度; - 修复小数选择器设置默认选择项可能无效的 bug; - 添加中国大陆车牌号码选择器; ## ~~1.3.1 - 2016.12.17~~ - 对 1.2.\*版本作兼容处理。 ## ~~1.3.0 - 2016.12.15~~ - 支持设置选择器主体背景颜色; - 所有选择器支持滑动实时监听; - 所有选择器支持内嵌到其他视图容器; - 重构单项选择器,数字选择器支持小数; ## ~~1.2.4 - 2016.11.23~~ - 修复默认选中第一项时颜色不高亮问题; - 修复联动选择器数组越界问题; - 多级联动选择器支持设置各列比例; - 时期及时间选择器内部逻辑修改; ## ~~1.2.3 - 2016.10.13~~ - 修复日期选择器中当开始年份和结束年份相同时的 Bug; - 修复年月日时分选择器的设置默认值时分没有补零的 Bug; - 支持所有选择器顶部高度及字号的设置; - 修复日期选择器选中项显示有误问题,感谢@msdx; ## ~~1.2.2 - 2016.09.01~~ - 日期选择器支持年份正序和逆序; - 时间选择器可以限定时分范围; - 选择器可指定弹框显示位置,如居中; - 日期选择器可以限定年月日范围; - 修复几个已知的 bug; ## ~~1.2.1 - 2016.07.23~~ - 地址选择器增加获取城市编码,感谢@weishd; - 修改注释,优化部分代码,修复一个已知的 bug; ## ~~1.1.3 - 2016.06.14~~ - 添加日期时间选择器,感谢@dongzhaoqi; ## ~~1.1.2 - 2016.05.06~~ - 添加二三级联动选择器; - 文件选择器布局调整; ## ~~1.1.1 - 2016.04.23~~ - 地址选择器支持只选择省和市、不能混淆某些类,感谢@Wastrel 及@lutas2000; ## ~~1.1.0 - 2016.01.29~~ - 添加注解约束,如“setOffset()”只能是 1 至 4; - 所有枚举类改为常量来表示,据说这样可以节约内存; - 支持自定义选择器的顶部及底部的视图; - 支持使用第三方动画库来实现窗口动画; ## ~~1.0.3 - 2016.01.19~~ - 日期时间、地址、单项、数字等选择器支持伪循环滚动。 ## ~~1.0.2 - 2016.01.15~~ - 年或月变动时,保持之前选择的日不动:如果之前选择的日是之前年月的最大日,则日自动为该年月的最大日。 ## ~~1.0.1 - 2016.01.14~~ - 精简文件选择器的数据适配器; - 添加选择器顶部确定、取消按钮所在容器的背景色设置。 ## ~~1.0.0 - 2016.01.13~~ - 发布到 jcenter,支持远程 maven 依赖。 ================================================ FILE: ColorPicker/README.md ================================================ # 颜色选择器 颜色选择面板,改自[AndroidColorPicker](https://github.com/jbruchanov/AndroidColorPicker) ================================================ FILE: ColorPicker/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation api project(':Common') } ================================================ FILE: ColorPicker/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: ColorPicker/src/main/AndroidManifest.xml ================================================ ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/BrightnessGradientView.java ================================================ /* * 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.colorpicker; import android.content.Context; import android.util.AttributeSet; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 12:59 */ public class BrightnessGradientView extends ColorGradientView { public BrightnessGradientView(Context context) { super(context); asBrightnessGradient(); } public BrightnessGradientView(Context context, AttributeSet attrs) { super(context, attrs); asBrightnessGradient(); } public BrightnessGradientView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); asBrightnessGradient(); } } ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/ColorGradientView.java ================================================ /* * 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.colorpicker; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ComposeShader; import android.graphics.LinearGradient; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import androidx.annotation.DrawableRes; /** * 颜色选择面板。Adapted from https://github.com/jbruchanov/AndroidColorPicker * * @author 贵州山野羡民(1032694760@qq.com) * @since 2015/7/20 */ @SuppressWarnings("unused") public class ColorGradientView extends View { private static final int[] GRAD_COLORS = new int[]{Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.RED}; private static final int[] GRAD_ALPHA = new int[]{Color.WHITE, Color.TRANSPARENT}; private ColorGradientView gradientView; private Shader mShader; private Drawable mPointerDrawable; private Paint mPaint; private Paint mPaintBackground; private final RectF mGradientRect = new RectF(); private final float[] mHSV = new float[]{1f, 1f, 1f}; private final int[] mSelectedColorGradient = new int[]{0, Color.BLACK}; private float mRadius = 0; private int mSelectedColor = 0; private boolean brightnessGradient = false; private int mLastX = Integer.MIN_VALUE; private int mLastY; private int mPointerHeight; private int mPointerWidth; private boolean mLockPointerInBounds = false; private OnColorChangedListener mOnColorChangedListener; public ColorGradientView(Context context) { super(context); init(); } public ColorGradientView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ColorGradientView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init() { setClickable(true); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintBackground = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintBackground.setColor(Color.WHITE); setLayerType(View.LAYER_TYPE_SOFTWARE, isInEditMode() ? null : mPaint); setPointerDrawable(R.mipmap.color_picker_pointer); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int desiredWidth = 0; int desiredHeight = 0; if (mPointerDrawable != null) { desiredHeight = mPointerDrawable.getIntrinsicHeight(); //this is nonsense, but at least have something than 0 desiredWidth = mPointerDrawable.getIntrinsicWidth(); } int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int width; int height; //Measure Width if (widthMode == MeasureSpec.EXACTLY) { //Must be this size width = widthSize; } else if (widthMode == MeasureSpec.AT_MOST) { //Can't be bigger than... width = Math.min(desiredWidth, widthSize); } else { //Be whatever you want width = desiredWidth; } //Measure Height if (heightMode == MeasureSpec.EXACTLY) { //Must be this size height = heightSize; } else if (heightMode == MeasureSpec.AT_MOST) { //Can't be bigger than... height = Math.min(desiredHeight, heightSize); } else { //Be whatever you want height = desiredHeight; } //MUST CALL THIS setMeasuredDimension(width, height); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mShader != null) { canvas.drawRoundRect(mGradientRect, mRadius, mRadius, mPaintBackground); canvas.drawRoundRect(mGradientRect, mRadius, mRadius, mPaint); } onDrawPointer(canvas); } private void onDrawPointer(Canvas canvas) { if (mPointerDrawable != null) { int vh = getHeight(); int pwh = mPointerWidth >> 1; int phh = mPointerHeight >> 1; float tx, ty; if (!brightnessGradient) { // fixed: 17-1-7 Math operands should be cast before assignment tx = (float) (mLastX - pwh); ty = (float) (mLastY - phh); if (mLockPointerInBounds) { tx = Math.max(mGradientRect.left, Math.min(tx, mGradientRect.right - mPointerWidth)); ty = Math.max(mGradientRect.top, Math.min(ty, mGradientRect.bottom - mPointerHeight)); } else { tx = Math.max(mGradientRect.left - pwh, Math.min(tx, mGradientRect.right - pwh)); ty = Math.max(mGradientRect.top - pwh, Math.min(ty, mGradientRect.bottom - phh)); } } else {//vertical lock tx = (float) (mLastX - pwh); ty = mPointerHeight != mPointerDrawable.getIntrinsicHeight() ? (vh >> 1) - phh : 0; if (mLockPointerInBounds) { tx = Math.max(mGradientRect.left, Math.min(tx, mGradientRect.right - mPointerWidth)); ty = Math.max(mGradientRect.top, Math.min(ty, mGradientRect.bottom - mPointerHeight)); } else { tx = Math.max(mGradientRect.left - pwh, Math.min(tx, mGradientRect.right - pwh)); ty = Math.max(mGradientRect.top - pwh, Math.min(ty, mGradientRect.bottom - phh)); } } canvas.translate(tx, ty); mPointerDrawable.draw(canvas); canvas.translate(-tx, -ty); } } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); mGradientRect.set(getPaddingLeft(), getPaddingTop(), right - left - getPaddingRight(), bottom - top - getPaddingBottom()); if (changed) { buildShader(); } if (mPointerDrawable != null) { int h = (int) mGradientRect.height(); int ph = mPointerDrawable.getIntrinsicHeight(); int pw = mPointerDrawable.getIntrinsicWidth(); mPointerHeight = ph; mPointerWidth = pw; if (h < ph) { mPointerHeight = h; mPointerWidth = (int) (pw * (h / (float) ph)); } mPointerDrawable.setBounds(0, 0, mPointerWidth, mPointerHeight); updatePointerPosition(); } } private void buildShader() { if (brightnessGradient) { mShader = new LinearGradient(mGradientRect.left, mGradientRect.top, mGradientRect.right, mGradientRect.top, mSelectedColorGradient, null, Shader.TileMode.CLAMP); } else { LinearGradient gradientShader = new LinearGradient(mGradientRect.left, mGradientRect.top, mGradientRect.right, mGradientRect.top, GRAD_COLORS, null, Shader.TileMode.CLAMP); LinearGradient alphaShader = new LinearGradient(0, mGradientRect.top + (mGradientRect.height() / 3), 0, mGradientRect.bottom, GRAD_ALPHA, null, Shader.TileMode.CLAMP); mShader = new ComposeShader(alphaShader, gradientShader, PorterDuff.Mode.MULTIPLY); } mPaint.setShader(mShader); } public void setRadius(float radius) { // fixed: 17-1-7 Equality tests should not be made with floating point values. if ((int) radius != (int) mRadius) { mRadius = radius; invalidate(); } } @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { mLastX = (int) event.getX(); mLastY = (int) event.getY(); onUpdateColorSelection(mLastX, mLastY); invalidate(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: getParent().requestDisallowInterceptTouchEvent(false); break; } return super.onTouchEvent(event); } protected void onUpdateColorSelection(int x, int y) { x = (int) Math.max(mGradientRect.left, Math.min(x, mGradientRect.right)); y = (int) Math.max(mGradientRect.top, Math.min(y, mGradientRect.bottom)); if (brightnessGradient) { float b = pointToValueBrightness(x); mHSV[2] = b; mSelectedColor = Color.HSVToColor(mHSV); } else { float hue = pointToHue(x); float sat = pointToSaturation(y); mHSV[0] = hue; mHSV[1] = sat; mHSV[2] = 1f; mSelectedColor = Color.HSVToColor(mHSV); } dispatchColorChanged(mSelectedColor); } protected void dispatchColorChanged(int color) { if (gradientView != null) { gradientView.setColor(color, false); } if (mOnColorChangedListener != null) { mOnColorChangedListener.onColorChanged(this, color); } } public final void asBrightnessGradient() { this.brightnessGradient = true; } public void setBrightnessGradientView(ColorGradientView gradientView) { if (this.gradientView != gradientView) { this.gradientView = gradientView; if (this.gradientView != null) { this.gradientView.asBrightnessGradient(); this.gradientView.setColor(mSelectedColor); } } } public int getSelectedColor() { return mSelectedColor; } public void setColor(int selectedColor) { setColor(selectedColor, true); } protected void setColor(int selectedColor, boolean updatePointers) { Color.colorToHSV(selectedColor, mHSV); if (brightnessGradient) { mSelectedColorGradient[0] = getColorForGradient(mHSV); mSelectedColor = Color.HSVToColor(mHSV); buildShader(); if (mLastX != Integer.MIN_VALUE) { mHSV[2] = pointToValueBrightness(mLastX); } selectedColor = Color.HSVToColor(mHSV); } if (updatePointers) { updatePointerPosition(); } mSelectedColor = selectedColor; invalidate(); dispatchColorChanged(mSelectedColor); } private int getColorForGradient(float[] hsv) { // fixed: 17-1-7 Equality tests should not be made with floating point values. if ((int) hsv[2] != 1) { float oldV = hsv[2]; hsv[2] = 1; int color = Color.HSVToColor(hsv); hsv[2] = oldV; return color; } else { return Color.HSVToColor(hsv); } } private void updatePointerPosition() { if (mGradientRect.width() != 0 && mGradientRect.height() != 0) { if (!brightnessGradient) { mLastX = hueToPoint(mHSV[0]); mLastY = saturationToPoint(mHSV[1]); } else { mLastX = brightnessToPoint(mHSV[2]); } } } public void setOnColorChangedListener(OnColorChangedListener onColorChangedListener) { mOnColorChangedListener = onColorChangedListener; } //region HSL math private float pointToHue(float x) { x = x - mGradientRect.left; return x * 360f / mGradientRect.width(); } private int hueToPoint(float hue) { return (int) (mGradientRect.left + ((hue * mGradientRect.width()) / 360)); } private float pointToSaturation(float y) { y = y - mGradientRect.top; return 1 - (1.f / mGradientRect.height() * y); } private int saturationToPoint(float sat) { sat = 1 - sat; return (int) (mGradientRect.top + (mGradientRect.height() * sat)); } private float pointToValueBrightness(float x) { x = x - mGradientRect.left; return 1 - (1.f / mGradientRect.width() * x); } private int brightnessToPoint(float val) { val = 1 - val; return (int) (mGradientRect.left + (mGradientRect.width() * val)); } //endregion HSL math public void setPointerDrawable(Drawable pointerDrawable) { if (pointerDrawable == null) { return; } if (mPointerDrawable != pointerDrawable) { mPointerDrawable = pointerDrawable; requestLayout(); } } public void setPointerDrawable(@DrawableRes int pointerDrawable) { setPointerDrawable(getResources().getDrawable(pointerDrawable)); } public void recycle() { mPaint = null; mPaintBackground = null; if (mPointerDrawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) mPointerDrawable).getBitmap(); if (null != bitmap && !bitmap.isRecycled()) { bitmap.recycle(); } } } public void setLockPointerInBounds(boolean lockPointerInBounds) { if (lockPointerInBounds != mLockPointerInBounds) { mLockPointerInBounds = lockPointerInBounds; invalidate(); } } @Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.isBrightnessGradient = brightnessGradient; ss.color = mSelectedColor; return ss; } @Override protected void onRestoreInstanceState(Parcelable state) { if (!(state instanceof SavedState)) { super.onRestoreInstanceState(state); return; } SavedState ss = (SavedState) state; super.onRestoreInstanceState(ss.getSuperState()); brightnessGradient = ss.isBrightnessGradient; setColor(ss.color, true); } } ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/ColorPicker.java ================================================ /* * 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.colorpicker; import android.app.Activity; import android.graphics.Color; import android.view.View; import android.widget.TextView; import androidx.annotation.CallSuper; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.dialog.ModalDialog; import java.util.Locale; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 10:54 */ @SuppressWarnings("unused") public class ColorPicker extends ModalDialog implements OnColorChangedListener { protected ColorGradientView colorGradientView; protected BrightnessGradientView brightnessGradientView; private boolean initialized = false; private int initColor = Color.YELLOW; private OnColorPickedListener onColorPickedListener; public ColorPicker(@NonNull Activity activity) { super(activity); } public ColorPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { return View.inflate(activity, R.layout.color_picker_content, null); } @CallSuper @Override protected void initView() { super.initView(); colorGradientView = contentView.findViewById(R.id.color_picker_panel); brightnessGradientView = contentView.findViewById(R.id.color_picker_bright); } @CallSuper @Override protected void initData() { super.initData(); initialized = true; if (cancelView != null) { cancelView.setOnClickListener(this); } if (okView != null) { okView.setOnClickListener(this); } colorGradientView.setOnColorChangedListener(this); brightnessGradientView.setOnColorChangedListener(this); colorGradientView.setBrightnessGradientView(brightnessGradientView); //将触发onColorChanged,故必须先待其他控件初始化完成后才能调用 colorGradientView.setColor(initColor); } @Override protected void onCancel() { } @Override protected void onOk() { if (onColorPickedListener != null) { onColorPickedListener.onColorPicked(getCurrentColor()); } } @Override public void onColorChanged(ColorGradientView gradientView, @ColorInt int color) { updateCurrentColor(color); } private void updateCurrentColor(@ColorInt int color) { titleView.setText(Utils.toHexString(color, false).toUpperCase(Locale.PRC)); titleView.setTextColor(color); titleView.setShadowLayer(10, 5, 5, Utils.reverseColor(color)); } /** * 设置初始默认颜色 * * @param initColor 颜色值,如:0xFFFF00FF */ public void setInitColor(@ColorInt int initColor) { this.initColor = initColor; if (initialized) { colorGradientView.setColor(initColor); } } /** * 设置颜色选择监听器 */ public void setOnColorPickListener(OnColorPickedListener onColorPickedListener) { this.onColorPickedListener = onColorPickedListener; } /** * 获取当前选择的颜色 */ @ColorInt public final int getCurrentColor() { try { return Color.parseColor("#" + titleView.getText()); } catch (Exception e) { DialogLog.print(e); return initColor; } } /** * 获取16进制颜色值视图 */ public final TextView getHexView() { return getTitleView(); } /** * 获取颜色面板视图 */ public final ColorGradientView getColorGradientView() { return colorGradientView; } /** * 获取亮度面板视图 */ public final BrightnessGradientView getBrightnessGradientView() { return brightnessGradientView; } } ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/OnColorChangedListener.java ================================================ /* * 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.colorpicker; import androidx.annotation.ColorInt; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2015/7/20 */ public interface OnColorChangedListener { void onColorChanged(ColorGradientView gradientView, @ColorInt int color); } ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/OnColorPickedListener.java ================================================ /* * 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.colorpicker; import androidx.annotation.ColorInt; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2015/7/20 */ public interface OnColorPickedListener { void onColorPicked(@ColorInt int pickedColor); } ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/SavedState.java ================================================ /* * 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.colorpicker; import android.os.Parcel; import android.os.Parcelable; import android.view.View; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 10:56 */ class SavedState extends View.BaseSavedState { int color; boolean isBrightnessGradient; SavedState(Parcelable superState) { super(superState); } private SavedState(Parcel in) { super(in); color = in.readInt(); isBrightnessGradient = in.readInt() == 1; } @Override public void writeToParcel(Parcel out, int flags) { super.writeToParcel(out, flags); out.writeInt(color); out.writeInt(isBrightnessGradient ? 1 : 0); } public static final Creator CREATOR = new Creator() { public SavedState createFromParcel(Parcel in) { return new SavedState(in); } public SavedState[] newArray(int size) { return new SavedState[size]; } }; } ================================================ FILE: ColorPicker/src/main/java/com/github/gzuliyujiang/colorpicker/Utils.java ================================================ /* * 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.colorpicker; import android.graphics.Color; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import com.github.gzuliyujiang.dialog.DialogLog; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 11:30 */ class Utils { @ColorInt public static int reverseColor(@ColorInt int color) { int alpha = Color.alpha(color); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return Color.argb(alpha, 255 - red, 255 - green, 255 - blue); } /** * 转换为6位十六进制颜色代码,不含“#” */ @NonNull public static String toHexString(@ColorInt int color, boolean includeAlpha) { String alpha = Integer.toHexString(Color.alpha(color)); String red = Integer.toHexString(Color.red(color)); String green = Integer.toHexString(Color.green(color)); String blue = Integer.toHexString(Color.blue(color)); if (alpha.length() == 1) { alpha = "0" + alpha; } if (red.length() == 1) { red = "0" + red; } if (green.length() == 1) { green = "0" + green; } if (blue.length() == 1) { blue = "0" + blue; } String colorString; if (includeAlpha) { colorString = alpha + red + green + blue; DialogLog.print(String.format("%s to color string is %s", color, colorString)); } else { colorString = red + green + blue; DialogLog.print(String.format("%s to color string is %s%s%s%s, exclude alpha is %s", color, alpha, red, green, blue, colorString)); } return colorString; } } ================================================ FILE: ColorPicker/src/main/res/layout/color_picker_content.xml ================================================ ================================================ FILE: Common/README.md ================================================ # 基础选择器 选择器底部弹窗。 ================================================ FILE: Common/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation implementation androidxLibrary.core api androidxLibrary.activity } ================================================ FILE: Common/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: Common/src/main/AndroidManifest.xml ================================================ ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/BaseDialog.java ================================================ /* * 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.dialog; import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RoundRectShape; import android.os.Build; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import androidx.annotation.CallSuper; import androidx.annotation.ColorInt; import androidx.annotation.Dimension; import androidx.annotation.DrawableRes; import androidx.annotation.FloatRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StyleRes; import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleEventObserver; import androidx.lifecycle.LifecycleOwner; /** * 屏幕底部弹出对话框 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2017/4/12 */ @SuppressWarnings({"WeakerAccess", "unused"}) public abstract class BaseDialog extends Dialog implements DialogInterface.OnShowListener, DialogInterface.OnDismissListener, LifecycleEventObserver { public static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT; public static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; protected Activity activity; protected View contentView; public BaseDialog(@NonNull Activity activity) { this(activity, R.style.DialogTheme_Base); } public BaseDialog(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); init(activity); } public final View getContentView() { return contentView; } private void init(Activity activity) { if (activity instanceof LifecycleOwner) { ((LifecycleOwner) activity).getLifecycle().addObserver(this); } this.activity = activity; //触摸屏幕取消窗体 setCanceledOnTouchOutside(false); //按返回键取消窗体 setCancelable(false); super.setOnShowListener(this); super.setOnDismissListener(this); Window window = super.getWindow(); if (window != null) { //requestFeature must be called before adding content window.requestFeature(Window.FEATURE_NO_TITLE); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setLayout(activity.getResources().getDisplayMetrics().widthPixels, WindowManager.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.CENTER); window.getDecorView().setPadding(0, 0, 0, 0); } onInit(null); // 调用create或show才能触发onCreate if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.create(); } else { readyView(); } } @Override public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) { if (event.equals(Lifecycle.Event.ON_DESTROY)) { DialogLog.print("dismiss dialog when " + source.getClass().getName() + " on destroy"); dismiss(); source.getLifecycle().removeObserver(this); } } /** * @deprecated 使用 {@link #onInit(Bundle)} 代替 */ @Deprecated @CallSuper protected void onInit(@NonNull Activity activity, @Nullable Bundle savedInstanceState) { DialogLog.print("dialog onInit"); } @CallSuper protected void onInit(@Nullable Bundle savedInstanceState) { //noinspection deprecation onInit(activity, savedInstanceState); } @Override protected final void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DialogLog.print("dialog onCreate"); if (contentView == null) { readyView(); } } private void readyView() { contentView = createContentView(); contentView.setFocusable(true); contentView.setFocusableInTouchMode(true); setContentView(contentView); initView(); } @NonNull protected abstract View createContentView(); /** * @deprecated 使用 {@link #initView()} 代替 */ @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated @CallSuper protected void initView(View contentView) { DialogLog.print("dialog initView"); } @CallSuper protected void initView() { //noinspection deprecation initView(contentView); } public final void disableCancel() { setCancelable(false); setCanceledOnTouchOutside(false); } public final void setBackgroundColor(@ColorInt int color) { setBackgroundColor(CornerRound.No, color); } public final void setBackgroundColor(@CornerRound int cornerRound, @ColorInt int color) { setBackgroundColor(cornerRound, 20, color); } public final void setBackgroundColor(@CornerRound int cornerRound, @Dimension(unit = Dimension.DP) int radius, @ColorInt int color) { if (contentView == null) { return; } float radiusInPX = contentView.getResources().getDisplayMetrics().density * radius; contentView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); Drawable drawable; switch (cornerRound) { case CornerRound.Top: float[] outerRadii = new float[]{radiusInPX, radiusInPX, radiusInPX, radiusInPX, 0, 0, 0, 0}; ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(outerRadii, null, null)); shapeDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); drawable = shapeDrawable; break; case CornerRound.All: GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setCornerRadius(radiusInPX); gradientDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); drawable = gradientDrawable; break; default: drawable = new ColorDrawable(color); break; } contentView.setBackground(drawable); } public final void setBackgroundResource(@DrawableRes int resId) { if (contentView == null) { return; } contentView.setBackgroundResource(resId); } public final void setBackgroundDrawable(Drawable drawable) { if (contentView == null) { return; } contentView.setBackground(drawable); } public final void setLayout(int width, int height) { getWindow().setLayout(width, height); } public final void setWidth(int width) { getWindow().setLayout(width, getWindow().getAttributes().height); } public final void setHeight(int height) { getWindow().setLayout(getWindow().getAttributes().width, height); } public final void setGravity(int gravity) { getWindow().setGravity(gravity); } public final void setDimAmount(@FloatRange(from = 0, to = 1) float amount) { getWindow().setDimAmount(amount); } public final void setAnimationStyle(@StyleRes int animRes) { getWindow().setWindowAnimations(animRes); } @Override public void setOnShowListener(@Nullable OnShowListener listener) { if (listener == null) { return; } final OnShowListener current = this; super.setOnShowListener(dialog -> { current.onShow(dialog); listener.onShow(dialog); }); } @Override public void setOnDismissListener(@Nullable OnDismissListener listener) { if (listener == null) { return; } final OnDismissListener current = this; super.setOnDismissListener(dialog -> { current.onDismiss(dialog); listener.onDismiss(dialog); }); } @CallSuper @Override public void show() { if (isShowing()) { return; } showSafe(); } protected void showSafe() { try { super.show(); DialogLog.print("dialog show"); } catch (Throwable e) { //...not attached to window manager //...Unable to add window...is your activity running? //...Activity...has leaked window...that was originally added here DialogLog.print(e); } } @CallSuper @Override public void dismiss() { if (!isShowing()) { return; } dismissSafe(); } protected void dismissSafe() { try { super.dismiss(); DialogLog.print("dialog dismiss"); } catch (Throwable e) { //...not attached to window manager //...Activity...has leaked window...that was originally added here DialogLog.print(e); } } @CallSuper @Override public void onAttachedToWindow() { DialogLog.print("dialog attached to window"); super.onAttachedToWindow(); initData(); } @CallSuper protected void initData() { DialogLog.print("dialog initData"); } @CallSuper @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); DialogLog.print("dialog detached from window"); } /** * @see #onAttachedToWindow() */ @CallSuper @Override public void onShow(DialogInterface dialog) { DialogLog.print("dialog onShow"); } /** * @see #onDetachedFromWindow() */ @CallSuper @Override public void onDismiss(DialogInterface dialog) { DialogLog.print("dialog onDismiss"); } } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/BottomDialog.java ================================================ /* * 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.dialog; import android.app.Activity; import android.content.DialogInterface; import android.graphics.PixelFormat; import android.graphics.Point; import android.os.Build; import android.os.Bundle; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StyleRes; /** * 屏幕底部弹出对话框 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/4/15 20:54 */ public abstract class BottomDialog extends BaseDialog { protected View maskView; public BottomDialog(@NonNull Activity activity) { super(activity, R.style.DialogTheme_Sheet); } public BottomDialog(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @Override public void onInit(@Nullable Bundle savedInstanceState) { super.onInit(savedInstanceState); setCancelable(true); setCanceledOnTouchOutside(true); setWidth(activity.getResources().getDisplayMetrics().widthPixels); setGravity(Gravity.BOTTOM); } @Override public void onShow(DialogInterface dialog) { super.onShow(dialog); if (enableMaskView()) { addMaskView(); } } protected boolean enableMaskView() { return true; } protected void addMaskView() { // 通过自定义遮罩层视图解决自带弹窗遮罩致使系统导航栏背景过暗不一体问题 try { // 取消弹窗遮罩效果 android:backgroundDimEnabled=false getWindow().setDimAmount(0); // 自定义遮罩层视图 WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.width = WindowManager.LayoutParams.MATCH_PARENT; Point screenRealSize = new Point(); activity.getWindowManager().getDefaultDisplay().getRealSize(screenRealSize); int navBarIdentifier = activity.getResources().getIdentifier("navigation_bar_height", "dimen", "android"); params.height = screenRealSize.y - activity.getResources().getDimensionPixelSize(navBarIdentifier); params.gravity = Gravity.TOP; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { // 取消弹窗遮罩效果后,异形屏的状态栏没法被自定义的遮罩试图挡住,需结合systemUiVisibility params.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; } params.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; params.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; params.format = PixelFormat.TRANSLUCENT; params.token = activity.getWindow().getDecorView().getWindowToken(); params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN; maskView = new View(activity); maskView.setBackgroundColor(0x7F000000); maskView.setFitsSystemWindows(false); maskView.setOnKeyListener((view, keyCode, event) -> { if (keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } return false; }); activity.getWindowManager().addView(maskView, params); DialogLog.print("dialog add mask view"); } catch (Throwable e) { //...not attached to window manager // Activity ...... has leaked window android.view.View DialogLog.print(e); } } @Override public void onDismiss(DialogInterface dialog) { removeMaskView(); super.onDismiss(dialog); } protected void removeMaskView() { if (maskView == null) { DialogLog.print("mask view is null"); return; } try { activity.getWindowManager().removeViewImmediate(maskView); DialogLog.print("dialog remove mask view"); } catch (Throwable e) { //...not attached to window manager // Activity ...... has leaked window android.view.View DialogLog.print(e); } maskView = null; } } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/CornerRound.java ================================================ /* * 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.dialog; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/17 9:58 */ public @interface CornerRound { int No = 0; int Top = 1; int All = 2; } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/DialogColor.java ================================================ /* * 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.dialog; import android.graphics.Color; import androidx.annotation.ColorInt; import java.io.Serializable; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/17 17:04 */ public class DialogColor implements Serializable { private int contentBackgroundColor = Color.WHITE; private int topLineColor = 0xFFDDDDDD; private int titleTextColor = 0xFF666666; private int cancelTextColor = 0xFF333333; private int okTextColor = 0xFF333333; private int cancelEllipseColor = 0xFFF4F4F4; private int okEllipseColor = 0xFF0081FF; public DialogColor contentBackgroundColor(@ColorInt int color) { this.contentBackgroundColor = color; return this; } @ColorInt public int contentBackgroundColor() { return contentBackgroundColor; } public DialogColor topLineColor(@ColorInt int color) { this.topLineColor = color; return this; } @ColorInt public int topLineColor() { return topLineColor; } public DialogColor titleTextColor(@ColorInt int color) { this.titleTextColor = color; return this; } @ColorInt public int titleTextColor() { return titleTextColor; } public DialogColor cancelTextColor(@ColorInt int color) { this.cancelTextColor = color; return this; } @ColorInt public int cancelTextColor() { return cancelTextColor; } public DialogColor okTextColor(@ColorInt int color) { this.okTextColor = color; return this; } @ColorInt public int okTextColor() { return okTextColor; } public DialogColor cancelEllipseColor(@ColorInt int color) { this.cancelEllipseColor = color; return this; } @ColorInt public int cancelEllipseColor() { return cancelEllipseColor; } public DialogColor okEllipseColor(@ColorInt int color) { this.okEllipseColor = color; return this; } @ColorInt public int okEllipseColor() { return okEllipseColor; } } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/DialogConfig.java ================================================ /* * 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.dialog; /** * @author 贵州山魈羡民 (1032694760@qq.com) * @since 2021/9/16 15:55 */ public final class DialogConfig { private static int dialogStyle = DialogStyle.Default; private static DialogColor dialogColor = new DialogColor(); private DialogConfig() { super(); } public static void setDialogStyle(@DialogStyle int style) { dialogStyle = style; } @DialogStyle public static int getDialogStyle() { return dialogStyle; } public static void setDialogColor(DialogColor color) { dialogColor = color; } public static DialogColor getDialogColor() { if (dialogColor == null) { dialogColor = new DialogColor(); } return dialogColor; } } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/DialogLog.java ================================================ /* * 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.dialog; import android.util.Log; import androidx.annotation.NonNull; /** * 调试日志工具类 * * @author 贵州山魈羡民 (1032694760@qq.com) * @since 2021/3/26 21:34 */ public final class DialogLog { private static final String TAG = "AndroidPicker"; private static boolean enable = false; private DialogLog() { super(); } /** * 启用调试日志 */ public static void enable() { enable = true; } /** * 打印调试日志 * * @param log 日志信息 */ public static void print(@NonNull Object log) { if (!enable) { return; } Log.d(TAG, log.toString()); } } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/DialogStyle.java ================================================ /* * 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.dialog; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * 弹窗样式枚举 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/16 15:31 */ @Retention(RetentionPolicy.SOURCE) public @interface DialogStyle { int Default = 0; int One = 1; int Two = 2; int Three = 3; } ================================================ FILE: Common/src/main/java/com/github/gzuliyujiang/dialog/ModalDialog.java ================================================ /* * 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.dialog; import android.app.Activity; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.CallSuper; import androidx.annotation.Dimension; import androidx.annotation.IntRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StyleRes; import androidx.core.graphics.ColorUtils; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/3 15:23 */ @SuppressWarnings("unused") public abstract class ModalDialog extends BottomDialog implements View.OnClickListener { protected View headerView; protected TextView cancelView; protected TextView titleView; protected TextView okView; protected View topLineView; protected View bodyView; protected View footerView; public ModalDialog(@NonNull Activity activity) { super(activity, DialogConfig.getDialogStyle() == DialogStyle.Three ? R.style.DialogTheme_Fade : R.style.DialogTheme_Sheet); } public ModalDialog(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @Override public void onInit(@Nullable Bundle savedInstanceState) { super.onInit(savedInstanceState); if (DialogConfig.getDialogStyle() == DialogStyle.Three) { setWidth((int) (activity.getResources().getDisplayMetrics().widthPixels * 0.8f)); setGravity(Gravity.CENTER); } } @Override protected boolean enableMaskView() { return DialogConfig.getDialogStyle() != DialogStyle.Three; } @NonNull @Override protected View createContentView() { LinearLayout rootLayout = new LinearLayout(activity); rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); rootLayout.setOrientation(LinearLayout.VERTICAL); rootLayout.setGravity(Gravity.CENTER); rootLayout.setPadding(0, 0, 0, 0); headerView = createHeaderView(); if (headerView == null) { headerView = new View(activity); headerView.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); } rootLayout.addView(headerView); topLineView = createTopLineView(); if (topLineView == null) { topLineView = new View(activity); topLineView.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); } rootLayout.addView(topLineView); bodyView = createBodyView(); rootLayout.addView(bodyView, new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f)); footerView = createFooterView(); if (footerView == null) { footerView = new View(activity); footerView.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); } rootLayout.addView(footerView); return rootLayout; } @Nullable protected View createHeaderView() { switch (DialogConfig.getDialogStyle()) { case DialogStyle.One: return View.inflate(activity, R.layout.dialog_header_style_1, null); case DialogStyle.Two: return View.inflate(activity, R.layout.dialog_header_style_2, null); case DialogStyle.Three: return View.inflate(activity, R.layout.dialog_header_style_3, null); default: return View.inflate(activity, R.layout.dialog_header_style_default, null); } } @Nullable protected View createTopLineView() { if (DialogConfig.getDialogStyle() == DialogStyle.Default) { View view = new View(activity); view.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, (int) (1 * activity.getResources().getDisplayMetrics().density))); view.setBackgroundColor(DialogConfig.getDialogColor().topLineColor()); return view; } return null; } @NonNull protected abstract View createBodyView(); @Nullable protected View createFooterView() { switch (DialogConfig.getDialogStyle()) { case DialogStyle.One: return View.inflate(activity, R.layout.dialog_footer_style_1, null); case DialogStyle.Two: return View.inflate(activity, R.layout.dialog_footer_style_2, null); case DialogStyle.Three: return View.inflate(activity, R.layout.dialog_footer_style_3, null); default: return null; } } @CallSuper @Override protected void initView() { super.initView(); int color = DialogConfig.getDialogColor().contentBackgroundColor(); switch (DialogConfig.getDialogStyle()) { case DialogStyle.One: case DialogStyle.Two: setBackgroundColor(CornerRound.Top, color); break; case DialogStyle.Three: setBackgroundColor(CornerRound.All, color); break; default: setBackgroundColor(CornerRound.No, color); break; } cancelView = contentView.findViewById(R.id.dialog_modal_cancel); if (cancelView == null) { throw new IllegalArgumentException("Cancel view id not found"); } titleView = contentView.findViewById(R.id.dialog_modal_title); if (titleView == null) { throw new IllegalArgumentException("Title view id not found"); } okView = contentView.findViewById(R.id.dialog_modal_ok); if (okView == null) { throw new IllegalArgumentException("Ok view id not found"); } titleView.setTextColor(DialogConfig.getDialogColor().titleTextColor()); cancelView.setTextColor(DialogConfig.getDialogColor().cancelTextColor()); okView.setTextColor(DialogConfig.getDialogColor().okTextColor()); cancelView.setOnClickListener(this); okView.setOnClickListener(this); maybeBuildEllipseButton(); } private void maybeBuildEllipseButton() { if (DialogConfig.getDialogStyle() != DialogStyle.One && DialogConfig.getDialogStyle() != DialogStyle.Two) { return; } if (DialogConfig.getDialogStyle() == DialogStyle.Two) { Drawable background = cancelView.getBackground(); if (background != null) { background.setColorFilter(new PorterDuffColorFilter(DialogConfig.getDialogColor().cancelEllipseColor(), PorterDuff.Mode.SRC_IN)); cancelView.setBackground(background); } else { cancelView.setBackgroundResource(R.mipmap.dialog_close_icon); } } else { GradientDrawable cancelDrawable = new GradientDrawable(); cancelDrawable.setCornerRadius(okView.getResources().getDisplayMetrics().density * 999); cancelDrawable.setColor(DialogConfig.getDialogColor().cancelEllipseColor()); cancelView.setBackground(cancelDrawable); if (ColorUtils.calculateLuminance(DialogConfig.getDialogColor().cancelEllipseColor()) < 0.5f) { cancelView.setTextColor(0xFFFFFFFF); } else { cancelView.setTextColor(0xFF666666); } } GradientDrawable okDrawable = new GradientDrawable(); okDrawable.setCornerRadius(okView.getResources().getDisplayMetrics().density * 999); okDrawable.setColor(DialogConfig.getDialogColor().okEllipseColor()); okView.setBackground(okDrawable); if (ColorUtils.calculateLuminance(DialogConfig.getDialogColor().okEllipseColor()) < 0.5f) { okView.setTextColor(0xFFFFFFFF); } else { okView.setTextColor(0xFF333333); } } @Override public void setTitle(final @Nullable CharSequence title) { if (titleView != null) { titleView.post(new Runnable() { @Override public void run() { titleView.setText(title); } }); } else { super.setTitle(title); } } @Override public void setTitle(final int titleId) { if (titleView != null) { titleView.post(new Runnable() { @Override public void run() { titleView.setText(titleId); } }); } else { super.setTitle(titleId); } } @CallSuper @Override public void onClick(View v) { int id = v.getId(); if (id == R.id.dialog_modal_cancel) { DialogLog.print("cancel clicked"); onCancel(); dismiss(); } else if (id == R.id.dialog_modal_ok) { DialogLog.print("ok clicked"); onOk(); dismiss(); } } protected abstract void onCancel(); protected abstract void onOk(); public final void setBodyWidth(@Dimension(unit = Dimension.DP) @IntRange(from = 50) int bodyWidth) { ViewGroup.LayoutParams layoutParams = bodyView.getLayoutParams(); int width = WRAP_CONTENT; if (bodyWidth != WRAP_CONTENT && bodyWidth != MATCH_PARENT) { width = (int) (bodyView.getResources().getDisplayMetrics().density * bodyWidth); } layoutParams.width = width; bodyView.setLayoutParams(layoutParams); } public final void setBodyHeight(@Dimension(unit = Dimension.DP) @IntRange(from = 50) int bodyHeight) { ViewGroup.LayoutParams layoutParams = bodyView.getLayoutParams(); int height = WRAP_CONTENT; if (bodyHeight != WRAP_CONTENT && bodyHeight != MATCH_PARENT) { height = (int) (bodyView.getResources().getDisplayMetrics().density * bodyHeight); } layoutParams.height = height; bodyView.setLayoutParams(layoutParams); } public final View getHeaderView() { if (headerView == null) { headerView = new View(activity); } return headerView; } public final View getTopLineView() { return topLineView; } public final View getBodyView() { return bodyView; } public final View getFooterView() { return footerView; } public final TextView getCancelView() { return cancelView; } public final TextView getTitleView() { return titleView; } public final TextView getOkView() { return okView; } } ================================================ FILE: Common/src/main/res/anim/dialog_sheet_enter.xml ================================================ ================================================ FILE: Common/src/main/res/anim/dialog_sheet_exit.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_footer_style_1.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_footer_style_2.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_footer_style_3.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_header_style_1.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_header_style_2.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_header_style_3.xml ================================================ ================================================ FILE: Common/src/main/res/layout/dialog_header_style_default.xml ================================================ ================================================ FILE: Common/src/main/res/values/dialog_anims.xml ================================================ ================================================ FILE: Common/src/main/res/values/dialog_themes.xml ================================================ ================================================ FILE: FilePicker/README.md ================================================ # 文件/目录选择器 注意合规性,允许APP读取外置存储器,调用之前要确保已获得用户授予`READ_EXTERNAL_STORAGE`权限。 ================================================ FILE: FilePicker/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation implementation androidxLibrary.recyclerview api project(':Common') } ================================================ FILE: FilePicker/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: FilePicker/src/main/AndroidManifest.xml ================================================ ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/ExplorerConfig.java ================================================ /* * 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.filepicker; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Environment; import androidx.annotation.Dimension; import androidx.core.content.ContextCompat; import com.github.gzuliyujiang.filepicker.annotation.ExplorerMode; import com.github.gzuliyujiang.filepicker.annotation.FileSort; import com.github.gzuliyujiang.filepicker.contract.OnFileClickedListener; import com.github.gzuliyujiang.filepicker.contract.OnFileLoadedListener; import com.github.gzuliyujiang.filepicker.contract.OnFilePickedListener; import com.github.gzuliyujiang.filepicker.contract.OnPathClickedListener; import java.io.File; import java.io.Serializable; import java.util.Arrays; /** * @author liyujiang * @since 2022/3/16 19:57 */ @SuppressWarnings({"UnusedReturnValue", "unused"}) public class ExplorerConfig implements Serializable { private final Context context; private File rootDir; private boolean loadAsync; private String[] allowExtensions = null; private int explorerMode = ExplorerMode.FILE; private boolean showHomeDir = true; private boolean showUpDir = true; private boolean showHideDir = true; private int fileSort = FileSort.BY_NAME_ASC; private int itemHeight = 40; private Drawable homeIcon; private Drawable upIcon; private Drawable folderIcon; private Drawable fileIcon; private OnFileLoadedListener onFileLoadedListener; private OnPathClickedListener onPathClickedListener; private OnFileClickedListener onFileClickedListener; private OnFilePickedListener onFilePickedListener; public ExplorerConfig(Context context) { this.context = context; homeIcon = ContextCompat.getDrawable(context, R.mipmap.file_picker_home); upIcon = ContextCompat.getDrawable(context, R.mipmap.file_picker_up); folderIcon = ContextCompat.getDrawable(context, R.mipmap.file_picker_folder); fileIcon = ContextCompat.getDrawable(context, R.mipmap.file_picker_file); } /** * 设置根目录 */ public void setRootDir(File rootDir) { this.rootDir = rootDir; } public File getRootDir() { if (rootDir == null) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { rootDir = Environment.getExternalStorageDirectory(); } else { rootDir = context.getFilesDir(); } } return rootDir; } /** * 设置是否异步加载文件列表,默认是同步列出文件 */ public void setLoadAsync(boolean loadAsync) { this.loadAsync = loadAsync; } public boolean isLoadAsync() { return loadAsync; } /** * 设置列表条目的显示高度 */ public ExplorerConfig setItemHeight(@Dimension(unit = Dimension.DP) int itemHeight) { if (itemHeight < 10 || itemHeight > 100) { return this; } this.itemHeight = itemHeight; return this; } public int getItemHeight() { return itemHeight; } /** * 设置文件的图标 */ public ExplorerConfig setFileIcon(Drawable fileIcon) { if (fileIcon == null) { return this; } this.fileIcon = fileIcon; return this; } public Drawable getFileIcon() { return fileIcon; } /** * 设置文件夹的图标 */ public ExplorerConfig setFolderIcon(Drawable folderIcon) { if (folderIcon == null) { return this; } this.folderIcon = folderIcon; return this; } public Drawable getFolderIcon() { return folderIcon; } /** * 设置“返回主页”的图标 */ public ExplorerConfig setHomeIcon(Drawable homeIcon) { if (homeIcon == null) { return this; } this.homeIcon = homeIcon; return this; } public Drawable getHomeIcon() { return homeIcon; } /** * 设置“返回上级”的图标 */ public ExplorerConfig setUpIcon(Drawable upIcon) { if (upIcon == null) { return this; } this.upIcon = upIcon; return this; } public Drawable getUpIcon() { return upIcon; } /** * 设置允许的扩展名,如[".kml",".kmz"] */ public ExplorerConfig setAllowExtensions(String[] allowExtensions) { if (this.allowExtensions != null && Arrays.equals(this.allowExtensions, allowExtensions)) { return this; } this.allowExtensions = allowExtensions; return this; } public String[] getAllowExtensions() { return allowExtensions; } @ExplorerMode public int getExplorerMode() { return explorerMode; } /** * 设置是目录模式还是文件模式 */ public void setExplorerMode(@ExplorerMode int explorerMode) { this.explorerMode = explorerMode; } /** * 设置是否显示返回主目录 */ public ExplorerConfig setShowHomeDir(boolean showHomeDir) { if (this.showHomeDir == showHomeDir) { return this; } this.showHomeDir = showHomeDir; return this; } public boolean isShowHomeDir() { return showHomeDir; } /** * 设置是否显示返回上一级 */ public ExplorerConfig setShowUpDir(boolean showUpDir) { if (this.showUpDir == showUpDir) { return this; } this.showUpDir = showUpDir; return this; } public boolean isShowUpDir() { return showUpDir; } /** * 设置是否显示隐藏的目录(以“.”开头) */ public ExplorerConfig setShowHideDir(boolean showHideDir) { if (this.showHideDir == showHideDir) { return this; } this.showHideDir = showHideDir; return this; } public boolean isShowHideDir() { return showHideDir; } /** * 设置文件排序方式,支持的排序方式已枚举为{@link FileSort} */ public ExplorerConfig setFileSort(@FileSort int fileSort) { if (this.fileSort == fileSort) { return this; } this.fileSort = fileSort; return this; } @FileSort public int getFileSort() { return fileSort; } /** * 设置文件加载监听器 */ public ExplorerConfig setOnFileLoadedListener(OnFileLoadedListener listener) { onFileLoadedListener = listener; return this; } public OnFileLoadedListener getOnFileLoadedListener() { return onFileLoadedListener; } /** * 设置各层级路径点击监听器 */ public ExplorerConfig setOnPathClickedListener(OnPathClickedListener listener) { onPathClickedListener = listener; return this; } public OnPathClickedListener getOnPathClickedListener() { return onPathClickedListener; } public OnFileClickedListener getOnFileClickedListener() { return onFileClickedListener; } /** * 设置文件或目录点击监听器 */ public void setOnFileClickedListener(OnFileClickedListener onFileClickedListener) { this.onFileClickedListener = onFileClickedListener; } public OnFilePickedListener getOnFilePickedListener() { return onFilePickedListener; } /** * 设置文件或目录选择监听器 */ public void setOnFilePickedListener(OnFilePickedListener onFilePickedListener) { this.onFilePickedListener = onFilePickedListener; } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/FileExplorer.java ================================================ /* * 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.filepicker; import android.content.Context; import android.os.Build; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.filepicker.adapter.FileAdapter; import com.github.gzuliyujiang.filepicker.adapter.FileEntity; import com.github.gzuliyujiang.filepicker.adapter.PathAdapter; import com.github.gzuliyujiang.filepicker.adapter.ViewHolder; import com.github.gzuliyujiang.filepicker.contract.OnFileLoadedListener; import com.github.gzuliyujiang.filepicker.contract.OnPathClickedListener; import java.io.File; import java.util.Locale; /** * 文件浏览器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 18:50 */ @SuppressWarnings("unused") public class FileExplorer extends FrameLayout implements OnFileLoadedListener, OnPathClickedListener { private CharSequence emptyHint; private FileAdapter fileAdapter; private PathAdapter pathAdapter; private ProgressBar loadingView; private RecyclerView fileListView; private TextView emptyHintView; private RecyclerView pathListView; private ExplorerConfig explorerConfig; public FileExplorer(Context context) { super(context); init(context); } public FileExplorer(Context context, AttributeSet attrs) { super(context, attrs); init(context); } public FileExplorer(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public FileExplorer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(context); } private void init(Context context) { explorerConfig = new ExplorerConfig(context); View contentView = inflate(context, R.layout.file_picker_content, this); pathListView = contentView.findViewById(R.id.file_picker_path_list); loadingView = contentView.findViewById(R.id.file_picker_loading); fileListView = contentView.findViewById(R.id.file_picker_file_list); emptyHintView = contentView.findViewById(R.id.file_picker_empty_hint); pathAdapter = new PathAdapter(context); pathAdapter.setOnPathClickedListener(this); pathListView.setAdapter(pathAdapter); fileAdapter = new FileAdapter(explorerConfig); fileListView.setAdapter(fileAdapter); emptyHint = Locale.getDefault().getDisplayLanguage().contains("中文") ? "<空>" : ""; emptyHintView.setText(emptyHint); } /** * 以默认配置加载文件列表 */ public void load() { load(null); } /** * 以自定义配置加载文件列表 */ public void load(@Nullable ExplorerConfig config) { if (config != null) { explorerConfig = config; fileAdapter = new FileAdapter(config); fileListView.setAdapter(fileAdapter); } explorerConfig.setOnFileLoadedListener(this); explorerConfig.setOnPathClickedListener(this); refreshCurrent(explorerConfig.getRootDir()); } @Override public void onFileLoaded(@NonNull File file) { loadingView.setVisibility(INVISIBLE); fileListView.setVisibility(View.VISIBLE); int itemCount = fileAdapter.getItemCount(); if (explorerConfig.isShowHomeDir()) { itemCount--; } if (explorerConfig.isShowUpDir()) { itemCount--; } if (itemCount < 1) { DialogLog.print("no files, or dir is empty"); emptyHintView.setVisibility(View.VISIBLE); emptyHintView.setText(emptyHint); } else { DialogLog.print("files or dirs count: " + itemCount); emptyHintView.setVisibility(View.INVISIBLE); } pathListView.post(new Runnable() { @Override public void run() { pathListView.scrollToPosition(pathAdapter.getItemCount() - 1); } }); } @Override public void onPathClicked(RecyclerView.Adapter adapter, int position, @NonNull String path) { DialogLog.print("clicked path name: " + path); if (adapter instanceof PathAdapter) { refreshCurrent(new File(path)); } else if (adapter instanceof FileAdapter) { FileEntity entity = fileAdapter.getItem(position); DialogLog.print("clicked file item: " + entity); File file = entity.getFile(); if (file.isDirectory()) { refreshCurrent(file); return; } if (explorerConfig.getOnFileClickedListener() != null) { explorerConfig.getOnFileClickedListener().onFileClicked(file); } } } /** * 设置指定路径下没有文件或目录时的提示语 */ public void setEmptyHint(@NonNull CharSequence emptyHint) { if (TextUtils.equals(this.emptyHint, emptyHint)) { return; } this.emptyHint = emptyHint; emptyHintView.setText(emptyHint); } /** * 重新加载指定路径下的文件或目录到当前列表 */ public final void refreshCurrent(File current) { if (current == null) { DialogLog.print("current dir is null"); return; } loadingView.setVisibility(VISIBLE); fileListView.setVisibility(View.INVISIBLE); emptyHintView.setVisibility(View.INVISIBLE); long millis = System.currentTimeMillis(); pathAdapter.updatePath(current); fileAdapter.loadData(current); long spent = System.currentTimeMillis() - millis; DialogLog.print("spent: " + spent + " ms" + ", async=" + explorerConfig.isLoadAsync() + ", thread=" + Thread.currentThread()); } public final FileAdapter getFileAdapter() { return fileAdapter; } public final PathAdapter getPathAdapter() { return pathAdapter; } public ExplorerConfig getExplorerConfig() { return explorerConfig; } public final File getRootDir() { return explorerConfig.getRootDir(); } /** * 获取当前加载的文件夹 */ public final File getCurrentFile() { return fileAdapter.getCurrentFile(); } /** * 获取各级路径所在的视图 */ public final RecyclerView getPathListView() { return pathListView; } /** * 获取文件或目录列表所在的视图 */ public final RecyclerView getFileListView() { return fileListView; } public final TextView getEmptyHintView() { return emptyHintView; } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/FilePicker.java ================================================ /* * 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.filepicker; import android.app.Activity; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StyleRes; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.filepicker.annotation.ExplorerMode; import com.github.gzuliyujiang.filepicker.contract.OnFileClickedListener; import java.io.File; /** * 文件目录选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2015/9/29 */ @SuppressWarnings("unused") public class FilePicker extends ModalDialog { private FileExplorer fileExplorer; private boolean initialized = false; private ExplorerConfig explorerConfig; public FilePicker(Activity activity) { super(activity); } public FilePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { fileExplorer = new FileExplorer(activity); return fileExplorer; } @Override protected void initView() { super.initView(); setHeight((int) (activity.getResources().getDisplayMetrics().heightPixels * 0.6f)); } @Override protected void initData() { super.initData(); initialized = true; setExplorerConfig(explorerConfig); final ExplorerConfig config = fileExplorer.getExplorerConfig(); config.setOnFileClickedListener(new OnFileClickedListener() { @Override public void onFileClicked(@NonNull File file) { if (config.getExplorerMode() == ExplorerMode.FILE) { dismiss(); config.getOnFilePickedListener().onFilePicked(file); } } }); if (config.getExplorerMode() == ExplorerMode.FILE) { okView.setVisibility(View.GONE); } } @Override protected void onCancel() { } @Override protected void onOk() { File currentFile = fileExplorer.getCurrentFile(); DialogLog.print("picked directory: " + currentFile); if (fileExplorer.getExplorerConfig().getOnFilePickedListener() != null) { fileExplorer.getExplorerConfig().getOnFilePickedListener().onFilePicked(currentFile); } } /** * 设置文件管理器配置 */ public void setExplorerConfig(@Nullable ExplorerConfig config) { explorerConfig = config; if (initialized) { fileExplorer.load(config); } } public final File getCurrentFile() { return fileExplorer.getCurrentFile(); } /** * 获取文件管理器对象 */ public final FileExplorer getFileExplorer() { return fileExplorer; } public final RecyclerView getFileListView() { return fileExplorer.getFileListView(); } public final TextView getEmptyHintView() { return fileExplorer.getEmptyHintView(); } public final RecyclerView getPathListView() { return fileExplorer.getPathListView(); } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/adapter/FileAdapter.java ================================================ /* * 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.filepicker.adapter; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.os.Handler; import android.os.Looper; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.filepicker.ExplorerConfig; import com.github.gzuliyujiang.filepicker.annotation.ExplorerMode; import com.github.gzuliyujiang.filepicker.annotation.FileSort; import com.github.gzuliyujiang.filepicker.filter.SimpleFilter; import com.github.gzuliyujiang.filepicker.sort.SortByExtension; import com.github.gzuliyujiang.filepicker.sort.SortByName; import com.github.gzuliyujiang.filepicker.sort.SortBySize; import com.github.gzuliyujiang.filepicker.sort.SortByTime; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; /** * 文件目录数据适配 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2014/05/23 18:02 */ @SuppressWarnings("unused") public class FileAdapter extends RecyclerView.Adapter { private static final ExecutorService THREAD_POOL = Executors.newCachedThreadPool(); private static final Handler UI_HANDLER = new Handler(Looper.getMainLooper()); public static final String DIR_ROOT = "."; public static final String DIR_PARENT = ".."; private final List data = new ArrayList<>(); private File currentFile = null; private final ConcurrentLinkedQueue> futureTasks = new ConcurrentLinkedQueue<>(); private ExplorerConfig explorerConfig; public FileAdapter(ExplorerConfig explorerConfig) { this.explorerConfig = explorerConfig; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { Context context = parent.getContext(); LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setGravity(Gravity.CENTER_VERTICAL); int height = (int) (explorerConfig.getItemHeight() * context.getResources().getDisplayMetrics().density); int matchParent = ViewGroup.LayoutParams.MATCH_PARENT; layout.setLayoutParams(new ViewGroup.LayoutParams(matchParent, height)); int padding = (int) (5 * context.getResources().getDisplayMetrics().density); layout.setPadding(padding, padding, padding, padding); ImageView imageView = new ImageView(context); int size = (int) (20 * context.getResources().getDisplayMetrics().density); imageView.setLayoutParams(new LinearLayout.LayoutParams(size, size)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(android.R.drawable.ic_menu_report_image); layout.addView(imageView); TextView textView = new TextView(context); LinearLayout.LayoutParams tvParams = new LinearLayout.LayoutParams(matchParent, matchParent); tvParams.leftMargin = (int) (10 * context.getResources().getDisplayMetrics().density); textView.setLayoutParams(tvParams); textView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); textView.setSingleLine(); layout.addView(textView); ViewHolder viewHolder = new ViewHolder(layout); viewHolder.textView = textView; viewHolder.imageView = imageView; return viewHolder; } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { final int adapterPosition = holder.getAdapterPosition(); final FileEntity item = getItem(adapterPosition); holder.imageView.setImageDrawable(item.getIcon()); holder.textView.setText(item.getName()); if (explorerConfig.getOnPathClickedListener() == null) { return; } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { explorerConfig.getOnPathClickedListener().onPathClicked(FileAdapter.this, adapterPosition, item.getFile().getAbsolutePath()); } }); } @Override public long getItemId(int position) { return position; } @Override public int getItemCount() { return data.size(); } public void setExplorerConfig(ExplorerConfig explorerConfig) { this.explorerConfig = explorerConfig; loadData(currentFile); } public ExplorerConfig getExplorerConfig() { return explorerConfig; } public final void recycleData() { data.clear(); if (explorerConfig.getHomeIcon() instanceof BitmapDrawable) { Bitmap homeBitmap = ((BitmapDrawable) explorerConfig.getHomeIcon()).getBitmap(); if (null != homeBitmap && !homeBitmap.isRecycled()) { homeBitmap.recycle(); } } if (explorerConfig.getUpIcon() instanceof BitmapDrawable) { Bitmap upBitmap = ((BitmapDrawable) explorerConfig.getUpIcon()).getBitmap(); if (null != upBitmap && !upBitmap.isRecycled()) { upBitmap.recycle(); } } if (explorerConfig.getFolderIcon() instanceof BitmapDrawable) { Bitmap folderBitmap = ((BitmapDrawable) explorerConfig.getFolderIcon()).getBitmap(); if (null != folderBitmap && !folderBitmap.isRecycled()) { folderBitmap.recycle(); } } if (explorerConfig.getFileIcon() instanceof BitmapDrawable) { Bitmap fileBitmap = ((BitmapDrawable) explorerConfig.getFileIcon()).getBitmap(); if (null != fileBitmap && !fileBitmap.isRecycled()) { fileBitmap.recycle(); } } } public File getCurrentFile() { return currentFile; } public FileEntity getItem(int position) { return data.get(position); } public void loadData(final File dir) { if (!explorerConfig.isLoadAsync()) { reallyRefresh(loadDataSync(dir)); return; } FutureTask lastTask = futureTasks.peek(); if (lastTask != null && !lastTask.isDone()) { lastTask.cancel(true); } FutureTask newTask = new FutureTask<>(new Callable() { @Override public Void call() { final List temp = loadDataSync(dir); FutureTask task = futureTasks.poll(); if (task != null && task.isCancelled()) { DialogLog.print("data load is canceled: " + currentFile); return null; } UI_HANDLER.post(new Runnable() { @Override public void run() { reallyRefresh(temp); } }); return null; } }); futureTasks.add(newTask); THREAD_POOL.execute(newTask); } @SuppressLint("NotifyDataSetChanged") private void reallyRefresh(List temp) { data.clear(); data.addAll(temp); notifyDataSetChanged(); if (explorerConfig.getOnFileLoadedListener() != null) { explorerConfig.getOnFileLoadedListener().onFileLoaded(currentFile); } DialogLog.print("notify changed when data loaded: " + currentFile); } private List loadDataSync(File dir) { if (dir == null) { DialogLog.print("current directory is null"); dir = explorerConfig.getRootDir(); } long millis = System.currentTimeMillis(); List entities = new ArrayList<>(); DialogLog.print("will load directory: " + dir); currentFile = dir; if (explorerConfig.isShowHomeDir()) { //添加“返回主目录” FileEntity root = new FileEntity(); root.setIcon(explorerConfig.getHomeIcon()); root.setName(DIR_ROOT); root.setFile(explorerConfig.getRootDir()); entities.add(root); } if (explorerConfig.isShowUpDir() && !File.separator.equals(dir.getAbsolutePath())) { //添加“返回上一级目录” FileEntity parent = new FileEntity(); parent.setIcon(explorerConfig.getUpIcon()); parent.setName(DIR_PARENT); parent.setFile(dir.getParentFile()); entities.add(parent); } SimpleFilter filter = new SimpleFilter(explorerConfig.getExplorerMode() == ExplorerMode.DIRECTORY, explorerConfig.getAllowExtensions()); List files = listFiles(currentFile, filter); sortFiles(files, explorerConfig.getFileSort()); for (File file : files) { if (!explorerConfig.isShowHideDir() && file.getName().startsWith(".")) { continue; } FileEntity FileEntity = new FileEntity(); if (file.isDirectory()) { FileEntity.setIcon(explorerConfig.getFolderIcon()); } else { FileEntity.setIcon(explorerConfig.getFileIcon()); } FileEntity.setName(file.getName()); FileEntity.setFile(file); entities.add(FileEntity); } long spent = System.currentTimeMillis() - millis; DialogLog.print("spent: " + spent + " ms" + ", async=" + explorerConfig.isLoadAsync() + ", thread=" + Thread.currentThread()); return entities; } /** * 列出指定目录下的所有子目录 */ private List listFiles(File startDir, FileFilter fileFilter) { DialogLog.print(String.format("list dir %s by filter %s", startDir, fileFilter.getClass().getName())); if (!startDir.isDirectory()) { return new ArrayList<>(); } File[] dirs = startDir.listFiles(fileFilter); if (dirs == null) { return new ArrayList<>(); } return Arrays.asList(dirs); } private void sortFiles(List files, @FileSort int sort) { switch (sort) { case FileSort.BY_NAME_ASC: Collections.sort(files, new SortByName()); break; case FileSort.BY_NAME_DESC: Collections.sort(files, new SortByName()); Collections.reverse(files); break; case FileSort.BY_TIME_ASC: Collections.sort(files, new SortByTime()); break; case FileSort.BY_TIME_DESC: Collections.sort(files, new SortByTime()); Collections.reverse(files); break; case FileSort.BY_SIZE_ASC: Collections.sort(files, new SortBySize()); break; case FileSort.BY_SIZE_DESC: Collections.sort(files, new SortBySize()); Collections.reverse(files); break; case FileSort.BY_EXTENSION_ASC: Collections.sort(files, new SortByExtension()); break; case FileSort.BY_EXTENSION_DESC: Collections.sort(files, new SortByExtension()); Collections.reverse(files); break; } } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/adapter/FileEntity.java ================================================ /* * 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.filepicker.adapter; import android.graphics.drawable.Drawable; import androidx.annotation.NonNull; import java.io.File; import java.io.Serializable; /** * 文件项信息 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2014/05/23 18:02 */ public class FileEntity implements Serializable { private Drawable icon; private String name; private File file; public void setIcon(Drawable icon) { this.icon = icon; } public Drawable getIcon() { return icon; } public String getName() { return name; } public void setName(String name) { this.name = name; } public File getFile() { return file; } public void setFile(File file) { this.file = file; } @NonNull @Override public String toString() { return "FileEntity{" + "name='" + name + '\'' + ", file='" + file + '\'' + '}'; } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/adapter/PathAdapter.java ================================================ /* * 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.filepicker.adapter; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.filepicker.R; import com.github.gzuliyujiang.filepicker.contract.OnPathClickedListener; import java.io.File; import java.util.Collections; import java.util.LinkedList; /** * 文件路径数据适配 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2017/01/08 01:20 */ @SuppressWarnings("unused") public class PathAdapter extends RecyclerView.Adapter { private static final String ROOT_HINT = "ROOT"; private final Context context; private final LinkedList paths = new LinkedList<>(); private Drawable arrowIcon = null; private OnPathClickedListener onPathClickedListener; public PathAdapter(@NonNull Context context) { this.context = context; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { int wrapContent = ViewGroup.LayoutParams.WRAP_CONTENT; LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setGravity(Gravity.CENTER_VERTICAL); layout.setLayoutParams(new ViewGroup.LayoutParams(wrapContent, wrapContent)); TextView textView = new TextView(context); LinearLayout.LayoutParams tvParams = new LinearLayout.LayoutParams(wrapContent, wrapContent); textView.setLayoutParams(tvParams); textView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); int padding = (int) (5 * context.getResources().getDisplayMetrics().density); textView.setPadding(padding, 0, padding, 0); layout.addView(textView); ImageView imageView = new ImageView(context); int size = (int) (15 * context.getResources().getDisplayMetrics().density); imageView.setLayoutParams(new LinearLayout.LayoutParams(size, size)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); layout.addView(imageView); ViewHolder viewHolder = new ViewHolder(layout); viewHolder.textView = textView; viewHolder.imageView = imageView; return viewHolder; } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { final int adapterPosition = holder.getAdapterPosition(); holder.textView.setText(paths.get(adapterPosition)); holder.imageView.setImageDrawable(arrowIcon); if (adapterPosition == getItemCount() - 1) { holder.textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); holder.imageView.setVisibility(View.GONE); } else { holder.textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); holder.imageView.setVisibility(View.VISIBLE); } if (onPathClickedListener == null) { return; } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onPathClickedListener.onPathClicked(PathAdapter.this, adapterPosition, getPath(adapterPosition)); } }); } @Override public long getItemId(int position) { return position; } @Override public int getItemCount() { return paths.size(); } public void setArrowIcon(Drawable arrowIcon) { this.arrowIcon = arrowIcon; } @SuppressLint("NotifyDataSetChanged") public void updatePath(File file) { if (arrowIcon == null) { arrowIcon = ContextCompat.getDrawable(context, R.mipmap.file_picker_arrow); } paths.clear(); String path = file.getAbsolutePath(); if (!File.separator.equals(path)) { Collections.addAll(paths, path.substring(path.indexOf(File.separator) + 1) .split(File.separator)); } paths.addFirst(ROOT_HINT); notifyDataSetChanged(); } public String getPath(int position) { StringBuilder sb = new StringBuilder(File.separator); //忽略根目录 if (position == 0) { return sb.toString(); } for (int i = 1; i <= position; i++) { sb.append(paths.get(i)).append(File.separator); } return sb.toString(); } public final void recycleData() { paths.clear(); if (arrowIcon instanceof BitmapDrawable) { Bitmap homeBitmap = ((BitmapDrawable) arrowIcon).getBitmap(); if (null != homeBitmap && !homeBitmap.isRecycled()) { homeBitmap.recycle(); } } } public void setOnPathClickedListener(OnPathClickedListener listener) { onPathClickedListener = listener; } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/adapter/ViewHolder.java ================================================ /* * 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.filepicker.adapter; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 20:47 */ public class ViewHolder extends RecyclerView.ViewHolder { public TextView textView; public ImageView imageView; public ViewHolder(@NonNull View itemView) { super(itemView); } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/annotation/ExplorerMode.java ================================================ /* * 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.filepicker.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 15:28 */ @Retention(RetentionPolicy.SOURCE) public @interface ExplorerMode { int DIRECTORY = 0; int FILE = 1; } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/annotation/FileSort.java ================================================ /* * 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.filepicker.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 14:35 */ @Retention(RetentionPolicy.SOURCE) public @interface FileSort { int BY_NAME_ASC = 0; int BY_NAME_DESC = 1; int BY_TIME_ASC = 2; int BY_TIME_DESC = 3; int BY_SIZE_ASC = 4; int BY_SIZE_DESC = 5; int BY_EXTENSION_ASC = 6; int BY_EXTENSION_DESC = 7; } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/contract/OnFileClickedListener.java ================================================ /* * 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.filepicker.contract; import androidx.annotation.NonNull; import java.io.File; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 19:33 */ public interface OnFileClickedListener { void onFileClicked(@NonNull File file); } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/contract/OnFileLoadedListener.java ================================================ /* * 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.filepicker.contract; import androidx.annotation.NonNull; import java.io.File; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2022/3/16 14:29 */ public interface OnFileLoadedListener { void onFileLoaded(@NonNull File file); } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/contract/OnFilePickedListener.java ================================================ /* * 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.filepicker.contract; import androidx.annotation.NonNull; import java.io.File; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2015/9/29 */ public interface OnFilePickedListener { void onFilePicked(@NonNull File file); } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/contract/OnPathClickedListener.java ================================================ /* * 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.filepicker.contract; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.github.gzuliyujiang.filepicker.adapter.ViewHolder; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 20:15 */ public interface OnPathClickedListener { void onPathClicked(RecyclerView.Adapter adapter, int position, @NonNull String path); } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/filter/PatternFilter.java ================================================ /* * 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.filepicker.filter; import androidx.annotation.NonNull; import java.io.File; import java.io.FileFilter; import java.util.regex.Pattern; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 15:07 */ public class PatternFilter implements FileFilter { private final Pattern pattern; public PatternFilter(@NonNull Pattern pattern) { this.pattern = pattern; } @Override public boolean accept(File pathname) { if (pathname == null) { return false; } return pattern.matcher(pathname.getName()).find(); } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/filter/SimpleFilter.java ================================================ /* * 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.filepicker.filter; import android.text.TextUtils; import androidx.annotation.Nullable; import com.github.gzuliyujiang.dialog.DialogLog; import java.io.File; import java.io.FileFilter; import java.util.Arrays; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 15:11 */ public class SimpleFilter implements FileFilter { private final boolean isOnlyDir; private final String[] allowExtensions; public SimpleFilter(boolean isOnlyDir, @Nullable String[] allowExtensions) { this.isOnlyDir = isOnlyDir; this.allowExtensions = allowExtensions; } @Override public boolean accept(File pathname) { if (pathname == null) { DialogLog.print("Filter>>>pathname is null"); return false; } if (pathname.isDirectory()) { DialogLog.print("Filter>>>pathname is directory: " + pathname); return true; } if (isOnlyDir && pathname.isFile()) { DialogLog.print("Filter>>>except directory but is file: " + pathname); return false; } if (allowExtensions == null || allowExtensions.length == 0) { DialogLog.print("Filter>>>allow extensions is empty: " + pathname); return true; } //返回当前目录所有以某些扩展名结尾的文件 String extension = getExtension(pathname.getPath()); DialogLog.print("Filter>>>extension of " + pathname + ": " + extension); boolean contains = false; for (String allowExtension : allowExtensions) { if (TextUtils.isEmpty(allowExtension) || allowExtension.contains(extension)) { contains = true; break; } } DialogLog.print("Filter>>>allow extensions is " + Arrays.toString(allowExtensions) + ", contains: " + contains); return contains; } private String getExtension(String path) { if (path == null) { return ""; } String ext = ""; int slashPos = path.lastIndexOf(File.separator); if (slashPos != -1) { path = path.substring(slashPos); } int dotPos = path.lastIndexOf('.'); if (dotPos != -1) { ext = path.substring(dotPos + 1); } else { ext = path; } return ext; } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/sort/SortByExtension.java ================================================ /* * 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.filepicker.sort; import java.io.File; import java.util.Comparator; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2014/4/18 */ public class SortByExtension implements Comparator { @Override public int compare(File f1, File f2) { if (f1 == null || f2 == null) { if (f1 == null) { return -1; } else { return 1; } } else { if (f1.isDirectory() && f2.isFile()) { return -1; } else if (f1.isFile() && f2.isDirectory()) { return 1; } else { return f1.getName().compareToIgnoreCase(f2.getName()); } } } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/sort/SortByName.java ================================================ /* * 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.filepicker.sort; import java.io.File; import java.util.Comparator; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2014/4/18 */ public class SortByName implements Comparator { private static final boolean CASE_SENSITIVE = false; @Override public int compare(File f1, File f2) { if (f1 == null || f2 == null) { if (f1 == null) { return -1; } else { return 1; } } else { if (f1.isDirectory() && f2.isFile()) { return -1; } else if (f1.isFile() && f2.isDirectory()) { return 1; } else { String s1 = f1.getName(); String s2 = f2.getName(); if (CASE_SENSITIVE) { return s1.compareTo(s2); } else { return s1.compareToIgnoreCase(s2); } } } } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/sort/SortBySize.java ================================================ /* * 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.filepicker.sort; import java.io.File; import java.util.Comparator; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2014/4/18 */ public class SortBySize implements Comparator { @Override public int compare(File f1, File f2) { if (f1 == null || f2 == null) { if (f1 == null) { return -1; } else { return 1; } } else { if (f1.isDirectory() && f2.isFile()) { return -1; } else if (f1.isFile() && f2.isDirectory()) { return 1; } else { if (f1.length() < f2.length()) { return -1; } else if (f1.length() > f2.length()) { return 1; } else { return 0; } } } } } ================================================ FILE: FilePicker/src/main/java/com/github/gzuliyujiang/filepicker/sort/SortByTime.java ================================================ /* * 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.filepicker.sort; import java.io.File; import java.util.Comparator; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2014/4/18 */ public class SortByTime implements Comparator { @Override public int compare(File f1, File f2) { if (f1 == null || f2 == null) { if (f1 == null) { return -1; } else { return 1; } } else { if (f1.isDirectory() && f2.isFile()) { return -1; } else if (f1.isFile() && f2.isDirectory()) { return 1; } else { if (f1.lastModified() > f2.lastModified()) { return -1; } else if (f1.lastModified() < f2.lastModified()) { return -1; } else { return 0; } } } } } ================================================ FILE: FilePicker/src/main/res/layout/file_picker_content.xml ================================================ ================================================ FILE: ImagePicker/README.md ================================================ # 图片选择(相机+相册+裁剪) 图片选择(相机+相册+裁剪),改自 [ImagePicker](https://github.com/linchaolong/ImagePicker) 及 [Android-Image-Cropper](https://github.com/ArthurHub/Android-Image-Cropper) 。 注意合规性,允许APP使用摄像头,允许APP读取/写入外置存储器,调用之前要确保已获得用户授予`CAMERA`、`READ_EXTERNAL_STORAGE`、`WRITE_EXTERNAL_STORAGE`权限。 ## 简单用法 ```java public class ImagePickerActivity extends FragmentActivity { private final PickCallback cropCallback = new PickCallback() { @Override public void onPermissionDenied(String[] permissions, String message) { Toast.makeText(ImagePickerActivity.this, message, Toast.LENGTH_SHORT).show(); } @Override public void cropConfig(ActivityBuilder builder) { builder.setMultiTouchEnabled(true) .setGuidelines(CropImageView.Guidelines.ON_TOUCH) .setCropShape(CropImageView.CropShape.OVAL) .setRequestedSize(400, 400) .setFixAspectRatio(true) .setAspectRatio(1, 1); } @Override public void onCropImage(@Nullable Uri imageUri) { Toast.makeText(ImagePickerActivity.this, String.valueOf(imageUri), Toast.LENGTH_SHORT).show(); } }; public void onCamera(View view) { ImagePicker.getInstance().startCamera(this, true, cropCallback); } public void onGallery(View view) { ImagePicker.getInstance().startGallery(this, true, cropCallback); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); ImagePicker.getInstance().onActivityResult(this, requestCode, resultCode, data); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); ImagePicker.getInstance().onRequestPermissionsResult(this, requestCode, permissions, grantResults); } } ``` ================================================ FILE: ImagePicker/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation implementation androidxLibrary.core implementation androidxLibrary.fragment implementation androidxLibrary.exifinterface } ================================================ FILE: ImagePicker/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: ImagePicker/src/main/AndroidManifest.xml ================================================ ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/ActivityBuilder.java ================================================ package com.github.gzuliyujiang.imagepicker; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Rect; import android.net.Uri; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; /** * Builder used for creating Image Crop Activity by user request. */ @SuppressWarnings({"unused", "UnusedReturnValue"}) public class ActivityBuilder { /** * The image to crop source Android uri. */ private final Uri mSource; /** * Options for image crop UX */ private final CropImageOptions mOptions; public ActivityBuilder(Uri source) { mSource = source; mOptions = new CropImageOptions(); } /** * Get {@link CropImageActivity} intent to start the activity. */ public Intent getCropIntent(@NonNull Context context) { mOptions.validate(); Intent intent = new Intent(context, CropImageActivity.class); intent.putExtra(CropImageConsts.CROP_IMAGE_EXTRA_SOURCE, mSource); intent.putExtra(CropImageConsts.CROP_IMAGE_EXTRA_OPTIONS, mOptions); return intent; } /** * Start {@link CropImageActivity}. * * @param activity activity to receive result */ public void start(@NonNull Activity activity) { mOptions.validate(); activity.startActivityForResult(getCropIntent(activity), CropImageConsts.CROP_IMAGE_ACTIVITY_REQUEST_CODE); } /** * Start {@link CropImageActivity}. * * @param fragment fragment to receive result */ public void start(@NonNull Fragment fragment) { fragment.startActivityForResult(getCropIntent(fragment.requireActivity()), CropImageConsts.CROP_IMAGE_ACTIVITY_REQUEST_CODE); } /** * The shape of the cropping window.
* To set square/circle crop shape set aspect ratio to 1:1.
* Default: RECTANGLE */ public ActivityBuilder setCropShape(@NonNull CropImageView.CropShape cropShape) { mOptions.cropShape = cropShape; return this; } /** * An edge of the crop window will snap to the corresponding edge of a specified bounding box * when the crop window edge is less than or equal to this distance (in pixels) away from the bounding box * edge (in pixels).
* Default: 3dp */ public ActivityBuilder setSnapRadius(float snapRadius) { mOptions.snapRadius = snapRadius; return this; } /** * The radius of the touchable area around the handle (in pixels).
* We are basing this value off of the recommended 48dp Rhythm.
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm
* Default: 48dp */ public ActivityBuilder setTouchRadius(float touchRadius) { mOptions.touchRadius = touchRadius; return this; } /** * whether the guidelines should be on, off, or only showing when resizing.
* Default: ON_TOUCH */ public ActivityBuilder setGuidelines(@NonNull CropImageView.Guidelines guidelines) { mOptions.guidelines = guidelines; return this; } /** * The initial scale type of the image in the crop image view
* Default: FIT_CENTER */ public ActivityBuilder setScaleType(@NonNull CropImageView.ScaleType scaleType) { mOptions.scaleType = scaleType; return this; } /** * if to show crop overlay UI what contains the crop window UI surrounded by background over the cropping * image.
* default: true, may disable for animation or frame transition. */ public ActivityBuilder setShowCropOverlay(boolean showCropOverlay) { mOptions.showCropOverlay = showCropOverlay; return this; } /** * if auto-zoom functionality is enabled.
* default: true. */ public ActivityBuilder setAutoZoomEnabled(boolean autoZoomEnabled) { mOptions.autoZoomEnabled = autoZoomEnabled; return this; } /** * if multi touch functionality is enabled.
* default: true. */ public ActivityBuilder setMultiTouchEnabled(boolean multiTouchEnabled) { mOptions.multiTouchEnabled = multiTouchEnabled; return this; } /** * The max zoom allowed during cropping.
* Default: 4 */ public ActivityBuilder setMaxZoom(int maxZoom) { mOptions.maxZoom = maxZoom; return this; } /** * The initial crop window padding from image borders in percentage of the cropping image dimensions.
* Default: 0.1 */ public ActivityBuilder setInitialCropWindowPaddingRatio(float initialCropWindowPaddingRatio) { mOptions.initialCropWindowPaddingRatio = initialCropWindowPaddingRatio; return this; } /** * whether the width to height aspect ratio should be maintained or free to change.
* Default: false */ public ActivityBuilder setFixAspectRatio(boolean fixAspectRatio) { mOptions.fixAspectRatio = fixAspectRatio; return this; } /** * the X,Y value of the aspect ratio.
* Also sets fixes aspect ratio to TRUE.
* Default: 1/1 * * @param aspectRatioX the width * @param aspectRatioY the height */ public ActivityBuilder setAspectRatio(int aspectRatioX, int aspectRatioY) { mOptions.aspectRatioX = aspectRatioX; mOptions.aspectRatioY = aspectRatioY; mOptions.fixAspectRatio = true; return this; } /** * the thickness of the guidelines lines (in pixels).
* Default: 3dp */ public ActivityBuilder setBorderLineThickness(float borderLineThickness) { mOptions.borderLineThickness = borderLineThickness; return this; } /** * the color of the guidelines lines.
* Default: Color.argb(170, 255, 255, 255) */ public ActivityBuilder setBorderLineColor(int borderLineColor) { mOptions.borderLineColor = borderLineColor; return this; } /** * thickness of the corner line (in pixels).
* Default: 2dp */ public ActivityBuilder setBorderCornerThickness(float borderCornerThickness) { mOptions.borderCornerThickness = borderCornerThickness; return this; } /** * the offset of corner line from crop window border (in pixels).
* Default: 5dp */ public ActivityBuilder setBorderCornerOffset(float borderCornerOffset) { mOptions.borderCornerOffset = borderCornerOffset; return this; } /** * the length of the corner line away from the corner (in pixels).
* Default: 14dp */ public ActivityBuilder setBorderCornerLength(float borderCornerLength) { mOptions.borderCornerLength = borderCornerLength; return this; } /** * the color of the corner line.
* Default: WHITE */ public ActivityBuilder setBorderCornerColor(int borderCornerColor) { mOptions.borderCornerColor = borderCornerColor; return this; } /** * the thickness of the guidelines lines (in pixels).
* Default: 1dp */ public ActivityBuilder setGuidelinesThickness(float guidelinesThickness) { mOptions.guidelinesThickness = guidelinesThickness; return this; } /** * the color of the guidelines lines.
* Default: Color.argb(170, 255, 255, 255) */ public ActivityBuilder setGuidelinesColor(int guidelinesColor) { mOptions.guidelinesColor = guidelinesColor; return this; } /** * the color of the overlay background around the crop window cover the image parts not in the crop window.
* Default: Color.argb(119, 0, 0, 0) */ public ActivityBuilder setBackgroundColor(int backgroundColor) { mOptions.backgroundColor = backgroundColor; return this; } /** * the min size the crop window is allowed to be (in pixels).
* Default: 42dp, 42dp */ public ActivityBuilder setMinCropWindowSize(int minCropWindowWidth, int minCropWindowHeight) { mOptions.minCropWindowWidth = minCropWindowWidth; mOptions.minCropWindowHeight = minCropWindowHeight; return this; } /** * the min size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
* Default: 40px, 40px */ public ActivityBuilder setMinCropResultSize(int minCropResultWidth, int minCropResultHeight) { mOptions.minCropResultWidth = minCropResultWidth; mOptions.minCropResultHeight = minCropResultHeight; return this; } /** * the max size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
* Default: 99999, 99999 */ public ActivityBuilder setMaxCropResultSize(int maxCropResultWidth, int maxCropResultHeight) { mOptions.maxCropResultWidth = maxCropResultWidth; mOptions.maxCropResultHeight = maxCropResultHeight; return this; } /** * the Android Uri to save the cropped image to.
* Default: NONE, will create a temp file */ public ActivityBuilder setOutputUri(Uri outputUri) { mOptions.outputUri = outputUri; return this; } /** * the compression format to use when writting the image.
* Default: JPEG */ public ActivityBuilder setOutputCompressFormat(Bitmap.CompressFormat outputCompressFormat) { mOptions.outputCompressFormat = outputCompressFormat; return this; } /** * the quility (if applicable) to use when writting the image (0 - 100).
* Default: 90 */ public ActivityBuilder setOutputCompressQuality(int outputCompressQuality) { mOptions.outputCompressQuality = outputCompressQuality; return this; } /** * the size to resize the cropped image to.
* Uses {@link CropImageView.RequestSizeOptions#RESIZE_INSIDE} option.
* Default: 0, 0 - not set, will not resize */ public ActivityBuilder setRequestedSize(int reqWidth, int reqHeight) { return setRequestedSize(reqWidth, reqHeight, CropImageView.RequestSizeOptions.RESIZE_INSIDE); } /** * the size to resize the cropped image to.
* Default: 0, 0 - not set, will not resize */ public ActivityBuilder setRequestedSize(int reqWidth, int reqHeight, CropImageView.RequestSizeOptions options) { mOptions.outputRequestWidth = reqWidth; mOptions.outputRequestHeight = reqHeight; mOptions.outputRequestSizeOptions = options; return this; } /** * if the result of crop image activity should not save the cropped image bitmap.
* Used if you want to crop the image manually and need only the crop rectangle and rotation data.
* Default: false */ public ActivityBuilder setNoOutputImage(boolean noOutputImage) { mOptions.noOutputImage = noOutputImage; return this; } /** * the initial rectangle to set on the cropping image after loading.
* Default: NONE - will initialize using initial crop window padding ratio */ public ActivityBuilder setInitialCropWindowRectangle(Rect initialCropWindowRectangle) { mOptions.initialCropWindowRectangle = initialCropWindowRectangle; return this; } /** * the initial rotation to set on the cropping image after loading (0-360 degrees clockwise).
* Default: NONE - will read image exif data */ public ActivityBuilder setInitialRotation(int initialRotation) { mOptions.initialRotation = initialRotation; return this; } /** * if to allow rotation during cropping.
* Default: true */ public ActivityBuilder setAllowRotation(boolean allowRotation) { mOptions.allowRotation = allowRotation; return this; } /** * The amount of degreees to rotate clockwise or counter-clockwise (0-360).
* Default: 90 */ public ActivityBuilder setRotationDegrees(int rotationDegrees) { mOptions.rotationDegrees = rotationDegrees; return this; } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/ActivityResult.java ================================================ package com.github.gzuliyujiang.imagepicker; import android.graphics.Bitmap; import android.graphics.Rect; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; /** * Result data of Crop Image Activity. */ public class ActivityResult extends CropImageView.CropResult implements Parcelable { public static final Creator CREATOR = new Creator() { @Override public ActivityResult createFromParcel(Parcel in) { return new ActivityResult(in); } @Override public ActivityResult[] newArray(int size) { return new ActivityResult[size]; } }; public ActivityResult(Bitmap bitmap, Uri uri, Exception error, float[] cropPoints, Rect cropRect, int rotation, int sampleSize) { super(bitmap, uri, error, cropPoints, cropRect, rotation, sampleSize); } protected ActivityResult(Parcel in) { super(null, in.readParcelable(Uri.class.getClassLoader()), (Exception) in.readSerializable(), in.createFloatArray(), in.readParcelable(Rect.class.getClassLoader()), in.readInt(), in.readInt()); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeParcelable(getUri(), flags); dest.writeSerializable(getError()); dest.writeFloatArray(getCropPoints()); dest.writeParcelable(getCropRect(), flags); dest.writeInt(getRotation()); dest.writeInt(getSampleSize()); } @Override public int describeContents() { return 0; } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/BitmapCroppingTask.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.net.Uri; import android.os.AsyncTask; import java.lang.ref.WeakReference; /** * Task to crop bitmap asynchronously from the UI thread. */ @SuppressLint("StaticFieldLeak") final class BitmapCroppingTask extends AsyncTask { //region: Fields and Consts /** * Use a WeakReference to ensure the ImageView can be garbage collected */ private final WeakReference mCropImageViewReference; /** * the bitmap to crop */ private final Bitmap mBitmap; /** * The Android URI of the image to load */ private final Uri mUri; /** * Required cropping 4 points (x0,y0,x1,y1,x2,y2,x3,y3) */ private final float[] mCropPoints; /** * Degrees the image was rotated after loading */ private final int mDegreesRotated; /** * the original width of the image to be cropped (for image loaded from URI) */ private final int mOrgWidth; /** * the original height of the image to be cropped (for image loaded from URI) */ private final int mOrgHeight; /** * is there is fixed aspect ratio for the crop rectangle */ private final boolean mFixAspectRatio; /** * the X aspect ration of the crop rectangle */ private final int mAspectRatioX; /** * the Y aspect ration of the crop rectangle */ private final int mAspectRatioY; /** * required width of the cropping image */ private final int mReqWidth; /** * required height of the cropping image */ private final int mReqHeight; /** * The option to handle requested width/height */ private final CropImageView.RequestSizeOptions mReqSizeOptions; /** * the Android Uri to save the cropped image to */ private final Uri mSaveUri; /** * the compression format to use when writing the image */ private final Bitmap.CompressFormat mSaveCompressFormat; /** * the quality (if applicable) to use when writing the image (0 - 100) */ private final int mSaveCompressQuality; //endregion BitmapCroppingTask(CropImageView cropImageView, Bitmap bitmap, float[] cropPoints, int degreesRotated, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY, int reqWidth, int reqHeight, CropImageView.RequestSizeOptions options, Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality) { mCropImageViewReference = new WeakReference<>(cropImageView); mBitmap = bitmap; mCropPoints = cropPoints; mUri = null; mDegreesRotated = degreesRotated; mFixAspectRatio = fixAspectRatio; mAspectRatioX = aspectRatioX; mAspectRatioY = aspectRatioY; mReqWidth = reqWidth; mReqHeight = reqHeight; mReqSizeOptions = options; mSaveUri = saveUri; mSaveCompressFormat = saveCompressFormat; mSaveCompressQuality = saveCompressQuality; mOrgWidth = 0; mOrgHeight = 0; } BitmapCroppingTask(CropImageView cropImageView, Uri uri, float[] cropPoints, int degreesRotated, int orgWidth, int orgHeight, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY, int reqWidth, int reqHeight, CropImageView.RequestSizeOptions options, Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality) { mCropImageViewReference = new WeakReference<>(cropImageView); mUri = uri; mCropPoints = cropPoints; mDegreesRotated = degreesRotated; mFixAspectRatio = fixAspectRatio; mAspectRatioX = aspectRatioX; mAspectRatioY = aspectRatioY; mOrgWidth = orgWidth; mOrgHeight = orgHeight; mReqWidth = reqWidth; mReqHeight = reqHeight; mReqSizeOptions = options; mSaveUri = saveUri; mSaveCompressFormat = saveCompressFormat; mSaveCompressQuality = saveCompressQuality; mBitmap = null; } /** * The Android URI that this task is currently loading. */ public Uri getUri() { return mUri; } /** * Crop image in background. * * @param params ignored * @return the decoded bitmap data */ @Override protected BitmapCroppingTask.Result doInBackground(Void... params) { try { if (!isCancelled()) { CropImageView cropImageView = mCropImageViewReference.get(); Context mContext = cropImageView.getContext(); BitmapUtils.BitmapSampled bitmapSampled; if (mUri != null) { bitmapSampled = BitmapUtils.cropBitmap(mContext, mUri, mCropPoints, mDegreesRotated, mOrgWidth, mOrgHeight, mFixAspectRatio, mAspectRatioX, mAspectRatioY, mReqWidth, mReqHeight); } else if (mBitmap != null) { bitmapSampled = BitmapUtils.cropBitmapObjectHandleOOM(mBitmap, mCropPoints, mDegreesRotated, mFixAspectRatio, mAspectRatioX, mAspectRatioY); } else { return new Result((Bitmap) null, 1); } Bitmap bitmap = BitmapUtils.resizeBitmap(bitmapSampled.bitmap, mReqWidth, mReqHeight, mReqSizeOptions); if (mSaveUri == null) { return new Result(bitmap, bitmapSampled.sampleSize); } else { BitmapUtils.writeBitmapToUri(mContext, bitmap, mSaveUri, mSaveCompressFormat, mSaveCompressQuality); bitmap.recycle(); return new Result(mSaveUri, bitmapSampled.sampleSize); } } return null; } catch (Exception e) { return new Result(e, mSaveUri != null); } } /** * Once complete, see if ImageView is still around and set bitmap. * * @param result the result of bitmap cropping */ @Override protected void onPostExecute(Result result) { if (result != null) { boolean completeCalled = false; if (!isCancelled()) { CropImageView cropImageView = mCropImageViewReference.get(); if (cropImageView != null) { completeCalled = true; cropImageView.onImageCroppingAsyncComplete(result); } } if (!completeCalled && result.bitmap != null) { // fast release of unused bitmap result.bitmap.recycle(); } } } //region: Inner class: Result /** * The result of BitmapCroppingWorkerTask async loading. */ static final class Result { /** * The cropped bitmap */ public final Bitmap bitmap; /** * The saved cropped bitmap uri */ public final Uri uri; /** * The error that occurred during async bitmap cropping. */ final Exception error; /** * is the cropping request was to get a bitmap or to save it to uri */ final boolean isSave; /** * sample size used creating the crop bitmap to lower its size */ final int sampleSize; Result(Bitmap bitmap, int sampleSize) { this.bitmap = bitmap; this.uri = null; this.error = null; this.isSave = false; this.sampleSize = sampleSize; } Result(Uri uri, int sampleSize) { this.bitmap = null; this.uri = uri; this.error = null; this.isSave = true; this.sampleSize = sampleSize; } Result(Exception error, boolean isSave) { this.bitmap = null; this.uri = null; this.error = error; this.isSave = isSave; this.sampleSize = 1; } } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/BitmapLoadingTask.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.content.Context; import android.graphics.Bitmap; import android.net.Uri; import android.os.AsyncTask; import android.util.DisplayMetrics; import java.lang.ref.WeakReference; /** * Task to load bitmap asynchronously from the UI thread. */ final class BitmapLoadingTask extends AsyncTask { //region: Fields and Consts /** * Use a WeakReference to ensure the ImageView can be garbage collected */ private final WeakReference mCropImageViewReference; /** * The Android URI of the image to load */ private final Uri mUri; /** * required width of the cropping image after density adjustment */ private final int mWidth; /** * required height of the cropping image after density adjustment */ private final int mHeight; //endregion public BitmapLoadingTask(CropImageView cropImageView, Uri uri) { mUri = uri; mCropImageViewReference = new WeakReference<>(cropImageView); DisplayMetrics metrics = cropImageView.getResources().getDisplayMetrics(); double densityAdj = metrics.density > 1 ? 1 / metrics.density : 1; mWidth = (int) (metrics.widthPixels * densityAdj); mHeight = (int) (metrics.heightPixels * densityAdj); } /** * The Android URI that this task is currently loading. */ public Uri getUri() { return mUri; } /** * Decode image in background. * * @param params ignored * @return the decoded bitmap data */ @Override protected Result doInBackground(Void... params) { try { CropImageView cropImageView = mCropImageViewReference.get(); Context mContext = cropImageView.getContext(); if (!isCancelled()) { BitmapUtils.BitmapSampled decodeResult = BitmapUtils.decodeSampledBitmap(mContext, mUri, mWidth, mHeight); if (!isCancelled()) { BitmapUtils.RotateBitmapResult rotateResult = BitmapUtils.rotateBitmapByExif(decodeResult.bitmap, mContext, mUri); return new Result(mUri, rotateResult.bitmap, decodeResult.sampleSize, rotateResult.degrees); } } return null; } catch (Exception e) { return new Result(mUri, e); } } /** * Once complete, see if ImageView is still around and set bitmap. * * @param result the result of bitmap loading */ @Override protected void onPostExecute(Result result) { if (result != null) { boolean completeCalled = false; if (!isCancelled()) { CropImageView cropImageView = mCropImageViewReference.get(); if (cropImageView != null) { completeCalled = true; cropImageView.onSetImageUriAsyncComplete(result); } } if (!completeCalled && result.bitmap != null) { // fast release of unused bitmap result.bitmap.recycle(); } } } //region: Inner class: Result /** * The result of BitmapLoadingWorkerTask async loading. */ public static final class Result { /** * The Android URI of the image to load */ public final Uri uri; /** * The loaded bitmap */ public final Bitmap bitmap; /** * The sample size used to load the given bitmap */ public final int loadSampleSize; /** * The degrees the image was rotated */ public final int degreesRotated; /** * The error that occurred during async bitmap loading. */ public final Exception error; Result(Uri uri, Bitmap bitmap, int loadSampleSize, int degreesRotated) { this.uri = uri; this.bitmap = bitmap; this.loadSampleSize = loadSampleSize; this.degreesRotated = degreesRotated; this.error = null; } Result(Uri uri, Exception error) { this.uri = uri; this.bitmap = null; this.loadSampleSize = 0; this.degreesRotated = 0; this.error = error; } } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/BitmapUtils.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; import android.net.Uri; import android.provider.MediaStore; import android.util.Log; import android.util.Pair; import androidx.exifinterface.media.ExifInterface; import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.ref.WeakReference; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; /** * Utility class that deals with operations with an ImageView. */ final class BitmapUtils { static final Rect EMPTY_RECT = new Rect(); static final RectF EMPTY_RECT_F = new RectF(); /** * Reusable rectangle for general internal usage */ static final RectF RECT = new RectF(); /** * Reusable point for general internal usage */ static final float[] POINTS = new float[6]; /** * Reusable point for general internal usage */ static final float[] POINTS2 = new float[6]; /** * Used to know the max texture size allowed to be rendered */ private static int mMaxTextureSize; /** * used to save bitmaps during state save and restore so not to reload them. */ static Pair> mStateBitmap; /** * Rotate the given image by reading the Exif value of the image (uri).
* If no rotation is required the image will not be rotated.
* New bitmap is created and the old one is recycled. */ static RotateBitmapResult rotateBitmapByExif(Bitmap bitmap, Context context, Uri uri) { try { File file = getFileFromUri(context, uri); if (file.exists()) { ExifInterface ei = new ExifInterface(file.getAbsolutePath()); return rotateBitmapByExif(bitmap, ei); } } catch (Exception ignored) { } return new RotateBitmapResult(bitmap, 0); } /** * Rotate the given image by given Exif value.
* If no rotation is required the image will not be rotated.
* New bitmap is created and the old one is recycled. */ static RotateBitmapResult rotateBitmapByExif(Bitmap bitmap, ExifInterface exif) { int degrees; int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: degrees = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degrees = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degrees = 270; break; default: degrees = 0; break; } return new RotateBitmapResult(bitmap, degrees); } /** * Decode bitmap from stream using sampling to get bitmap with the requested limit. */ static BitmapSampled decodeSampledBitmap(Context context, Uri uri, int reqWidth, int reqHeight) { try { ContentResolver resolver = context.getContentResolver(); // First decode with inJustDecodeBounds=true to check dimensions BitmapFactory.Options options = decodeImageForOption(resolver, uri); // Calculate inSampleSize options.inSampleSize = Math.max( calculateInSampleSizeByReqestedSize(options.outWidth, options.outHeight, reqWidth, reqHeight), calculateInSampleSizeByMaxTextureSize(options.outWidth, options.outHeight)); // Decode bitmap with inSampleSize set Bitmap bitmap = decodeImage(resolver, uri, options); return new BitmapSampled(bitmap, options.inSampleSize); } catch (Exception e) { throw new RuntimeException("Failed to load sampled bitmap: " + uri + "\r\n" + e.getMessage(), e); } } /** * Crop image bitmap from given bitmap using the given points in the original bitmap and the given rotation.
* if the rotation is not 0,90,180 or 270 degrees then we must first crop a larger area of the image that * contains the requires rectangle, rotate and then crop again a sub rectangle.
* If crop fails due to OOM we scale the cropping image by 0.5 every time it fails until it is small enough. */ static BitmapSampled cropBitmapObjectHandleOOM(Bitmap bitmap, float[] points, int degreesRotated, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY) { int scale = 1; while (true) { try { Bitmap cropBitmap = cropBitmapObjectWithScale(bitmap, points, degreesRotated, fixAspectRatio, aspectRatioX, aspectRatioY, 1 / (float) scale); return new BitmapSampled(cropBitmap, scale); } catch (OutOfMemoryError e) { scale *= 2; if (scale > 8) { throw e; } } } } /** * Crop image bitmap from given bitmap using the given points in the original bitmap and the given rotation.
* if the rotation is not 0,90,180 or 270 degrees then we must first crop a larger area of the image that * contains the requires rectangle, rotate and then crop again a sub rectangle. * * @param scale how much to scale the cropped image part, use 0.5 to lower the image by half (OOM handling) */ private static Bitmap cropBitmapObjectWithScale(Bitmap bitmap, float[] points, int degreesRotated, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY, float scale) { // get the rectangle in original image that contains the required cropped area (larger for non rectangular crop) Rect rect = getRectFromPoints(points, bitmap.getWidth(), bitmap.getHeight(), fixAspectRatio, aspectRatioX, aspectRatioY); // crop and rotate the cropped image in one operation Matrix matrix = new Matrix(); matrix.setScale(scale, scale); matrix.postRotate(degreesRotated, bitmap.getWidth() / 2f, bitmap.getHeight() / 2f); Bitmap result = Bitmap.createBitmap(bitmap, rect.left, rect.top, rect.width(), rect.height(), matrix, true); if (result == bitmap) { // corner case when all bitmap is selected, no worth optimizing for it result = bitmap.copy(bitmap.getConfig(), false); } // rotating by 0, 90, 180 or 270 degrees doesn't require extra cropping if (degreesRotated % 90 != 0) { // extra crop because non rectangular crop cannot be done directly on the image without rotating first result = cropForRotatedImage(result, points, rect, degreesRotated, fixAspectRatio, aspectRatioX, aspectRatioY); } return result; } /** * Crop image bitmap from URI by decoding it with specific width and height to down-sample if required.
* Additionally if OOM is thrown try to increase the sampling (2,4,8). */ static BitmapSampled cropBitmap(Context context, Uri loadedImageUri, float[] points, int degreesRotated, int orgWidth, int orgHeight, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY, int reqWidth, int reqHeight) { int sampleMulti = 1; while (true) { try { // if successful, just return the resulting bitmap return cropBitmap(context, loadedImageUri, points, degreesRotated, orgWidth, orgHeight, fixAspectRatio, aspectRatioX, aspectRatioY, reqWidth, reqHeight, sampleMulti); } catch (OutOfMemoryError e) { // if OOM try to increase the sampling to lower the memory usage sampleMulti *= 2; if (sampleMulti > 16) { throw new RuntimeException("Failed to handle OOM by sampling (" + sampleMulti + "): " + loadedImageUri + "\r\n" + e.getMessage(), e); } } } } /** * Get left value of the bounding rectangle of the given points. */ static float getRectLeft(float[] points) { return Math.min(Math.min(Math.min(points[0], points[2]), points[4]), points[6]); } /** * Get top value of the bounding rectangle of the given points. */ static float getRectTop(float[] points) { return Math.min(Math.min(Math.min(points[1], points[3]), points[5]), points[7]); } /** * Get right value of the bounding rectangle of the given points. */ static float getRectRight(float[] points) { return Math.max(Math.max(Math.max(points[0], points[2]), points[4]), points[6]); } /** * Get bottom value of the bounding rectangle of the given points. */ static float getRectBottom(float[] points) { return Math.max(Math.max(Math.max(points[1], points[3]), points[5]), points[7]); } /** * Get width of the bounding rectangle of the given points. */ static float getRectWidth(float[] points) { return getRectRight(points) - getRectLeft(points); } /** * Get heightof the bounding rectangle of the given points. */ static float getRectHeight(float[] points) { return getRectBottom(points) - getRectTop(points); } /** * Get horizontal center value of the bounding rectangle of the given points. */ static float getRectCenterX(float[] points) { return (getRectRight(points) + getRectLeft(points)) / 2f; } /** * Get verical center value of the bounding rectangle of the given points. */ static float getRectCenterY(float[] points) { return (getRectBottom(points) + getRectTop(points)) / 2f; } /** * Get a rectangle for the given 4 points (x0,y0,x1,y1,x2,y2,x3,y3) by finding the min/max 2 points that * contains the given 4 points and is a stright rectangle. */ static Rect getRectFromPoints(float[] points, int imageWidth, int imageHeight, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY) { int left = Math.round(Math.max(0, getRectLeft(points))); int top = Math.round(Math.max(0, getRectTop(points))); int right = Math.round(Math.min(imageWidth, getRectRight(points))); int bottom = Math.round(Math.min(imageHeight, getRectBottom(points))); Rect rect = new Rect(left, top, right, bottom); if (fixAspectRatio) { fixRectForAspectRatio(rect, aspectRatioX, aspectRatioY); } return rect; } /** * Fix the given rectangle if it doesn't confirm to aspect ration rule.
* Make sure that width and height are equal if 1:1 fixed aspect ratio is requested. */ private static void fixRectForAspectRatio(Rect rect, int aspectRatioX, int aspectRatioY) { if (aspectRatioX == aspectRatioY && rect.width() != rect.height()) { if (rect.height() > rect.width()) { rect.bottom -= rect.height() - rect.width(); } else { rect.right -= rect.width() - rect.height(); } } } /** * Write the given bitmap to the given uri using the given compression. */ static void writeBitmapToUri(Context context, Bitmap bitmap, Uri uri, Bitmap.CompressFormat compressFormat, int compressQuality) throws FileNotFoundException { OutputStream outputStream = null; try { outputStream = context.getContentResolver().openOutputStream(uri); bitmap.compress(compressFormat, compressQuality, outputStream); } finally { closeSafe(outputStream); } } /** * Resize the given bitmap to the given width/height by the given option.
*/ static Bitmap resizeBitmap(Bitmap bitmap, int reqWidth, int reqHeight, CropImageView.RequestSizeOptions options) { try { if (reqWidth > 0 && reqHeight > 0 && (options == CropImageView.RequestSizeOptions.RESIZE_FIT || options == CropImageView.RequestSizeOptions.RESIZE_INSIDE || options == CropImageView.RequestSizeOptions.RESIZE_EXACT)) { Bitmap resized = null; if (options == CropImageView.RequestSizeOptions.RESIZE_EXACT) { resized = Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, false); } else { int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scale = Math.max(width / (float) reqWidth, height / (float) reqHeight); if (scale > 1 || options == CropImageView.RequestSizeOptions.RESIZE_FIT) { resized = Bitmap.createScaledBitmap(bitmap, (int) (width / scale), (int) (height / scale), false); } } if (resized != null) { if (resized != bitmap) { bitmap.recycle(); } return resized; } } } catch (Exception e) { Log.w("AIC", "Failed to resize cropped image, return bitmap before resize", e); } return bitmap; } //region: Private methods /** * Crop image bitmap from URI by decoding it with specific width and height to down-sample if required. * * @param orgWidth used to get rectangle from points (handle edge cases to limit rectangle) * @param orgHeight used to get rectangle from points (handle edge cases to limit rectangle) * @param sampleMulti used to increase the sampling of the image to handle memory issues. */ private static BitmapSampled cropBitmap(Context context, Uri loadedImageUri, float[] points, int degreesRotated, int orgWidth, int orgHeight, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY, int reqWidth, int reqHeight, int sampleMulti) { // get the rectangle in original image that contains the required cropped area (larger for non rectangular crop) Rect rect = getRectFromPoints(points, orgWidth, orgHeight, fixAspectRatio, aspectRatioX, aspectRatioY); int width = reqWidth > 0 ? reqWidth : rect.width(); int height = reqHeight > 0 ? reqHeight : rect.height(); Bitmap result = null; int sampleSize = 1; try { // decode only the required image from URI, optionally sub-sampling if reqWidth/reqHeight is given. BitmapSampled bitmapSampled = decodeSampledBitmapRegion(context, loadedImageUri, rect, width, height, sampleMulti); result = bitmapSampled.bitmap; sampleSize = bitmapSampled.sampleSize; } catch (Exception ignored) { } if (result != null) { try { // rotate the decoded region by the required amount result = rotateBitmapInt(result, degreesRotated); // rotating by 0, 90, 180 or 270 degrees doesn't require extra cropping if (degreesRotated % 90 != 0) { // extra crop because non rectangular crop cannot be done directly on the image without rotating first result = cropForRotatedImage(result, points, rect, degreesRotated, fixAspectRatio, aspectRatioX, aspectRatioY); } } catch (OutOfMemoryError e) { if (result != null) { result.recycle(); } throw e; } return new BitmapSampled(result, sampleSize); } else { // failed to decode region, may be skia issue, try full decode and then crop return cropBitmap(context, loadedImageUri, points, degreesRotated, fixAspectRatio, aspectRatioX, aspectRatioY, sampleMulti, rect, width, height); } } /** * Crop bitmap by fully loading the original and then cropping it, fallback in case cropping region failed. */ private static BitmapSampled cropBitmap(Context context, Uri loadedImageUri, float[] points, int degreesRotated, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY, int sampleMulti, Rect rect, int width, int height) { Bitmap result = null; int sampleSize; try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = sampleSize = sampleMulti * calculateInSampleSizeByReqestedSize(rect.width(), rect.height(), width, height); Bitmap fullBitmap = decodeImage(context.getContentResolver(), loadedImageUri, options); if (fullBitmap != null) { try { // adjust crop points by the sampling because the image is smaller float[] points2 = new float[points.length]; System.arraycopy(points, 0, points2, 0, points.length); for (int i = 0; i < points2.length; i++) { points2[i] = points2[i] / options.inSampleSize; } result = cropBitmapObjectWithScale(fullBitmap, points2, degreesRotated, fixAspectRatio, aspectRatioX, aspectRatioY, 1); } finally { if (result != fullBitmap) { fullBitmap.recycle(); } } } } catch (OutOfMemoryError e) { if (result != null) { result.recycle(); } throw e; } catch (Exception e) { throw new RuntimeException("Failed to load sampled bitmap: " + loadedImageUri + "\r\n" + e.getMessage(), e); } return new BitmapSampled(result, sampleSize); } /** * Decode image from uri using "inJustDecodeBounds" to get the image dimensions. */ private static BitmapFactory.Options decodeImageForOption(ContentResolver resolver, Uri uri) throws FileNotFoundException { InputStream stream = null; try { stream = resolver.openInputStream(uri); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(stream, EMPTY_RECT, options); options.inJustDecodeBounds = false; return options; } finally { closeSafe(stream); } } /** * Decode image from uri using given "inSampleSize", but if failed due to out-of-memory then raise * the inSampleSize until success. */ private static Bitmap decodeImage(ContentResolver resolver, Uri uri, BitmapFactory.Options options) throws FileNotFoundException { do { InputStream stream = null; try { stream = resolver.openInputStream(uri); return BitmapFactory.decodeStream(stream, EMPTY_RECT, options); } catch (OutOfMemoryError e) { options.inSampleSize *= 2; } finally { closeSafe(stream); } } while (options.inSampleSize <= 512); throw new RuntimeException("Failed to decode image: " + uri); } /** * Decode specific rectangle bitmap from stream using sampling to get bitmap with the requested limit. * * @param sampleMulti used to increase the sampling of the image to handle memory issues. */ private static BitmapSampled decodeSampledBitmapRegion(Context context, Uri uri, Rect rect, int reqWidth, int reqHeight, int sampleMulti) { InputStream stream = null; BitmapRegionDecoder decoder = null; try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = sampleMulti * calculateInSampleSizeByReqestedSize(rect.width(), rect.height(), reqWidth, reqHeight); stream = context.getContentResolver().openInputStream(uri); decoder = BitmapRegionDecoder.newInstance(stream, false); do { try { return new BitmapSampled(decoder.decodeRegion(rect, options), options.inSampleSize); } catch (OutOfMemoryError e) { options.inSampleSize *= 2; } } while (options.inSampleSize <= 512); } catch (Exception e) { throw new RuntimeException("Failed to load sampled bitmap: " + uri + "\r\n" + e.getMessage(), e); } finally { closeSafe(stream); if (decoder != null) { decoder.recycle(); } } return new BitmapSampled(null, 1); } /** * Special crop of bitmap rotated by not stright angle, in this case the original crop bitmap contains parts * beyond the required crop area, this method crops the already cropped and rotated bitmap to the final * rectangle.
* Note: rotating by 0, 90, 180 or 270 degrees doesn't require extra cropping. */ private static Bitmap cropForRotatedImage(Bitmap bitmap, float[] points, Rect rect, int degreesRotated, boolean fixAspectRatio, int aspectRatioX, int aspectRatioY) { if (degreesRotated % 90 != 0) { int adjLeft = 0, adjTop = 0, width = 0, height = 0; double rads = Math.toRadians(degreesRotated); int compareTo = degreesRotated < 90 || (degreesRotated > 180 && degreesRotated < 270) ? rect.left : rect.right; for (int i = 0; i < points.length; i += 2) { if (points[i] >= compareTo - 1 && points[i] <= compareTo + 1) { adjLeft = (int) Math.abs(Math.sin(rads) * (rect.bottom - points[i + 1])); adjTop = (int) Math.abs(Math.cos(rads) * (points[i + 1] - rect.top)); width = (int) Math.abs((points[i + 1] - rect.top) / Math.sin(rads)); height = (int) Math.abs((rect.bottom - points[i + 1]) / Math.cos(rads)); break; } } rect.set(adjLeft, adjTop, adjLeft + width, adjTop + height); if (fixAspectRatio) { fixRectForAspectRatio(rect, aspectRatioX, aspectRatioY); } Bitmap bitmapTmp = bitmap; bitmap = Bitmap.createBitmap(bitmap, rect.left, rect.top, rect.width(), rect.height()); if (bitmapTmp != bitmap) { bitmapTmp.recycle(); } } return bitmap; } /** * Calculate the largest inSampleSize value that is a power of 2 and keeps both * height and width larger than the requested height and width. */ private static int calculateInSampleSizeByReqestedSize(int width, int height, int reqWidth, int reqHeight) { int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { while ((height / 2 / inSampleSize) > reqHeight && (width / 2 / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } /** * Calculate the largest inSampleSize value that is a power of 2 and keeps both * height and width smaller than max texture size allowed for the device. */ private static int calculateInSampleSizeByMaxTextureSize(int width, int height) { int inSampleSize = 1; if (mMaxTextureSize == 0) { mMaxTextureSize = getMaxTextureSize(); } if (mMaxTextureSize > 0) { while ((height / inSampleSize) > mMaxTextureSize || (width / inSampleSize) > mMaxTextureSize) { inSampleSize *= 2; } } return inSampleSize; } /** * Get {@link File} object for the given Android URI.
* Use content resolver to get real path if direct path doesn't return valid file. */ private static File getFileFromUri(Context context, Uri uri) { // first try by direct path File file = new File(uri.getPath()); if (file.exists()) { return file; } // try reading real path from content resolver (gallery images) Cursor cursor = null; try { String[] proj = { MediaStore.Images.Media.DATA}; cursor = context.getContentResolver().query(uri, proj, null, null, null); if (cursor != null) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String realPath = cursor.getString(column_index); file = new File(realPath); } } catch (Exception ignored) { } finally { if (cursor != null) { cursor.close(); } } return file; } /** * Rotate the given bitmap by the given degrees.
* New bitmap is created and the old one is recycled. */ private static Bitmap rotateBitmapInt(Bitmap bitmap, int degrees) { if (degrees > 0) { Matrix matrix = new Matrix(); matrix.setRotate(degrees); Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); if (newBitmap != bitmap) { bitmap.recycle(); } return newBitmap; } else { return bitmap; } } /** * Get the max size of bitmap allowed to be rendered on the device.
* http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit. */ private static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; try { // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) { maximumTextureSize = textureSize[0]; } } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); } catch (Exception e) { return IMAGE_MAX_BITMAP_DIMENSION; } } /** * Close the given closeable object (Stream) in a safe way: check if it is null and catch-log * exception thrown. * * @param closeable the closable object to close */ private static void closeSafe(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException ignored) { } } } //endregion //region: Inner class: BitmapSampled /** * Holds bitmap instance and the sample size that the bitmap was loaded/cropped with. */ static final class BitmapSampled { /** * The bitmap instance */ public final Bitmap bitmap; /** * The sample size used to lower the size of the bitmap (1,2,4,8,...) */ final int sampleSize; BitmapSampled(Bitmap bitmap, int sampleSize) { this.bitmap = bitmap; this.sampleSize = sampleSize; } } //endregion //region: Inner class: RotateBitmapResult /** * The result of {@link #rotateBitmapByExif(Bitmap, ExifInterface)}. */ static final class RotateBitmapResult { /** * The loaded bitmap */ public final Bitmap bitmap; /** * The degrees the image was rotated */ final int degrees; RotateBitmapResult(Bitmap bitmap, int degrees) { this.bitmap = bitmap; this.degrees = degrees; } } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropImageActivity.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import java.io.File; import java.io.IOException; /** * Built-in activity for image cropping.
*/ public class CropImageActivity extends FragmentActivity implements View.OnClickListener, CropImageView.OnSetImageUriCompleteListener, CropImageView.OnCropImageCompleteListener { /** * The crop image view library widget used in the activity */ private CropImageView mCropImageView; /** * Persist URI image to crop URI if specific permissions are required */ private Uri mCropImageUri; /** * the options that were set for the crop image */ private CropImageOptions mOptions; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setStatusBarColor(0xFF000000); getWindow().setNavigationBarColor(0xFF000000); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { getWindow().setNavigationBarDividerColor(0xFF000000); } setContentView(R.layout.crop_image_activity); findViewById(R.id.crop_image_back).setOnClickListener(this); View rotateView = findViewById(R.id.crop_image_rotate); rotateView.setOnClickListener(this); findViewById(R.id.crop_image_done).setOnClickListener(this); mCropImageView = findViewById(R.id.crop_image_content); Intent intent = getIntent(); mCropImageUri = intent.getParcelableExtra(CropImageConsts.CROP_IMAGE_EXTRA_SOURCE); mOptions = intent.getParcelableExtra(CropImageConsts.CROP_IMAGE_EXTRA_OPTIONS); mCropImageView.setCropImageOptions(mOptions); if (!mOptions.allowRotation) { rotateView.setVisibility(View.GONE); } if (savedInstanceState == null) { if (mCropImageUri == null || mCropImageUri.equals(Uri.EMPTY)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && HybridityUtils.isExplicitCameraPermissionRequired(this)) { // request permissions and handle the result in onRequestPermissionsResult() requestPermissions(new String[]{Manifest.permission.CAMERA}, CropImageConsts.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE); } else { startCamera(); } } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && HybridityUtils.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) { // request permissions and handle the result in onRequestPermissionsResult() requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImageConsts.PICK_IMAGE_PERMISSIONS_REQUEST_CODE); } else { // no permissions required or already grunted, can start crop image activity mCropImageView.setImageUriAsync(mCropImageUri); } } } private void startCamera() { startActivityForResult(HybridityUtils.getCameraIntent(this), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } @Override public void onClick(View view) { int id = view.getId(); if (id == R.id.crop_image_back) { setResultCancel(); } else if (id == R.id.crop_image_rotate) { rotateImage(mOptions.rotationDegrees); } else if (id == R.id.crop_image_done) { cropImage(); } } @Override protected void onStart() { super.onStart(); mCropImageView.setOnSetImageUriCompleteListener(this); mCropImageView.setOnCropImageCompleteListener(this); } @Override protected void onStop() { super.onStop(); mCropImageView.setOnSetImageUriCompleteListener(null); mCropImageView.setOnCropImageCompleteListener(null); } @Override public void onBackPressed() { super.onBackPressed(); setResultCancel(); } @Override @SuppressLint("NewApi") protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // handle result of pick image chooser if (requestCode == CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE) { if (resultCode == Activity.RESULT_CANCELED) { //User cancelled the picker. We don't have anything to crop setResultCancel(); } if (resultCode == Activity.RESULT_OK) { mCropImageUri = HybridityUtils.getPickImageResultUri(this, data); // For API >= 23 we need to check specifically that we have permissions to read external storage. if (HybridityUtils.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) { // request permissions and handle the result in onRequestPermissionsResult() requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImageConsts.PICK_IMAGE_PERMISSIONS_REQUEST_CODE); } else { // no permissions required or already grunted, can start crop image activity mCropImageView.setImageUriAsync(mCropImageUri); } } } } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == CropImageConsts.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) { if (mCropImageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // required permissions granted, start crop image activity mCropImageView.setImageUriAsync(mCropImageUri); } else { // Cancelling, required permissions are not granted setResultCancel(); } } else if (requestCode == CropImageConsts.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) { //Irrespective of whether camera permission was given or not, we show the picker //The picker will not add the camera intent if permission is not available startCamera(); } } @Override public void onSetImageUriComplete(CropImageView view, Uri uri, Exception error) { if (error == null) { if (mOptions.initialCropWindowRectangle != null) { mCropImageView.setCropRect(mOptions.initialCropWindowRectangle); } if (mOptions.initialRotation > -1) { mCropImageView.setRotatedDegrees(mOptions.initialRotation); } } else { setResult(null, error, 1); } } @Override public void onCropImageComplete(CropImageView view, CropImageView.CropResult result) { setResult(result.getUri(), result.getError(), result.getSampleSize()); } /** * Execute crop image and save the result tou output uri. */ protected void cropImage() { if (mOptions.noOutputImage) { setResult(null, null, 1); } else { Uri outputUri = getOutputUri(); mCropImageView.saveCroppedImageAsync(outputUri, mOptions.outputCompressFormat, mOptions.outputCompressQuality, mOptions.outputRequestWidth, mOptions.outputRequestHeight, mOptions.outputRequestSizeOptions); } } /** * Rotate the image in the crop image view. */ protected void rotateImage(int degrees) { mCropImageView.rotateImage(degrees); } /** * Get Android uri to save the cropped image into.
* Use the given in options or create a temp file. */ protected Uri getOutputUri() { Uri outputUri = mOptions.outputUri; if (outputUri.equals(Uri.EMPTY)) { try { String ext = mOptions.outputCompressFormat == Bitmap.CompressFormat.JPEG ? ".jpg" : mOptions.outputCompressFormat == Bitmap.CompressFormat.PNG ? ".png" : ".webp"; outputUri = Uri.fromFile(File.createTempFile("cropped", ext, getCacheDir())); } catch (IOException e) { throw new RuntimeException("Failed to create temp file for output image", e); } } return outputUri; } /** * Result with cropped image data or error if failed. */ protected void setResult(Uri uri, Exception error, int sampleSize) { int resultCode = error == null ? RESULT_OK : CropImageConsts.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE; setResult(resultCode, getResultIntent(uri, error, sampleSize)); finish(); } /** * Cancel of cropping activity. */ protected void setResultCancel() { setResult(RESULT_CANCELED); finish(); } /** * Get intent instance to be used for the result of this activity. */ protected Intent getResultIntent(Uri uri, Exception error, int sampleSize) { ActivityResult result = new ActivityResult(null, uri, error, mCropImageView.getCropPoints(), mCropImageView.getCropRect(), mCropImageView.getRotatedDegrees(), sampleSize); Intent intent = new Intent(); intent.putExtra(CropImageConsts.CROP_IMAGE_EXTRA_RESULT, result); return intent; } /** * Update the color of a specific menu item to the given color. */ private void updateMenuItemIconColor(Menu menu, int itemId, int color) { MenuItem menuItem = menu.findItem(itemId); if (menuItem != null) { Drawable menuItemIcon = menuItem.getIcon(); if (menuItemIcon != null) { try { menuItemIcon.mutate(); menuItemIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); menuItem.setIcon(menuItemIcon); } catch (Exception ignore) { } } } } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropImageAnimation.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.graphics.Matrix; import android.graphics.RectF; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.ImageView; /** * Animation to handle smooth cropping image matrix transformation change, specifically for zoom-in/out. */ final class CropImageAnimation extends Animation implements Animation.AnimationListener { //region: Fields and Consts private final ImageView mImageView; private final CropOverlayView mCropOverlayView; private final float[] mStartBoundPoints = new float[8]; private final float[] mEndBoundPoints = new float[8]; private final RectF mStartCropWindowRect = new RectF(); private final RectF mEndCropWindowRect = new RectF(); private final float[] mStartImageMatrix = new float[9]; private final float[] mEndImageMatrix = new float[9]; private final RectF mAnimRect = new RectF(); private final float[] mAnimPoints = new float[8]; private final float[] mAnimMatrix = new float[9]; //endregion public CropImageAnimation(ImageView cropImageView, CropOverlayView cropOverlayView) { mImageView = cropImageView; mCropOverlayView = cropOverlayView; setDuration(300); setFillAfter(true); setInterpolator(new AccelerateDecelerateInterpolator()); setAnimationListener(this); } public void setStartState(float[] boundPoints, Matrix imageMatrix) { reset(); System.arraycopy(boundPoints, 0, mStartBoundPoints, 0, 8); mStartCropWindowRect.set(mCropOverlayView.getCropWindowRect()); imageMatrix.getValues(mStartImageMatrix); } public void setEndState(float[] boundPoints, Matrix imageMatrix) { System.arraycopy(boundPoints, 0, mEndBoundPoints, 0, 8); mEndCropWindowRect.set(mCropOverlayView.getCropWindowRect()); imageMatrix.getValues(mEndImageMatrix); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { mAnimRect.left = mStartCropWindowRect.left + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime; mAnimRect.top = mStartCropWindowRect.top + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime; mAnimRect.right = mStartCropWindowRect.right + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime; mAnimRect.bottom = mStartCropWindowRect.bottom + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime; mCropOverlayView.setCropWindowRect(mAnimRect); for (int i = 0; i < mAnimPoints.length; i++) { mAnimPoints[i] = mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime; } mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight()); for (int i = 0; i < mAnimMatrix.length; i++) { mAnimMatrix[i] = mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime; } Matrix m = mImageView.getImageMatrix(); m.setValues(mAnimMatrix); mImageView.setImageMatrix(m); mImageView.invalidate(); mCropOverlayView.invalidate(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mImageView.clearAnimation(); } @Override public void onAnimationRepeat(Animation animation) { } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropImageConsts.java ================================================ package com.github.gzuliyujiang.imagepicker; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/7/29 17:49 */ public final class CropImageConsts { /** * The key used to pass crop image source URI to {@link CropImageActivity}. */ public static final String CROP_IMAGE_EXTRA_SOURCE = "CROP_IMAGE_EXTRA_SOURCE"; /** * The key used to pass crop image options to {@link CropImageActivity}. */ public static final String CROP_IMAGE_EXTRA_OPTIONS = "CROP_IMAGE_EXTRA_OPTIONS"; /** * The key used to pass crop image result data back from {@link CropImageActivity}. */ public static final String CROP_IMAGE_EXTRA_RESULT = "CROP_IMAGE_EXTRA_RESULT"; /** * The request code used to start pick image activity to be used on result to identify the this specific request. */ public static final int PICK_IMAGE_CHOOSER_REQUEST_CODE = 200; /** * The request code used to request permission to pick image from external storage. */ public static final int PICK_IMAGE_PERMISSIONS_REQUEST_CODE = 201; /** * The request code used to request permission to capture image from camera. */ public static final int CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE = 2011; /** * The request code used to start {@link CropImageActivity} to be used on result to identify the this specific * request. */ public static final int CROP_IMAGE_ACTIVITY_REQUEST_CODE = 203; /** * The result code used to return error from {@link CropImageActivity}. */ public static final int CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE = 204; } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropImageOptions.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth; // inexhaustible as the great rivers. // When they come to an end; // they begin again; // like the days and months; // they die and are reborn; // like the four seasons." // // - Sun Tsu; // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Rect; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.util.DisplayMetrics; import android.util.TypedValue; /** * All the possible options that can be set to customize crop image.
* Initialized with default values. */ public class CropImageOptions implements Parcelable { public static final Creator CREATOR = new Creator() { @Override public CropImageOptions createFromParcel(Parcel in) { return new CropImageOptions(in); } @Override public CropImageOptions[] newArray(int size) { return new CropImageOptions[size]; } }; /** * The shape of the cropping window. */ public CropImageView.CropShape cropShape; /** * An edge of the crop window will snap to the corresponding edge of a specified bounding box when the crop * window edge is less than or equal to this distance (in pixels) away from the bounding box edge. (in pixels) */ public float snapRadius; /** * The radius of the touchable area around the handle. (in pixels)
* We are basing this value off of the recommended 48dp Rhythm.
* See: http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm */ public float touchRadius; /** * whether the guidelines should be on, off, or only showing when resizing. */ public CropImageView.Guidelines guidelines; /** * The initial scale type of the image in the crop image view */ public CropImageView.ScaleType scaleType; /** * if to show crop overlay UI what contains the crop window UI surrounded by background over the cropping * image.
* default: true, may disable for animation or frame transition. */ public boolean showCropOverlay; /** * if to show progress bar when image async loading/cropping is in progress.
* default: true, disable to provide custom progress bar UI. */ public boolean showProgressBar; /** * if auto-zoom functionality is enabled.
* default: true. */ public boolean autoZoomEnabled; /** * if multi-touch should be enabled on the crop box * default: false */ public boolean multiTouchEnabled; /** * The max zoom allowed during cropping. */ public int maxZoom; /** * The initial crop window padding from image borders in percentage of the cropping image dimensions. */ public float initialCropWindowPaddingRatio; /** * whether the width to height aspect ratio should be maintained or free to change. */ public boolean fixAspectRatio; /** * the X value of the aspect ratio. */ public int aspectRatioX; /** * the Y value of the aspect ratio. */ public int aspectRatioY; /** * the thickness of the guidelines lines in pixels. (in pixels) */ public float borderLineThickness; /** * the color of the guidelines lines */ public int borderLineColor; /** * thickness of the corner line. (in pixels) */ public float borderCornerThickness; /** * the offset of corner line from crop window border. (in pixels) */ public float borderCornerOffset; /** * the length of the corner line away from the corner. (in pixels) */ public float borderCornerLength; /** * the color of the corner line */ public int borderCornerColor; /** * the thickness of the guidelines lines. (in pixels) */ public float guidelinesThickness; /** * the color of the guidelines lines */ public int guidelinesColor; /** * the color of the overlay background around the crop window cover the image parts not in the crop window. */ public int backgroundColor; /** * the min width the crop window is allowed to be. (in pixels) */ public int minCropWindowWidth; /** * the min height the crop window is allowed to be. (in pixels) */ public int minCropWindowHeight; /** * the min width the resulting cropping image is allowed to be, affects the cropping window limits. (in pixels) */ public int minCropResultWidth; /** * the min height the resulting cropping image is allowed to be, affects the cropping window limits. (in pixels) */ public int minCropResultHeight; /** * the max width the resulting cropping image is allowed to be, affects the cropping window limits. (in pixels) */ public int maxCropResultWidth; /** * the max height the resulting cropping image is allowed to be, affects the cropping window limits. (in pixels) */ public int maxCropResultHeight; /** * the Android Uri to save the cropped image to */ public Uri outputUri; /** * the compression format to use when writing the image */ public Bitmap.CompressFormat outputCompressFormat; /** * the quality (if applicable) to use when writing the image (0 - 100) */ public int outputCompressQuality; /** * the width to resize the cropped image to (see options) */ public int outputRequestWidth; /** * the height to resize the cropped image to (see options) */ public int outputRequestHeight; /** * the resize method to use on the cropped bitmap (see options documentation) */ public CropImageView.RequestSizeOptions outputRequestSizeOptions; /** * if the result of crop image activity should not save the cropped image bitmap */ public boolean noOutputImage; /** * the initial rectangle to set on the cropping image after loading */ public Rect initialCropWindowRectangle; /** * the initial rotation to set on the cropping image after loading (0-360 degrees clockwise) */ public int initialRotation; /** * if to allow (all) rotation during cropping (activity) */ public boolean allowRotation; /** * the amount of degreees to rotate clockwise or counter-clockwise */ public int rotationDegrees; /** * Init options with defaults. */ public CropImageOptions() { DisplayMetrics dm = Resources.getSystem().getDisplayMetrics(); cropShape = CropImageView.CropShape.RECTANGLE; snapRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, dm); touchRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, dm); guidelines = CropImageView.Guidelines.ON_TOUCH; scaleType = CropImageView.ScaleType.FIT_CENTER; showCropOverlay = true; showProgressBar = true; autoZoomEnabled = true; multiTouchEnabled = false; maxZoom = 4; initialCropWindowPaddingRatio = 0.1f; fixAspectRatio = false; aspectRatioX = 1; aspectRatioY = 1; borderLineThickness = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, dm); borderLineColor = Color.argb(170, 255, 255, 255); borderCornerThickness = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, dm); borderCornerOffset = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, dm); borderCornerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, dm); borderCornerColor = Color.WHITE; guidelinesThickness = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, dm); guidelinesColor = Color.argb(170, 255, 255, 255); backgroundColor = Color.argb(119, 0, 0, 0); minCropWindowWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 42, dm); minCropWindowHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 42, dm); minCropResultWidth = 40; minCropResultHeight = 40; maxCropResultWidth = 99999; maxCropResultHeight = 99999; outputUri = Uri.EMPTY; outputCompressFormat = Bitmap.CompressFormat.JPEG; outputCompressQuality = 90; outputRequestWidth = 0; outputRequestHeight = 0; outputRequestSizeOptions = CropImageView.RequestSizeOptions.NONE; noOutputImage = false; initialCropWindowRectangle = null; initialRotation = -1; allowRotation = true; rotationDegrees = 90; } /** * Create object from parcel. */ protected CropImageOptions(Parcel in) { cropShape = CropImageView.CropShape.values()[in.readInt()]; snapRadius = in.readFloat(); touchRadius = in.readFloat(); guidelines = CropImageView.Guidelines.values()[in.readInt()]; scaleType = CropImageView.ScaleType.values()[in.readInt()]; showCropOverlay = in.readByte() != 0; showProgressBar = in.readByte() != 0; autoZoomEnabled = in.readByte() != 0; multiTouchEnabled = in.readByte() != 0; maxZoom = in.readInt(); initialCropWindowPaddingRatio = in.readFloat(); fixAspectRatio = in.readByte() != 0; aspectRatioX = in.readInt(); aspectRatioY = in.readInt(); borderLineThickness = in.readFloat(); borderLineColor = in.readInt(); borderCornerThickness = in.readFloat(); borderCornerOffset = in.readFloat(); borderCornerLength = in.readFloat(); borderCornerColor = in.readInt(); guidelinesThickness = in.readFloat(); guidelinesColor = in.readInt(); backgroundColor = in.readInt(); minCropWindowWidth = in.readInt(); minCropWindowHeight = in.readInt(); minCropResultWidth = in.readInt(); minCropResultHeight = in.readInt(); maxCropResultWidth = in.readInt(); maxCropResultHeight = in.readInt(); outputUri = in.readParcelable(Uri.class.getClassLoader()); outputCompressFormat = Bitmap.CompressFormat.valueOf(in.readString()); outputCompressQuality = in.readInt(); outputRequestWidth = in.readInt(); outputRequestHeight = in.readInt(); outputRequestSizeOptions = CropImageView.RequestSizeOptions.values()[in.readInt()]; noOutputImage = in.readByte() != 0; initialCropWindowRectangle = in.readParcelable(Rect.class.getClassLoader()); initialRotation = in.readInt(); allowRotation = in.readByte() != 0; rotationDegrees = in.readInt(); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(cropShape.ordinal()); dest.writeFloat(snapRadius); dest.writeFloat(touchRadius); dest.writeInt(guidelines.ordinal()); dest.writeInt(scaleType.ordinal()); dest.writeByte((byte) (showCropOverlay ? 1 : 0)); dest.writeByte((byte) (showProgressBar ? 1 : 0)); dest.writeByte((byte) (autoZoomEnabled ? 1 : 0)); dest.writeByte((byte) (multiTouchEnabled ? 1 : 0)); dest.writeInt(maxZoom); dest.writeFloat(initialCropWindowPaddingRatio); dest.writeByte((byte) (fixAspectRatio ? 1 : 0)); dest.writeInt(aspectRatioX); dest.writeInt(aspectRatioY); dest.writeFloat(borderLineThickness); dest.writeInt(borderLineColor); dest.writeFloat(borderCornerThickness); dest.writeFloat(borderCornerOffset); dest.writeFloat(borderCornerLength); dest.writeInt(borderCornerColor); dest.writeFloat(guidelinesThickness); dest.writeInt(guidelinesColor); dest.writeInt(backgroundColor); dest.writeInt(minCropWindowWidth); dest.writeInt(minCropWindowHeight); dest.writeInt(minCropResultWidth); dest.writeInt(minCropResultHeight); dest.writeInt(maxCropResultWidth); dest.writeInt(maxCropResultHeight); dest.writeParcelable(outputUri, flags); dest.writeString(outputCompressFormat.name()); dest.writeInt(outputCompressQuality); dest.writeInt(outputRequestWidth); dest.writeInt(outputRequestHeight); dest.writeInt(outputRequestSizeOptions.ordinal()); dest.writeInt(noOutputImage ? 1 : 0); dest.writeParcelable(initialCropWindowRectangle, flags); dest.writeInt(initialRotation); dest.writeByte((byte) (allowRotation ? 1 : 0)); dest.writeInt(rotationDegrees); } @Override public int describeContents() { return 0; } /** * Validate all the options are withing valid range. * * @throws IllegalArgumentException if any of the options is not valid */ public void validate() { if (maxZoom < 0) { throw new IllegalArgumentException("Cannot set max zoom to a number < 1"); } if (touchRadius < 0) { throw new IllegalArgumentException("Cannot set touch radius value to a number <= 0 "); } if (initialCropWindowPaddingRatio < 0 || initialCropWindowPaddingRatio >= 0.5) { throw new IllegalArgumentException("Cannot set initial crop window padding value to a number < 0 or >= 0.5"); } if (aspectRatioX <= 0) { throw new IllegalArgumentException("Cannot set aspect ratio value to a number less than or equal to 0."); } if (aspectRatioY <= 0) { throw new IllegalArgumentException("Cannot set aspect ratio value to a number less than or equal to 0."); } if (borderLineThickness < 0) { throw new IllegalArgumentException("Cannot set line thickness value to a number less than 0."); } if (borderCornerThickness < 0) { throw new IllegalArgumentException("Cannot set corner thickness value to a number less than 0."); } if (guidelinesThickness < 0) { throw new IllegalArgumentException("Cannot set guidelines thickness value to a number less than 0."); } if (minCropWindowHeight < 0) { throw new IllegalArgumentException("Cannot set min crop window height value to a number < 0 "); } if (minCropResultWidth < 0) { throw new IllegalArgumentException("Cannot set min crop result width value to a number < 0 "); } if (minCropResultHeight < 0) { throw new IllegalArgumentException("Cannot set min crop result height value to a number < 0 "); } if (maxCropResultWidth < minCropResultWidth) { throw new IllegalArgumentException("Cannot set max crop result width to smaller value than min crop result width"); } if (maxCropResultHeight < minCropResultHeight) { throw new IllegalArgumentException("Cannot set max crop result height to smaller value than min crop result height"); } if (outputRequestWidth < 0) { throw new IllegalArgumentException("Cannot set request width value to a number < 0 "); } if (outputRequestHeight < 0) { throw new IllegalArgumentException("Cannot set request height value to a number < 0 "); } if (rotationDegrees < 0 || rotationDegrees > 360) { throw new IllegalArgumentException("Cannot set rotation degrees value to a number < 0 or > 360"); } } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropImageView.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; import android.util.AttributeSet; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ProgressBar; import androidx.exifinterface.media.ExifInterface; import java.lang.ref.WeakReference; import java.util.UUID; /** * Custom view that provides cropping capabilities to an image. */ public class CropImageView extends FrameLayout { //region: Fields and Consts /** * Image view widget used to show the image for cropping. */ private final ImageView mImageView; /** * Overlay over the image view to show cropping UI. */ private final CropOverlayView mCropOverlayView; /** * The matrix used to transform the cropping image in the image view */ private final Matrix mImageMatrix = new Matrix(); /** * Reusing matrix instance for reverse matrix calculations. */ private final Matrix mImageInverseMatrix = new Matrix(); /** * Progress bar widget to show progress bar on async image loading and cropping. */ private final ProgressBar mProgressBar; /** * Rectengale used in image matrix transformation calculation (reusing rect instance) */ private final float[] mImagePoints = new float[8]; /** * Animation class to smooth animate zoom-in/out */ private CropImageAnimation mAnimation; private Bitmap mBitmap; private int mDegreesRotated; private int mLayoutWidth; private int mLayoutHeight; private int mImageResource; /** * The initial scale type of the image in the crop image view */ private ScaleType mScaleType; /** * if to show crop overlay UI what contains the crop window UI surrounded by background over the cropping * image.
* default: true, may disable for animation or frame transition. */ private boolean mShowCropOverlay = true; /** * if to show progress bar when image async loading/cropping is in progress.
* default: true, disable to provide custom progress bar UI. */ private boolean mShowProgressBar = true; /** * if auto-zoom functionality is enabled.
* default: true. */ private boolean mAutoZoomEnabled; /** * The max zoom allowed during cropping */ private int mMaxZoom; /** * callback to be invoked when image async loading is complete. */ private OnSetImageUriCompleteListener mOnSetImageUriCompleteListener; /** * callback to be invoked when image async cropping is complete. */ private OnCropImageCompleteListener mOnCropImageCompleteListener; /** * The URI that the image was loaded from (if loaded from URI) */ private Uri mLoadedImageUri; /** * The sample size the image was loaded by if was loaded by URI */ private int mLoadedSampleSize = 1; /** * The current zoom level to to scale the cropping image */ private float mZoom = 1; /** * The X offset that the cropping image was translated after zooming */ private float mZoomOffsetX; /** * The Y offset that the cropping image was translated after zooming */ private float mZoomOffsetY; /** * Used to restore the cropping windows rectangle after state restore */ private RectF mRestoreCropWindowRect; /** * Used to detect size change to handle auto-zoom using {@link #handleCropWindowChanged(boolean, boolean)} in * {@link #layout(int, int, int, int)}. */ private boolean mSizeChanged; /** * Task used to load bitmap async from UI thread */ private WeakReference mBitmapLoadingWorkerTask; /** * Task used to crop bitmap async from UI thread */ private WeakReference mBitmapCroppingWorkerTask; //endregion public CropImageView(Context context) { this(context, null); } public CropImageView(Context context, AttributeSet attrs) { super(context, attrs); CropImageOptions options = new CropImageOptions(); if (attrs != null) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CropImageView, 0, 0); try { options.fixAspectRatio = ta.getBoolean(R.styleable.CropImageView_cropFixAspectRatio, options.fixAspectRatio); options.aspectRatioX = ta.getInteger(R.styleable.CropImageView_cropAspectRatioX, options.aspectRatioX); options.aspectRatioY = ta.getInteger(R.styleable.CropImageView_cropAspectRatioY, options.aspectRatioY); options.scaleType = ScaleType.values()[ta.getInt( R.styleable.CropImageView_cropScaleType, options.scaleType.ordinal())]; options.autoZoomEnabled = ta.getBoolean(R.styleable.CropImageView_cropAutoZoomEnabled, options.autoZoomEnabled); options.multiTouchEnabled = ta.getBoolean(R.styleable.CropImageView_cropMultiTouchEnabled, options.multiTouchEnabled); options.maxZoom = ta.getInteger(R.styleable.CropImageView_cropMaxZoom, options.maxZoom); options.cropShape = CropShape.values()[ta.getInt( R.styleable.CropImageView_cropShape, options.cropShape.ordinal())]; options.guidelines = Guidelines.values()[ta.getInt( R.styleable.CropImageView_cropGuidelines, options.guidelines.ordinal())]; options.snapRadius = ta.getDimension(R.styleable.CropImageView_cropSnapRadius, options.snapRadius); options.touchRadius = ta.getDimension(R.styleable.CropImageView_cropTouchRadius, options.touchRadius); options.initialCropWindowPaddingRatio = ta.getFloat( R.styleable.CropImageView_cropInitialCropWindowPaddingRatio, options.initialCropWindowPaddingRatio); options.borderLineThickness = ta.getDimension(R.styleable.CropImageView_cropBorderLineThickness, options.borderLineThickness); options.borderLineColor = ta.getInteger(R.styleable.CropImageView_cropBorderLineColor, options.borderLineColor); options.borderCornerThickness = ta.getDimension( R.styleable.CropImageView_cropBorderCornerThickness, options.borderCornerThickness); options.borderCornerOffset = ta.getDimension(R.styleable.CropImageView_cropBorderCornerOffset, options.borderCornerOffset); options.borderCornerLength = ta.getDimension(R.styleable.CropImageView_cropBorderCornerLength, options.borderCornerLength); options.borderCornerColor = ta.getInteger(R.styleable.CropImageView_cropBorderCornerColor, options.borderCornerColor); options.guidelinesThickness = ta.getDimension(R.styleable.CropImageView_cropGuidelinesThickness, options.guidelinesThickness); options.guidelinesColor = ta.getInteger(R.styleable.CropImageView_cropGuidelinesColor, options.guidelinesColor); options.backgroundColor = ta.getInteger(R.styleable.CropImageView_cropBackgroundColor, options.backgroundColor); options.showCropOverlay = ta.getBoolean(R.styleable.CropImageView_cropShowCropOverlay, mShowCropOverlay); options.showProgressBar = ta.getBoolean(R.styleable.CropImageView_cropShowProgressBar, mShowProgressBar); options.borderCornerThickness = ta.getDimension( R.styleable.CropImageView_cropBorderCornerThickness, options.borderCornerThickness); options.minCropWindowWidth = (int) ta.getDimension( R.styleable.CropImageView_cropMinCropWindowWidth, options.minCropWindowWidth); options.minCropWindowHeight = (int) ta.getDimension( R.styleable.CropImageView_cropMinCropWindowHeight, options.minCropWindowHeight); options.minCropResultWidth = (int) ta.getFloat(R.styleable.CropImageView_cropMinCropResultWidthPX, options.minCropResultWidth); options.minCropResultHeight = (int) ta.getFloat( R.styleable.CropImageView_cropMinCropResultHeightPX, options.minCropResultHeight); options.maxCropResultWidth = (int) ta.getFloat(R.styleable.CropImageView_cropMaxCropResultWidthPX, options.maxCropResultWidth); options.maxCropResultHeight = (int) ta.getFloat( R.styleable.CropImageView_cropMaxCropResultHeightPX, options.maxCropResultHeight); // if aspect ratio is set then set fixed to true if (ta.hasValue(R.styleable.CropImageView_cropAspectRatioX) && ta.hasValue(R.styleable.CropImageView_cropAspectRatioX) && !ta.hasValue(R.styleable.CropImageView_cropFixAspectRatio)) { options.fixAspectRatio = true; } } finally { ta.recycle(); } } options.validate(); mScaleType = options.scaleType; mAutoZoomEnabled = options.autoZoomEnabled; mMaxZoom = options.maxZoom; mShowCropOverlay = options.showCropOverlay; mShowProgressBar = options.showProgressBar; LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.crop_image_view, this, true); mImageView = v.findViewById(R.id.ImageView_image); mImageView.setScaleType(ImageView.ScaleType.MATRIX); mCropOverlayView = v.findViewById(R.id.CropOverlayView); mCropOverlayView.setCropWindowChangeListener(new CropOverlayView.CropWindowChangeListener() { @Override public void onCropWindowChanged(boolean inProgress) { handleCropWindowChanged(inProgress, true); } }); mCropOverlayView.setInitialAttributeValues(options); mProgressBar = v.findViewById(R.id.CropProgressBar); setProgressBarVisibility(); } public void setCropImageOptions(CropImageOptions options) { options.validate(); mScaleType = options.scaleType; mAutoZoomEnabled = options.autoZoomEnabled; mMaxZoom = options.maxZoom; mShowCropOverlay = options.showCropOverlay; mShowProgressBar = options.showProgressBar; mCropOverlayView.setInitialAttributeValues(options); } /** * Get the scale type of the image in the crop view. */ public ScaleType getScaleType() { return mScaleType; } /** * Set the scale type of the image in the crop view */ public void setScaleType(ScaleType scaleType) { if (scaleType != mScaleType) { mScaleType = scaleType; mZoom = 1; mZoomOffsetX = mZoomOffsetY = 0; mCropOverlayView.resetCropOverlayView(); requestLayout(); } } /** * The shape of the cropping area - rectangle/circular. */ public CropShape getCropShape() { return mCropOverlayView.getCropShape(); } /** * The shape of the cropping area - rectangle/circular.
* To set square/circle crop shape set aspect ratio to 1:1. */ public void setCropShape(CropShape cropShape) { mCropOverlayView.setCropShape(cropShape); } /** * if auto-zoom functionality is enabled. default: true. */ public boolean isAutoZoomEnabled() { return mAutoZoomEnabled; } /** * Set auto-zoom functionality to enabled/disabled. */ public void setAutoZoomEnabled(boolean autoZoomEnabled) { if (mAutoZoomEnabled != autoZoomEnabled) { mAutoZoomEnabled = autoZoomEnabled; handleCropWindowChanged(false, false); mCropOverlayView.invalidate(); } } /** * Set multi touch functionality to enabled/disabled. */ public void setMultiTouchEnabled(boolean multiTouchEnabled) { if (mCropOverlayView.setMultiTouchEnabled(multiTouchEnabled)) { handleCropWindowChanged(false, false); mCropOverlayView.invalidate(); } } /** * The max zoom allowed during cropping. */ public int getMaxZoom() { return mMaxZoom; } /** * The max zoom allowed during cropping. */ public void setMaxZoom(int maxZoom) { if (mMaxZoom != maxZoom && maxZoom > 0) { mMaxZoom = maxZoom; handleCropWindowChanged(false, false); mCropOverlayView.invalidate(); } } /** * the min size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
*/ public void setMinCropResultSize(int minCropResultWidth, int minCropResultHeight) { mCropOverlayView.setMinCropResultSize(minCropResultWidth, minCropResultHeight); } /** * the max size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
*/ public void setMaxCropResultSize(int maxCropResultWidth, int maxCropResultHeight) { mCropOverlayView.setMaxCropResultSize(maxCropResultWidth, maxCropResultHeight); } /** * Get the amount of degrees the cropping image is rotated cloackwise.
* * @return 0-360 */ public int getRotatedDegrees() { return mDegreesRotated; } /** * Set the amount of degrees the cropping image is rotated cloackwise.
* * @param degrees 0-360 */ public void setRotatedDegrees(int degrees) { if (mDegreesRotated != degrees) { rotateImage(degrees - mDegreesRotated); } } /** * whether the aspect ratio is fixed or not; true fixes the aspect ratio, while false allows it to be changed. */ public boolean isFixAspectRatio() { return mCropOverlayView.isFixAspectRatio(); } /** * Sets whether the aspect ratio is fixed or not; true fixes the aspect ratio, while false allows it to be changed. */ public void setFixedAspectRatio(boolean fixAspectRatio) { mCropOverlayView.setFixedAspectRatio(fixAspectRatio); } /** * Get the current guidelines option set. */ public Guidelines getGuidelines() { return mCropOverlayView.getGuidelines(); } /** * Sets the guidelines for the CropOverlayView to be either on, off, or to show when resizing the application. */ public void setGuidelines(Guidelines guidelines) { mCropOverlayView.setGuidelines(guidelines); } /** * both the X and Y values of the aspectRatio. */ public Pair getAspectRatio() { return new Pair<>(mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY()); } /** * Sets the both the X and Y values of the aspectRatio.
* Sets fixed aspect ratio to TRUE. * * @param aspectRatioX int that specifies the new X value of the aspect ratio * @param aspectRatioY int that specifies the new Y value of the aspect ratio */ public void setAspectRatio(int aspectRatioX, int aspectRatioY) { mCropOverlayView.setAspectRatioX(aspectRatioX); mCropOverlayView.setAspectRatioY(aspectRatioY); setFixedAspectRatio(true); } /** * Clears set aspect ratio values and sets fixed aspect ratio to FALSE. */ public void clearAspectRatio() { mCropOverlayView.setAspectRatioX(1); mCropOverlayView.setAspectRatioY(1); setFixedAspectRatio(false); } /** * An edge of the crop window will snap to the corresponding edge of a * specified bounding box when the crop window edge is less than or equal to * this distance (in pixels) away from the bounding box edge. (default: 3dp) */ public void setSnapRadius(float snapRadius) { if (snapRadius >= 0) { mCropOverlayView.setSnapRadius(snapRadius); } } /** * if to show progress bar when image async loading/cropping is in progress.
* default: true, disable to provide custom progress bar UI. */ public boolean isShowProgressBar() { return mShowProgressBar; } /** * if to show progress bar when image async loading/cropping is in progress.
* default: true, disable to provide custom progress bar UI. */ public void setShowProgressBar(boolean showProgressBar) { if (mShowProgressBar != showProgressBar) { mShowProgressBar = showProgressBar; setProgressBarVisibility(); } } /** * if to show crop overlay UI what contains the crop window UI surrounded by background over the cropping * image.
* default: true, may disable for animation or frame transition. */ public boolean isShowCropOverlay() { return mShowCropOverlay; } /** * if to show crop overlay UI what contains the crop window UI surrounded by background over the cropping * image.
* default: true, may disable for animation or frame transition. */ public void setShowCropOverlay(boolean showCropOverlay) { if (mShowCropOverlay != showCropOverlay) { mShowCropOverlay = showCropOverlay; setCropOverlayVisibility(); } } /** * Returns the integer of the imageResource */ public int getImageResource() { return mImageResource; } /** * Get the URI of an image that was set by URI, null otherwise. */ public Uri getImageUri() { return mLoadedImageUri; } /** * Gets the crop window's position relative to the source Bitmap (not the image * displayed in the CropImageView) using the original image rotation. * * @return a Rect instance containing cropped area boundaries of the source Bitmap */ public Rect getCropRect() { if (mBitmap != null) { // get the points of the crop rectangle adjusted to source bitmap float[] points = getCropPoints(); int orgWidth = mBitmap.getWidth() * mLoadedSampleSize; int orgHeight = mBitmap.getHeight() * mLoadedSampleSize; // get the rectangle for the points (it may be larger than original if rotation is not stright) return BitmapUtils.getRectFromPoints(points, orgWidth, orgHeight, mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY()); } else { return null; } } /** * Gets the 4 points of crop window's position relative to the source Bitmap (not the image * displayed in the CropImageView) using the original image rotation.
* Note: the 4 points may not be a rectangle if the image was rotates to NOT stright angle (!= 90/180/270). * * @return 4 points (x0,y0,x1,y1,x2,y2,x3,y3) of cropped area boundaries */ public float[] getCropPoints() { // Get crop window position relative to the displayed image. RectF cropWindowRect = mCropOverlayView.getCropWindowRect(); float[] points = new float[]{ cropWindowRect.left, cropWindowRect.top, cropWindowRect.right, cropWindowRect.top, cropWindowRect.right, cropWindowRect.bottom, cropWindowRect.left, cropWindowRect.bottom }; mImageMatrix.invert(mImageInverseMatrix); mImageInverseMatrix.mapPoints(points); for (int i = 0; i < points.length; i++) { points[i] *= mLoadedSampleSize; } return points; } /** * Set the crop window position and size to the given rectangle.
* Image to crop must be first set before invoking this, for async - after complete callback. * * @param rect window rectangle (position and size) relative to source bitmap */ public void setCropRect(Rect rect) { mCropOverlayView.setInitialCropWindowRect(rect); } /** * Reset crop window to initial rectangle. */ public void resetCropRect() { mZoom = 1; mZoomOffsetX = 0; mZoomOffsetY = 0; mDegreesRotated = 0; applyImageMatrix(getWidth(), getHeight(), false, false); mCropOverlayView.resetCropWindowRect(); } /** * Gets the cropped image based on the current crop window. * * @return a new Bitmap representing the cropped image */ public Bitmap getCroppedImage() { return getCroppedImage(0, 0, RequestSizeOptions.NONE); } /** * Gets the cropped image based on the current crop window.
* Uses {@link RequestSizeOptions#RESIZE_INSIDE} option. * * @param reqWidth the width to resize the cropped image to * @param reqHeight the height to resize the cropped image to * @return a new Bitmap representing the cropped image */ public Bitmap getCroppedImage(int reqWidth, int reqHeight) { return getCroppedImage(reqWidth, reqHeight, RequestSizeOptions.RESIZE_INSIDE); } /** * Gets the cropped image based on the current crop window.
* * @param reqWidth the width to resize the cropped image to (see options) * @param reqHeight the height to resize the cropped image to (see options) * @param options the resize method to use, see its documentation * @return a new Bitmap representing the cropped image */ public Bitmap getCroppedImage(int reqWidth, int reqHeight, RequestSizeOptions options) { Bitmap croppedBitmap = null; if (mBitmap != null) { mImageView.clearAnimation(); reqWidth = options != RequestSizeOptions.NONE ? reqWidth : 0; reqHeight = options != RequestSizeOptions.NONE ? reqHeight : 0; if (mLoadedImageUri != null && (mLoadedSampleSize > 1 || options == RequestSizeOptions.SAMPLING)) { int orgWidth = mBitmap.getWidth() * mLoadedSampleSize; int orgHeight = mBitmap.getHeight() * mLoadedSampleSize; BitmapUtils.BitmapSampled bitmapSampled = BitmapUtils.cropBitmap(getContext(), mLoadedImageUri, getCropPoints(), mDegreesRotated, orgWidth, orgHeight, mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY(), reqWidth, reqHeight); croppedBitmap = bitmapSampled.bitmap; } else { croppedBitmap = BitmapUtils.cropBitmapObjectHandleOOM(mBitmap, getCropPoints(), mDegreesRotated, mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY()).bitmap; } croppedBitmap = BitmapUtils.resizeBitmap(croppedBitmap, reqWidth, reqHeight, options); } return croppedBitmap; } /** * Gets the cropped image based on the current crop window.
*/ public void getCroppedImageAsync() { getCroppedImageAsync(0, 0, RequestSizeOptions.NONE); } /** * Gets the cropped image based on the current crop window.
* Uses {@link RequestSizeOptions#RESIZE_INSIDE} option.
* The result will be invoked to listener set by {@link #setOnCropImageCompleteListener(OnCropImageCompleteListener)}. * * @param reqWidth the width to resize the cropped image to * @param reqHeight the height to resize the cropped image to */ public void getCroppedImageAsync(int reqWidth, int reqHeight) { getCroppedImageAsync(reqWidth, reqHeight, RequestSizeOptions.RESIZE_INSIDE); } /** * Gets the cropped image based on the current crop window.
* The result will be invoked to listener set by {@link #setOnCropImageCompleteListener(OnCropImageCompleteListener)}. * * @param reqWidth the width to resize the cropped image to (see options) * @param reqHeight the height to resize the cropped image to (see options) * @param options the resize method to use, see its documentation */ public void getCroppedImageAsync(int reqWidth, int reqHeight, RequestSizeOptions options) { if (mOnCropImageCompleteListener == null) { throw new IllegalArgumentException("mOnCropImageCompleteListener is not set"); } startCropWorkerTask(reqWidth, reqHeight, options, null, null, 0); } /** * Save the cropped image based on the current crop window to the given uri.
* Uses JPEG image compression with 90 compression quality.
* * @param saveUri the Android Uri to save the cropped image to */ public void saveCroppedImageAsync(Uri saveUri) { saveCroppedImageAsync(saveUri, Bitmap.CompressFormat.JPEG, 90, 0, 0, RequestSizeOptions.NONE); } /** * Save the cropped image based on the current crop window to the given uri.
* * @param saveUri the Android Uri to save the cropped image to * @param saveCompressFormat the compression format to use when writing the image * @param saveCompressQuality the quality (if applicable) to use when writing the image (0 - 100) */ public void saveCroppedImageAsync(Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality) { saveCroppedImageAsync(saveUri, saveCompressFormat, saveCompressQuality, 0, 0, RequestSizeOptions.NONE); } /** * Save the cropped image based on the current crop window to the given uri.
* Uses {@link RequestSizeOptions#RESIZE_INSIDE} option.
* * @param saveUri the Android Uri to save the cropped image to * @param saveCompressFormat the compression format to use when writing the image * @param saveCompressQuality the quality (if applicable) to use when writing the image (0 - 100) * @param reqWidth the width to resize the cropped image to * @param reqHeight the height to resize the cropped image to */ public void saveCroppedImageAsync(Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality, int reqWidth, int reqHeight) { saveCroppedImageAsync(saveUri, saveCompressFormat, saveCompressQuality, reqWidth, reqHeight, RequestSizeOptions.RESIZE_INSIDE); } /** * Save the cropped image based on the current crop window to the given uri.
* * @param saveUri the Android Uri to save the cropped image to * @param saveCompressFormat the compression format to use when writing the image * @param saveCompressQuality the quality (if applicable) to use when writing the image (0 - 100) * @param reqWidth the width to resize the cropped image to (see options) * @param reqHeight the height to resize the cropped image to (see options) * @param options the resize method to use, see its documentation */ public void saveCroppedImageAsync(Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality, int reqWidth, int reqHeight, RequestSizeOptions options) { if (mOnCropImageCompleteListener == null) { throw new IllegalArgumentException("mOnCropImageCompleteListener is not set"); } startCropWorkerTask(reqWidth, reqHeight, options, saveUri, saveCompressFormat, saveCompressQuality); } /** * Set the callback to be invoked when image async loading ({@link #setImageUriAsync(Uri)}) * is complete (successful or failed). */ public void setOnSetImageUriCompleteListener(OnSetImageUriCompleteListener listener) { mOnSetImageUriCompleteListener = listener; } /** * Set the callback to be invoked when image async cropping image ({@link #getCroppedImageAsync()} or * {@link #saveCroppedImageAsync(Uri)}) is complete (successful or failed). */ public void setOnCropImageCompleteListener(OnCropImageCompleteListener listener) { mOnCropImageCompleteListener = listener; } /** * Sets a Bitmap as the content of the CropImageView. * * @param bitmap the Bitmap to set */ public void setImageBitmap(Bitmap bitmap) { mCropOverlayView.setInitialCropWindowRect(null); setBitmap(bitmap); } /** * Sets a Bitmap and initializes the image rotation according to the EXIT data.
*
* The EXIF can be retrieved by doing the following: * ExifInterface exif = new ExifInterface(path); * * @param bitmap the original bitmap to set; if null, this * @param exif the EXIF information about this bitmap; may be null */ public void setImageBitmap(Bitmap bitmap, ExifInterface exif) { Bitmap setBitmap; if (bitmap != null && exif != null) { BitmapUtils.RotateBitmapResult result = BitmapUtils.rotateBitmapByExif(bitmap, exif); setBitmap = result.bitmap; mDegreesRotated = result.degrees; } else { setBitmap = bitmap; } mCropOverlayView.setInitialCropWindowRect(null); setBitmap(setBitmap); } /** * Sets a Drawable as the content of the CropImageView. * * @param resId the drawable resource ID to set */ public void setImageResource(int resId) { if (resId != 0) { mCropOverlayView.setInitialCropWindowRect(null); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resId); setBitmap(bitmap, resId); } } /** * Sets a bitmap loaded from the given Android URI as the content of the CropImageView.
* Can be used with URI from gallery or camera source.
* Will rotate the image by exif data.
* * @param uri the URI to load the image from */ public void setImageUriAsync(Uri uri) { if (uri != null) { BitmapLoadingTask task = mBitmapLoadingWorkerTask != null ? mBitmapLoadingWorkerTask.get() : null; if (task != null) { // cancel previous loading (no check if the same URI because camera URI can be the same for different images) task.cancel(true); } // either no existing task is working or we canceled it, need to load new URI clearImageInt(); mCropOverlayView.setInitialCropWindowRect(null); mBitmapLoadingWorkerTask = new WeakReference<>(new BitmapLoadingTask(this, uri)); mBitmapLoadingWorkerTask.get().execute(); setProgressBarVisibility(); } } /** * Clear the current image set for cropping. */ public void clearImage() { clearImageInt(); mCropOverlayView.setInitialCropWindowRect(null); } /** * Rotates image by the specified number of degrees clockwise.
* Negative values represent counter-clockwise rotations. * * @param degrees Integer specifying the number of degrees to rotate. */ public void rotateImage(int degrees) { if (mBitmap != null) { // Force degrees to be a non-zero value between 0 and 360 (inclusive) if (degrees < 0) { degrees = (degrees % 360) + 360; } else { degrees = degrees % 360; } boolean flipAxes = !mCropOverlayView.isFixAspectRatio() && ((degrees > 45 && degrees < 135) || (degrees > 215 && degrees < 305)); BitmapUtils.RECT.set(mCropOverlayView.getCropWindowRect()); float halfWidth = (flipAxes ? BitmapUtils.RECT.height() : BitmapUtils.RECT.width()) / 2f; float halfHeight = (flipAxes ? BitmapUtils.RECT.width() : BitmapUtils.RECT.height()) / 2f; mImageMatrix.invert(mImageInverseMatrix); BitmapUtils.POINTS[0] = BitmapUtils.RECT.centerX(); BitmapUtils.POINTS[1] = BitmapUtils.RECT.centerY(); BitmapUtils.POINTS[2] = 0; BitmapUtils.POINTS[3] = 0; BitmapUtils.POINTS[4] = 1; BitmapUtils.POINTS[5] = 0; mImageInverseMatrix.mapPoints(BitmapUtils.POINTS); // This is valid because degrees is not negative. mDegreesRotated = (mDegreesRotated + degrees) % 360; applyImageMatrix(getWidth(), getHeight(), true, false); // adjust the zoom so the crop window size remains the same even after image scale change mImageMatrix.mapPoints(BitmapUtils.POINTS2, BitmapUtils.POINTS); mZoom /= Math.sqrt(Math.pow(BitmapUtils.POINTS2[4] - BitmapUtils.POINTS2[2], 2) + Math.pow( BitmapUtils.POINTS2[5] - BitmapUtils.POINTS2[3], 2)); mZoom = Math.max(mZoom, 1); applyImageMatrix(getWidth(), getHeight(), true, false); mImageMatrix.mapPoints(BitmapUtils.POINTS2, BitmapUtils.POINTS); // adjust the width/height by the changes in scaling to the image double change = Math.sqrt( Math.pow(BitmapUtils.POINTS2[4] - BitmapUtils.POINTS2[2], 2) + Math.pow( BitmapUtils.POINTS2[5] - BitmapUtils.POINTS2[3], 2)); halfWidth *= change; halfHeight *= change; // calculate the new crop window rectangle to center in the same location and have proper width/height BitmapUtils.RECT.set(BitmapUtils.POINTS2[0] - halfWidth, BitmapUtils.POINTS2[1] - halfHeight, BitmapUtils.POINTS2[0] + halfWidth, BitmapUtils.POINTS2[1] + halfHeight); mCropOverlayView.resetCropOverlayView(); mCropOverlayView.setCropWindowRect(BitmapUtils.RECT); applyImageMatrix(getWidth(), getHeight(), true, false); handleCropWindowChanged(false, false); // make sure the crop window rectangle is within the cropping image bounds after all the changes mCropOverlayView.fixCurrentCropWindowRect(); } } //region: Private methods /** * On complete of the async bitmap loading by {@link #setImageUriAsync(Uri)} set the result * to the widget if still relevant and call listener if set. * * @param result the result of bitmap loading */ void onSetImageUriAsyncComplete(BitmapLoadingTask.Result result) { mBitmapLoadingWorkerTask = null; setProgressBarVisibility(); if (result.error == null) { setBitmap(result.bitmap, result.uri, result.loadSampleSize, result.degreesRotated); } OnSetImageUriCompleteListener listener = mOnSetImageUriCompleteListener; if (listener != null) { listener.onSetImageUriComplete(this, result.uri, result.error); } } /** * On complete of the async bitmap cropping by {@link #getCroppedImageAsync()} call listener if set. * * @param result the result of bitmap cropping */ void onImageCroppingAsyncComplete(BitmapCroppingTask.Result result) { mBitmapCroppingWorkerTask = null; setProgressBarVisibility(); OnCropImageCompleteListener listener = mOnCropImageCompleteListener; if (listener != null) { CropResult cropResult = new CropResult(result.bitmap, result.uri, result.error, getCropPoints(), getCropRect(), getRotatedDegrees(), result.sampleSize); listener.onCropImageComplete(this, cropResult); } } /** * {@link #setBitmap(Bitmap, int, Uri, int, int)}} */ private void setBitmap(Bitmap bitmap) { setBitmap(bitmap, 0, null, 1, 0); } /** * {@link #setBitmap(Bitmap, int, Uri, int, int)}} */ private void setBitmap(Bitmap bitmap, int imageResource) { setBitmap(bitmap, imageResource, null, 1, 0); } /** * {@link #setBitmap(Bitmap, int, Uri, int, int)}} */ private void setBitmap(Bitmap bitmap, Uri imageUri, int loadSampleSize, int degreesRotated) { setBitmap(bitmap, 0, imageUri, loadSampleSize, degreesRotated); } /** * Set the given bitmap to be used in for cropping
* Optionally clear full if the bitmap is new, or partial clear if the bitmap has been manipulated. */ private void setBitmap(Bitmap bitmap, int imageResource, Uri imageUri, int loadSampleSize, int degreesRotated) { if (mBitmap == null || !mBitmap.equals(bitmap)) { mImageView.clearAnimation(); clearImageInt(); mBitmap = bitmap; mImageView.setImageBitmap(mBitmap); mLoadedImageUri = imageUri; mImageResource = imageResource; mLoadedSampleSize = loadSampleSize; mDegreesRotated = degreesRotated; applyImageMatrix(getWidth(), getHeight(), true, false); if (mCropOverlayView != null) { mCropOverlayView.resetCropOverlayView(); setCropOverlayVisibility(); } } } /** * Clear the current image set for cropping.
* Full clear will also clear the data of the set image like Uri or Resource id while partial clear * will only clear the bitmap and recycle if required. */ private void clearImageInt() { // if we allocated the bitmap, release it as fast as possible if (mBitmap != null && (mImageResource > 0 || mLoadedImageUri != null)) { mBitmap.recycle(); } mBitmap = null; // clean the loaded image flags for new image mImageResource = 0; mLoadedImageUri = null; mLoadedSampleSize = 1; mDegreesRotated = 0; mZoom = 1; mZoomOffsetX = 0; mZoomOffsetY = 0; mImageMatrix.reset(); mImageView.setImageBitmap(null); setCropOverlayVisibility(); } /** * Gets the cropped image based on the current crop window.
* If (reqWidth,reqHeight) is given AND image is loaded from URI cropping will try to use sample size to fit in * the requested width and height down-sampling if possible - optimization to get best size to quality.
* * @param reqWidth the width to resize the cropped image to (see options) * @param reqHeight the height to resize the cropped image to (see options) * @param options the resize method to use on the cropped bitmap * @param saveUri optional: to save the cropped image to * @param saveCompressFormat if saveUri is given, the given compression will be used for saving the image * @param saveCompressQuality if saveUri is given, the given quality will be used for the compression. */ public void startCropWorkerTask(int reqWidth, int reqHeight, RequestSizeOptions options, Uri saveUri, Bitmap.CompressFormat saveCompressFormat, int saveCompressQuality) { if (mBitmap != null) { mImageView.clearAnimation(); BitmapCroppingTask currentTask = mBitmapCroppingWorkerTask != null ? mBitmapCroppingWorkerTask.get() : null; if (currentTask != null) { // cancel previous cropping currentTask.cancel(true); } reqWidth = options != RequestSizeOptions.NONE ? reqWidth : 0; reqHeight = options != RequestSizeOptions.NONE ? reqHeight : 0; int orgWidth = mBitmap.getWidth() * mLoadedSampleSize; int orgHeight = mBitmap.getHeight() * mLoadedSampleSize; if (mLoadedImageUri != null && (mLoadedSampleSize > 1 || options == RequestSizeOptions.SAMPLING)) { mBitmapCroppingWorkerTask = new WeakReference<>(new BitmapCroppingTask(this, mLoadedImageUri, getCropPoints(), mDegreesRotated, orgWidth, orgHeight, mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY(), reqWidth, reqHeight, options, saveUri, saveCompressFormat, saveCompressQuality)); } else { mBitmapCroppingWorkerTask = new WeakReference<>(new BitmapCroppingTask(this, mBitmap, getCropPoints(), mDegreesRotated, mCropOverlayView.isFixAspectRatio(), mCropOverlayView.getAspectRatioX(), mCropOverlayView.getAspectRatioY(), reqWidth, reqHeight, options, saveUri, saveCompressFormat, saveCompressQuality)); } mBitmapCroppingWorkerTask.get().execute(); setProgressBarVisibility(); } } @Override public Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable("instanceState", super.onSaveInstanceState()); bundle.putParcelable("LOADED_IMAGE_URI", mLoadedImageUri); bundle.putInt("LOADED_IMAGE_RESOURCE", mImageResource); if (mLoadedImageUri == null && mImageResource < 1) { bundle.putParcelable("SET_BITMAP", mBitmap); } if (mLoadedImageUri != null && mBitmap != null) { String key = UUID.randomUUID().toString(); BitmapUtils.mStateBitmap = new Pair<>(key, new WeakReference<>(mBitmap)); bundle.putString("LOADED_IMAGE_STATE_BITMAP_KEY", key); } if (mBitmapLoadingWorkerTask != null) { BitmapLoadingTask task = mBitmapLoadingWorkerTask.get(); if (task != null) { bundle.putParcelable("LOADING_IMAGE_URI", task.getUri()); } } bundle.putInt("LOADED_SAMPLE_SIZE", mLoadedSampleSize); bundle.putInt("DEGREES_ROTATED", mDegreesRotated); bundle.putParcelable("INITIAL_CROP_RECT", mCropOverlayView.getInitialCropWindowRect()); BitmapUtils.RECT.set(mCropOverlayView.getCropWindowRect()); mImageMatrix.invert(mImageInverseMatrix); mImageInverseMatrix.mapRect(BitmapUtils.RECT); bundle.putParcelable("CROP_WINDOW_RECT", BitmapUtils.RECT); bundle.putString("CROP_SHAPE", mCropOverlayView.getCropShape().name()); bundle.putBoolean("CROP_AUTO_ZOOM_ENABLED", mAutoZoomEnabled); bundle.putInt("CROP_MAX_ZOOM", mMaxZoom); return bundle; } @Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; // prevent restoring state if already set by outside code if (mBitmapLoadingWorkerTask == null && mLoadedImageUri == null && mBitmap == null && mImageResource == 0) { Uri uri = bundle.getParcelable("LOADED_IMAGE_URI"); if (uri != null) { String key = bundle.getString("LOADED_IMAGE_STATE_BITMAP_KEY"); if (key != null) { Bitmap stateBitmap = BitmapUtils.mStateBitmap != null && BitmapUtils.mStateBitmap.first.equals(key) ? BitmapUtils.mStateBitmap.second.get() : null; if (stateBitmap != null && !stateBitmap.isRecycled()) { BitmapUtils.mStateBitmap = null; setBitmap(stateBitmap, uri, bundle.getInt("LOADED_SAMPLE_SIZE"), 0); } } if (mLoadedImageUri == null) { setImageUriAsync(uri); } } else { int resId = bundle.getInt("LOADED_IMAGE_RESOURCE"); if (resId > 0) { setImageResource(resId); } else { Bitmap bitmap = bundle.getParcelable("SET_BITMAP"); if (bitmap != null) { setBitmap(bitmap); } else { uri = bundle.getParcelable("LOADING_IMAGE_URI"); if (uri != null) { setImageUriAsync(uri); } } } } mDegreesRotated = bundle.getInt("DEGREES_ROTATED"); mCropOverlayView.setInitialCropWindowRect(bundle.getParcelable("INITIAL_CROP_RECT")); mRestoreCropWindowRect = bundle.getParcelable("CROP_WINDOW_RECT"); mCropOverlayView.setCropShape(CropShape.valueOf(bundle.getString("CROP_SHAPE"))); mAutoZoomEnabled = bundle.getBoolean("CROP_AUTO_ZOOM_ENABLED"); mMaxZoom = bundle.getInt("CROP_MAX_ZOOM"); } super.onRestoreInstanceState(bundle.getParcelable("instanceState")); } else { super.onRestoreInstanceState(state); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); if (mBitmap != null) { // Bypasses a baffling bug when used within a ScrollView, where heightSize is set to 0. if (heightSize == 0) { heightSize = mBitmap.getHeight(); } int desiredWidth; int desiredHeight; double viewToBitmapWidthRatio = Double.POSITIVE_INFINITY; double viewToBitmapHeightRatio = Double.POSITIVE_INFINITY; // Checks if either width or height needs to be fixed if (widthSize < mBitmap.getWidth()) { viewToBitmapWidthRatio = (double) widthSize / (double) mBitmap.getWidth(); } if (heightSize < mBitmap.getHeight()) { viewToBitmapHeightRatio = (double) heightSize / (double) mBitmap.getHeight(); } // If either needs to be fixed, choose smallest ratio and calculate from there if (viewToBitmapWidthRatio != Double.POSITIVE_INFINITY || viewToBitmapHeightRatio != Double.POSITIVE_INFINITY) { if (viewToBitmapWidthRatio <= viewToBitmapHeightRatio) { desiredWidth = widthSize; desiredHeight = (int) (mBitmap.getHeight() * viewToBitmapWidthRatio); } else { desiredHeight = heightSize; desiredWidth = (int) (mBitmap.getWidth() * viewToBitmapHeightRatio); } } else { // Otherwise, the picture is within frame layout bounds. Desired width is simply picture size desiredWidth = mBitmap.getWidth(); desiredHeight = mBitmap.getHeight(); } int width = getOnMeasureSpec(widthMode, widthSize, desiredWidth); int height = getOnMeasureSpec(heightMode, heightSize, desiredHeight); mLayoutWidth = width; mLayoutHeight = height; setMeasuredDimension(mLayoutWidth, mLayoutHeight); } else { setMeasuredDimension(widthSize, heightSize); } } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); if (mLayoutWidth > 0 && mLayoutHeight > 0) { // Gets original parameters, and creates the new parameters ViewGroup.LayoutParams origParams = this.getLayoutParams(); origParams.width = mLayoutWidth; origParams.height = mLayoutHeight; setLayoutParams(origParams); if (mBitmap != null) { applyImageMatrix(r - l, b - t, true, false); // after state restore we want to restore the window crop, possible only after widget size is known if (mRestoreCropWindowRect != null) { mImageMatrix.mapRect(mRestoreCropWindowRect); mCropOverlayView.setCropWindowRect(mRestoreCropWindowRect); handleCropWindowChanged(false, false); mCropOverlayView.fixCurrentCropWindowRect(); mRestoreCropWindowRect = null; } else if (mSizeChanged) { mSizeChanged = false; handleCropWindowChanged(false, false); } } else { updateImageBounds(true); } } else { updateImageBounds(true); } } /** * Detect size change to handle auto-zoom using {@link #handleCropWindowChanged(boolean, boolean)} in * {@link #layout(int, int, int, int)}. */ @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mSizeChanged = oldw > 0 && oldh > 0; } /** * Handle crop window change to:
* 1. Execute auto-zoom-in/out depending on the area covered of cropping window relative to the * available view area.
* 2. Slide the zoomed sub-area if the cropping window is outside of the visible view sub-area.
* * @param inProgress is the crop window change is still in progress by the user * @param animate if to animate the change to the image matrix, or set it directly */ private void handleCropWindowChanged(boolean inProgress, boolean animate) { int width = getWidth(); int height = getHeight(); if (mBitmap != null && width > 0 && height > 0) { RectF cropRect = mCropOverlayView.getCropWindowRect(); if (inProgress) { if (cropRect.left < 0 || cropRect.top < 0 || cropRect.right > width || cropRect.bottom > height) { applyImageMatrix(width, height, false, false); } } else if (mAutoZoomEnabled || mZoom > 1) { float newZoom = 0; // keep the cropping window covered area to 50%-65% of zoomed sub-area if (mZoom < mMaxZoom && cropRect.width() < width * 0.5f && cropRect.height() < height * 0.5f) { newZoom = Math.min(mMaxZoom, Math.min(width / (cropRect.width() / mZoom / 0.64f), height / (cropRect.height() / mZoom / 0.64f))); } if (mZoom > 1 && (cropRect.width() > width * 0.65f || cropRect.height() > height * 0.65f)) { newZoom = Math.max(1, Math.min(width / (cropRect.width() / mZoom / 0.51f), height / (cropRect.height() / mZoom / 0.51f))); } if (!mAutoZoomEnabled) { newZoom = 1; } if (newZoom > 0 && newZoom != mZoom) { if (animate) { if (mAnimation == null) { // lazy create animation single instance mAnimation = new CropImageAnimation(mImageView, mCropOverlayView); } // set the state for animation to start from mAnimation.setStartState(mImagePoints, mImageMatrix); } mZoom = newZoom; applyImageMatrix(width, height, true, animate); } } } } /** * Apply matrix to handle the image inside the image view. * * @param width the width of the image view * @param height the height of the image view */ private void applyImageMatrix(float width, float height, boolean center, boolean animate) { if (mBitmap != null && width > 0 && height > 0) { mImageMatrix.invert(mImageInverseMatrix); RectF cropRect = mCropOverlayView.getCropWindowRect(); mImageInverseMatrix.mapRect(cropRect); mImageMatrix.reset(); // move the image to the center of the image view first so we can manipulate it from there mImageMatrix.postTranslate((width - mBitmap.getWidth()) / 2, (height - mBitmap.getHeight()) / 2); mapImagePointsByImageMatrix(); // rotate the image the required degrees from center of image if (mDegreesRotated > 0) { mImageMatrix.postRotate(mDegreesRotated, BitmapUtils.getRectCenterX(mImagePoints), BitmapUtils .getRectCenterY(mImagePoints)); mapImagePointsByImageMatrix(); } // scale the image to the image view, image rect transformed to know new width/height float scale = Math.min(width / BitmapUtils.getRectWidth(mImagePoints), height / BitmapUtils .getRectHeight(mImagePoints)); if (mScaleType == ScaleType.FIT_CENTER || (mScaleType == ScaleType.CENTER_INSIDE && scale < 1) || (scale > 1 && mAutoZoomEnabled)) { mImageMatrix.postScale(scale, scale, BitmapUtils.getRectCenterX(mImagePoints), BitmapUtils .getRectCenterY(mImagePoints)); mapImagePointsByImageMatrix(); } // scale by the current zoom level mImageMatrix.postScale(mZoom, mZoom, BitmapUtils.getRectCenterX(mImagePoints), BitmapUtils .getRectCenterY(mImagePoints)); mapImagePointsByImageMatrix(); mImageMatrix.mapRect(cropRect); if (center) { // set the zoomed area to be as to the center of cropping window as possible mZoomOffsetX = width > BitmapUtils.getRectWidth(mImagePoints) ? 0 : Math.max(Math.min(width / 2 - cropRect.centerX(), -BitmapUtils.getRectLeft(mImagePoints)), getWidth() - BitmapUtils .getRectRight(mImagePoints)) / mZoom; mZoomOffsetY = height > BitmapUtils.getRectHeight(mImagePoints) ? 0 : Math.max(Math.min(height / 2 - cropRect.centerY(), -BitmapUtils.getRectTop(mImagePoints)), getHeight() - BitmapUtils .getRectBottom(mImagePoints)) / mZoom; } else { // adjust the zoomed area so the crop window rectangle will be inside the area in case it was moved outside mZoomOffsetX = Math.min( Math.max(mZoomOffsetX * mZoom, -cropRect.left), -cropRect.right + width) / mZoom; mZoomOffsetY = Math.min( Math.max(mZoomOffsetY * mZoom, -cropRect.top), -cropRect.bottom + height) / mZoom; } // apply to zoom offset translate and update the crop rectangle to offset correctly mImageMatrix.postTranslate(mZoomOffsetX * mZoom, mZoomOffsetY * mZoom); cropRect.offset(mZoomOffsetX * mZoom, mZoomOffsetY * mZoom); mCropOverlayView.setCropWindowRect(cropRect); mapImagePointsByImageMatrix(); // set matrix to apply if (animate) { // set the state for animation to end in, start animation now mAnimation.setEndState(mImagePoints, mImageMatrix); mImageView.startAnimation(mAnimation); } else { mImageView.setImageMatrix(mImageMatrix); } // update the image rectangle in the crop overlay updateImageBounds(false); } } /** * Adjust the given image rectangle by image transformation matrix to know the final rectangle of the image.
* To get the proper rectangle it must be first reset to orginal image rectangle. */ private void mapImagePointsByImageMatrix() { mImagePoints[0] = 0; mImagePoints[1] = 0; mImagePoints[2] = mBitmap.getWidth(); mImagePoints[3] = 0; mImagePoints[4] = mBitmap.getWidth(); mImagePoints[5] = mBitmap.getHeight(); mImagePoints[6] = 0; mImagePoints[7] = mBitmap.getHeight(); mImageMatrix.mapPoints(mImagePoints); } /** * Determines the specs for the onMeasure function. Calculates the width or height * depending on the mode. * * @param measureSpecMode The mode of the measured width or height. * @param measureSpecSize The size of the measured width or height. * @param desiredSize The desired size of the measured width or height. * @return The final size of the width or height. */ private static int getOnMeasureSpec(int measureSpecMode, int measureSpecSize, int desiredSize) { // Measure Width int spec; if (measureSpecMode == MeasureSpec.EXACTLY) { // Must be this size spec = measureSpecSize; } else if (measureSpecMode == MeasureSpec.AT_MOST) { // Can't be bigger than...; match_parent value spec = Math.min(desiredSize, measureSpecSize); } else { // Be whatever you want; wrap_content spec = desiredSize; } return spec; } /** * Set visibility of crop overlay to hide it when there is no image or specificly set by client. */ private void setCropOverlayVisibility() { if (mCropOverlayView != null) { mCropOverlayView.setVisibility(mShowCropOverlay && mBitmap != null ? VISIBLE : INVISIBLE); } } /** * Set visibility of progress bar when async loading/cropping is in process and show is enabled. */ private void setProgressBarVisibility() { boolean visible = mShowProgressBar && (mBitmap == null && mBitmapLoadingWorkerTask != null || mBitmapCroppingWorkerTask != null); mProgressBar.setVisibility(visible ? VISIBLE : INVISIBLE); } /** * Update the scale factor between the actual image bitmap and the shown image.
*/ private void updateImageBounds(boolean clear) { if (mBitmap != null && !clear) { // Get the scale factor between the actual Bitmap dimensions and the displayed dimensions for width/height. float scaleFactorWidth = mBitmap.getWidth() * mLoadedSampleSize / BitmapUtils.getRectWidth(mImagePoints); float scaleFactorHeight = mBitmap.getHeight() * mLoadedSampleSize / BitmapUtils.getRectHeight(mImagePoints); mCropOverlayView.setCropWindowLimits(getWidth(), getHeight(), scaleFactorWidth, scaleFactorHeight); } // set the bitmap rectangle and update the crop window after scale factor is set mCropOverlayView.setBounds(clear ? null : mImagePoints, getWidth(), getHeight()); } //endregion //region: Inner class: CropShape /** * The possible cropping area shape.
* To set square/circle crop shape set aspect ratio to 1:1. */ public enum CropShape { RECTANGLE, OVAL } //endregion //region: Inner class: ScaleType /** * Options for scaling the bounds of cropping image to the bounds of Crop Image View.
* Note: Some options are affected by auto-zoom, if enabled. */ public enum ScaleType { /** * Scale the image uniformly (maintain the image's aspect ratio) to fit in crop image view.
* The largest dimension will be equals to crop image view and the second dimension will be smaller. */ FIT_CENTER, /** * Center the image in the view, but perform no scaling.
* Note: If auto-zoom is enabled and the source image is smaller than crop image view then it will be * scaled uniformly to fit the crop image view. */ CENTER, /** * Scale the image uniformly (maintain the image's aspect ratio) so that both * dimensions (width and height) of the image will be equal to or larger than the * corresponding dimension of the view (minus padding).
* The image is then centered in the view. */ CENTER_CROP, /** * Scale the image uniformly (maintain the image's aspect ratio) so that both * dimensions (width and height) of the image will be equal to or less than the * corresponding dimension of the view (minus padding).
* The image is then centered in the view.
* Note: If auto-zoom is enabled and the source image is smaller than crop image view then it will be * scaled uniformly to fit the crop image view. */ CENTER_INSIDE } //endregion //region: Inner class: Guidelines /** * The possible guidelines showing types. */ public enum Guidelines { /** * Never show */ OFF, /** * Show when crop move action is live */ ON_TOUCH, /** * Always show */ ON } //endregion //region: Inner class: RequestSizeOptions /** * Possible options for handling requested width/height for cropping. */ public enum RequestSizeOptions { /** * No resize/sampling is done unless required for memory management (OOM). */ NONE, /** * Only sample the image during loading (if image set using URI) so the smallest of the image * dimensions will be between the requested size and x2 requested size.
* NOTE: resulting image will not be exactly requested width/height * see: Loading Large * Bitmaps Efficiently. */ SAMPLING, /** * Resize the image uniformly (maintain the image's aspect ratio) so that both * dimensions (width and height) of the image will be equal to or less than the * corresponding requested dimension.
* If the image is smaller than the requested size it will NOT change. */ RESIZE_INSIDE, /** * Resize the image uniformly (maintain the image's aspect ratio) to fit in the given width/height.
* The largest dimension will be equals to the requested and the second dimension will be smaller.
* If the image is smaller than the requested size it will enlarge it. */ RESIZE_FIT, /** * Resize the image to fit exactly in the given width/height.
* This resize method does NOT preserve aspect ratio.
* If the image is smaller than the requested size it will enlarge it. */ RESIZE_EXACT } //endregion //region: Inner class: OnSetImageUriCompleteListener /** * Interface definition for a callback to be invoked when image async loading is complete. */ public interface OnSetImageUriCompleteListener { /** * Called when a crop image view has completed loading image for cropping.
* If loading failed error parameter will contain the error. * * @param view The crop image view that loading of image was complete. * @param uri the URI of the image that was loading * @param error if error occurred during loading will contain the error, otherwise null. */ void onSetImageUriComplete(CropImageView view, Uri uri, Exception error); } //endregion //region: Inner class: OnGetCroppedImageCompleteListener /** * Interface definition for a callback to be invoked when image async crop is complete. */ public interface OnCropImageCompleteListener { /** * Called when a crop image view has completed cropping image.
* Result object contains the cropped bitmap, saved cropped image uri, crop points data or * the error occured during cropping. * * @param view The crop image view that cropping of image was complete. * @param result the crop image result data (with cropped image or error) */ void onCropImageComplete(CropImageView view, CropResult result); } //endregion //region: Inner class: OnSaveCroppedImageCompleteListener //region: Inner class: ActivityResult /** * Result data of crop image. */ public static class CropResult { /** * The cropped image bitmap result.
* Null if save cropped image was executed, no output requested or failure. */ private final Bitmap mBitmap; /** * The Android uri of the saved cropped image result.
* Null if get cropped image was executed, no output requested or failure. */ private final Uri mUri; /** * The error that failed the loading/cropping (null if successful) */ private final Exception mError; /** * The 4 points of the cropping window in the source image */ private final float[] mCropPoints; /** * The rectangle of the cropping window in the source image */ private final Rect mCropRect; /** * The final rotation of the cropped image relative to source */ private final int mRotation; /** * sample size used creating the crop bitmap to lower its size */ private final int mSampleSize; public CropResult(Bitmap bitmap, Uri uri, Exception error, float[] cropPoints, Rect cropRect, int rotation, int sampleSize) { mBitmap = bitmap; mUri = uri; mError = error; mCropPoints = cropPoints; mCropRect = cropRect; mRotation = rotation; mSampleSize = sampleSize; } /** * Is the result is success or error. */ public boolean isSuccessful() { return mError == null; } /** * The cropped image bitmap result.
* Null if save cropped image was executed, no output requested or failure. */ public Bitmap getBitmap() { return mBitmap; } /** * The Android uri of the saved cropped image result * Null if get cropped image was executed, no output requested or failure. */ public Uri getUri() { return mUri; } /** * The error that failed the loading/cropping (null if successful) */ public Exception getError() { return mError; } /** * The 4 points of the cropping window in the source image */ public float[] getCropPoints() { return mCropPoints; } /** * The rectangle of the cropping window in the source image */ public Rect getCropRect() { return mCropRect; } /** * The final rotation of the cropped image relative to source */ public int getRotation() { return mRotation; } /** * sample size used creating the crop bitmap to lower its size */ public int getSampleSize() { return mSampleSize; } } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropOverlayView.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; import android.os.Build; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; import java.util.Arrays; /** * A custom View representing the crop window and the shaded background outside the crop window. */ public class CropOverlayView extends View { //region: Fields and Consts /** * Gesture detector used for multi touch box scaling */ private ScaleGestureDetector mScaleDetector; /** * Boolean to see if multi touch is enabled for the crop rectangle */ private boolean mMultiTouchEnabled; /** * Handler from crop window stuff, moving and knowing possition. */ private final CropWindowHandler mCropWindowHandler = new CropWindowHandler(); /** * Listener to publicj crop window changes */ private CropWindowChangeListener mCropWindowChangeListener; /** * Rectangle used for drawing */ private final RectF mDrawRect = new RectF(); /** * The Paint used to draw the white rectangle around the crop area. */ private Paint mBorderPaint; /** * The Paint used to draw the corners of the Border */ private Paint mBorderCornerPaint; /** * The Paint used to draw the guidelines within the crop area when pressed. */ private Paint mGuidelinePaint; /** * The Paint used to darken the surrounding areas outside the crop area. */ private Paint mBackgroundPaint; /** * Used for oval crop window shape or non-straight rotation drawing. */ private final Path mPath = new Path(); /** * The bounding box around the Bitmap that we are cropping. */ private final float[] mBoundsPoints = new float[8]; /** * The bounding box around the Bitmap that we are cropping. */ private final RectF mCalcBounds = new RectF(); /** * The bounding image view width used to know the crop overlay is at view edges. */ private int mViewWidth; /** * The bounding image view height used to know the crop overlay is at view edges. */ private int mViewHeight; /** * The offset to draw the border corener from the border */ private float mBorderCornerOffset; /** * the length of the border corner to draw */ private float mBorderCornerLength; /** * The initial crop window padding from image borders */ private float mInitialCropWindowPaddingRatio; /** * The radius of the touch zone (in pixels) around a given Handle. */ private float mTouchRadius; /** * An edge of the crop window will snap to the corresponding edge of a specified bounding box * when the crop window edge is less than or equal to this distance (in pixels) away from the bounding box edge. */ private float mSnapRadius; /** * The Handle that is currently pressed; null if no Handle is pressed. */ private CropWindowMoveHandler mMoveHandler; /** * Flag indicating if the crop area should always be a certain aspect ratio (indicated by mTargetAspectRatio). */ private boolean mFixAspectRatio; /** * save the current aspect ratio of the image */ private int mAspectRatioX; /** * save the current aspect ratio of the image */ private int mAspectRatioY; /** * The aspect ratio that the crop area should maintain; * this variable is only used when mMaintainAspectRatio is true. */ private float mTargetAspectRatio = ((float) mAspectRatioX) / mAspectRatioY; /** * Instance variables for customizable attributes */ private CropImageView.Guidelines mGuidelines; /** * The shape of the cropping area - rectangle/circular. */ private CropImageView.CropShape mCropShape; /** * the initial crop window rectangle to set */ private final Rect mInitialCropWindowRect = new Rect(); /** * Whether the Crop View has been initialized for the first time */ private boolean initializedCropWindow; /** * Used to set back LayerType after changing to software. */ private Integer mOriginalLayerType; //endregion public CropOverlayView(Context context) { this(context, null); } public CropOverlayView(Context context, AttributeSet attrs) { super(context, attrs); } /** * Set the crop window change listener. */ public void setCropWindowChangeListener(CropWindowChangeListener listener) { mCropWindowChangeListener = listener; } /** * Get the left/top/right/bottom coordinates of the crop window. */ public RectF getCropWindowRect() { return mCropWindowHandler.getRect(); } /** * Set the left/top/right/bottom coordinates of the crop window. */ public void setCropWindowRect(RectF rect) { mCropWindowHandler.setRect(rect); } /** * Fix the current crop window rectangle if it is outside of cropping image or view bounds. */ public void fixCurrentCropWindowRect() { RectF rect = getCropWindowRect(); fixCropWindowRectByRules(rect); mCropWindowHandler.setRect(rect); } /** * Informs the CropOverlayView of the image's position relative to the * ImageView. This is necessary to call in order to draw the crop window. * * @param boundsPoints the image's bounding points * @param viewWidth The bounding image view width. * @param viewHeight The bounding image view height. */ public void setBounds(float[] boundsPoints, int viewWidth, int viewHeight) { if (boundsPoints == null || !Arrays.equals(mBoundsPoints, boundsPoints)) { if (boundsPoints == null) { Arrays.fill(mBoundsPoints, 0); } else { System.arraycopy(boundsPoints, 0, mBoundsPoints, 0, boundsPoints.length); } mViewWidth = viewWidth; mViewHeight = viewHeight; RectF cropRect = mCropWindowHandler.getRect(); if (cropRect.width() == 0 || cropRect.height() == 0) { initCropWindow(); } } } /** * Resets the crop overlay view. */ public void resetCropOverlayView() { if (initializedCropWindow) { setCropWindowRect(BitmapUtils.EMPTY_RECT_F); initCropWindow(); invalidate(); } } /** * The shape of the cropping area - rectangle/circular. */ public CropImageView.CropShape getCropShape() { return mCropShape; } /** * The shape of the cropping area - rectangle/circular. */ public void setCropShape(CropImageView.CropShape cropShape) { if (mCropShape != cropShape) { mCropShape = cropShape; invalidate(); } } /** * Get the current guidelines option set. */ public CropImageView.Guidelines getGuidelines() { return mGuidelines; } /** * Sets the guidelines for the CropOverlayView to be either on, off, or to show when resizing the application. */ public void setGuidelines(CropImageView.Guidelines guidelines) { if (mGuidelines != guidelines) { mGuidelines = guidelines; if (initializedCropWindow) { invalidate(); } } } /** * whether the aspect ratio is fixed or not; true fixes the aspect ratio, while false allows it to be changed. */ public boolean isFixAspectRatio() { return mFixAspectRatio; } /** * Sets whether the aspect ratio is fixed or not; true fixes the aspect ratio, while false allows it to be changed. */ public void setFixedAspectRatio(boolean fixAspectRatio) { if (mFixAspectRatio != fixAspectRatio) { mFixAspectRatio = fixAspectRatio; if (initializedCropWindow) { initCropWindow(); invalidate(); } } } /** * the X value of the aspect ratio; */ public int getAspectRatioX() { return mAspectRatioX; } /** * Sets the X value of the aspect ratio; is defaulted to 1. */ public void setAspectRatioX(int aspectRatioX) { if (aspectRatioX <= 0) { throw new IllegalArgumentException("Cannot set aspect ratio value to a number less than or equal to 0."); } else if (mAspectRatioX != aspectRatioX) { mAspectRatioX = aspectRatioX; mTargetAspectRatio = ((float) mAspectRatioX) / mAspectRatioY; if (initializedCropWindow) { initCropWindow(); invalidate(); } } } /** * the Y value of the aspect ratio; */ public int getAspectRatioY() { return mAspectRatioY; } /** * Sets the Y value of the aspect ratio; is defaulted to 1. * * @param aspectRatioY int that specifies the new Y value of the aspect * ratio */ public void setAspectRatioY(int aspectRatioY) { if (aspectRatioY <= 0) { throw new IllegalArgumentException("Cannot set aspect ratio value to a number less than or equal to 0."); } else if (mAspectRatioY != aspectRatioY) { mAspectRatioY = aspectRatioY; mTargetAspectRatio = ((float) mAspectRatioX) / mAspectRatioY; if (initializedCropWindow) { initCropWindow(); invalidate(); } } } /** * An edge of the crop window will snap to the corresponding edge of a * specified bounding box when the crop window edge is less than or equal to * this distance (in pixels) away from the bounding box edge. (default: 3) */ public void setSnapRadius(float snapRadius) { mSnapRadius = snapRadius; } /** * Set multi touch functionality to enabled/disabled. */ public boolean setMultiTouchEnabled(boolean multiTouchEnabled) { if (mMultiTouchEnabled != multiTouchEnabled) { mMultiTouchEnabled = multiTouchEnabled; if (mMultiTouchEnabled && mScaleDetector == null) { mScaleDetector = new ScaleGestureDetector(getContext(), new ScaleListener()); } return true; } return false; } /** * the min size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
*/ public void setMinCropResultSize(int minCropResultWidth, int minCropResultHeight) { mCropWindowHandler.setMinCropResultSize(minCropResultWidth, minCropResultHeight); } /** * the max size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
*/ public void setMaxCropResultSize(int maxCropResultWidth, int maxCropResultHeight) { mCropWindowHandler.setMaxCropResultSize(maxCropResultWidth, maxCropResultHeight); } /** * set the max width/height and scale factor of the shown image to original image to scale the limits * appropriately. */ public void setCropWindowLimits(float maxWidth, float maxHeight, float scaleFactorWidth, float scaleFactorHeight) { mCropWindowHandler.setCropWindowLimits(maxWidth, maxHeight, scaleFactorWidth, scaleFactorHeight); } /** * Get crop window initial rectangle. */ public Rect getInitialCropWindowRect() { return mInitialCropWindowRect; } /** * Set crop window initial rectangle to be used instead of default. */ public void setInitialCropWindowRect(Rect rect) { mInitialCropWindowRect.set(rect != null ? rect : BitmapUtils.EMPTY_RECT); if (initializedCropWindow) { initCropWindow(); invalidate(); callOnCropWindowChanged(false); } } /** * Reset crop window to initial rectangle. */ public void resetCropWindowRect() { if (initializedCropWindow) { initCropWindow(); invalidate(); callOnCropWindowChanged(false); } } /** * Sets all initial values, but does not call initCropWindow to reset the views.
* Used once at the very start to initialize the attributes. */ public void setInitialAttributeValues(CropImageOptions options) { mCropWindowHandler.setInitialAttributeValues(options); setCropShape(options.cropShape); setSnapRadius(options.snapRadius); setGuidelines(options.guidelines); setFixedAspectRatio(options.fixAspectRatio); setAspectRatioX(options.aspectRatioX); setAspectRatioY(options.aspectRatioY); setMultiTouchEnabled(options.multiTouchEnabled); mTouchRadius = options.touchRadius; mInitialCropWindowPaddingRatio = options.initialCropWindowPaddingRatio; mBorderPaint = getNewPaintOrNull(options.borderLineThickness, options.borderLineColor); mBorderCornerOffset = options.borderCornerOffset; mBorderCornerLength = options.borderCornerLength; mBorderCornerPaint = getNewPaintOrNull(options.borderCornerThickness, options.borderCornerColor); mGuidelinePaint = getNewPaintOrNull(options.guidelinesThickness, options.guidelinesColor); mBackgroundPaint = getNewPaint(options.backgroundColor); } //region: Private methods /** * Set the initial crop window size and position. This is dependent on the * size and position of the image being cropped. */ private void initCropWindow() { float leftLimit = Math.max(BitmapUtils.getRectLeft(mBoundsPoints), 0); float topLimit = Math.max(BitmapUtils.getRectTop(mBoundsPoints), 0); float rightLimit = Math.min(BitmapUtils.getRectRight(mBoundsPoints), getWidth()); float bottomLimit = Math.min(BitmapUtils.getRectBottom(mBoundsPoints), getHeight()); if (rightLimit <= leftLimit || bottomLimit <= topLimit) { return; } RectF rect = new RectF(); // Tells the attribute functions the crop window has already been initialized initializedCropWindow = true; float horizontalPadding = mInitialCropWindowPaddingRatio * (rightLimit - leftLimit); float verticalPadding = mInitialCropWindowPaddingRatio * (bottomLimit - topLimit); if (mInitialCropWindowRect.width() > 0 && mInitialCropWindowRect.height() > 0) { // Get crop window position relative to the displayed image. rect.left = leftLimit + mInitialCropWindowRect.left / mCropWindowHandler.getScaleFactorWidth(); rect.top = topLimit + mInitialCropWindowRect.top / mCropWindowHandler.getScaleFactorHeight(); rect.right = rect.left + mInitialCropWindowRect.width() / mCropWindowHandler.getScaleFactorWidth(); rect.bottom = rect.top + mInitialCropWindowRect.height() / mCropWindowHandler.getScaleFactorHeight(); // Correct for floating point errors. Crop rect boundaries should not exceed the source Bitmap bounds. rect.left = Math.max(leftLimit, rect.left); rect.top = Math.max(topLimit, rect.top); rect.right = Math.min(rightLimit, rect.right); rect.bottom = Math.min(bottomLimit, rect.bottom); } else if (mFixAspectRatio) { // If the image aspect ratio is wider than the crop aspect ratio, // then the image height is the determining initial length. Else, vice-versa. float bitmapAspectRatio = (rightLimit - leftLimit) / (bottomLimit - topLimit); if (bitmapAspectRatio > mTargetAspectRatio) { rect.top = topLimit + verticalPadding; rect.bottom = bottomLimit - verticalPadding; float centerX = getWidth() / 2f; //dirty fix for wrong crop overlay aspect ratio when using fixed aspect ratio mTargetAspectRatio = (float) mAspectRatioX / mAspectRatioY; // Limits the aspect ratio to no less than 40 wide or 40 tall float cropWidth = Math.max(mCropWindowHandler.getMinCropWidth(), rect.height() * mTargetAspectRatio); float halfCropWidth = cropWidth / 2f; rect.left = centerX - halfCropWidth; rect.right = centerX + halfCropWidth; } else { rect.left = leftLimit + horizontalPadding; rect.right = rightLimit - horizontalPadding; float centerY = getHeight() / 2f; // Limits the aspect ratio to no less than 40 wide or 40 tall float cropHeight = Math.max(mCropWindowHandler.getMinCropHeight(), rect.width() / mTargetAspectRatio); float halfCropHeight = cropHeight / 2f; rect.top = centerY - halfCropHeight; rect.bottom = centerY + halfCropHeight; } } else { // Initialize crop window to have 10% padding w/ respect to image. rect.left = leftLimit + horizontalPadding; rect.top = topLimit + verticalPadding; rect.right = rightLimit - horizontalPadding; rect.bottom = bottomLimit - verticalPadding; } fixCropWindowRectByRules(rect); mCropWindowHandler.setRect(rect); } /** * Fix the given rect to fit into bitmap rect and follow min, max and aspect ratio rules. */ private void fixCropWindowRectByRules(RectF rect) { if (rect.width() < mCropWindowHandler.getMinCropWidth()) { float adj = (mCropWindowHandler.getMinCropWidth() - rect.width()) / 2; rect.left -= adj; rect.right += adj; } if (rect.height() < mCropWindowHandler.getMinCropHeight()) { float adj = (mCropWindowHandler.getMinCropHeight() - rect.height()) / 2; rect.top -= adj; rect.bottom += adj; } if (rect.width() > mCropWindowHandler.getMaxCropWidth()) { float adj = (rect.width() - mCropWindowHandler.getMaxCropWidth()) / 2; rect.left += adj; rect.right -= adj; } if (rect.height() > mCropWindowHandler.getMaxCropHeight()) { float adj = (rect.height() - mCropWindowHandler.getMaxCropHeight()) / 2; rect.top += adj; rect.bottom -= adj; } calculateBounds(rect); if (mCalcBounds.width() > 0 && mCalcBounds.height() > 0) { float leftLimit = Math.max(mCalcBounds.left, 0); float topLimit = Math.max(mCalcBounds.top, 0); float rightLimit = Math.min(mCalcBounds.right, getWidth()); float bottomLimit = Math.min(mCalcBounds.bottom, getHeight()); if (rect.left < leftLimit) { rect.left = leftLimit; } if (rect.top < topLimit) { rect.top = topLimit; } if (rect.right > rightLimit) { rect.right = rightLimit; } if (rect.bottom > bottomLimit) { rect.bottom = bottomLimit; } } if (mFixAspectRatio && Math.abs(rect.width() - rect.height() * mTargetAspectRatio) > 0.1) { if (rect.width() > rect.height() * mTargetAspectRatio) { float adj = Math.abs(rect.height() * mTargetAspectRatio - rect.width()) / 2; rect.left += adj; rect.right -= adj; } else { float adj = Math.abs(rect.width() / mTargetAspectRatio - rect.height()) / 2; rect.top += adj; rect.bottom -= adj; } } } /** * Draw crop overview by drawing background over image not in the cripping area, then borders and guidelines. */ @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Draw translucent background for the cropped area. drawBackground(canvas); if (mCropWindowHandler.showGuidelines()) { // Determines whether guidelines should be drawn or not if (mGuidelines == CropImageView.Guidelines.ON) { drawGuidelines(canvas); } else if (mGuidelines == CropImageView.Guidelines.ON_TOUCH && mMoveHandler != null) { // Draw only when resizing drawGuidelines(canvas); } } drawBorders(canvas); drawCorners(canvas); } /** * Draw shadow background over the image not including the crop area. */ private void drawBackground(Canvas canvas) { RectF rect = mCropWindowHandler.getRect(); float left = Math.max(BitmapUtils.getRectLeft(mBoundsPoints), 0); float top = Math.max(BitmapUtils.getRectTop(mBoundsPoints), 0); float right = Math.min(BitmapUtils.getRectRight(mBoundsPoints), getWidth()); float bottom = Math.min(BitmapUtils.getRectBottom(mBoundsPoints), getHeight()); if (mCropShape == CropImageView.CropShape.RECTANGLE) { if (!isNonStraightAngleRotated()) { canvas.drawRect(left, top, right, rect.top, mBackgroundPaint); canvas.drawRect(left, rect.bottom, right, bottom, mBackgroundPaint); canvas.drawRect(left, rect.top, rect.left, rect.bottom, mBackgroundPaint); canvas.drawRect(rect.right, rect.top, right, rect.bottom, mBackgroundPaint); } else { mPath.reset(); mPath.moveTo(mBoundsPoints[0], mBoundsPoints[1]); mPath.lineTo(mBoundsPoints[2], mBoundsPoints[3]); mPath.lineTo(mBoundsPoints[4], mBoundsPoints[5]); mPath.lineTo(mBoundsPoints[6], mBoundsPoints[7]); mPath.close(); canvas.save(); canvas.clipPath(mPath, Region.Op.INTERSECT); canvas.clipRect(rect, Region.Op.DIFFERENCE); canvas.drawRect(left, top, right, bottom, mBackgroundPaint); canvas.restore(); } } else { mPath.reset(); mDrawRect.set(rect.left, rect.top, rect.right, rect.bottom); mPath.addOval(mDrawRect, Path.Direction.CW); canvas.save(); canvas.clipPath(mPath, Region.Op.DIFFERENCE); canvas.drawRect(left, top, right, bottom, mBackgroundPaint); canvas.restore(); } } /** * Draw 2 veritcal and 2 horizontal guidelines inside the cropping area to split it into 9 equal parts. */ private void drawGuidelines(Canvas canvas) { if (mGuidelinePaint != null) { float sw = mBorderPaint != null ? mBorderPaint.getStrokeWidth() : 0; RectF rect = mCropWindowHandler.getRect(); rect.inset(sw, sw); float oneThirdCropWidth = rect.width() / 3; float oneThirdCropHeight = rect.height() / 3; if (mCropShape == CropImageView.CropShape.OVAL) { float w = rect.width() / 2 - sw; float h = rect.height() / 2 - sw; // Draw vertical guidelines. float x1 = rect.left + oneThirdCropWidth; float x2 = rect.right - oneThirdCropWidth; float yv = (float) (h * Math.sin(Math.acos((w - oneThirdCropWidth) / w))); canvas.drawLine(x1, rect.top + h - yv, x1, rect.bottom - h + yv, mGuidelinePaint); canvas.drawLine(x2, rect.top + h - yv, x2, rect.bottom - h + yv, mGuidelinePaint); // Draw horizontal guidelines. float y1 = rect.top + oneThirdCropHeight; float y2 = rect.bottom - oneThirdCropHeight; float xv = (float) (w * Math.cos(Math.asin((h - oneThirdCropHeight) / h))); canvas.drawLine(rect.left + w - xv, y1, rect.right - w + xv, y1, mGuidelinePaint); canvas.drawLine(rect.left + w - xv, y2, rect.right - w + xv, y2, mGuidelinePaint); } else { // Draw vertical guidelines. float x1 = rect.left + oneThirdCropWidth; float x2 = rect.right - oneThirdCropWidth; canvas.drawLine(x1, rect.top, x1, rect.bottom, mGuidelinePaint); canvas.drawLine(x2, rect.top, x2, rect.bottom, mGuidelinePaint); // Draw horizontal guidelines. float y1 = rect.top + oneThirdCropHeight; float y2 = rect.bottom - oneThirdCropHeight; canvas.drawLine(rect.left, y1, rect.right, y1, mGuidelinePaint); canvas.drawLine(rect.left, y2, rect.right, y2, mGuidelinePaint); } } } /** * Draw borders of the crop area. */ private void drawBorders(Canvas canvas) { if (mBorderPaint != null) { float w = mBorderPaint.getStrokeWidth(); RectF rect = mCropWindowHandler.getRect(); rect.inset(w / 2, w / 2); if (mCropShape == CropImageView.CropShape.RECTANGLE) { // Draw rectangle crop window border. canvas.drawRect(rect, mBorderPaint); } else { // Draw circular crop window border canvas.drawOval(rect, mBorderPaint); } } } /** * Draw the corner of crop overlay. */ private void drawCorners(Canvas canvas) { if (mBorderCornerPaint != null) { float lineWidth = mBorderPaint != null ? mBorderPaint.getStrokeWidth() : 0; float cornerWidth = mBorderCornerPaint.getStrokeWidth(); float w = cornerWidth / 2 + mBorderCornerOffset; RectF rect = mCropWindowHandler.getRect(); rect.inset(w, w); float cornerOffset = (cornerWidth - lineWidth) / 2; float cornerExtension = cornerWidth / 2 + cornerOffset; // Top left canvas.drawLine(rect.left - cornerOffset, rect.top - cornerExtension, rect.left - cornerOffset, rect.top + mBorderCornerLength, mBorderCornerPaint); canvas.drawLine(rect.left - cornerExtension, rect.top - cornerOffset, rect.left + mBorderCornerLength, rect.top - cornerOffset, mBorderCornerPaint); // Top right canvas.drawLine(rect.right + cornerOffset, rect.top - cornerExtension, rect.right + cornerOffset, rect.top + mBorderCornerLength, mBorderCornerPaint); canvas.drawLine(rect.right + cornerExtension, rect.top - cornerOffset, rect.right - mBorderCornerLength, rect.top - cornerOffset, mBorderCornerPaint); // Bottom left canvas.drawLine(rect.left - cornerOffset, rect.bottom + cornerExtension, rect.left - cornerOffset, rect.bottom - mBorderCornerLength, mBorderCornerPaint); canvas.drawLine(rect.left - cornerExtension, rect.bottom + cornerOffset, rect.left + mBorderCornerLength, rect.bottom + cornerOffset, mBorderCornerPaint); // Bottom left canvas.drawLine(rect.right + cornerOffset, rect.bottom + cornerExtension, rect.right + cornerOffset, rect.bottom - mBorderCornerLength, mBorderCornerPaint); canvas.drawLine(rect.right + cornerExtension, rect.bottom + cornerOffset, rect.right - mBorderCornerLength, rect.bottom + cornerOffset, mBorderCornerPaint); } } /** * Creates the Paint object for drawing. */ private static Paint getNewPaint(int color) { Paint paint = new Paint(); paint.setColor(color); return paint; } /** * Creates the Paint object for given thickness and color, if thickness < 0 return null. */ private static Paint getNewPaintOrNull(float thickness, int color) { if (thickness > 0) { Paint borderPaint = new Paint(); borderPaint.setColor(color); borderPaint.setStrokeWidth(thickness); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setAntiAlias(true); return borderPaint; } else { return null; } } @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { // If this View is not enabled, don't allow for touch interactions. if (isEnabled()) { if (mMultiTouchEnabled) { mScaleDetector.onTouchEvent(event); } switch (event.getAction()) { case MotionEvent.ACTION_DOWN: onActionDown(event.getX(), event.getY()); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: getParent().requestDisallowInterceptTouchEvent(false); onActionUp(); return true; case MotionEvent.ACTION_MOVE: onActionMove(event.getX(), event.getY()); getParent().requestDisallowInterceptTouchEvent(true); return true; default: return false; } } else { return false; } } /** * On press down start crop window movment depending on the location of the press.
* if press is far from crop window then no move handler is returned (null). */ private void onActionDown(float x, float y) { mMoveHandler = mCropWindowHandler.getMoveHandler(x, y, mTouchRadius, mCropShape); if (mMoveHandler != null) { invalidate(); } } /** * Clear move handler starting in {@link #onActionDown(float, float)} if exists. */ private void onActionUp() { if (mMoveHandler != null) { mMoveHandler = null; callOnCropWindowChanged(false); invalidate(); } } /** * Handle move of crop window using the move handler created in {@link #onActionDown(float, float)}.
* The move handler will do the proper move/resize of the crop window. */ private void onActionMove(float x, float y) { if (mMoveHandler != null) { float snapRadius = mSnapRadius; RectF rect = mCropWindowHandler.getRect(); if (calculateBounds(rect)) { snapRadius = 0; } mMoveHandler.move(rect, x, y, mCalcBounds, mViewWidth, mViewHeight, snapRadius, mFixAspectRatio, mTargetAspectRatio); mCropWindowHandler.setRect(rect); callOnCropWindowChanged(true); invalidate(); } } /** * Calculate the bounding rectangle for current crop window, handle non-straight rotation angles.
* If the rotation angle is straight then the bounds rectangle is the bitmap rectangle, * otherwsie we find the max rectangle that is within the image bounds starting from the crop window rectangle. * * @param rect the crop window rectangle to start finsing bounded rectangle from * @return true - non straight rotation in place, false - otherwise. */ private boolean calculateBounds(RectF rect) { float left = BitmapUtils.getRectLeft(mBoundsPoints); float top = BitmapUtils.getRectTop(mBoundsPoints); float right = BitmapUtils.getRectRight(mBoundsPoints); float bottom = BitmapUtils.getRectBottom(mBoundsPoints); if (!isNonStraightAngleRotated()) { mCalcBounds.set(left, top, right, bottom); return false; } else { float x0 = mBoundsPoints[0]; float y0 = mBoundsPoints[1]; float x2 = mBoundsPoints[4]; float y2 = mBoundsPoints[5]; float x3 = mBoundsPoints[6]; float y3 = mBoundsPoints[7]; if (mBoundsPoints[7] < mBoundsPoints[1]) { if (mBoundsPoints[1] < mBoundsPoints[3]) { x0 = mBoundsPoints[6]; y0 = mBoundsPoints[7]; x2 = mBoundsPoints[2]; y2 = mBoundsPoints[3]; x3 = mBoundsPoints[4]; y3 = mBoundsPoints[5]; } else { x0 = mBoundsPoints[4]; y0 = mBoundsPoints[5]; x2 = mBoundsPoints[0]; y2 = mBoundsPoints[1]; x3 = mBoundsPoints[2]; y3 = mBoundsPoints[3]; } } else if (mBoundsPoints[1] > mBoundsPoints[3]) { x0 = mBoundsPoints[2]; y0 = mBoundsPoints[3]; x2 = mBoundsPoints[6]; y2 = mBoundsPoints[7]; x3 = mBoundsPoints[0]; y3 = mBoundsPoints[1]; } float a0 = (y3 - y0) / (x3 - x0); float a1 = -1f / a0; float b0 = y0 - a0 * x0; float b1 = y0 - a1 * x0; float b2 = y2 - a0 * x2; float b3 = y2 - a1 * x2; float c0 = (rect.centerY() - rect.top) / (rect.centerX() - rect.left); float c1 = -c0; float d0 = rect.top - c0 * rect.left; float d1 = rect.top - c1 * rect.right; left = Math.max(left, (d0 - b0) / (a0 - c0) < rect.right ? (d0 - b0) / (a0 - c0) : left); left = Math.max(left, (d0 - b1) / (a1 - c0) < rect.right ? (d0 - b1) / (a1 - c0) : left); left = Math.max(left, (d1 - b3) / (a1 - c1) < rect.right ? (d1 - b3) / (a1 - c1) : left); right = Math.min(right, (d1 - b1) / (a1 - c1) > rect.left ? (d1 - b1) / (a1 - c1) : right); right = Math.min(right, (d1 - b2) / (a0 - c1) > rect.left ? (d1 - b2) / (a0 - c1) : right); right = Math.min(right, (d0 - b2) / (a0 - c0) > rect.left ? (d0 - b2) / (a0 - c0) : right); top = Math.max(top, Math.max(a0 * left + b0, a1 * right + b1)); bottom = Math.min(bottom, Math.min(a1 * left + b3, a0 * right + b2)); mCalcBounds.left = left; mCalcBounds.top = top; mCalcBounds.right = right; mCalcBounds.bottom = bottom; return true; } } /** * Is the cropping image has been rotated by NOT 0,90,180 or 270 degrees. */ @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean isNonStraightAngleRotated() { return mBoundsPoints[0] != mBoundsPoints[6] && mBoundsPoints[1] != mBoundsPoints[7]; } /** * Invoke on crop change listener safe, don't let the app crash on exception. */ private void callOnCropWindowChanged(boolean inProgress) { try { if (mCropWindowChangeListener != null) { mCropWindowChangeListener.onCropWindowChanged(inProgress); } } catch (Exception e) { Log.e("AIC", "Exception in crop window changed", e); } } //endregion //region: Inner class: CropWindowChangeListener /** * Interface definition for a callback to be invoked when crop window rectangle is changing. */ public interface CropWindowChangeListener { /** * Called after a change in crop window rectangle. * * @param inProgress is the crop window change operation is still in progress by user touch */ void onCropWindowChanged(boolean inProgress); } //endregion //region: Inner class: ScaleListener /** * Handle scaling the rectangle based on two finger input */ private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { @Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public boolean onScale(ScaleGestureDetector detector) { RectF rect = mCropWindowHandler.getRect(); float x = detector.getFocusX(); float y = detector.getFocusY(); float dY = detector.getCurrentSpanY() / 2; float dX = detector.getCurrentSpanX() / 2; float newTop = y - dY; float newLeft = x - dX; float newRight = x + dX; float newBottom = y + dY; if (newLeft < newRight && newTop <= newBottom && newLeft >= 0 && newRight <= mCropWindowHandler.getMaxCropWidth() && newTop >= 0 && newBottom <= mCropWindowHandler.getMaxCropHeight()) { rect.set(newLeft, newTop, newRight, newBottom); mCropWindowHandler.setRect(rect); invalidate(); } return true; } } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropWindowHandler.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.graphics.RectF; /** * Handler from crop window stuff, moving and knowing possition. */ final class CropWindowHandler { //region: Fields and Consts /** * The 4 edges of the crop window defining its coordinates and size */ private final RectF mEdges = new RectF(); /** * Rectangle used to return the edges rectangle without ability to change it and without creating new all the time. */ private final RectF mGetEdges = new RectF(); /** * Minimum width in pixels that the crop window can get. */ private float mMinCropWindowWidth; /** * Minimum height in pixels that the crop window can get. */ private float mMinCropWindowHeight; /** * Maximum width in pixels that the crop window can CURRENTLY get. */ private float mMaxCropWindowWidth; /** * Maximum height in pixels that the crop window can CURRENTLY get. */ private float mMaxCropWindowHeight; /** * Minimum width in pixels that the result of cropping an image can get, * affects crop window width adjusted by width scale factor. */ private float mMinCropResultWidth; /** * Minimum height in pixels that the result of cropping an image can get, * affects crop window height adjusted by height scale factor. */ private float mMinCropResultHeight; /** * Maximum width in pixels that the result of cropping an image can get, * affects crop window width adjusted by width scale factor. */ private float mMaxCropResultWidth; /** * Maximum height in pixels that the result of cropping an image can get, * affects crop window height adjusted by height scale factor. */ private float mMaxCropResultHeight; /** * The width scale factor of shown image and actual image */ private float mScaleFactorWidth = 1; /** * The height scale factor of shown image and actual image */ private float mScaleFactorHeight = 1; //endregion /** * Get the left/top/right/bottom coordinates of the crop window. */ public RectF getRect() { mGetEdges.set(mEdges); return mGetEdges; } /** * Minimum width in pixels that the crop window can get. */ public float getMinCropWidth() { return Math.max(mMinCropWindowWidth, mMinCropResultWidth / mScaleFactorWidth); } /** * Minimum height in pixels that the crop window can get. */ public float getMinCropHeight() { return Math.max(mMinCropWindowHeight, mMinCropResultHeight / mScaleFactorHeight); } /** * Maximum width in pixels that the crop window can get. */ public float getMaxCropWidth() { return Math.min(mMaxCropWindowWidth, mMaxCropResultWidth / mScaleFactorWidth); } /** * Maximum height in pixels that the crop window can get. */ public float getMaxCropHeight() { return Math.min(mMaxCropWindowHeight, mMaxCropResultHeight / mScaleFactorHeight); } /** * get the scale factor (on width) of the showen image to original image. */ public float getScaleFactorWidth() { return mScaleFactorWidth; } /** * get the scale factor (on height) of the showen image to original image. */ public float getScaleFactorHeight() { return mScaleFactorHeight; } /** * the min size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
*/ public void setMinCropResultSize(int minCropResultWidth, int minCropResultHeight) { mMinCropResultWidth = minCropResultWidth; mMinCropResultHeight = minCropResultHeight; } /** * the max size the resulting cropping image is allowed to be, affects the cropping window limits * (in pixels).
*/ public void setMaxCropResultSize(int maxCropResultWidth, int maxCropResultHeight) { mMaxCropResultWidth = maxCropResultWidth; mMaxCropResultHeight = maxCropResultHeight; } /** * set the max width/height and scale factor of the showen image to original image to scale the limits * appropriately. */ public void setCropWindowLimits(float maxWidth, float maxHeight, float scaleFactorWidth, float scaleFactorHeight) { mMaxCropWindowWidth = maxWidth; mMaxCropWindowHeight = maxHeight; mScaleFactorWidth = scaleFactorWidth; mScaleFactorHeight = scaleFactorHeight; } /** * Set the variables to be used during crop window handling. */ public void setInitialAttributeValues(CropImageOptions options) { mMinCropWindowWidth = options.minCropWindowWidth; mMinCropWindowHeight = options.minCropWindowHeight; mMinCropResultWidth = options.minCropResultWidth; mMinCropResultHeight = options.minCropResultHeight; mMaxCropResultWidth = options.maxCropResultWidth; mMaxCropResultHeight = options.maxCropResultHeight; } /** * Set the left/top/right/bottom coordinates of the crop window. */ public void setRect(RectF rect) { mEdges.set(rect); } /** * Indicates whether the crop window is small enough that the guidelines * should be shown. Public because this function is also used to determine * if the center handle should be focused. * * @return boolean Whether the guidelines should be shown or not */ public boolean showGuidelines() { return !(mEdges.width() < 100 || mEdges.height() < 100); } /** * Determines which, if any, of the handles are pressed given the touch * coordinates, the bounding box, and the touch radius. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @param targetRadius the target radius in pixels * @return the Handle that was pressed; null if no Handle was pressed */ public CropWindowMoveHandler getMoveHandler(float x, float y, float targetRadius, CropImageView.CropShape cropShape) { CropWindowMoveHandler.Type type = cropShape == CropImageView.CropShape.OVAL ? getOvalPressedMoveType(x, y) : getRectanglePressedMoveType(x, y, targetRadius); return type != null ? new CropWindowMoveHandler(type, this, x, y) : null; } //region: Private methods /** * Determines which, if any, of the handles are pressed given the touch * coordinates, the bounding box, and the touch radius. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @param targetRadius the target radius in pixels * @return the Handle that was pressed; null if no Handle was pressed */ private CropWindowMoveHandler.Type getRectanglePressedMoveType(float x, float y, float targetRadius) { CropWindowMoveHandler.Type moveType = null; // Note: corner-handles take precedence, then side-handles, then center. if (CropWindowHandler.isInCornerTargetZone(x, y, mEdges.left, mEdges.top, targetRadius)) { moveType = CropWindowMoveHandler.Type.TOP_LEFT; } else if (CropWindowHandler.isInCornerTargetZone(x, y, mEdges.right, mEdges.top, targetRadius)) { moveType = CropWindowMoveHandler.Type.TOP_RIGHT; } else if (CropWindowHandler.isInCornerTargetZone(x, y, mEdges.left, mEdges.bottom, targetRadius)) { moveType = CropWindowMoveHandler.Type.BOTTOM_LEFT; } else if (CropWindowHandler.isInCornerTargetZone(x, y, mEdges.right, mEdges.bottom, targetRadius)) { moveType = CropWindowMoveHandler.Type.BOTTOM_RIGHT; } else if (CropWindowHandler.isInCenterTargetZone(x, y, mEdges.left, mEdges.top, mEdges.right, mEdges.bottom) && focusCenter()) { moveType = CropWindowMoveHandler.Type.CENTER; } else if (CropWindowHandler.isInHorizontalTargetZone(x, y, mEdges.left, mEdges.right, mEdges.top, targetRadius)) { moveType = CropWindowMoveHandler.Type.TOP; } else if (CropWindowHandler.isInHorizontalTargetZone(x, y, mEdges.left, mEdges.right, mEdges.bottom, targetRadius)) { moveType = CropWindowMoveHandler.Type.BOTTOM; } else if (CropWindowHandler.isInVerticalTargetZone(x, y, mEdges.left, mEdges.top, mEdges.bottom, targetRadius)) { moveType = CropWindowMoveHandler.Type.LEFT; } else if (CropWindowHandler.isInVerticalTargetZone(x, y, mEdges.right, mEdges.top, mEdges.bottom, targetRadius)) { moveType = CropWindowMoveHandler.Type.RIGHT; } else if (CropWindowHandler.isInCenterTargetZone(x, y, mEdges.left, mEdges.top, mEdges.right, mEdges.bottom) && !focusCenter()) { moveType = CropWindowMoveHandler.Type.CENTER; } return moveType; } /** * Determines which, if any, of the handles are pressed given the touch * coordinates, the bounding box/oval, and the touch radius. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @return the Handle that was pressed; null if no Handle was pressed */ private CropWindowMoveHandler.Type getOvalPressedMoveType(float x, float y) { /* Use a 6x6 grid system divided into 9 "handles", with the center the biggest region. While this is not perfect, it's a good quick-to-ship approach. TL T T T T TR L C C C C R L C C C C R L C C C C R L C C C C R BL B B B B BR */ float cellLength = mEdges.width() / 6; float leftCenter = mEdges.left + cellLength; float rightCenter = mEdges.left + (5 * cellLength); float cellHeight = mEdges.height() / 6; float topCenter = mEdges.top + cellHeight; float bottomCenter = mEdges.top + 5 * cellHeight; CropWindowMoveHandler.Type moveType; if (x < leftCenter) { if (y < topCenter) { moveType = CropWindowMoveHandler.Type.TOP_LEFT; } else if (y < bottomCenter) { moveType = CropWindowMoveHandler.Type.LEFT; } else { moveType = CropWindowMoveHandler.Type.BOTTOM_LEFT; } } else if (x < rightCenter) { if (y < topCenter) { moveType = CropWindowMoveHandler.Type.TOP; } else if (y < bottomCenter) { moveType = CropWindowMoveHandler.Type.CENTER; } else { moveType = CropWindowMoveHandler.Type.BOTTOM; } } else { if (y < topCenter) { moveType = CropWindowMoveHandler.Type.TOP_RIGHT; } else if (y < bottomCenter) { moveType = CropWindowMoveHandler.Type.RIGHT; } else { moveType = CropWindowMoveHandler.Type.BOTTOM_RIGHT; } } return moveType; } /** * Determines if the specified coordinate is in the target touch zone for a * corner handle. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @param handleX the x-coordinate of the corner handle * @param handleY the y-coordinate of the corner handle * @param targetRadius the target radius in pixels * @return true if the touch point is in the target touch zone; false * otherwise */ private static boolean isInCornerTargetZone(float x, float y, float handleX, float handleY, float targetRadius) { return Math.abs(x - handleX) <= targetRadius && Math.abs(y - handleY) <= targetRadius; } /** * Determines if the specified coordinate is in the target touch zone for a * horizontal bar handle. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @param handleXStart the left x-coordinate of the horizontal bar handle * @param handleXEnd the right x-coordinate of the horizontal bar handle * @param handleY the y-coordinate of the horizontal bar handle * @param targetRadius the target radius in pixels * @return true if the touch point is in the target touch zone; false * otherwise */ private static boolean isInHorizontalTargetZone(float x, float y, float handleXStart, float handleXEnd, float handleY, float targetRadius) { return x > handleXStart && x < handleXEnd && Math.abs(y - handleY) <= targetRadius; } /** * Determines if the specified coordinate is in the target touch zone for a * vertical bar handle. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @param handleX the x-coordinate of the vertical bar handle * @param handleYStart the top y-coordinate of the vertical bar handle * @param handleYEnd the bottom y-coordinate of the vertical bar handle * @param targetRadius the target radius in pixels * @return true if the touch point is in the target touch zone; false * otherwise */ private static boolean isInVerticalTargetZone(float x, float y, float handleX, float handleYStart, float handleYEnd, float targetRadius) { return Math.abs(x - handleX) <= targetRadius && y > handleYStart && y < handleYEnd; } /** * Determines if the specified coordinate falls anywhere inside the given * bounds. * * @param x the x-coordinate of the touch point * @param y the y-coordinate of the touch point * @param left the x-coordinate of the left bound * @param top the y-coordinate of the top bound * @param right the x-coordinate of the right bound * @param bottom the y-coordinate of the bottom bound * @return true if the touch point is inside the bounding rectangle; false * otherwise */ private static boolean isInCenterTargetZone(float x, float y, float left, float top, float right, float bottom) { return x > left && x < right && y > top && y < bottom; } /** * Determines if the cropper should focus on the center handle or the side * handles. If it is a small image, focus on the center handle so the user * can move it. If it is a large image, focus on the side handles so user * can grab them. Corresponds to the appearance of the * RuleOfThirdsGuidelines. * * @return true if it is small enough such that it should focus on the * center; less than show_guidelines limit */ private boolean focusCenter() { return !showGuidelines(); } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/CropWindowMoveHandler.java ================================================ // "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" package com.github.gzuliyujiang.imagepicker; import android.graphics.PointF; import android.graphics.RectF; /** * Handler to update crop window edges by the move type - Horizontal, Vertical, Corner or Center.
*/ final class CropWindowMoveHandler { //region: Fields and Consts /** * Minimum width in pixels that the crop window can get. */ private final float mMinCropWidth; /** * Minimum width in pixels that the crop window can get. */ private final float mMinCropHeight; /** * Maximum height in pixels that the crop window can get. */ private final float mMaxCropWidth; /** * Maximum height in pixels that the crop window can get. */ private final float mMaxCropHeight; /** * The type of crop window move that is handled. */ private final Type mType; /** * Holds the x and y offset between the exact touch location and the exact handle location that is activated. * There may be an offset because we allow for some leeway (specified by mHandleRadius) in activating a handle. * However, we want to maintain these offset values while the handle is being dragged so that the handle * doesn't jump. */ private final PointF mTouchOffset = new PointF(); //endregion /** * @param type the type of move this handler is executing * @param cropWindowHandler main crop window handle to get and update the crop window edges * @param touchX the location of the initial toch possition to measure move distance * @param touchY the location of the initial toch possition to measure move distance */ public CropWindowMoveHandler(Type type, CropWindowHandler cropWindowHandler, float touchX, float touchY) { mType = type; mMinCropWidth = cropWindowHandler.getMinCropWidth(); mMinCropHeight = cropWindowHandler.getMinCropHeight(); mMaxCropWidth = cropWindowHandler.getMaxCropWidth(); mMaxCropHeight = cropWindowHandler.getMaxCropHeight(); calculateTouchOffset(cropWindowHandler.getRect(), touchX, touchY); } /** * Updates the crop window by change in the toch location.
* Move type handled by this instance, as initialized in creation, affects how the change in toch location * changes the crop window position and size.
* After the crop window position/size is changed by toch move it may result in values that vialate contraints: * outside the bounds of the shown bitmap, smaller/larger than min/max size or missmatch in aspect ratio. * So a series of fixes is executed on "secondary" edges to adjust it by the "primary" edge movement.
* Primary is the edge directly affected by move type, secondary is the other edge.
* The crop window is changed by directly setting the Edge coordinates. * * @param x the new x-coordinate of this handle * @param y the new y-coordinate of this handle * @param bounds the bounding rectangle of the image * @param viewWidth The bounding image view width used to know the crop overlay is at view edges. * @param viewHeight The bounding image view height used to know the crop overlay is at view edges. * @param snapMargin the maximum distance (in pixels) at which the crop window should snap to the image * @param fixedAspectRatio is the aspect ration fixed and 'targetAspectRatio' should be used * @param aspectRatio the aspect ratio to maintain */ public void move(RectF rect, float x, float y, RectF bounds, int viewWidth, int viewHeight, float snapMargin, boolean fixedAspectRatio, float aspectRatio) { // Adjust the coordinates for the finger position's offset (i.e. the // distance from the initial touch to the precise handle location). // We want to maintain the initial touch's distance to the pressed // handle so that the crop window size does not "jump". float adjX = x + mTouchOffset.x; float adjY = y + mTouchOffset.y; if (mType == Type.CENTER) { moveCenter(rect, adjX, adjY, bounds, viewWidth, viewHeight, snapMargin); } else { if (fixedAspectRatio) { moveSizeWithFixedAspectRatio(rect, adjX, adjY, bounds, viewWidth, viewHeight, snapMargin, aspectRatio); } else { moveSizeWithFreeAspectRatio(rect, adjX, adjY, bounds, viewWidth, viewHeight, snapMargin); } } } //region: Private methods /** * Calculates the offset of the touch point from the precise location of the specified handle.
* Save these values in a member variable since we want to maintain this offset as we drag the handle. */ private void calculateTouchOffset(RectF rect, float touchX, float touchY) { float touchOffsetX = 0; float touchOffsetY = 0; // Calculate the offset from the appropriate handle. switch (mType) { case TOP_LEFT: touchOffsetX = rect.left - touchX; touchOffsetY = rect.top - touchY; break; case TOP_RIGHT: touchOffsetX = rect.right - touchX; touchOffsetY = rect.top - touchY; break; case BOTTOM_LEFT: touchOffsetX = rect.left - touchX; touchOffsetY = rect.bottom - touchY; break; case BOTTOM_RIGHT: touchOffsetX = rect.right - touchX; touchOffsetY = rect.bottom - touchY; break; case LEFT: touchOffsetX = rect.left - touchX; touchOffsetY = 0; break; case TOP: touchOffsetX = 0; touchOffsetY = rect.top - touchY; break; case RIGHT: touchOffsetX = rect.right - touchX; touchOffsetY = 0; break; case BOTTOM: touchOffsetX = 0; touchOffsetY = rect.bottom - touchY; break; case CENTER: touchOffsetX = rect.centerX() - touchX; touchOffsetY = rect.centerY() - touchY; break; default: break; } mTouchOffset.x = touchOffsetX; mTouchOffset.y = touchOffsetY; } /** * Center move only changes the position of the crop window without changing the size. */ private void moveCenter(RectF rect, float x, float y, RectF bounds, int viewWidth, int viewHeight, float snapRadius) { float dx = x - rect.centerX(); float dy = y - rect.centerY(); if (rect.left + dx < 0 || rect.right + dx > viewWidth || rect.left + dx < bounds.left || rect.right + dx > bounds.right) { dx /= 1.05f; mTouchOffset.x -= dx / 2; } if (rect.top + dy < 0 || rect.bottom + dy > viewHeight || rect.top + dy < bounds.top || rect.bottom + dy > bounds.bottom) { dy /= 1.05f; mTouchOffset.y -= dy / 2; } rect.offset(dx, dy); snapEdgesToBounds(rect, bounds, snapRadius); } /** * Change the size of the crop window on the required edge (or edges for corner size move) without * affecting "secondary" edges.
* Only the primary edge(s) are fixed to stay within limits. */ private void moveSizeWithFreeAspectRatio(RectF rect, float x, float y, RectF bounds, int viewWidth, int viewHeight, float snapMargin) { switch (mType) { case TOP_LEFT: adjustTop(rect, y, bounds, snapMargin, 0, false, false); adjustLeft(rect, x, bounds, snapMargin, 0, false, false); break; case TOP_RIGHT: adjustTop(rect, y, bounds, snapMargin, 0, false, false); adjustRight(rect, x, bounds, viewWidth, snapMargin, 0, false, false); break; case BOTTOM_LEFT: adjustBottom(rect, y, bounds, viewHeight, snapMargin, 0, false, false); adjustLeft(rect, x, bounds, snapMargin, 0, false, false); break; case BOTTOM_RIGHT: adjustBottom(rect, y, bounds, viewHeight, snapMargin, 0, false, false); adjustRight(rect, x, bounds, viewWidth, snapMargin, 0, false, false); break; case LEFT: adjustLeft(rect, x, bounds, snapMargin, 0, false, false); break; case TOP: adjustTop(rect, y, bounds, snapMargin, 0, false, false); break; case RIGHT: adjustRight(rect, x, bounds, viewWidth, snapMargin, 0, false, false); break; case BOTTOM: adjustBottom(rect, y, bounds, viewHeight, snapMargin, 0, false, false); break; default: break; } } /** * Change the size of the crop window on the required "primary" edge WITH affect to relevant "secondary" * edge via aspect ratio.
* Example: change in the left edge (primary) will affect top and bottom edges (secondary) to preserve the * given aspect ratio. */ private void moveSizeWithFixedAspectRatio(RectF rect, float x, float y, RectF bounds, int viewWidth, int viewHeight, float snapMargin, float aspectRatio) { switch (mType) { case TOP_LEFT: if (calculateAspectRatio(x, y, rect.right, rect.bottom) < aspectRatio) { adjustTop(rect, y, bounds, snapMargin, aspectRatio, true, false); adjustLeftByAspectRatio(rect, aspectRatio); } else { adjustLeft(rect, x, bounds, snapMargin, aspectRatio, true, false); adjustTopByAspectRatio(rect, aspectRatio); } break; case TOP_RIGHT: if (calculateAspectRatio(rect.left, y, x, rect.bottom) < aspectRatio) { adjustTop(rect, y, bounds, snapMargin, aspectRatio, false, true); adjustRightByAspectRatio(rect, aspectRatio); } else { adjustRight(rect, x, bounds, viewWidth, snapMargin, aspectRatio, true, false); adjustTopByAspectRatio(rect, aspectRatio); } break; case BOTTOM_LEFT: if (calculateAspectRatio(x, rect.top, rect.right, y) < aspectRatio) { adjustBottom(rect, y, bounds, viewHeight, snapMargin, aspectRatio, true, false); adjustLeftByAspectRatio(rect, aspectRatio); } else { adjustLeft(rect, x, bounds, snapMargin, aspectRatio, false, true); adjustBottomByAspectRatio(rect, aspectRatio); } break; case BOTTOM_RIGHT: if (calculateAspectRatio(rect.left, rect.top, x, y) < aspectRatio) { adjustBottom(rect, y, bounds, viewHeight, snapMargin, aspectRatio, false, true); adjustRightByAspectRatio(rect, aspectRatio); } else { adjustRight(rect, x, bounds, viewWidth, snapMargin, aspectRatio, false, true); adjustBottomByAspectRatio(rect, aspectRatio); } break; case LEFT: adjustLeft(rect, x, bounds, snapMargin, aspectRatio, true, true); adjustTopBottomByAspectRatio(rect, bounds, aspectRatio); break; case TOP: adjustTop(rect, y, bounds, snapMargin, aspectRatio, true, true); adjustLeftRightByAspectRatio(rect, bounds, aspectRatio); break; case RIGHT: adjustRight(rect, x, bounds, viewWidth, snapMargin, aspectRatio, true, true); adjustTopBottomByAspectRatio(rect, bounds, aspectRatio); break; case BOTTOM: adjustBottom(rect, y, bounds, viewHeight, snapMargin, aspectRatio, true, true); adjustLeftRightByAspectRatio(rect, bounds, aspectRatio); break; default: break; } } /** * Check if edges have gone out of bounds (including snap margin), and fix if needed. */ private void snapEdgesToBounds(RectF edges, RectF bounds, float margin) { if (edges.left < bounds.left + margin) { edges.offset(bounds.left - edges.left, 0); } if (edges.top < bounds.top + margin) { edges.offset(0, bounds.top - edges.top); } if (edges.right > bounds.right - margin) { edges.offset(bounds.right - edges.right, 0); } if (edges.bottom > bounds.bottom - margin) { edges.offset(0, bounds.bottom - edges.bottom); } } /** * Get the resulting x-position of the left edge of the crop window given * the handle's position and the image's bounding box and snap radius. * * @param left the position that the left edge is dragged to * @param bounds the bounding box of the image that is being cropped * @param snapMargin the snap distance to the image edge (in pixels) */ private void adjustLeft(RectF rect, float left, RectF bounds, float snapMargin, float aspectRatio, boolean topMoves, boolean bottomMoves) { float newLeft = left; if (newLeft < 0) { newLeft /= 1.05f; mTouchOffset.x -= newLeft / 1.1f; } if (newLeft < bounds.left) { mTouchOffset.x -= (newLeft - bounds.left) / 2f; } if (newLeft - bounds.left < snapMargin) { newLeft = bounds.left; } // Checks if the window is too small horizontally if (rect.right - newLeft < mMinCropWidth) { newLeft = rect.right - mMinCropWidth; } // Checks if the window is too large horizontally if (rect.right - newLeft > mMaxCropWidth) { newLeft = rect.right - mMaxCropWidth; } if (newLeft - bounds.left < snapMargin) { newLeft = bounds.left; } // check vertical bounds if aspect ratio is in play if (aspectRatio > 0) { float newHeight = (rect.right - newLeft) / aspectRatio; // Checks if the window is too small vertically if (newHeight < mMinCropHeight) { newLeft = Math.max(bounds.left, rect.right - mMinCropHeight * aspectRatio); newHeight = (rect.right - newLeft) / aspectRatio; } // Checks if the window is too large vertically if (newHeight > mMaxCropHeight) { newLeft = Math.max(bounds.left, rect.right - mMaxCropHeight * aspectRatio); newHeight = (rect.right - newLeft) / aspectRatio; } // if top AND bottom edge moves by aspect ratio check that it is within full height bounds if (topMoves && bottomMoves) { newLeft = Math.max(newLeft, Math.max(bounds.left, rect.right - bounds.height() * aspectRatio)); } else { // if top edge moves by aspect ratio check that it is within bounds if (topMoves && rect.bottom - newHeight < bounds.top) { newLeft = Math.max(bounds.left, rect.right - (rect.bottom - bounds.top) * aspectRatio); newHeight = (rect.right - newLeft) / aspectRatio; } // if bottom edge moves by aspect ratio check that it is within bounds if (bottomMoves && rect.top + newHeight > bounds.bottom) { newLeft = Math.max(newLeft, Math.max(bounds.left, rect.right - (bounds.bottom - rect.top) * aspectRatio)); } } } rect.left = newLeft; } /** * Get the resulting x-position of the right edge of the crop window given * the handle's position and the image's bounding box and snap radius. * * @param right the position that the right edge is dragged to * @param bounds the bounding box of the image that is being cropped * @param viewWidth view width * @param snapMargin the snap distance to the image edge (in pixels) */ private void adjustRight(RectF rect, float right, RectF bounds, int viewWidth, float snapMargin, float aspectRatio, boolean topMoves, boolean bottomMoves) { float newRight = right; if (newRight > viewWidth) { newRight = viewWidth + (newRight - viewWidth) / 1.05f; mTouchOffset.x -= (newRight - viewWidth) / 1.1f; } if (newRight > bounds.right) { mTouchOffset.x -= (newRight - bounds.right) / 2f; } // If close to the edge if (bounds.right - newRight < snapMargin) { newRight = bounds.right; } // Checks if the window is too small horizontally if (newRight - rect.left < mMinCropWidth) { newRight = rect.left + mMinCropWidth; } // Checks if the window is too large horizontally if (newRight - rect.left > mMaxCropWidth) { newRight = rect.left + mMaxCropWidth; } // If close to the edge if (bounds.right - newRight < snapMargin) { newRight = bounds.right; } // check vertical bounds if aspect ratio is in play if (aspectRatio > 0) { float newHeight = (newRight - rect.left) / aspectRatio; // Checks if the window is too small vertically if (newHeight < mMinCropHeight) { newRight = Math.min(bounds.right, rect.left + mMinCropHeight * aspectRatio); newHeight = (newRight - rect.left) / aspectRatio; } // Checks if the window is too large vertically if (newHeight > mMaxCropHeight) { newRight = Math.min(bounds.right, rect.left + mMaxCropHeight * aspectRatio); newHeight = (newRight - rect.left) / aspectRatio; } // if top AND bottom edge moves by aspect ratio check that it is within full height bounds if (topMoves && bottomMoves) { newRight = Math.min(newRight, Math.min(bounds.right, rect.left + bounds.height() * aspectRatio)); } else { // if top edge moves by aspect ratio check that it is within bounds if (topMoves && rect.bottom - newHeight < bounds.top) { newRight = Math.min(bounds.right, rect.left + (rect.bottom - bounds.top) * aspectRatio); newHeight = (newRight - rect.left) / aspectRatio; } // if bottom edge moves by aspect ratio check that it is within bounds if (bottomMoves && rect.top + newHeight > bounds.bottom) { newRight = Math.min(newRight, Math.min(bounds.right, rect.left + (bounds.bottom - rect.top) * aspectRatio)); } } } rect.right = newRight; } /** * Get the resulting y-position of the top edge of the crop window given the * handle's position and the image's bounding box and snap radius. * * @param top the x-position that the top edge is dragged to * @param bounds the bounding box of the image that is being cropped * @param snapMargin the snap distance to the image edge (in pixels) */ private void adjustTop(RectF rect, float top, RectF bounds, float snapMargin, float aspectRatio, boolean leftMoves, boolean rightMoves) { float newTop = top; if (newTop < 0) { newTop /= 1.05f; mTouchOffset.y -= newTop / 1.1f; } if (newTop < bounds.top) { mTouchOffset.y -= (newTop - bounds.top) / 2f; } if (newTop - bounds.top < snapMargin) { newTop = bounds.top; } // Checks if the window is too small vertically if (rect.bottom - newTop < mMinCropHeight) { newTop = rect.bottom - mMinCropHeight; } // Checks if the window is too large vertically if (rect.bottom - newTop > mMaxCropHeight) { newTop = rect.bottom - mMaxCropHeight; } if (newTop - bounds.top < snapMargin) { newTop = bounds.top; } // check horizontal bounds if aspect ratio is in play if (aspectRatio > 0) { float newWidth = (rect.bottom - newTop) * aspectRatio; // Checks if the crop window is too small horizontally due to aspect ratio adjustment if (newWidth < mMinCropWidth) { newTop = Math.max(bounds.top, rect.bottom - (mMinCropWidth / aspectRatio)); newWidth = (rect.bottom - newTop) * aspectRatio; } // Checks if the crop window is too large horizontally due to aspect ratio adjustment if (newWidth > mMaxCropWidth) { newTop = Math.max(bounds.top, rect.bottom - (mMaxCropWidth / aspectRatio)); newWidth = (rect.bottom - newTop) * aspectRatio; } // if left AND right edge moves by aspect ratio check that it is within full width bounds if (leftMoves && rightMoves) { newTop = Math.max(newTop, Math.max(bounds.top, rect.bottom - bounds.width() / aspectRatio)); } else { // if left edge moves by aspect ratio check that it is within bounds if (leftMoves && rect.right - newWidth < bounds.left) { newTop = Math.max(bounds.top, rect.bottom - (rect.right - bounds.left) / aspectRatio); newWidth = (rect.bottom - newTop) * aspectRatio; } // if right edge moves by aspect ratio check that it is within bounds if (rightMoves && rect.left + newWidth > bounds.right) { newTop = Math.max(newTop, Math.max(bounds.top, rect.bottom - (bounds.right - rect.left) / aspectRatio)); } } } rect.top = newTop; } /** * Get the resulting y-position of the bottom edge of the crop window given * the handle's position and the image's bounding box and snap radius. * * @param bottom the position that the bottom edge is dragged to * @param bounds the bounding box of the image that is being cropped * @param viewHeight view height * @param snapMargin the snap distance to the image edge (in pixels) */ private void adjustBottom(RectF rect, float bottom, RectF bounds, int viewHeight, float snapMargin, float aspectRatio, boolean leftMoves, boolean rightMoves) { float newBottom = bottom; if (newBottom > viewHeight) { newBottom = viewHeight + (newBottom - viewHeight) / 1.05f; mTouchOffset.y -= (newBottom - viewHeight) / 1.1f; } if (newBottom > bounds.bottom) { mTouchOffset.y -= (newBottom - bounds.bottom) / 2f; } if (bounds.bottom - newBottom < snapMargin) { newBottom = bounds.bottom; } // Checks if the window is too small vertically if (newBottom - rect.top < mMinCropHeight) { newBottom = rect.top + mMinCropHeight; } // Checks if the window is too small vertically if (newBottom - rect.top > mMaxCropHeight) { newBottom = rect.top + mMaxCropHeight; } if (bounds.bottom - newBottom < snapMargin) { newBottom = bounds.bottom; } // check horizontal bounds if aspect ratio is in play if (aspectRatio > 0) { float newWidth = (newBottom - rect.top) * aspectRatio; // Checks if the window is too small horizontally if (newWidth < mMinCropWidth) { newBottom = Math.min(bounds.bottom, rect.top + mMinCropWidth / aspectRatio); newWidth = (newBottom - rect.top) * aspectRatio; } // Checks if the window is too large horizontally if (newWidth > mMaxCropWidth) { newBottom = Math.min(bounds.bottom, rect.top + mMaxCropWidth / aspectRatio); newWidth = (newBottom - rect.top) * aspectRatio; } // if left AND right edge moves by aspect ratio check that it is within full width bounds if (leftMoves && rightMoves) { newBottom = Math.min(newBottom, Math.min(bounds.bottom, rect.top + bounds.width() / aspectRatio)); } else { // if left edge moves by aspect ratio check that it is within bounds if (leftMoves && rect.right - newWidth < bounds.left) { newBottom = Math.min(bounds.bottom, rect.top + (rect.right - bounds.left) / aspectRatio); newWidth = (newBottom - rect.top) * aspectRatio; } // if right edge moves by aspect ratio check that it is within bounds if (rightMoves && rect.left + newWidth > bounds.right) { newBottom = Math.min(newBottom, Math.min(bounds.bottom, rect.top + (bounds.right - rect.left) / aspectRatio)); } } } rect.bottom = newBottom; } /** * Adjust left edge by current crop window height and the given aspect ratio, * the right edge remains in possition while the left adjusts to keep aspect ratio to the height. */ private void adjustLeftByAspectRatio(RectF rect, float aspectRatio) { rect.left = rect.right - rect.height() * aspectRatio; } /** * Adjust top edge by current crop window width and the given aspect ratio, * the bottom edge remains in possition while the top adjusts to keep aspect ratio to the width. */ private void adjustTopByAspectRatio(RectF rect, float aspectRatio) { rect.top = rect.bottom - rect.width() / aspectRatio; } /** * Adjust right edge by current crop window height and the given aspect ratio, * the left edge remains in possition while the left adjusts to keep aspect ratio to the height. */ private void adjustRightByAspectRatio(RectF rect, float aspectRatio) { rect.right = rect.left + rect.height() * aspectRatio; } /** * Adjust bottom edge by current crop window width and the given aspect ratio, * the top edge remains in possition while the top adjusts to keep aspect ratio to the width. */ private void adjustBottomByAspectRatio(RectF rect, float aspectRatio) { rect.bottom = rect.top + rect.width() / aspectRatio; } /** * Adjust left and right edges by current crop window height and the given aspect ratio, * both right and left edges adjusts equally relative to center to keep aspect ratio to the height. */ private void adjustLeftRightByAspectRatio(RectF rect, RectF bounds, float aspectRatio) { rect.inset((rect.width() - rect.height() * aspectRatio) / 2, 0); if (rect.left < bounds.left) { rect.offset(bounds.left - rect.left, 0); } if (rect.right > bounds.right) { rect.offset(bounds.right - rect.right, 0); } } /** * Adjust top and bottom edges by current crop window width and the given aspect ratio, * both top and bottom edges adjusts equally relative to center to keep aspect ratio to the width. */ private void adjustTopBottomByAspectRatio(RectF rect, RectF bounds, float aspectRatio) { rect.inset(0, (rect.height() - rect.width() / aspectRatio) / 2); if (rect.top < bounds.top) { rect.offset(0, bounds.top - rect.top); } if (rect.bottom > bounds.bottom) { rect.offset(0, bounds.bottom - rect.bottom); } } /** * Calculates the aspect ratio given a rectangle. */ private static float calculateAspectRatio(float left, float top, float right, float bottom) { return (right - left) / (bottom - top); } //endregion //region: Inner class: Type /** * The type of crop window move that is handled. */ public enum Type { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, LEFT, TOP, RIGHT, BOTTOM, CENTER } //endregion } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/HybridityUtils.java ================================================ package com.github.gzuliyujiang.imagepicker; import android.Manifest; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.provider.MediaStore; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.FileProvider; import java.io.File; import java.io.InputStream; /** * Created by linchaolong on 2017/5/10. */ final class HybridityUtils { public static Intent getCameraIntent(@NonNull Context context) { Uri outputFileUri = HybridityUtils.getCaptureImageOutputUri(context); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, HybridityUtils.getIntentUri(context, outputFileUri)); return intent; } public static Intent getGalleryIntent() { return getChooserIntent("image/*"); } public static Intent getChooserIntent(String mime) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mime); return intent; } public static Uri getPickImageResultUri(@NonNull Context context, @Nullable Intent data) { boolean isCamera = true; if (data != null && data.getData() != null) { String action = data.getAction(); isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE); } return isCamera || data.getData() == null ? getCaptureImageOutputUri(context) : data.getData(); } public static Uri getCaptureImageOutputUri(@NonNull Context context) { Uri outputFileUri = null; File getImage = context.getExternalCacheDir(); if (getImage != null) { outputFileUri = Uri.fromFile(new File(getImage.getPath(), "pickImageResult.jpeg")); } return outputFileUri; } /** * 获取文件的真实路径,比如:content://media/external/images/media/74275 的真实路径 file:///storage/sdcard0/Pictures/X.jpg *

* http://stackoverflow.com/questions/20028319/how-to-convert-content-media-external-images-media-y-to-file-storage-sdc */ public static String getRealPathFromUri(Context context, Uri contentUri) { Cursor cursor = null; try { String[] proj = {MediaStore.Images.Media.DATA}; cursor = context.getContentResolver().query(contentUri, proj, null, null, null); if (cursor == null) { return ""; } int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(columnIndex); } catch (IllegalStateException e) { //IllegalArgumentException: column '_data' does not exist. Available columns: [] return ""; } finally { if (cursor != null) { cursor.close(); } } } /** * Check if explicetly requesting camera permission is required.
* It is required in Android Marshmellow and above if "CAMERA" permission is requested in the manifest.
* See StackOverflow * question. */ public static boolean isExplicitCameraPermissionRequired(@NonNull Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return hasPermissionInManifest(context, Manifest.permission.CAMERA) && context.checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED; } return false; } /** * Check if the app requests a specific permission in the manifest. * * @param permissionName the permission to check * @return true - the permission in requested in manifest, false - not. */ public static boolean hasPermissionInManifest(@NonNull Context context, @NonNull String permissionName) { String packageName = context.getPackageName(); try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_PERMISSIONS); final String[] declaredPermisisons = packageInfo.requestedPermissions; if (declaredPermisisons != null && declaredPermisisons.length > 0) { for (String p : declaredPermisisons) { if (p.equalsIgnoreCase(permissionName)) { return true; } } } } catch (PackageManager.NameNotFoundException ignore) { } return false; } /** * Check if the given picked image URI requires READ_EXTERNAL_STORAGE permissions.
* Only relevant for API version 23 and above and not required for all URI's depends on the * implementation of the app that was used for picking the image. So we just test if we can open the stream or * do we get an exception when we try, Android is awesome. * * @param context used to access Android APIs, like content resolve, it is your activity/fragment/widget. * @param uri the result URI of image pick. * @return true - required permission are not granted, false - either no need for permissions or they are granted */ public static boolean isReadExternalStoragePermissionsRequired(@NonNull Context context, @NonNull Uri uri) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return hasPermissionInManifest(context, Manifest.permission.READ_EXTERNAL_STORAGE) && context.checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && isUriRequiresPermissions(context, uri); } return false; } /** * Test if we can open the given Android URI to test if permission required error is thrown.
* Only relevant for API version 23 and above. * * @param context used to access Android APIs, like content resolve, it is your activity/fragment/widget. * @param uri the result URI of image pick. */ public static boolean isUriRequiresPermissions(@NonNull Context context, @NonNull Uri uri) { try { ContentResolver resolver = context.getContentResolver(); InputStream stream = resolver.openInputStream(uri); if (stream != null) { stream.close(); } return false; } catch (Exception e) { return true; } } /** * 兼容 Android N,Intent中不能使用 file:///* */ public static Uri getIntentUri(Context context, Uri uri) { //support android N+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return getContentUri(context, uri); } else { return uri; } } public static Uri getContentUri(Context context, Uri fileUri) { return FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".imagepicker.provider", new File(fileUri.getPath())); } /** * content uri to path */ public static String getRealPathFromURI(Context context, Uri contentUri) { Cursor cursor = null; try { String[] proj = {MediaStore.Images.Media.DATA}; cursor = context.getContentResolver().query(contentUri, proj, null, null, null); int column_index; if (cursor != null) { column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } return ""; } finally { if (cursor != null) { cursor.close(); } } } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/ImagePicker.java ================================================ package com.github.gzuliyujiang.imagepicker; import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.fragment.app.Fragment; import java.io.File; import java.io.FileNotFoundException; /** * 图片选择器(相机拍照+相册选取+图片裁剪) * * @author 贵州山野羡民(1032694760@qq.com) * @since 2020/4/3 17:18 */ public class ImagePicker { private Uri cropImageUri; private boolean cropEnabled = true; private PickCallback callback; private static class Holder { private static final ImagePicker INSTANCE = new ImagePicker(); } public static ImagePicker getInstance() { return Holder.INSTANCE; } private ImagePicker() { super(); } /** * 启动照相机 */ public void startCamera(Activity activity, boolean cropEnabled, @NonNull PickCallback callback) { this.cropEnabled = cropEnabled; this.callback = callback; if (HybridityUtils.isExplicitCameraPermissionRequired(activity)) { ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CAMERA}, CropImageConsts.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE); } else { activity.startActivityForResult(HybridityUtils.getCameraIntent(activity), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } } /** * 启动照相机 */ public void startCamera(Fragment fragment, boolean cropEnabled, @NonNull PickCallback callback) { this.cropEnabled = cropEnabled; this.callback = callback; if (HybridityUtils.isExplicitCameraPermissionRequired(fragment.requireActivity())) { //noinspection deprecation fragment.requestPermissions(new String[]{Manifest.permission.CAMERA}, CropImageConsts.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE); } else { //noinspection deprecation fragment.startActivityForResult(HybridityUtils.getCameraIntent(fragment.requireActivity()), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } } /** * 启动图库选择器 */ public void startGallery(Activity activity, boolean cropEnabled, @NonNull PickCallback callback) { this.cropEnabled = cropEnabled; this.callback = callback; activity.startActivityForResult(HybridityUtils.getGalleryIntent(), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } /** * 启动图库选择器 */ public void startGallery(Fragment fragment, boolean cropEnabled, @NonNull PickCallback callback) { this.cropEnabled = cropEnabled; this.callback = callback; //noinspection deprecation fragment.startActivityForResult(HybridityUtils.getGalleryIntent(), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } /** * 启动文件选择器 */ public void startChooser(Activity activity, String mime, @NonNull PickCallback callback) { this.cropEnabled = false; this.callback = callback; activity.startActivityForResult(HybridityUtils.getChooserIntent(mime), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } /** * 启动文件选择器 */ public void startChooser(Fragment fragment, String mime, @NonNull PickCallback callback) { this.cropEnabled = false; this.callback = callback; //noinspection deprecation fragment.startActivityForResult(HybridityUtils.getChooserIntent(mime), CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE); } /** * 图片选择/裁剪结果回调,在 {@link Activity#onActivityResult(int, int, Intent)} 中调用 */ @SuppressWarnings("JavadocReference") public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { onActivityResultInner(activity, null, requestCode, resultCode, data); } /** * 图片选择/裁剪结果回调,在 {@link Fragment#onActivityResult(int, int, Intent)} 中调用 */ public void onActivityResult(Fragment fragment, int requestCode, int resultCode, Intent data) { onActivityResultInner(null, fragment, requestCode, resultCode, data); } private void onActivityResultInner(Activity activity, Fragment fragment, int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { if (callback != null) { callback.onCanceled(); } return; } Context context; if (activity != null) { context = activity; } else { context = fragment.getActivity(); } if (context != null && requestCode == CropImageConsts.PICK_IMAGE_CHOOSER_REQUEST_CODE) { Uri pickImageUri = HybridityUtils.getPickImageResultUri(context, data); // 检查读取文件权限 if (HybridityUtils.isReadExternalStoragePermissionsRequired(context, pickImageUri)) { if (activity != null) { ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImageConsts.PICK_IMAGE_PERMISSIONS_REQUEST_CODE); } else { //noinspection deprecation fragment.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImageConsts.PICK_IMAGE_PERMISSIONS_REQUEST_CODE); } } else { // 选择图片回调 if (activity != null) { handlePickImage(activity, null, pickImageUri); } else { handlePickImage(null, fragment, pickImageUri); } } } else if (requestCode == CropImageConsts.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { // 裁剪图片回调 handleCropResult(context, data); } } /** * 授权结果回调,在 {@link Activity#onRequestPermissionsResult(int, String[], int[])} 中调用 */ public void onRequestPermissionsResult(Activity activity, int requestCode, String[] permissions, int[] grantResults) { onRequestPermissionsResultInner(activity, null, requestCode, permissions, grantResults); } /** * 授权结果回调,在 {@link Fragment#onRequestPermissionsResult(int, String[], int[])} 中调用 */ public void onRequestPermissionsResult(Fragment fragment, int requestCode, String[] permissions, int[] grantResults) { onRequestPermissionsResultInner(null, fragment, requestCode, permissions, grantResults); } private void onRequestPermissionsResultInner(Activity activity, Fragment fragment, int requestCode, String[] permissions, int[] grantResults) { if (requestCode == CropImageConsts.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (activity != null) { startCamera(activity, cropEnabled, callback); } else { startCamera(fragment, cropEnabled, callback); } } else { if (callback != null) { callback.onPermissionDenied(permissions, "没有相机权限"); } } } else if (requestCode == CropImageConsts.PICK_IMAGE_PERMISSIONS_REQUEST_CODE) { if (cropImageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (activity != null) { handlePickImage(activity, null, cropImageUri); } else { handlePickImage(null, fragment, cropImageUri); } } else { if (callback != null) { callback.onPermissionDenied(permissions, "没有外部存储权限"); } } } } /** * 裁剪图片结果回调 */ private void handleCropResult(Context context, Intent data) { ActivityResult result = null; if (data != null) { result = data.getParcelableExtra(CropImageConsts.CROP_IMAGE_EXTRA_RESULT); } if (result == null) { return; } Exception error = result.getError(); if (error == null) { cropImageUri = result.getUri(); if (callback != null) { callback.onCropImage(handleUri(context, cropImageUri)); } } else { if (callback != null) { callback.onCropError(error); } } } /** * 选择图片结果回调 */ private void handlePickImage(Activity activity, Fragment fragment, Uri imageUri) { if (callback != null) { Context context; if (activity != null) { context = activity; } else { context = fragment.getContext(); } callback.onPickImage(handleUri(context, imageUri)); } if (!cropEnabled) { return; } if (imageUri == null || imageUri.equals(Uri.EMPTY)) { if (callback != null) { callback.onCropError(new IllegalArgumentException("Uri is null or empty")); } return; } ActivityBuilder builder = new ActivityBuilder(imageUri); if (callback != null) { callback.cropConfig(builder); } if (activity != null) { builder.start(activity); } else { builder.start(fragment); } } /** * 处理返回图片的 uri,content 协议自动转换 file 协议,避免 {@link FileNotFoundException} */ private Uri handleUri(Context context, Uri imageUri) { if ("content".equals(imageUri.getScheme())) { String realPath = HybridityUtils.getRealPathFromUri(context, imageUri); if (!TextUtils.isEmpty(realPath)) { return Uri.fromFile(new File(realPath)); } } return imageUri; } } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/ImageProvider.java ================================================ package com.github.gzuliyujiang.imagepicker; import androidx.core.content.FileProvider; /** * @author 贵州山魈羡民 (1032694760@qq.com) * @since 2020/12/1 14:58 */ public class ImageProvider extends FileProvider { } ================================================ FILE: ImagePicker/src/main/java/com/github/gzuliyujiang/imagepicker/PickCallback.java ================================================ package com.github.gzuliyujiang.imagepicker; import android.net.Uri; import androidx.annotation.NonNull; import androidx.annotation.Nullable; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2020/4/3 17:18 */ public abstract class PickCallback { /** * 用户取消回调 */ public void onCanceled() { } /** * 用户拒绝授权回调 */ public void onPermissionDenied(String[] permissions, String message) { } /** * 图片选择回调 */ public void onPickImage(@Nullable Uri imageUri) { } /** * 图片裁剪配置 */ public void cropConfig(ActivityBuilder builder) { builder.setMultiTouchEnabled(false) .setCropShape(CropImageView.CropShape.OVAL) .setRequestedSize(640, 640) .setAspectRatio(5, 5); } /** * 图片裁剪回调 */ public void onCropImage(@Nullable Uri imageUri) { } /** * 图片裁剪出错 */ public void onCropError(@NonNull Exception error) { } } ================================================ FILE: ImagePicker/src/main/res/layout/crop_image_activity.xml ================================================ ================================================ FILE: ImagePicker/src/main/res/layout/crop_image_view.xml ================================================ ================================================ FILE: ImagePicker/src/main/res/values/crop_image_attrs.xml ================================================ ================================================ FILE: ImagePicker/src/main/res/xml/crop_image_paths.xml ================================================ ================================================ FILE: LICENSE ================================================ 木兰宽松许可证, 第2版 木兰宽松许可证, 第2版 2020年1月 http://license.coscl.org.cn/MulanPSL2 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 0. 定义 “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 “法人实体”是指提交贡献的机构及其“关联实体”。 “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 1. 授予版权许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 2. 授予专利许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 3. 无商标许可 “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 4. 分发限制 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 5. 免责声明与责任限制 “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 6. 语言 “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 条款结束 如何将木兰宽松许可证,第2版,应用到您的软件 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under 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. Mulan Permissive Software License,Version 2 Mulan Permissive Software License,Version 2 (Mulan PSL v2) January 2020 http://license.coscl.org.cn/MulanPSL2 Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 0. Definition Software means the program and related documents which are licensed under this License and comprise all Contribution(s). Contribution means the copyrightable work licensed by a particular Contributor under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 6. Language THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. END OF THE TERMS AND CONDITIONS How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under 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. ================================================ FILE: NOTICE ================================================ 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. ================================================ FILE: README.md ================================================ # AndroidPicker [![API 19+](https://img.shields.io/badge/API-19%2B-green.svg)](https://github.com/gzu-liyujiang/AndroidPicker) ![Release APK](https://github.com/gzu-liyujiang/AndroidPicker/workflows/Release%20APK/badge.svg) 安卓选择器类库,包括日期及时间选择器(可用于出生日期、营业时间等)、单项选择器(可用于性别、民族、职业、学历、星座等)、二三级联动选择器(可用于车牌号、基金定投日期等)、城市地址选择器(分省级、地市级及区县级)、数字选择器(可用于年龄、身高、体重、温度等)、日历选日期择器(可用于酒店及机票预定日期)、颜色选择器、文件及目录选择器等…… 【抱歉!各位小伙伴,从2022年开始我已经没做安卓开发了,项目虽然已经趋于稳定,不过需要大家参与维护,多提PullRequest,我目前已经没法贡献代码了】 欢迎大伙儿在[Issues](https://github.com/gzu-liyujiang/AndroidPicker/issues)提交你的意见或建议。欢迎 Fork & Pull requests 贡献您的代码,大家共同学习【[AndroidPicker 交流群 604235437](https://jq.qq.com/?_wv=1027&k=42bKOeD)】。 - GitHub:https://github.com/gzu-liyujiang/AndroidPicker - 码云(GitEE):https://gitee.com/li_yu_jiang/AndroidPicker - Demo:[https://github.com/gzu-liyujiang/AndroidPicker/blob/master/demo.apk](/demo.apk) ## 接入指引 **最新版本** :[![jitpack](https://jitpack.io/v/gzu-liyujiang/AndroidPicker.svg)](https://jitpack.io/#gzu-liyujiang/AndroidPicker) (具体**历史版本号**参见 [更新日志](/ChangeLog.md)) ### 注意事项 - 3.0.0 开始完全重构了底层代码,改进了性能,对 XML 布局更友好, 3.x 版本 的 API 和 1.x 及 2.x 版本的不大一样,**请谨慎升级**。 - [1.x Support 版本封存分支](https://github.com/gzu-liyujiang/AndroidPicker/tree/1.x-support) - [2.0 androidx 版本封存分支](https://github.com/gzu-liyujiang/AndroidPicker/tree/2.0-androidx) ### 依赖配置 #### 在项目根目录下的`build.gradle`中 如果你的项目 Gradle 配置是在 7.0 以下,需要在 build.gradle 文件中加入: ```groovy allprojects { repositories { // JitPack 远程仓库:https://jitpack.io maven { url 'https://jitpack.io' } } } ``` 如果你的 Gradle 配置是 7.0 及以上,则需要在 settings.gradle 文件中加入: ```groovy dependencyResolutionManagement { repositories { // JitPack 远程仓库:https://jitpack.io maven { url 'https://jitpack.io' } } } ``` #### 在项目模块下的`build.gradle`中(以下依赖项不必全部引入,请按需来) 所有选择器的基础窗体(用于自定义弹窗): ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:Common:' } ``` 滚轮选择器的滚轮控件(用于自定义滚轮选择器): ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:WheelView:' } ``` 单项/数字、二三级联动、日期/时间等滚轮选择器: ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:WheelPicker:' } ``` 省市区地址选择器: ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:AddressPicker:' } ``` 文件/目录选择器: ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:FilePicker:' } ``` 颜色选择器: ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:ColorPicker:' } ``` 日历日期选择器([README.md](/CalendarPicker/README.md)): ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:CalendarPicker:' } ``` 图片选择器([README.md](/ImagePicker/README.md)): ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:ImagePicker:' } ``` 旧版本 **AndroidX 稳定版本** (不推荐): ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:Common:2.0.0' implementation 'com.github.gzu-liyujiang.AndroidPicker:WheelPicker:2.0.0' implementation 'com.github.gzu-liyujiang.AndroidPicker:FilePicker:2.0.0' implementation 'com.github.gzu-liyujiang.AndroidPicker:ColorPicker:2.0.0' } ``` 旧版本 **Support 稳定版本** (不推荐): ```groovy dependencies { implementation 'com.github.gzu-liyujiang.AndroidPicker:Common:1.5.6.20181018' implementation 'com.github.gzu-liyujiang.AndroidPicker:WheelPicker:1.5.6.20181018' implementation 'com.github.gzu-liyujiang.AndroidPicker:FilePicker:1.5.6.20181018' implementation 'com.github.gzu-liyujiang.AndroidPicker:ColorPicker:1.5.6.20181018' } ``` ## API 说明 [API 说明文档](/API.md) 。 ## 混淆规则 项目库混淆无需额外配置。 ## 用法示例 常见用法请参阅 [demo](/app),**高级用法**请细读[源码](/WheelPicker), 诸如可以重写同名的`assets/china_address.json`来自定义省市区数据, 重写同名的`DialogSheetAnimation`来自定义弹窗动画……。 代码是最好的老师,强烈建议拉取代码运行,尝试修改 demo 对比查看实际效果以便加深理解。 ### 在 Java 中 ```groovy List data = new ArrayList<>(); data.add(new GoodsCategoryBean(1, "食品生鲜")); data.add(new GoodsCategoryBean(2, "家用电器")); data.add(new GoodsCategoryBean(3, "家居生活")); data.add(new GoodsCategoryBean(4, "医疗保健")); data.add(new GoodsCategoryBean(5, "酒水饮料")); data.add(new GoodsCategoryBean(6, "图书音像")); OptionPicker picker = new OptionPicker(this); picker.setTitle("货物分类"); picker.setBodyWidth(140); picker.setData(data); picker.setDefaultPosition(2); picker.setOnOptionPickedListener(this); //OptionWheelLayout wheelLayout = picker.getWheelLayout(); //wheelLayout.setIndicatorEnabled(false); //wheelLayout.setTextColor(0xFFFF00FF); //wheelLayout.setSelectedTextColor(0xFFFF0000); //wheelLayout.setTextSize(15 * view.getResources().getDisplayMetrics().scaledDensity); //wheelLayout.setSelectedTextBold(true); //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.show(); ``` ```groovy DatePicker picker = new DatePicker(this); //picker.setBodyWidth(240); //DateWheelLayout wheelLayout = picker.getWheelLayout(); //wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY); //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); //wheelLayout.setIndicatorColor(0xFFFF0000); //wheelLayout.setIndicatorSize(view.getResources().getDisplayMetrics().density * 2); //wheelLayout.setTextColor(0xCCCC0000); //wheelLayout.setSelectedTextColor(0xFFFF0000); //wheelLayout.getYearLabelView().setTextColor(0xFF999999); //wheelLayout.getMonthLabelView().setTextColor(0xFF999999); picker.getWheelLayout().setResetWhenLinkage(false); picker.setOnDatePickedListener(this); picker.show(); ``` ```groovy AddressPicker picker = new AddressPicker(this); picker.setAddressMode(AddressMode.PROVINCE_CITY); //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.setTextSize(15 * view.getResources().getDisplayMetrics().scaledDensity); //wheelLayout.setSelectedTextBold(true); //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.getProvinceWheelView().formatItem(first), // picker.getCityWheelView().formatItem(second), // picker.getCountyWheelView().formatItem(third))); // } //}); //picker.getProvinceWheelView().setCurtainCorner(CurtainCorner.LEFT); //picker.getCityWheelView().setCurtainCorner(CurtainCorner.RIGHT); picker.show(); ``` ### 在 XML 中 ```xml ``` ```xml ... ``` ### 自定义样式(可选) #### 全局配置所有选择器样式及配色 ```java //4.0.0版本开始内置支持四种弹窗样式(Default、One、Two、Three),效果可运行Demo查看 public class DemoApp extends Application { @Override public void onCreate() { super.onCreate(); DialogConfig.setDialogStyle(DialogStyle.Default); DialogConfig.setDialogColor(new DialogColor() .cancelTextColor(0xFF999999) .okTextColor(0xFF0099CC)); } } ``` #### 自定义 style - **调用`setStyle`**(只作用于当前选择器,推荐) 在`app/.../res/values/styles.xml`中参考`WheelDefault`写个style,然后设置。 ```groovy picker.getWheelView().setStyle(R.style.WheelStyleDemo); ``` - **重写`WheelDefault`覆盖** (所有选择器都会生效,不推荐) 在`app/.../res/values/styles.xml`中**重写`WheelDefault`覆盖** 。 ```xml ``` #### 在Java中集成重写某一选择器样式及配色 ```java //仿蚂蚁财富APP定投周期选择弹窗样式 public class AntFortuneLikePicker extends LinkagePicker { private int lastDialogStyle; public AntFortuneLikePicker(@NonNull Activity activity) { super(activity); } @Override protected void onInit(@NonNull Context context) { super.onInit(context); lastDialogStyle = DialogConfig.getDialogStyle(); DialogConfig.setDialogStyle(DialogStyle.Default); } @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); DialogConfig.setDialogStyle(lastDialogStyle); } @Override protected void initData() { super.initData(); setBackgroundColor(0xFFFFFFFF); cancelView.setText("取消"); cancelView.setTextSize(16); cancelView.setTextColor(0xFF0081FF); okView.setTextColor(0xFF0081FF); okView.setText("确定"); okView.setTextSize(16); titleView.setTextColor(0xFF333333); titleView.setText("定投周期"); titleView.setTextSize(16); wheelLayout.setData(new AntFortuneLikeProvider()); wheelLayout.setAtmosphericEnabled(true); wheelLayout.setVisibleItemCount(7); wheelLayout.setCyclicEnabled(false); wheelLayout.setIndicatorEnabled(true); wheelLayout.setIndicatorColor(0xFFDDDDDD); wheelLayout.setIndicatorSize((int) (contentView.getResources().getDisplayMetrics().density * 1)); wheelLayout.setTextColor(0xFF999999); wheelLayout.setSelectedTextColor(0xFF333333); wheelLayout.setCurtainEnabled(false); wheelLayout.setCurvedEnabled(false); } } ```` ### 和`DialogFragment`结合 `XXXPicker` 都继承自 `android.app.Dialog` ,因此可以直接和`androidx.fragment.app.DialogFragment`结合使用。 ```java public class OptionPickerFragment extends DialogFragment { @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { OptionPicker picker = new OptionPicker(requireActivity()); picker.setData("土人", "里民子", "羡民", "穿青人", "不在56个民族之内", "未定民族"); picker.setOnOptionPickedListener(new OnOptionPickedListener() { @Override public void onOptionPicked(int position, Object item) { Toast.makeText(requireContext(), item.toString(), Toast.LENGTH_SHORT).show(); } }); picker.getWheelView().setStyle(R.style.WheelStyleDemo); return picker; } } ``` ## 效果预览 以下图片显示的效果可能已修改过,实际效果请运行 demo 查看。 - ![效果图](/screenshots/1.webp) - ![效果图](/screenshots/2.webp) - ![效果图](/screenshots/3.webp) - ![效果图](/screenshots/4.webp) - ![效果图](/screenshots/5.webp) - ![效果图](/screenshots/6.webp) - ![效果图](/screenshots/7.webp) - ![效果图](/screenshots/8.webp) - ![效果图](/screenshots/9.webp) ## 特别鸣谢 - [基于 View 的 WheelView](https://github.com/weidongjian/androidWheelView) - [基于 ListView 的 WheelView](https://github.com/venshine/WheelView) - [基于 ScrollView 的 WheelView](https://github.com/wangjiegulu/WheelView) - [SingleDateAndTimePicker](https://github.com/florent37/SingleDateAndTimePicker) - [China_Province_City](https://github.com/small-dream/China_Province_City) - [Administrative-divisions-of-China](https://github.com/modood/Administrative-divisions-of-China) - [AndroidColorPicker](https://github.com/jbruchanov/AndroidColorPicker) - [calendar](https://github.com/oxsource/calendar) - [Android-Image-Cropper](https://github.com/ArthurHub/Android-Image-Cropper) ## 许可协议 声明:不授权给 [@q88qaz](https://github.com/q88qaz) 这种“吃人家粮还骂人家娘”的厚颜无耻的伸手党及其关联企业使用 。 ### 3.0.0 之后 ```text Copyright (c) 2020-2021 gzu-liyujiang <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. ``` ### 3.0.0 之前 ```text MIT License Copyright (c) 穿青山魈人马 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` ================================================ FILE: WheelPicker/README.md ================================================ # 滚轮选择器 滚轮选择器,包括单项选择器、数字选择器、二三级联动选择器、日期时间选择器、生日选择器、民族选择器等。 ================================================ FILE: WheelPicker/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation api project(':Common') api project(':WheelView') } ================================================ FILE: WheelPicker/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: WheelPicker/src/main/AndroidManifest.xml ================================================ ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/BirthdayPicker.java ================================================ /* * 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; import android.app.Activity; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.wheelpicker.annotation.DateMode; import com.github.gzuliyujiang.wheelpicker.entity.DateEntity; import com.github.gzuliyujiang.wheelpicker.impl.BirthdayFormatter; import java.util.Calendar; /** * 出生日期选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 14:31 * @since 2.0 */ @SuppressWarnings("unused") public class BirthdayPicker extends DatePicker { private static final int MAX_AGE = 100; private DateEntity defaultValue; private boolean initialized = false; public BirthdayPicker(@NonNull Activity activity) { super(activity); } public BirthdayPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @Override protected void initData() { super.initData(); initialized = true; Calendar calendar = Calendar.getInstance(); int currentYear = calendar.get(Calendar.YEAR); int currentMonth = calendar.get(Calendar.MONTH) + 1; int currentDay = calendar.get(Calendar.DAY_OF_MONTH); DateEntity startValue = DateEntity.target(currentYear - MAX_AGE, 1, 1); DateEntity endValue = DateEntity.target(currentYear, currentMonth, currentDay); wheelLayout.setRange(startValue, endValue, defaultValue); wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY); wheelLayout.setDateFormatter(new BirthdayFormatter()); } public void setDefaultValue(int year, int month, int day) { defaultValue = DateEntity.target(year, month, day); if (initialized) { wheelLayout.setDefaultValue(defaultValue); } } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/CarPlatePicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import com.github.gzuliyujiang.wheelpicker.contract.OnCarPlatePickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkagePickedListener; import com.github.gzuliyujiang.wheelpicker.widget.CarPlateWheelLayout; /** * 中国大陆车牌号滚轮选择 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2016/12/18 10:47 */ @SuppressWarnings({"unused"}) public class CarPlatePicker extends LinkagePicker { private OnCarPlatePickedListener onCarPlatePickedListener; public CarPlatePicker(@NonNull Activity activity) { super(activity); } public CarPlatePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @Deprecated @Override public void setData(@NonNull LinkageProvider data) { throw new UnsupportedOperationException("Data already preset"); } @Deprecated @Override public void setOnLinkagePickedListener(OnLinkagePickedListener onLinkagePickedListener) { throw new UnsupportedOperationException("Use setOnCarPlatePickedListener instead"); } @NonNull @Override protected View createBodyView() { wheelLayout = new CarPlateWheelLayout(activity); return wheelLayout; } @Override protected void onOk() { if (onCarPlatePickedListener != null) { String province = wheelLayout.getFirstWheelView().getCurrentItem(); String letter = wheelLayout.getSecondWheelView().getCurrentItem(); onCarPlatePickedListener.onCarNumberPicked(province, letter); } } public void setOnCarPlatePickedListener(OnCarPlatePickedListener onCarPlatePickedListener) { this.onCarPlatePickedListener = onCarPlatePickedListener; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/ConstellationPicker.java ================================================ /* * 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; import android.app.Activity; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; 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; /** * 星座选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/17 13:10 */ @SuppressWarnings("WeakerAccess") public class ConstellationPicker extends OptionPicker { 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) { super(activity); } public ConstellationPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } public void setIncludeUnlimited(boolean includeUnlimited) { this.includeUnlimited = includeUnlimited; setData(provideData()); } @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() { 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; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatePicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.wheelpicker.contract.OnDatePickedListener; import com.github.gzuliyujiang.wheelpicker.widget.DateWheelLayout; /** * 日期选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 18:17 */ @SuppressWarnings("unused") public class DatePicker extends ModalDialog { protected DateWheelLayout wheelLayout; private OnDatePickedListener onDatePickedListener; public DatePicker(@NonNull Activity activity) { super(activity); } public DatePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { wheelLayout = new DateWheelLayout(activity); return wheelLayout; } @Override protected void onCancel() { } @Override protected void onOk() { if (onDatePickedListener != null) { int year = wheelLayout.getSelectedYear(); int month = wheelLayout.getSelectedMonth(); int day = wheelLayout.getSelectedDay(); onDatePickedListener.onDatePicked(year, month, day); } } public void setOnDatePickedListener(OnDatePickedListener onDatePickedListener) { this.onDatePickedListener = onDatePickedListener; } public final DateWheelLayout getWheelLayout() { return wheelLayout; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/DatimePicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.wheelpicker.contract.OnDatimePickedListener; import com.github.gzuliyujiang.wheelpicker.widget.DatimeWheelLayout; /** * 日期时间选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 18:21 */ @SuppressWarnings({"unused", "WeakerAccess"}) public class DatimePicker extends ModalDialog { protected DatimeWheelLayout wheelLayout; private OnDatimePickedListener onDatimePickedListener; public DatimePicker(@NonNull Activity activity) { super(activity); } public DatimePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { wheelLayout = new DatimeWheelLayout(activity); return wheelLayout; } @Override protected void onCancel() { } @Override protected void onOk() { if (onDatimePickedListener != null) { int year = wheelLayout.getSelectedYear(); int month = wheelLayout.getSelectedMonth(); int day = wheelLayout.getSelectedDay(); int hour = wheelLayout.getSelectedHour(); int minute = wheelLayout.getSelectedMinute(); int second = wheelLayout.getSelectedSecond(); onDatimePickedListener.onDatimePicked(year, month, day, hour, minute, second); } } public void setOnDatimePickedListener(OnDatimePickedListener onDatimePickedListener) { this.onDatimePickedListener = onDatimePickedListener; } public final DatimeWheelLayout getWheelLayout() { return wheelLayout; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/EthnicPicker.java ================================================ /* * 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; import android.app.Activity; import androidx.annotation.NonNull; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.wheelpicker.annotation.EthnicSpec; import com.github.gzuliyujiang.wheelpicker.entity.EthnicEntity; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; /** * 民族选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/12 13:50 */ @SuppressWarnings({"WeakerAccess", "unused"}) public class EthnicPicker extends OptionPicker { public static String JSON = "[{\"code\":\"01\",\"name\":\"汉族\",\"spelling\":\"Han\"}," + "{\"code\":\"02\",\"name\":\"蒙古族\",\"spelling\":\"Mongol\"}," + "{\"code\":\"03\",\"name\":\"回族\",\"spelling\":\"Hui\"}," + "{\"code\":\"04\",\"name\":\"藏族\",\"spelling\":\"Zang\"}," + "{\"code\":\"05\",\"name\":\"维吾尔族\",\"spelling\":\"Uygur\"}," + "{\"code\":\"06\",\"name\":\"苗族\",\"spelling\":\"Miao\"}," + "{\"code\":\"07\",\"name\":\"彝族\",\"spelling\":\"Yi\"}," + "{\"code\":\"08\",\"name\":\"壮族\",\"spelling\":\"Zhuang\"}," + "{\"code\":\"09\",\"name\":\"布依族\",\"spelling\":\"Buyei\"}," + "{\"code\":\"10\",\"name\":\"朝鲜族\",\"spelling\":\"Chosen\"}," + "{\"code\":\"11\",\"name\":\"满族\",\"spelling\":\"Man\"}," + "{\"code\":\"12\",\"name\":\"侗族\",\"spelling\":\"Dong\"}," + "{\"code\":\"13\",\"name\":\"瑶族\",\"spelling\":\"Yao\"}," + "{\"code\":\"14\",\"name\":\"白族\",\"spelling\":\"Bai\"}," + "{\"code\":\"15\",\"name\":\"土家族\",\"spelling\":\"Tujia\"}," + "{\"code\":\"16\",\"name\":\"哈尼族\",\"spelling\":\"Hani\"}," + "{\"code\":\"17\",\"name\":\"哈萨克族\",\"spelling\":\"Kazak\"}," + "{\"code\":\"18\",\"name\":\"傣族\",\"spelling\":\"Dai\"}," + "{\"code\":\"19\",\"name\":\"黎族\",\"spelling\":\"Li\"}," + "{\"code\":\"20\",\"name\":\"傈僳族\",\"spelling\":\"Lisu\"}," + "{\"code\":\"21\",\"name\":\"佤族\",\"spelling\":\"Va\"}," + "{\"code\":\"22\",\"name\":\"畲族\",\"spelling\":\"She\"}," + "{\"code\":\"23\",\"name\":\"高山族\",\"spelling\":\"Gaoshan\"}," + "{\"code\":\"24\",\"name\":\"拉祜族\",\"spelling\":\"Lahu\"}," + "{\"code\":\"25\",\"name\":\"水族\",\"spelling\":\"Sui\"}," + "{\"code\":\"26\",\"name\":\"东乡族\",\"spelling\":\"Dongxiang\"}," + "{\"code\":\"27\",\"name\":\"纳西族\",\"spelling\":\"Naxi\"}," + "{\"code\":\"28\",\"name\":\"景颇族\",\"spelling\":\"Jingpo\"}," + "{\"code\":\"29\",\"name\":\"柯尔克孜族\",\"spelling\":\"Kirgiz\"}," + "{\"code\":\"30\",\"name\":\"土族\",\"spelling\":\"Tu\"}," + "{\"code\":\"31\",\"name\":\"达斡尔族\",\"spelling\":\"Daur\"}," + "{\"code\":\"32\",\"name\":\"仫佬族\",\"spelling\":\"Mulao\"}," + "{\"code\":\"33\",\"name\":\"羌族\",\"spelling\":\"Qiang\"}," + "{\"code\":\"34\",\"name\":\"布朗族\",\"spelling\":\"Blang\"}," + "{\"code\":\"35\",\"name\":\"撒拉族\",\"spelling\":\"Salar\"}," + "{\"code\":\"36\",\"name\":\"毛难族\",\"spelling\":\"Maonan\"}," + "{\"code\":\"37\",\"name\":\"仡佬族\",\"spelling\":\"Gelao\"}," + "{\"code\":\"38\",\"name\":\"锡伯族\",\"spelling\":\"Xibe\"}," + "{\"code\":\"39\",\"name\":\"阿昌族\",\"spelling\":\"Achang\"}," + "{\"code\":\"40\",\"name\":\"普米族\",\"spelling\":\"Pumi\"}," + "{\"code\":\"41\",\"name\":\"塔吉克族\",\"spelling\":\"Tajik\"}," + "{\"code\":\"42\",\"name\":\"怒族\",\"spelling\":\"Nu\"}," + "{\"code\":\"43\",\"name\":\"乌孜别克族\",\"spelling\":\"Uzbek\"}," + "{\"code\":\"44\",\"name\":\"俄罗斯族\",\"spelling\":\"Russ\"}," + "{\"code\":\"45\",\"name\":\"鄂温克族\",\"spelling\":\"Ewenki\"}," + "{\"code\":\"46\",\"name\":\"德昂族\",\"spelling\":\"Deang\"}," + "{\"code\":\"47\",\"name\":\"保安族\",\"spelling\":\"Bonan\"}," + "{\"code\":\"48\",\"name\":\"裕固族\",\"spelling\":\"Yugur\"}," + "{\"code\":\"49\",\"name\":\"京族\",\"spelling\":\"Gin\"}," + "{\"code\":\"50\",\"name\":\"塔塔尔族\",\"spelling\":\"Tatar\"}," + "{\"code\":\"51\",\"name\":\"独龙族\",\"spelling\":\"Derung\"}," + "{\"code\":\"52\",\"name\":\"鄂伦春族\",\"spelling\":\"Oroqen\"}," + "{\"code\":\"53\",\"name\":\"赫哲族\",\"spelling\":\"Hezhen\"}," + "{\"code\":\"54\",\"name\":\"门巴族\",\"spelling\":\"Monba\"}," + "{\"code\":\"55\",\"name\":\"珞巴族\",\"spelling\":\"Lhoba\"}," + "{\"code\":\"56\",\"name\":\"基诺族\",\"spelling\":\"Jino\"}]"; private int ethnicSpec = EthnicSpec.DEFAULT; public EthnicPicker(@NonNull Activity activity) { super(activity); } public EthnicPicker(@NonNull Activity activity, int themeResId) { super(activity, themeResId); } public void setEthnicSpec(@EthnicSpec int ethnicSpec) { this.ethnicSpec = 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); super.setDefaultValue(entity); } public void setDefaultValueByName(String name) { EthnicEntity entity = new EthnicEntity(); entity.setName(name); super.setDefaultValue(entity); } public void setDefaultValueBySpelling(String spelling) { EthnicEntity entity = new EthnicEntity(); entity.setSpelling(spelling); super.setDefaultValue(entity); } @Override protected List provideData() { 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); EthnicEntity entity = new EthnicEntity(); entity.setCode(jsonObject.getString("code")); entity.setName(jsonObject.getString("name")); entity.setSpelling(jsonObject.getString("spelling")); data.add(entity); } } catch (JSONException e) { DialogLog.print(e); } switch (ethnicSpec) { case EthnicSpec.DEFAULT: EthnicEntity other = new EthnicEntity(); other.setCode("97"); other.setName("其他"); other.setSpelling("Other"); data.add(other); EthnicEntity foreign = new EthnicEntity(); foreign.setCode("98"); foreign.setName("外国血统"); foreign.setSpelling("Foreign"); data.add(foreign); break; case EthnicSpec.SEVENTH_NATIONAL_CENSUS: EthnicEntity unrecognized = new EthnicEntity(); unrecognized.setCode("97"); unrecognized.setName("未定族称人口"); unrecognized.setSpelling("Unrecognized"); data.add(unrecognized); EthnicEntity naturalization = new EthnicEntity(); naturalization.setCode("98"); naturalization.setName("入籍"); naturalization.setSpelling("Naturalization"); data.add(naturalization); break; default: break; } return data; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/LinkagePicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkagePickedListener; import com.github.gzuliyujiang.wheelpicker.widget.LinkageWheelLayout; import com.github.gzuliyujiang.wheelview.widget.WheelView; /** * 二三级联动选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @see com.github.gzuliyujiang.wheelview.contract.TextProvider * @see LinkageProvider * @see LinkageWheelLayout * @see OnLinkagePickedListener * @since 2019/6/17 11:21 */ @SuppressWarnings({"WeakerAccess", "unused"}) public class LinkagePicker extends ModalDialog { protected LinkageWheelLayout wheelLayout; private OnLinkagePickedListener onLinkagePickedListener; public LinkagePicker(@NonNull Activity activity) { super(activity); } public LinkagePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { wheelLayout = new LinkageWheelLayout(activity); return wheelLayout; } @Override protected void onCancel() { } @Override protected void onOk() { if (onLinkagePickedListener != null) { Object first = wheelLayout.getFirstWheelView().getCurrentItem(); Object second = wheelLayout.getSecondWheelView().getCurrentItem(); Object third = wheelLayout.getThirdWheelView().getCurrentItem(); onLinkagePickedListener.onLinkagePicked(first, second, third); } } public void setData(@NonNull LinkageProvider data) { wheelLayout.setData(data); } public void setDefaultValue(Object first, Object second, Object third) { wheelLayout.setDefaultValue(first, second, third); } public void setOnLinkagePickedListener(OnLinkagePickedListener onLinkagePickedListener) { this.onLinkagePickedListener = onLinkagePickedListener; } public final LinkageWheelLayout getWheelLayout() { return wheelLayout; } public final WheelView getFirstWheelView() { return wheelLayout.getFirstWheelView(); } public final WheelView getSecondWheelView() { return wheelLayout.getSecondWheelView(); } public final WheelView getThirdWheelView() { return wheelLayout.getThirdWheelView(); } public final TextView getFirstLabelView() { return wheelLayout.getFirstLabelView(); } public final TextView getSecondLabelView() { return wheelLayout.getSecondLabelView(); } public final TextView getThirdLabelView() { return wheelLayout.getThirdLabelView(); } public final ProgressBar getLoadingView() { return wheelLayout.getLoadingView(); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/NumberPicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.wheelpicker.contract.OnNumberPickedListener; import com.github.gzuliyujiang.wheelpicker.widget.NumberWheelLayout; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; import com.github.gzuliyujiang.wheelview.widget.WheelView; /** * 数字选择器 * * @author 李玉江[QQ:1032694760] * @since 2015/10/24 */ @SuppressWarnings("unused") public class NumberPicker extends ModalDialog { protected NumberWheelLayout wheelLayout; private OnNumberPickedListener onNumberPickedListener; public NumberPicker(@NonNull Activity activity) { super(activity); } public NumberPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { wheelLayout = new NumberWheelLayout(activity); return wheelLayout; } @Override protected void onCancel() { } @Override protected void onOk() { if (onNumberPickedListener != null) { int position = wheelLayout.getWheelView().getCurrentPosition(); Number item = wheelLayout.getWheelView().getCurrentItem(); onNumberPickedListener.onNumberPicked(position, item); } } public void setFormatter(WheelFormatter formatter) { wheelLayout.getWheelView().setFormatter(formatter); } public void setRange(int min, int max, int step) { wheelLayout.setRange(min, max, step); } public void setRange(float min, float max, float step) { wheelLayout.setRange(min, max, step); } public void setDefaultValue(Object item) { wheelLayout.setDefaultValue(item); } public void setDefaultPosition(int position) { wheelLayout.setDefaultPosition(position); } public final void setOnNumberPickedListener(OnNumberPickedListener onNumberPickedListener) { this.onNumberPickedListener = onNumberPickedListener; } public final NumberWheelLayout getWheelLayout() { return wheelLayout; } public final WheelView getWheelView() { return wheelLayout.getWheelView(); } public final TextView getLabelView() { return wheelLayout.getLabelView(); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/OptionPicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionPickedListener; import com.github.gzuliyujiang.wheelpicker.widget.OptionWheelLayout; import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.Arrays; import java.util.List; /** * 单项选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @see com.github.gzuliyujiang.wheelview.contract.TextProvider * @since 2019/5/8 10:04 */ @SuppressWarnings({"unused"}) public class OptionPicker extends ModalDialog { protected OptionWheelLayout wheelLayout; private OnOptionPickedListener onOptionPickedListener; private boolean initialized = false; private List data; private Object defaultValue; private int defaultPosition = -1; public OptionPicker(@NonNull Activity activity) { super(activity); } public OptionPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { wheelLayout = new OptionWheelLayout(activity); return wheelLayout; } @Override protected void initData() { super.initData(); initialized = true; if (data == null || data.size() == 0) { data = provideData(); } wheelLayout.setData(data); if (defaultValue != null) { wheelLayout.setDefaultValue(defaultValue); } if (defaultPosition != -1) { wheelLayout.setDefaultPosition(defaultPosition); } } @Override protected void onCancel() { } @Override protected void onOk() { if (onOptionPickedListener != null) { int position = wheelLayout.getWheelView().getCurrentPosition(); Object item = wheelLayout.getWheelView().getCurrentItem(); onOptionPickedListener.onOptionPicked(position, item); } } protected List provideData() { return null; } public final boolean isInitialized() { return initialized; } public void setData(Object... data) { setData(Arrays.asList(data)); } public void setData(List data) { this.data = data; if (initialized) { wheelLayout.setData(data); } } public void setDefaultValue(Object item) { this.defaultValue = item; if (initialized) { wheelLayout.setDefaultValue(item); } } public void setDefaultPosition(int position) { this.defaultPosition = position; if (initialized) { wheelLayout.setDefaultPosition(position); } } public void setOnOptionPickedListener(OnOptionPickedListener onOptionPickedListener) { this.onOptionPickedListener = onOptionPickedListener; } public final OptionWheelLayout getWheelLayout() { return wheelLayout; } public final WheelView getWheelView() { return wheelLayout.getWheelView(); } public final TextView getLabelView() { return wheelLayout.getLabelView(); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/PhoneCodePicker.java ================================================ /* * 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; import android.app.Activity; 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; /** * 手机号前缀选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/10 16:44 */ @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); } public PhoneCodePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } public void setOnlyChina(boolean onlyChina) { this.onlyChina = 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); super.setDefaultValue(entity); } public void setDefaultValueByName(String name) { PhoneCodeEntity entity = new PhoneCodeEntity(); entity.setName(name); super.setDefaultValue(entity); } public void setDefaultValueByEnglish(String english) { PhoneCodeEntity entity = new PhoneCodeEntity(); entity.setEnglish(english); super.setDefaultValue(entity); } @Override protected List provideData() { List data = new ArrayList<>(); 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; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/SexPicker.java ================================================ /* * 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; import android.app.Activity; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; 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; /** * 性别选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/23 11:48 */ @SuppressWarnings("WeakerAccess") public class SexPicker extends OptionPicker { 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) { super(activity); } public SexPicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } public void setIncludeSecrecy(boolean includeSecrecy) { this.includeSecrecy = includeSecrecy; setData(provideData()); } @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() { 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; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/TimePicker.java ================================================ /* * 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; import android.app.Activity; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.dialog.ModalDialog; import com.github.gzuliyujiang.wheelpicker.contract.OnTimeMeridiemPickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnTimePickedListener; import com.github.gzuliyujiang.wheelpicker.widget.TimeWheelLayout; /** * 时间选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 18:19 */ @SuppressWarnings("unused") public class TimePicker extends ModalDialog { protected TimeWheelLayout wheelLayout; private OnTimePickedListener onTimePickedListener; private OnTimeMeridiemPickedListener onTimeMeridiemPickedListener; public TimePicker(@NonNull Activity activity) { super(activity); } public TimePicker(@NonNull Activity activity, @StyleRes int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createBodyView() { wheelLayout = new TimeWheelLayout(activity); return wheelLayout; } @Override protected void onCancel() { } @Override protected void onOk() { int hour = wheelLayout.getSelectedHour(); int minute = wheelLayout.getSelectedMinute(); int second = wheelLayout.getSelectedSecond(); if (onTimePickedListener != null) { onTimePickedListener.onTimePicked(hour, minute, second); } if (onTimeMeridiemPickedListener != null) { onTimeMeridiemPickedListener.onTimePicked(hour, minute, second, wheelLayout.isAnteMeridiem()); } } public void setOnTimePickedListener(OnTimePickedListener onTimePickedListener) { this.onTimePickedListener = onTimePickedListener; } public void setOnTimeMeridiemPickedListener(OnTimeMeridiemPickedListener onTimeMeridiemPickedListener) { this.onTimeMeridiemPickedListener = onTimeMeridiemPickedListener; } public final TimeWheelLayout getWheelLayout() { return wheelLayout; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/annotation/DateMode.java ================================================ /* * 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.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * 日期模式 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 17:10 */ @Retention(RetentionPolicy.SOURCE) public @interface DateMode { /** * 不显示 */ int NONE = -1; /** * 年月日 */ int YEAR_MONTH_DAY = 0; /** * 年月 */ int YEAR_MONTH = 1; /** * 月日 */ int MONTH_DAY = 2; } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/annotation/EthnicSpec.java ================================================ /* * 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.annotation; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/12 14:22 */ public @interface EthnicSpec { int DEFAULT = 1; int GB3304_91 = 2; int SEVENTH_NATIONAL_CENSUS = 3; } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/annotation/TimeMode.java ================================================ /* * 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.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * 时间模式 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 17:09 */ @Retention(RetentionPolicy.SOURCE) public @interface TimeMode { /** * 不显示 */ int NONE = -1; /** * 24小时制(不含秒) */ int HOUR_24_NO_SECOND = 0; /** * 24小时制(包括秒) */ int HOUR_24_HAS_SECOND = 1; /** * 12小时制(不含秒) */ int HOUR_12_NO_SECOND = 2; /** * 12小时制(包括秒) */ int HOUR_12_HAS_SECOND = 3; } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/DateFormatter.java ================================================ /* * 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.contract; /** * 日期显示文本格式化接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:55 */ public interface DateFormatter { /** * 格式化年份 * * @param year 年份数字 * @return 格式化后最终显示的年份字符串 */ String formatYear(int year); /** * 格式化月份 * * @param month 月份数字 * @return 格式化后最终显示的月份字符串 */ String formatMonth(int month); /** * 格式化日子 * * @param day 日子数字 * @return 格式化后最终显示的日子字符串 */ String formatDay(int day); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/LinkageProvider.java ================================================ /* * 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.contract; import androidx.annotation.NonNull; import java.util.List; /** * 提供二级或三级联动数据 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 11:27 */ public interface LinkageProvider { int INDEX_NO_FOUND = -1; /** * 是否展示第一级 * * @return 返回true表示展示第一级 */ boolean firstLevelVisible(); /** * 是否展示第三级 * * @return 返回true表示展示第三级 */ boolean thirdLevelVisible(); /** * 提供第一级数据 * * @return 第一级数据 */ @NonNull List provideFirstData(); /** * 根据第一级数据联动第二级数据 * * @param firstIndex 第一级数据索引 * @return 第二级数据 */ @NonNull List linkageSecondData(int firstIndex); /** * 根据第一二级数据联动第三级数据 * * @param firstIndex 第一级数据索引 * @param secondIndex 第二级数据索引 * @return 第三级数据 */ @NonNull List linkageThirdData(int firstIndex, int secondIndex); /** * 根据第一数据值查找其索引 * * @param firstValue 第一级数据值 * @return 第一级数据索引 */ int findFirstIndex(Object firstValue); /** * 根据第二数据值查找其索引 * * @param firstIndex 第一级数据索引 * @param secondValue 第二级数据值 * @return 第二级数据索引 */ int findSecondIndex(int firstIndex, Object secondValue); /** * 根据第三数据值查找其索引 * * @param firstIndex 第一级数据索引 * @param secondIndex 第二级数据索引 * @param thirdValue 第三级数据值 * @return 第三级数据索引 */ int findThirdIndex(int firstIndex, int secondIndex, Object thirdValue); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnCarPlatePickedListener.java ================================================ /* * 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.contract; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/9 11:53 */ public interface OnCarPlatePickedListener { void onCarNumberPicked(String province, String letter); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnDatePickedListener.java ================================================ /* * 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.contract; /** * 日期选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:57 */ public interface OnDatePickedListener { /** * 已选择的日期 * * @param year 年 * @param month 月 * @param day 日 */ void onDatePicked(int year, int month, int day); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnDateSelectedListener.java ================================================ /* * 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.contract; /** * 日期选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:57 */ public interface OnDateSelectedListener { /** * 已选择的日期 * * @param year 年 * @param month 月 * @param day 日 */ void onDateSelected(int year, int month, int day); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnDatimePickedListener.java ================================================ /* * 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.contract; /** * 日期时间选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 17:29 */ public interface OnDatimePickedListener { /** * 日期时间选择回调 * * @param year 年 * @param month 月 * @param day 日 * @param hour 时 * @param minute 分 * @param second 秒 */ void onDatimePicked(int year, int month, int day, int hour, int minute, int second); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnDatimeSelectedListener.java ================================================ /* * 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.contract; /** * 日期时间选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 17:29 */ public interface OnDatimeSelectedListener { /** * 日期时间选择回调 * * @param year 年 * @param month 月 * @param day 日 * @param hour 时 * @param minute 分 * @param second 秒 */ void onDatimeSelected(int year, int month, int day, int hour, int minute, int second); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnLinkagePickedListener.java ================================================ /* * 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.contract; /** * 联动选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 18:23 */ public interface OnLinkagePickedListener { /** * 联动选择回调 * * @param first 选中项的第一级条目内容 * @param second 选中项的第二级条目内容 * @param third 选中项的第三级条目内容 */ void onLinkagePicked(Object first, Object second, Object third); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnLinkageSelectedListener.java ================================================ /* * 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.contract; /** * 联动选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 18:23 */ public interface OnLinkageSelectedListener { /** * 联动选择回调 * * @param first 选中项的第一级条目内容 * @param second 选中项的第二级条目内容 * @param third 选中项的第三级条目内容 */ void onLinkageSelected(Object first, Object second, Object third); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnNumberPickedListener.java ================================================ /* * 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.contract; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 15:17 */ public interface OnNumberPickedListener { void onNumberPicked(int position, Number item); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnNumberSelectedListener.java ================================================ /* * 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.contract; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 15:17 */ public interface OnNumberSelectedListener { void onNumberSelected(int position, Number item); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnOptionPickedListener.java ================================================ /* * 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.contract; /** * 单项条目选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 20:00 */ public interface OnOptionPickedListener { /** * 单项条目选择回调 * * @param position 选中项的索引 * @param item 选中项的内容 */ void onOptionPicked(int position, Object item); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnOptionSelectedListener.java ================================================ /* * 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.contract; /** * 单项条目选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 20:00 */ public interface OnOptionSelectedListener { /** * 单项条目选择回调 * * @param position 选中项的索引 * @param item 选中项的内容 */ void onOptionSelected(int position, Object item); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnTimeMeridiemPickedListener.java ================================================ /* * 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.contract; /** * 时间选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:58 */ public interface OnTimeMeridiemPickedListener { /** * 时间选择回调 * * @param hour 时 * @param minute 分 * @param second 秒 * @param isAnteMeridiem 是否上午 */ void onTimePicked(int hour, int minute, int second, boolean isAnteMeridiem); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnTimeMeridiemSelectedListener.java ================================================ /* * 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.contract; /** * 时间选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:58 */ public interface OnTimeMeridiemSelectedListener { /** * 时间选择回调 * * @param hour 时 * @param minute 分 * @param second 秒 * @param isAnteMeridiem 是否上午 */ void onTimeSelected(int hour, int minute, int second, boolean isAnteMeridiem); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnTimePickedListener.java ================================================ /* * 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.contract; /** * 时间选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:58 */ public interface OnTimePickedListener { /** * 时间选择回调 * * @param hour 时 * @param minute 分 * @param second 秒 */ void onTimePicked(int hour, int minute, int second); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/OnTimeSelectedListener.java ================================================ /* * 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.contract; /** * 时间选择接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:58 */ public interface OnTimeSelectedListener { /** * 时间选择回调 * * @param hour 时 * @param minute 分 * @param second 秒 */ void onTimeSelected(int hour, int minute, int second); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/contract/TimeFormatter.java ================================================ /* * 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.contract; /** * 时间显示文本格式化接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 19:55 */ public interface TimeFormatter { /** * 格式化小时数 * * @param hour 小时数 * @return 格式化后最终显示的小时数字符串 */ String formatHour(int hour); /** * 格式化分钟数 * * @param minute 分钟数 * @return 格式化后最终显示的分钟数字符串 */ String formatMinute(int minute); /** * 格式化秒数 * * @param second 秒数 * @return 格式化后最终显示的秒数字符串 */ String formatSecond(int second); } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/ConstellationEntity.java ================================================ /* * 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 + '\'' + '}'; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/DateEntity.java ================================================ /* * 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 java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Objects; /** * 日期数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 15:29 */ @SuppressWarnings({"unused"}) public class DateEntity implements Serializable { private int year; private int month; private int day; public static DateEntity target(int year, int month, int dayOfMonth) { DateEntity entity = new DateEntity(); entity.setYear(year); entity.setMonth(month); entity.setDay(dayOfMonth); return entity; } public static DateEntity target(Calendar calendar) { int year = calendar.get(Calendar.YEAR); // 月份的值是从0开始的,转为从1开始 int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); return target(year, month, day); } public static DateEntity target(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return target(calendar); } public static DateEntity today() { return target(Calendar.getInstance()); } public static DateEntity dayOnFuture(int dayOfMonth) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, dayOfMonth); return target(calendar); } public static DateEntity monthOnFuture(int month) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, month); return target(calendar); } public static DateEntity yearOnFuture(int year) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, year); return target(calendar); } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } public int getDay() { return day; } public void setDay(int day) { this.day = day; } public long toTimeInMillis() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DateEntity that = (DateEntity) o; return year == that.year && month == that.month && day == that.day; } @Override public int hashCode() { return Objects.hash(year, month, day); } @NonNull @Override public String toString() { return year + "-" + month + "-" + day; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/DatimeEntity.java ================================================ /* * 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 java.io.Serializable; import java.util.Calendar; /** * 日期时间数据实体。 *

 *     时间单位换算:
 *         // 1分 = 60秒
 *         // 1刻 = 15分
 *         // 1时 = 60分
 *         // 1日 = 12辰
 *         // 1日 = 24时
 *         // 1周 = 7日
 *         // 1月 = 30日
 *         // 1季 = 3月
 *         // 1年 = 12月
 *         // 1世 = 30年
 *         // 1运 = 12世 = 360年
 *         // 1会 = 30运 = 10800年
 *         // 1元 = 12会 = 129600年
 * 
* * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 17:30 */ @SuppressWarnings({"unused"}) public class DatimeEntity implements Serializable { private DateEntity date; private TimeEntity time; public static DatimeEntity now() { DatimeEntity entity = new DatimeEntity(); entity.setDate(DateEntity.today()); entity.setTime(TimeEntity.now()); return entity; } public static DatimeEntity minuteOnFuture(int minute) { DatimeEntity entity = now(); entity.setTime(TimeEntity.minuteOnFuture(minute)); return entity; } public static DatimeEntity hourOnFuture(int hour) { DatimeEntity entity = now(); entity.setTime(TimeEntity.hourOnFuture(hour)); return entity; } public static DatimeEntity dayOnFuture(int day) { DatimeEntity entity = now(); entity.setDate(DateEntity.dayOnFuture(day)); return entity; } public static DatimeEntity monthOnFuture(int month) { DatimeEntity entity = now(); entity.setDate(DateEntity.monthOnFuture(month)); return entity; } public static DatimeEntity yearOnFuture(int year) { DatimeEntity entity = now(); entity.setDate(DateEntity.yearOnFuture(year)); return entity; } public DateEntity getDate() { return date; } public void setDate(DateEntity date) { this.date = date; } public TimeEntity getTime() { return time; } public void setTime(TimeEntity time) { this.time = time; } public long toTimeInMillis() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, date.getYear()); calendar.set(Calendar.MONTH, date.getMonth() - 1); calendar.set(Calendar.DAY_OF_MONTH, date.getDay()); calendar.set(Calendar.HOUR_OF_DAY, time.getHour()); calendar.set(Calendar.MINUTE, time.getMinute()); calendar.set(Calendar.SECOND, time.getSecond()); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); } @NonNull @Override public String toString() { return date.toString() + " " + time.toString(); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/EthnicEntity.java ================================================ /* * 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/6/12 15:05 */ public class EthnicEntity implements TextProvider, Serializable { private static final boolean IS_CHINESE; private String code; private String name; private String spelling; static { IS_CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSpelling() { return spelling; } public void setSpelling(String spelling) { this.spelling = spelling; } @Override public String provideText() { if (IS_CHINESE) { return name; } return spelling; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } EthnicEntity that = (EthnicEntity) o; return Objects.equals(code, that.code) || Objects.equals(name, that.name) || Objects.equals(spelling, that.spelling); } @Override public int hashCode() { return Objects.hash(code, name, spelling); } @NonNull @Override public String toString() { return "EthnicEntity{" + "code='" + code + '\'' + ", name='" + name + '\'' + ", spelling='" + spelling + '\'' + '}'; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/PhoneCodeEntity.java ================================================ /* * 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/6/3 16:27 */ public class PhoneCodeEntity implements TextProvider, Serializable { private static final boolean IS_CHINESE; private String code; private String name; private String english; static { IS_CHINESE = Locale.getDefault().getDisplayLanguage().contains("中文"); } public String getCode() { return code; } public void setCode(String code) { this.code = code; } 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; } 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{" + "code='" + code + '\'' + ", name='" + name + '\'' + ", english" + english + '\'' + '}'; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/SexEntity.java ================================================ /* * 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 + '\'' + '}'; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/entity/TimeEntity.java ================================================ /* * 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 java.io.Serializable; import java.util.Calendar; import java.util.Date; /** * 时间数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/17 15:29 */ @SuppressWarnings({"unused"}) public class TimeEntity implements Serializable { private int hour; private int minute; private int second; public static TimeEntity target(int hourOfDay, int minute, int second) { TimeEntity entity = new TimeEntity(); entity.setHour(hourOfDay); entity.setMinute(minute); entity.setSecond(second); return entity; } public static TimeEntity target(Calendar calendar) { int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); return target(hour, minute, second); } public static TimeEntity target(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return target(calendar); } public static TimeEntity now() { return target(Calendar.getInstance()); } public static TimeEntity minuteOnFuture(int minute) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MINUTE, minute); return target(calendar); } public static TimeEntity hourOnFuture(int hourOfDay) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR_OF_DAY, hourOfDay); return target(calendar); } public int getHour() { return hour; } public void setHour(int hour) { this.hour = hour; } public int getMinute() { return minute; } public void setMinute(int minute) { this.minute = minute; } public int getSecond() { return second; } public void setSecond(int second) { this.second = second; } public long toTimeInMillis() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); } @NonNull @Override public String toString() { return hour + ":" + minute + ":" + second; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/BirthdayFormatter.java ================================================ /* * 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.impl; /** * 生日格式化 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 14:31 */ public class BirthdayFormatter extends SimpleDateFormatter { @Override public String formatYear(int year) { return super.formatYear(year) + "年"; } @Override public String formatMonth(int month) { return super.formatMonth(month) + "月"; } @Override public String formatDay(int day) { return super.formatDay(day) + "日"; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/CarPlateProvider.java ================================================ /* * 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.impl; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 数据参见 http://www.360doc.com/content/12/0602/07/3899427_215339300.shtml * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/9 11:31 */ public class CarPlateProvider implements LinkageProvider { private static final String[] ABBREVIATIONS = { "京", "津", "冀", "晋", "蒙", "辽", "吉", "黑", "沪", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "渝", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新"}; @Override public boolean firstLevelVisible() { return true; } @Override public boolean thirdLevelVisible() { return false; } @NonNull @Override public List provideFirstData() { List provinces = new ArrayList<>(); Collections.addAll(provinces, ABBREVIATIONS); return provinces; } @NonNull @Override public List linkageSecondData(int firstIndex) { List letters = new ArrayList<>(); if (firstIndex == INDEX_NO_FOUND) { firstIndex = 0; } String province = provideFirstData().get(firstIndex); switch (province) { case "京": for (char i = 'A'; i <= 'M'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.add("Y"); break; case "津": case "青": for (char i = 'A'; i <= 'H'; i++) { letters.add(String.valueOf(i)); } break; case "冀": for (char i = 'A'; i <= 'H'; i++) { letters.add(String.valueOf(i)); } letters.add("J"); letters.add("R"); letters.add("S"); letters.add("T"); break; case "晋": for (char i = 'A'; i <= 'M'; i++) { letters.add(String.valueOf(i)); } letters.remove("G"); letters.remove("I"); break; case "蒙": case "赣": for (char i = 'A'; i <= 'M'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); break; case "辽": case "甘": for (char i = 'A'; i <= 'P'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); break; case "吉": case "闽": for (char i = 'A'; i <= 'K'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); break; case "黑": case "新": for (char i = 'A'; i <= 'R'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); break; case "沪": for (char i = 'A'; i <= 'D'; i++) { letters.add(String.valueOf(i)); } letters.add("R"); break; case "苏": for (char i = 'A'; i <= 'N'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); break; case "浙": for (char i = 'A'; i <= 'L'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); break; case "皖": case "鄂": for (char i = 'A'; i <= 'S'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); break; case "鲁": for (char i = 'A'; i <= 'V'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); letters.add("Y"); break; case "豫": for (char i = 'A'; i <= 'U'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); break; case "湘": for (char i = 'A'; i <= 'N'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); letters.add("U"); break; case "粤": for (char i = 'A'; i <= 'Z'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); break; case "桂": for (char i = 'A'; i <= 'P'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.remove("O"); letters.add("R"); break; case "琼": case "宁": for (char i = 'A'; i <= 'E'; i++) { letters.add(String.valueOf(i)); } break; case "渝": for (char i = 'A'; i <= 'D'; i++) { letters.add(String.valueOf(i)); } letters.remove("D"); letters.remove("E"); break; case "川": for (char i = 'A'; i <= 'Z'; i++) { letters.add(String.valueOf(i)); } letters.remove("G"); letters.remove("I"); letters.remove("O"); break; case "贵": case "藏": for (char i = 'A'; i <= 'J'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); break; case "云": // “A-V”为昆明市东川区(原东川市) letters.add("A-V"); for (char i = 'A'; i <= 'S'; i++) { letters.add(String.valueOf(i)); } letters.remove("B"); letters.remove("I"); letters.remove("O"); break; case "陕": for (char i = 'A'; i <= 'K'; i++) { letters.add(String.valueOf(i)); } letters.remove("I"); letters.add("V"); break; } return letters; } @NonNull @Override public List linkageThirdData(int firstIndex, int secondIndex) { return new ArrayList<>(); } @Override public int findFirstIndex(Object firstValue) { if (firstValue == null) { return INDEX_NO_FOUND; } for (int i = 0, n = ABBREVIATIONS.length; i < n; i++) { String abbreviation = ABBREVIATIONS[i]; if (abbreviation.equals(firstValue.toString())) { return i; } } return INDEX_NO_FOUND; } @Override public int findSecondIndex(int firstIndex, Object secondValue) { if (secondValue == null) { return INDEX_NO_FOUND; } List letters = linkageSecondData(firstIndex); for (int i = 0, n = letters.size(); i < n; i++) { String letter = letters.get(i); if (letter.equals(secondValue.toString())) { return i; } } return INDEX_NO_FOUND; } @Override public int findThirdIndex(int firstIndex, int secondIndex, Object thirdValue) { return 0; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/SimpleDateFormatter.java ================================================ /* * 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.impl; import com.github.gzuliyujiang.wheelpicker.contract.DateFormatter; /** * 简单的日期格式化 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/15 18:11 */ public class SimpleDateFormatter implements DateFormatter { @Override public String formatYear(int year) { if (year < 1000) { year += 1000; } return "" + year; } @Override public String formatMonth(int month) { return month < 10 ? "0" + month : "" + month; } @Override public String formatDay(int day) { return day < 10 ? "0" + day : "" + day; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/SimpleTimeFormatter.java ================================================ /* * 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.impl; import com.github.gzuliyujiang.wheelpicker.contract.TimeFormatter; import com.github.gzuliyujiang.wheelpicker.widget.TimeWheelLayout; /** * 简单的时间格式化 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/15 18:13 */ public class SimpleTimeFormatter implements TimeFormatter { private final TimeWheelLayout wheelLayout; public SimpleTimeFormatter(TimeWheelLayout wheelLayout) { this.wheelLayout = wheelLayout; } @Override public String formatHour(int hour) { if (wheelLayout.isHour12Mode()) { if (hour == 0) { hour = 24; } if (hour > 12) { hour = hour - 12; } } return hour < 10 ? "0" + hour : "" + hour; } @Override public String formatMinute(int minute) { return minute < 10 ? "0" + minute : "" + minute; } @Override public String formatSecond(int second) { return second < 10 ? "0" + second : "" + second; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/SimpleWheelFormatter.java ================================================ /* * 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.impl; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 00:06 */ public class SimpleWheelFormatter implements WheelFormatter { @Override public String formatItem(@NonNull Object item) { return item.toString(); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/UnitDateFormatter.java ================================================ /* * 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.impl; import com.github.gzuliyujiang.wheelpicker.contract.DateFormatter; /** * 带单位的日期格式化 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/4 11:33 */ public class UnitDateFormatter implements DateFormatter { @Override public String formatYear(int year) { return year + "年"; } @Override public String formatMonth(int month) { return month + "月"; } @Override public String formatDay(int day) { return day + "日"; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/impl/UnitTimeFormatter.java ================================================ /* * 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.impl; import com.github.gzuliyujiang.wheelpicker.contract.TimeFormatter; /** * 带单位的时间格式化 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/4 11:33 */ public class UnitTimeFormatter implements TimeFormatter { @Override public String formatHour(int hour) { return hour + "点"; } @Override public String formatMinute(int minute) { return minute + "分"; } @Override public String formatSecond(int second) { return second + "秒"; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/BaseWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.text.TextUtils; import android.util.AttributeSet; import android.widget.LinearLayout; import androidx.annotation.ColorInt; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Px; import androidx.annotation.StyleRes; import com.github.gzuliyujiang.wheelpicker.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.widget.WheelView; import java.util.ArrayList; import java.util.List; /** * 抽象的滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 16:18 */ @SuppressWarnings("unused") public abstract class BaseWheelLayout extends LinearLayout implements OnWheelChangedListener { private final List wheelViews = new ArrayList<>(); public BaseWheelLayout(Context context) { super(context); init(context, null, R.attr.WheelStyle, R.style.WheelDefault); } public BaseWheelLayout(Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(context, attrs, R.attr.WheelStyle, R.style.WheelDefault); } public BaseWheelLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr, R.style.WheelDefault); } public BaseWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr, defStyleRes); } private void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { setOrientation(VERTICAL); inflate(context, provideLayoutRes(), this); onInit(context); wheelViews.clear(); wheelViews.addAll(provideWheelViews()); initAttrs(context, attrs, defStyleAttr, defStyleRes); for (WheelView wheelView : wheelViews) { wheelView.setOnWheelChangedListener(this); } } protected void onInit(@NonNull Context context) { } private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { float density = context.getResources().getDisplayMetrics().density; float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity; TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BaseWheelLayout, defStyleAttr, defStyleRes); setVisibleItemCount(typedArray.getInt(R.styleable.BaseWheelLayout_wheel_visibleItemCount, 5)); setSameWidthEnabled(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_sameWidthEnabled, false)); setMaxWidthText(typedArray.getString(R.styleable.BaseWheelLayout_wheel_maxWidthText)); setTextColor(typedArray.getColor(R.styleable.BaseWheelLayout_wheel_itemTextColor, 0xFF888888)); setSelectedTextColor(typedArray.getColor(R.styleable.BaseWheelLayout_wheel_itemTextColorSelected, 0xFF000000)); setTextSize(typedArray.getDimension(R.styleable.BaseWheelLayout_wheel_itemTextSize, 15 * scaledDensity)); setSelectedTextSize(typedArray.getDimension(R.styleable.BaseWheelLayout_wheel_itemTextSizeSelected, 15 * scaledDensity)); setSelectedTextBold(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_itemTextBoldSelected, false)); setTextAlign(typedArray.getInt(R.styleable.BaseWheelLayout_wheel_itemTextAlign, ItemTextAlign.CENTER)); setItemSpace(typedArray.getDimensionPixelSize(R.styleable.BaseWheelLayout_wheel_itemSpace, (int) (20 * density))); setCyclicEnabled(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_cyclicEnabled, false)); setIndicatorEnabled(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_indicatorEnabled, false)); setIndicatorColor(typedArray.getColor(R.styleable.BaseWheelLayout_wheel_indicatorColor, 0xFFC9C9C9)); setIndicatorSize(typedArray.getDimension(R.styleable.BaseWheelLayout_wheel_indicatorSize, 1 * density)); setCurvedIndicatorSpace(typedArray.getDimensionPixelSize(R.styleable.BaseWheelLayout_wheel_curvedIndicatorSpace, (int) (1 * density))); setCurtainEnabled(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_curtainEnabled, false)); setCurtainColor(typedArray.getColor(R.styleable.BaseWheelLayout_wheel_curtainColor, 0x88FFFFFF)); setCurtainCorner(typedArray.getInt(R.styleable.BaseWheelLayout_wheel_curtainCorner, CurtainCorner.NONE)); setCurtainRadius(typedArray.getDimension(R.styleable.BaseWheelLayout_wheel_curtainRadius, 0)); setAtmosphericEnabled(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_atmosphericEnabled, false)); setCurvedEnabled(typedArray.getBoolean(R.styleable.BaseWheelLayout_wheel_curvedEnabled, false)); setCurvedMaxAngle(typedArray.getInteger(R.styleable.BaseWheelLayout_wheel_curvedMaxAngle, 90)); typedArray.recycle(); onAttributeSet(context, attrs); } protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { } @LayoutRes protected abstract int provideLayoutRes(); protected abstract List provideWheelViews(); public void setStyle(@StyleRes int style) { initAttrs(getContext(), null, R.attr.WheelStyle, style); requestLayout(); invalidate(); } @Override public void onWheelScrolled(WheelView view, int offset) { } @Override public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { } @Override public void onWheelLoopFinished(WheelView view) { } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); for (WheelView wheelView : wheelViews) { wheelView.setEnabled(enabled); } } public void setVisibleItemCount(int visibleItemCount) { for (WheelView wheelView : wheelViews) { wheelView.setVisibleItemCount(visibleItemCount); } } public void setItemSpace(@Px int space) { for (WheelView wheelView : wheelViews) { wheelView.setItemSpace(space); } } public void setSameWidthEnabled(boolean sameWidthEnabled) { for (WheelView wheelView : wheelViews) { wheelView.setSameWidthEnabled(sameWidthEnabled); } } public void setDefaultItemPosition(int position) { for (WheelView wheelView : wheelViews) { wheelView.setDefaultPosition(position); } } public void setCurtainEnabled(boolean hasCurtain) { for (WheelView wheelView : wheelViews) { wheelView.setCurtainEnabled(hasCurtain); } } public void setCurtainColor(@ColorInt int color) { for (WheelView wheelView : wheelViews) { wheelView.setCurtainColor(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); } } public void setCurvedEnabled(boolean curved) { for (WheelView wheelView : wheelViews) { wheelView.setCurvedEnabled(curved); } } public void setCurvedMaxAngle(int curvedMaxAngle) { for (WheelView wheelView : wheelViews) { wheelView.setCurvedMaxAngle(curvedMaxAngle); } } public void setCurvedIndicatorSpace(@Px int space) { for (WheelView wheelView : wheelViews) { wheelView.setCurvedIndicatorSpace(space); } } public void setCyclicEnabled(boolean cyclic) { for (WheelView wheelView : wheelViews) { wheelView.setCyclicEnabled(cyclic); } } public void setIndicatorEnabled(boolean hasIndicator) { for (WheelView wheelView : wheelViews) { wheelView.setIndicatorEnabled(hasIndicator); } } public void setIndicatorSize(@Px float size) { for (WheelView wheelView : wheelViews) { wheelView.setIndicatorSize(size); } } public void setIndicatorColor(@ColorInt int color) { for (WheelView wheelView : wheelViews) { wheelView.setIndicatorColor(color); } } public void setMaxWidthText(String text) { if (TextUtils.isEmpty(text)) { return; } for (WheelView wheelView : wheelViews) { wheelView.setMaxWidthText(text); } } public void setTextSize(@Px float textSize) { for (WheelView wheelView : wheelViews) { wheelView.setTextSize(textSize); } } public void setSelectedTextSize(@Px float textSize) { for (WheelView wheelView : wheelViews) { wheelView.setSelectedTextSize(textSize); } } public void setTextColor(@ColorInt int color) { for (WheelView wheelView : wheelViews) { wheelView.setTextColor(color); } } public void setSelectedTextColor(@ColorInt int color) { for (WheelView wheelView : wheelViews) { wheelView.setSelectedTextColor(color); } } public void setSelectedTextBold(boolean bold) { for (WheelView wheelView : wheelViews) { wheelView.setSelectedTextBold(bold); } } public void setTextAlign(@ItemTextAlign int align) { for (WheelView wheelView : wheelViews) { wheelView.setTextAlign(align); } } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/CarPlateWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.util.AttributeSet; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.impl.CarPlateProvider; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/9 11:57 */ public class CarPlateWheelLayout extends LinkageWheelLayout { private CarPlateProvider provider; public CarPlateWheelLayout(Context context) { super(context); } public CarPlateWheelLayout(Context context, AttributeSet attrs) { super(context, attrs); } public CarPlateWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } 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 CarPlateProvider(); setData(provider); } @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { super.onAttributeSet(context, attrs); setFirstVisible(provider.firstLevelVisible()); setThirdVisible(provider.thirdLevelVisible()); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DateWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.annotation.DateMode; import com.github.gzuliyujiang.wheelpicker.contract.DateFormatter; import com.github.gzuliyujiang.wheelpicker.contract.OnDateSelectedListener; import com.github.gzuliyujiang.wheelpicker.entity.DateEntity; import com.github.gzuliyujiang.wheelpicker.impl.SimpleDateFormatter; 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; import java.util.Arrays; import java.util.List; /** * 日期滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 16:12 */ @SuppressWarnings("unused") public class DateWheelLayout extends BaseWheelLayout { private NumberWheelView yearWheelView; private NumberWheelView monthWheelView; private NumberWheelView dayWheelView; private TextView yearLabelView; private TextView monthLabelView; private TextView dayLabelView; private DateEntity startValue; private DateEntity endValue; private Integer selectedYear; private Integer selectedMonth; private Integer selectedDay; private OnDateSelectedListener onDateSelectedListener; private boolean resetWhenLinkage = true; public DateWheelLayout(Context context) { super(context); } public DateWheelLayout(Context context, AttributeSet attrs) { super(context, attrs); } public DateWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public DateWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected int provideLayoutRes() { return R.layout.wheel_picker_date; } @Override protected List provideWheelViews() { return Arrays.asList(yearWheelView, monthWheelView, dayWheelView); } @Override protected void onInit(@NonNull Context context) { yearWheelView = findViewById(R.id.wheel_picker_date_year_wheel); monthWheelView = findViewById(R.id.wheel_picker_date_month_wheel); dayWheelView = findViewById(R.id.wheel_picker_date_day_wheel); yearLabelView = findViewById(R.id.wheel_picker_date_year_label); monthLabelView = findViewById(R.id.wheel_picker_date_month_label); dayLabelView = findViewById(R.id.wheel_picker_date_day_label); } @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DateWheelLayout); setDateMode(typedArray.getInt(R.styleable.DateWheelLayout_wheel_dateMode, DateMode.YEAR_MONTH_DAY)); String yearLabel = typedArray.getString(R.styleable.DateWheelLayout_wheel_yearLabel); String monthLabel = typedArray.getString(R.styleable.DateWheelLayout_wheel_monthLabel); String dayLabel = typedArray.getString(R.styleable.DateWheelLayout_wheel_dayLabel); typedArray.recycle(); setDateLabel(yearLabel, monthLabel, dayLabel); setDateFormatter(new SimpleDateFormatter()); } @Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (visibility == VISIBLE && startValue == null && endValue == null) { setRange(DateEntity.today(), DateEntity.yearOnFuture(30), DateEntity.today()); } } @Override public void onWheelSelected(WheelView view, int position) { int id = view.getId(); if (id == R.id.wheel_picker_date_year_wheel) { selectedYear = yearWheelView.getItem(position); if (resetWhenLinkage) { selectedMonth = null; selectedDay = null; } changeMonth(selectedYear); dateSelectedCallback(); return; } if (id == R.id.wheel_picker_date_month_wheel) { selectedMonth = monthWheelView.getItem(position); if (resetWhenLinkage) { selectedDay = null; } changeDay(selectedYear, selectedMonth); dateSelectedCallback(); return; } if (id == R.id.wheel_picker_date_day_wheel) { selectedDay = dayWheelView.getItem(position); dateSelectedCallback(); } } @Override public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { int id = view.getId(); if (id == R.id.wheel_picker_date_year_wheel) { monthWheelView.setEnabled(state == ScrollState.IDLE); dayWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_date_month_wheel) { yearWheelView.setEnabled(state == ScrollState.IDLE); dayWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_date_day_wheel) { yearWheelView.setEnabled(state == ScrollState.IDLE); monthWheelView.setEnabled(state == ScrollState.IDLE); } } private void dateSelectedCallback() { if (onDateSelectedListener == null) { return; } dayWheelView.post(new Runnable() { @Override public void run() { onDateSelectedListener.onDateSelected(selectedYear, selectedMonth, selectedDay); } }); } public void setDateMode(@DateMode int dateMode) { yearWheelView.setVisibility(View.VISIBLE); yearLabelView.setVisibility(View.VISIBLE); monthWheelView.setVisibility(View.VISIBLE); monthLabelView.setVisibility(View.VISIBLE); dayWheelView.setVisibility(View.VISIBLE); dayLabelView.setVisibility(View.VISIBLE); if (dateMode == DateMode.NONE) { yearWheelView.setVisibility(View.GONE); yearLabelView.setVisibility(View.GONE); monthWheelView.setVisibility(View.GONE); monthLabelView.setVisibility(View.GONE); dayWheelView.setVisibility(View.GONE); dayLabelView.setVisibility(View.GONE); return; } if (dateMode == DateMode.MONTH_DAY) { yearWheelView.setVisibility(View.GONE); yearLabelView.setVisibility(View.GONE); return; } if (dateMode == DateMode.YEAR_MONTH) { dayWheelView.setVisibility(View.GONE); dayLabelView.setVisibility(View.GONE); } } /** * 设置日期时间范围 */ public void setRange(DateEntity startValue, DateEntity endValue) { setRange(startValue, endValue, null); } /** * 设置日期时间范围 */ public void setRange(DateEntity startValue, DateEntity endValue, DateEntity defaultValue) { if (startValue == null) { startValue = DateEntity.today(); } if (endValue == null) { endValue = DateEntity.yearOnFuture(30); } if (endValue.toTimeInMillis() < startValue.toTimeInMillis()) { throw new IllegalArgumentException("Ensure the start date is less than the end date"); } this.startValue = startValue; this.endValue = endValue; if (defaultValue != null) { selectedYear = defaultValue.getYear(); selectedMonth = defaultValue.getMonth(); selectedDay = defaultValue.getDay(); } else { selectedYear = null; selectedMonth = null; selectedDay = null; } changeYear(); } public void setDefaultValue(DateEntity defaultValue) { setRange(startValue, endValue, defaultValue); } public void setDateFormatter(final DateFormatter dateFormatter) { if (dateFormatter == null) { return; } yearWheelView.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object value) { return dateFormatter.formatYear((Integer) value); } }); monthWheelView.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object value) { return dateFormatter.formatMonth((Integer) value); } }); dayWheelView.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object value) { return dateFormatter.formatDay((Integer) value); } }); } public void setDateLabel(CharSequence year, CharSequence month, CharSequence day) { yearLabelView.setText(year); monthLabelView.setText(month); dayLabelView.setText(day); } public void setOnDateSelectedListener(OnDateSelectedListener onDateSelectedListener) { this.onDateSelectedListener = onDateSelectedListener; } public void setResetWhenLinkage(boolean resetWhenLinkage) { this.resetWhenLinkage = resetWhenLinkage; } public final DateEntity getStartValue() { return startValue; } public final DateEntity getEndValue() { return endValue; } public final NumberWheelView getYearWheelView() { return yearWheelView; } public final NumberWheelView getMonthWheelView() { return monthWheelView; } public final NumberWheelView getDayWheelView() { return dayWheelView; } public final TextView getYearLabelView() { return yearLabelView; } public final TextView getMonthLabelView() { return monthLabelView; } public final TextView getDayLabelView() { return dayLabelView; } public final int getSelectedYear() { return yearWheelView.getCurrentItem(); } public final int getSelectedMonth() { return monthWheelView.getCurrentItem(); } public final int getSelectedDay() { return dayWheelView.getCurrentItem(); } private void changeYear() { final int min = Math.min(startValue.getYear(), endValue.getYear()); final int max = Math.max(startValue.getYear(), endValue.getYear()); if (selectedYear == null) { selectedYear = min; } else { selectedYear = Math.max(selectedYear, min); selectedYear = Math.min(selectedYear, max); } yearWheelView.setRange(min, max, 1); yearWheelView.setDefaultValue(selectedYear); changeMonth(selectedYear); } private void changeMonth(int year) { final int min, max; //开始年份和结束年份相同(即只有一个年份,这种情况建议使用月日模式) if (startValue.getYear() == endValue.getYear()) { min = Math.min(startValue.getMonth(), endValue.getMonth()); max = Math.max(startValue.getMonth(), endValue.getMonth()); } //当前所选年份和开始年份相同 else if (year == startValue.getYear()) { min = startValue.getMonth(); max = 12; } //当前所选年份和结束年份相同 else if (year == endValue.getYear()) { min = 1; max = endValue.getMonth(); } //当前所选年份在开始年份和结束年份之间 else { min = 1; max = 12; } if (selectedMonth == null) { selectedMonth = min; } else { selectedMonth = Math.max(selectedMonth, min); selectedMonth = Math.min(selectedMonth, max); } monthWheelView.setRange(min, max, 1); monthWheelView.setDefaultValue(selectedMonth); changeDay(year, selectedMonth); } private void changeDay(int year, int month) { final int min, max; //开始年月及结束年月相同情况 if (year == startValue.getYear() && month == startValue.getMonth() && year == endValue.getYear() && month == endValue.getMonth()) { min = startValue.getDay(); max = endValue.getDay(); } //开始年月相同情况 else if (year == startValue.getYear() && month == startValue.getMonth()) { min = startValue.getDay(); max = getTotalDaysInMonth(year, month); } //结束年月相同情况 else if (year == endValue.getYear() && month == endValue.getMonth()) { min = 1; max = endValue.getDay(); } else { min = 1; max = getTotalDaysInMonth(year, month); } if (selectedDay == null) { selectedDay = min; } else { selectedDay = Math.max(selectedDay, min); selectedDay = Math.min(selectedDay, max); } dayWheelView.setRange(min, max, 1); dayWheelView.setDefaultValue(selectedDay); } /** * 根据年份及月份获取每月的天数,类似于{@link java.util.Calendar#getActualMaximum(int)} */ private int getTotalDaysInMonth(int year, int month) { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: // 大月月份为31天 return 31; case 4: case 6: case 9: case 11: // 小月月份为30天 return 30; case 2: // 二月需要判断是否闰年 if (year <= 0) { return 29; } // 是否闰年:能被4整除但不能被100整除;能被400整除; boolean isLeap = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; if (isLeap) { return 29; } else { return 28; } default: return 30; } } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/DatimeWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.annotation.DateMode; import com.github.gzuliyujiang.wheelpicker.annotation.TimeMode; import com.github.gzuliyujiang.wheelpicker.contract.DateFormatter; import com.github.gzuliyujiang.wheelpicker.contract.OnDatimeSelectedListener; import com.github.gzuliyujiang.wheelpicker.contract.TimeFormatter; import com.github.gzuliyujiang.wheelpicker.entity.DatimeEntity; import com.github.gzuliyujiang.wheelpicker.impl.SimpleDateFormatter; import com.github.gzuliyujiang.wheelpicker.impl.SimpleTimeFormatter; import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.widget.NumberWheelView; import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.ArrayList; import java.util.List; /** * 日期时间滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 15:26 */ @SuppressWarnings("unused") public class DatimeWheelLayout extends BaseWheelLayout { private DateWheelLayout dateWheelLayout; private TimeWheelLayout timeWheelLayout; private DatimeEntity startValue; private DatimeEntity endValue; private OnDatimeSelectedListener onDatimeSelectedListener; public DatimeWheelLayout(Context context) { super(context); } public DatimeWheelLayout(Context context, AttributeSet attrs) { super(context, attrs); } public DatimeWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public DatimeWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected int provideLayoutRes() { return R.layout.wheel_picker_datime; } @Override protected List provideWheelViews() { List list = new ArrayList<>(); list.addAll(dateWheelLayout.provideWheelViews()); list.addAll(timeWheelLayout.provideWheelViews()); return list; } @Override protected void onInit(@NonNull Context context) { dateWheelLayout = findViewById(R.id.wheel_picker_date_wheel); timeWheelLayout = findViewById(R.id.wheel_picker_time_wheel); } @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DatimeWheelLayout); setDateMode(typedArray.getInt(R.styleable.DatimeWheelLayout_wheel_dateMode, DateMode.YEAR_MONTH_DAY)); setTimeMode(typedArray.getInt(R.styleable.DatimeWheelLayout_wheel_timeMode, TimeMode.HOUR_24_NO_SECOND)); String yearLabel = typedArray.getString(R.styleable.DatimeWheelLayout_wheel_yearLabel); String monthLabel = typedArray.getString(R.styleable.DatimeWheelLayout_wheel_monthLabel); String dayLabel = typedArray.getString(R.styleable.DatimeWheelLayout_wheel_dayLabel); setDateLabel(yearLabel, monthLabel, dayLabel); String hourLabel = typedArray.getString(R.styleable.DatimeWheelLayout_wheel_hourLabel); String minuteLabel = typedArray.getString(R.styleable.DatimeWheelLayout_wheel_minuteLabel); String secondLabel = typedArray.getString(R.styleable.DatimeWheelLayout_wheel_secondLabel); typedArray.recycle(); setTimeLabel(hourLabel, minuteLabel, secondLabel); setDateFormatter(new SimpleDateFormatter()); setTimeFormatter(new SimpleTimeFormatter(timeWheelLayout)); } @Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (visibility == VISIBLE && startValue == null && endValue == null) { setRange(DatimeEntity.now(), DatimeEntity.yearOnFuture(30), DatimeEntity.now()); } } @Override public void onWheelSelected(WheelView view, int position) { dateWheelLayout.onWheelSelected(view, position); timeWheelLayout.onWheelSelected(view, position); if (onDatimeSelectedListener == null) { return; } timeWheelLayout.post(new Runnable() { @Override public void run() { onDatimeSelectedListener.onDatimeSelected(dateWheelLayout.getSelectedYear(), dateWheelLayout.getSelectedMonth(), dateWheelLayout.getSelectedDay(), timeWheelLayout.getSelectedHour(), timeWheelLayout.getSelectedMinute(), timeWheelLayout.getSelectedSecond()); } }); } @Override public void onWheelScrolled(WheelView view, int offset) { dateWheelLayout.onWheelScrolled(view, offset); timeWheelLayout.onWheelScrolled(view, offset); } @Override public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { dateWheelLayout.onWheelScrollStateChanged(view, state); timeWheelLayout.onWheelScrollStateChanged(view, state); } @Override public void onWheelLoopFinished(WheelView view) { dateWheelLayout.onWheelLoopFinished(view); timeWheelLayout.onWheelLoopFinished(view); } public void setDateMode(@DateMode int dateMode) { dateWheelLayout.setDateMode(dateMode); } public void setTimeMode(@TimeMode int timeMode) { timeWheelLayout.setTimeMode(timeMode); } /** * 设置日期时间范围 */ public void setRange(DatimeEntity startValue, DatimeEntity endValue) { setRange(startValue, endValue, null); } /** * 设置日期时间范围 */ public void setRange(DatimeEntity startValue, DatimeEntity endValue, DatimeEntity defaultValue) { if (startValue == null) { startValue = DatimeEntity.now(); } if (endValue == null) { endValue = DatimeEntity.yearOnFuture(10); } if (defaultValue == null) { defaultValue = startValue; } dateWheelLayout.setRange(startValue.getDate(), endValue.getDate(), defaultValue.getDate()); timeWheelLayout.setRange(null, null, defaultValue.getTime()); this.startValue = startValue; this.endValue = endValue; } public void setDefaultValue(DatimeEntity defaultValue) { if (defaultValue == null) { defaultValue = DatimeEntity.now(); } dateWheelLayout.setDefaultValue(defaultValue.getDate()); timeWheelLayout.setDefaultValue(defaultValue.getTime()); } public void setDateFormatter(DateFormatter dateFormatter) { dateWheelLayout.setDateFormatter(dateFormatter); } public void setTimeFormatter(TimeFormatter timeFormatter) { timeWheelLayout.setTimeFormatter(timeFormatter); } public void setDateLabel(CharSequence year, CharSequence month, CharSequence day) { dateWheelLayout.setDateLabel(year, month, day); } public void setTimeLabel(CharSequence hour, CharSequence minute, CharSequence second) { timeWheelLayout.setTimeLabel(hour, minute, second); } public void setOnDatimeSelectedListener(OnDatimeSelectedListener onDatimeSelectedListener) { this.onDatimeSelectedListener = onDatimeSelectedListener; } public void setResetWhenLinkage(boolean dateResetWhenLinkage, boolean timeResetWhenLinkage) { dateWheelLayout.setResetWhenLinkage(dateResetWhenLinkage); timeWheelLayout.setResetWhenLinkage(timeResetWhenLinkage); } public final DatimeEntity getStartValue() { return startValue; } public final DatimeEntity getEndValue() { return endValue; } public final DateWheelLayout getDateWheelLayout() { return dateWheelLayout; } public final TimeWheelLayout getTimeWheelLayout() { return timeWheelLayout; } public final NumberWheelView getYearWheelView() { return dateWheelLayout.getYearWheelView(); } public final NumberWheelView getMonthWheelView() { return dateWheelLayout.getMonthWheelView(); } public final NumberWheelView getDayWheelView() { return dateWheelLayout.getDayWheelView(); } public final NumberWheelView getHourWheelView() { return timeWheelLayout.getHourWheelView(); } public final NumberWheelView getMinuteWheelView() { return timeWheelLayout.getMinuteWheelView(); } public final NumberWheelView getSecondWheelView() { return timeWheelLayout.getSecondWheelView(); } public final WheelView getMeridiemWheelView() { return timeWheelLayout.getMeridiemWheelView(); } public final TextView getYearLabelView() { return dateWheelLayout.getYearLabelView(); } public final TextView getMonthLabelView() { return dateWheelLayout.getMonthLabelView(); } public final TextView getDayLabelView() { return dateWheelLayout.getDayLabelView(); } public final TextView getHourLabelView() { return timeWheelLayout.getHourLabelView(); } public final TextView getMinuteLabelView() { return timeWheelLayout.getMinuteLabelView(); } public final TextView getSecondLabelView() { return timeWheelLayout.getSecondLabelView(); } public final int getSelectedYear() { return dateWheelLayout.getSelectedYear(); } public final int getSelectedMonth() { return dateWheelLayout.getSelectedMonth(); } public final int getSelectedDay() { return dateWheelLayout.getSelectedDay(); } public final int getSelectedHour() { return timeWheelLayout.getSelectedHour(); } public final int getSelectedMinute() { return timeWheelLayout.getSelectedMinute(); } public final int getSelectedSecond() { return timeWheelLayout.getSelectedSecond(); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/LinkageWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.CallSuper; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkageSelectedListener; import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.contract.WheelFormatter; import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.Arrays; import java.util.List; /** * 二三级联动滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/15 11:55 */ @SuppressWarnings("unused") public class LinkageWheelLayout extends BaseWheelLayout { private WheelView firstWheelView, secondWheelView, thirdWheelView; private TextView firstLabelView, secondLabelView, thirdLabelView; private ProgressBar loadingView; private Object firstValue, secondValue, thirdValue; private int firstIndex, secondIndex, thirdIndex; private LinkageProvider dataProvider; private OnLinkageSelectedListener onLinkageSelectedListener; public LinkageWheelLayout(Context context) { super(context); } public LinkageWheelLayout(Context context, AttributeSet attrs) { super(context, attrs); } public LinkageWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public LinkageWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected int provideLayoutRes() { return R.layout.wheel_picker_linkage; } @CallSuper @Override protected List provideWheelViews() { return Arrays.asList(firstWheelView, secondWheelView, thirdWheelView); } @CallSuper @Override protected void onInit(@NonNull Context context) { firstWheelView = findViewById(R.id.wheel_picker_linkage_first_wheel); secondWheelView = findViewById(R.id.wheel_picker_linkage_second_wheel); thirdWheelView = findViewById(R.id.wheel_picker_linkage_third_wheel); firstLabelView = findViewById(R.id.wheel_picker_linkage_first_label); secondLabelView = findViewById(R.id.wheel_picker_linkage_second_label); thirdLabelView = findViewById(R.id.wheel_picker_linkage_third_label); loadingView = findViewById(R.id.wheel_picker_linkage_loading); } @CallSuper @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LinkageWheelLayout); setFirstVisible(typedArray.getBoolean(R.styleable.LinkageWheelLayout_wheel_firstVisible, true)); setThirdVisible(typedArray.getBoolean(R.styleable.LinkageWheelLayout_wheel_thirdVisible, true)); String firstLabel = typedArray.getString(R.styleable.LinkageWheelLayout_wheel_firstLabel); String secondLabel = typedArray.getString(R.styleable.LinkageWheelLayout_wheel_secondLabel); String thirdLabel = typedArray.getString(R.styleable.LinkageWheelLayout_wheel_thirdLabel); typedArray.recycle(); setLabel(firstLabel, secondLabel, thirdLabel); } @CallSuper @Override public void onWheelSelected(WheelView view, int position) { int id = view.getId(); if (id == R.id.wheel_picker_linkage_first_wheel) { firstIndex = position; secondIndex = 0; thirdIndex = 0; changeSecondData(); changeThirdData(); selectedCallback(); return; } if (id == R.id.wheel_picker_linkage_second_wheel) { secondIndex = position; thirdIndex = 0; changeThirdData(); selectedCallback(); return; } if (id == R.id.wheel_picker_linkage_third_wheel) { thirdIndex = position; selectedCallback(); } } @CallSuper @Override public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { int id = view.getId(); if (id == R.id.wheel_picker_linkage_first_wheel) { secondWheelView.setEnabled(state == ScrollState.IDLE); thirdWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_linkage_second_wheel) { firstWheelView.setEnabled(state == ScrollState.IDLE); thirdWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_linkage_third_wheel) { firstWheelView.setEnabled(state == ScrollState.IDLE); secondWheelView.setEnabled(state == ScrollState.IDLE); } } public void setData(@NonNull LinkageProvider provider) { setFirstVisible(provider.firstLevelVisible()); setThirdVisible(provider.thirdLevelVisible()); if (firstValue != null) { firstIndex = provider.findFirstIndex(firstValue); } if (secondValue != null) { secondIndex = provider.findSecondIndex(firstIndex, secondValue); } if (thirdValue != null) { thirdIndex = provider.findThirdIndex(firstIndex, secondIndex, thirdValue); } dataProvider = provider; changeFirstData(); changeSecondData(); changeThirdData(); } public void setDefaultValue(Object first, Object second, Object third) { if (dataProvider != null) { firstIndex = dataProvider.findFirstIndex(first); secondIndex = dataProvider.findSecondIndex(firstIndex, second); thirdIndex = dataProvider.findThirdIndex(firstIndex, secondIndex, third); changeFirstData(); changeSecondData(); changeThirdData(); } else { this.firstValue = first; this.secondValue = second; this.thirdValue = third; } } public void setFormatter(WheelFormatter first, WheelFormatter second, WheelFormatter third) { firstWheelView.setFormatter(first); secondWheelView.setFormatter(second); thirdWheelView.setFormatter(third); } public void setLabel(CharSequence first, CharSequence second, CharSequence third) { firstLabelView.setText(first); secondLabelView.setText(second); thirdLabelView.setText(third); } public void showLoading() { loadingView.setVisibility(VISIBLE); } public void hideLoading() { loadingView.setVisibility(GONE); } public void setOnLinkageSelectedListener(OnLinkageSelectedListener onLinkageSelectedListener) { this.onLinkageSelectedListener = onLinkageSelectedListener; } public void setFirstVisible(boolean visible) { if (visible) { firstWheelView.setVisibility(VISIBLE); firstLabelView.setVisibility(VISIBLE); } else { firstWheelView.setVisibility(GONE); firstLabelView.setVisibility(GONE); } } public void setThirdVisible(boolean visible) { if (visible) { thirdWheelView.setVisibility(VISIBLE); thirdLabelView.setVisibility(VISIBLE); } else { thirdWheelView.setVisibility(GONE); thirdLabelView.setVisibility(GONE); } } private void selectedCallback() { if (onLinkageSelectedListener == null) { return; } thirdWheelView.post(new Runnable() { @Override public void run() { Object first = firstWheelView.getCurrentItem(); Object second = secondWheelView.getCurrentItem(); Object third = thirdWheelView.getCurrentItem(); onLinkageSelectedListener.onLinkageSelected(first, second, third); } }); } private void changeFirstData() { firstWheelView.setData(dataProvider.provideFirstData()); firstWheelView.setDefaultPosition(firstIndex); } private void changeSecondData() { secondWheelView.setData(dataProvider.linkageSecondData(firstIndex)); secondWheelView.setDefaultPosition(secondIndex); } private void changeThirdData() { if (!dataProvider.thirdLevelVisible()) { return; } thirdWheelView.setData(dataProvider.linkageThirdData(firstIndex, secondIndex)); thirdWheelView.setDefaultPosition(thirdIndex); } public final WheelView getFirstWheelView() { return firstWheelView; } public final WheelView getSecondWheelView() { return secondWheelView; } public final WheelView getThirdWheelView() { return thirdWheelView; } public final TextView getFirstLabelView() { return firstLabelView; } public final TextView getSecondLabelView() { return secondLabelView; } public final TextView getThirdLabelView() { return thirdLabelView; } public final ProgressBar getLoadingView() { return loadingView; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/NumberWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.contract.OnNumberSelectedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionSelectedListener; import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.ArrayList; import java.util.List; /** * 数字滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 18:35 */ public class NumberWheelLayout extends OptionWheelLayout { private OnNumberSelectedListener onNumberSelectedListener; public NumberWheelLayout(Context context) { super(context); } public NumberWheelLayout(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public NumberWheelLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public NumberWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { super.onAttributeSet(context, attrs); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NumberWheelLayout); float minNumber = typedArray.getFloat(R.styleable.NumberWheelLayout_wheel_minNumber, 0); float maxNumber = typedArray.getFloat(R.styleable.NumberWheelLayout_wheel_maxNumber, 10); float stepNumber = typedArray.getFloat(R.styleable.NumberWheelLayout_wheel_stepNumber, 1); boolean isDecimal = typedArray.getBoolean(R.styleable.NumberWheelLayout_wheel_isDecimal, false); typedArray.recycle(); if (isDecimal) { setRange(minNumber, maxNumber, stepNumber); } else { setRange((int) minNumber, (int) maxNumber, (int) stepNumber); } } @Override public void onWheelSelected(WheelView view, int position) { super.onWheelSelected(view, position); if (onNumberSelectedListener != null) { Object item = getWheelView().getItem(position); onNumberSelectedListener.onNumberSelected(position, (Number) item); } } /** * @deprecated 使用 {@link #setRange} 代替 */ @Deprecated @Override public void setData(List data) { throw new UnsupportedOperationException("Use setRange instead"); } /** * @deprecated 使用 {@link #setOnNumberSelectedListener} 代替 */ @Deprecated @Override public void setOnOptionSelectedListener(OnOptionSelectedListener onOptionSelectedListener) { throw new UnsupportedOperationException("Use setOnNumberSelectedListener instead"); } public void setOnNumberSelectedListener(OnNumberSelectedListener onNumberSelectedListener) { this.onNumberSelectedListener = onNumberSelectedListener; } public void setRange(int min, int max, int step) { int minValue = Math.min(min, max); int maxValue = Math.max(min, max); // 指定初始容量,避免OutOfMemory int capacity = (maxValue - minValue) / step; List data = new ArrayList<>(capacity); for (int i = minValue; i <= maxValue; i = i + step) { data.add(i); } super.setData(data); } public void setRange(float min, float max, float step) { float minValue = Math.min(min, max); float maxValue = Math.max(min, max); // 指定初始容量,避免OutOfMemory int capacity = (int) ((maxValue - minValue) / step); List data = new ArrayList<>(capacity); for (float i = minValue; i <= maxValue; i = i + step) { data.add(i); } super.setData(data); } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/OptionWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.widget.TextView; import androidx.annotation.CallSuper; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionSelectedListener; import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.Collections; import java.util.List; /** * 单项滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/6 23:13 */ @SuppressWarnings("unused") public class OptionWheelLayout extends BaseWheelLayout { private WheelView wheelView; private TextView labelView; private OnOptionSelectedListener onOptionSelectedListener; public OptionWheelLayout(Context context) { super(context); } public OptionWheelLayout(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public OptionWheelLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public OptionWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected int provideLayoutRes() { return R.layout.wheel_picker_option; } @CallSuper @Override protected List provideWheelViews() { return Collections.singletonList(wheelView); } @CallSuper @Override protected void onInit(@NonNull Context context) { wheelView = findViewById(R.id.wheel_picker_option_wheel); labelView = findViewById(R.id.wheel_picker_option_label); } @CallSuper @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.OptionWheelLayout); labelView.setText(typedArray.getString(R.styleable.OptionWheelLayout_wheel_label)); typedArray.recycle(); } @CallSuper @Override public void onWheelSelected(WheelView view, int position) { if (onOptionSelectedListener != null) { onOptionSelectedListener.onOptionSelected(position, wheelView.getItem(position)); } } public void setData(List data) { wheelView.setData(data); } public void setDefaultValue(Object value) { wheelView.setDefaultValue(value); } public void setDefaultPosition(int position) { wheelView.setDefaultPosition(position); } public void setOnOptionSelectedListener(OnOptionSelectedListener onOptionSelectedListener) { this.onOptionSelectedListener = onOptionSelectedListener; } public final WheelView getWheelView() { return wheelView; } public final TextView getLabelView() { return labelView; } } ================================================ FILE: WheelPicker/src/main/java/com/github/gzuliyujiang/wheelpicker/widget/TimeWheelLayout.java ================================================ /* * 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.widget; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.wheelpicker.R; import com.github.gzuliyujiang.wheelpicker.annotation.TimeMode; import com.github.gzuliyujiang.wheelpicker.contract.OnTimeMeridiemSelectedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnTimeSelectedListener; import com.github.gzuliyujiang.wheelpicker.contract.TimeFormatter; import com.github.gzuliyujiang.wheelpicker.entity.TimeEntity; import com.github.gzuliyujiang.wheelpicker.impl.SimpleTimeFormatter; 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; import java.util.Arrays; import java.util.List; /** * 时间滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/5 16:20 */ @SuppressWarnings("unused") public class TimeWheelLayout extends BaseWheelLayout { private NumberWheelView hourWheelView; private NumberWheelView minuteWheelView; private NumberWheelView secondWheelView; private TextView hourLabelView; private TextView minuteLabelView; private TextView secondLabelView; private WheelView meridiemWheelView; private TimeEntity startValue; private TimeEntity endValue; private TimeEntity defaultValue; private Integer selectedHour; private Integer selectedMinute; private Integer selectedSecond; private boolean isAnteMeridiem; private int timeMode; private int hourStep = 1; private int minuteStep = 1; private int secondStep = 1; private OnTimeSelectedListener onTimeSelectedListener; private OnTimeMeridiemSelectedListener onTimeMeridiemSelectedListener; private boolean resetWhenLinkage = true; public TimeWheelLayout(Context context) { super(context); } public TimeWheelLayout(Context context, AttributeSet attrs) { super(context, attrs); } public TimeWheelLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TimeWheelLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected int provideLayoutRes() { return R.layout.wheel_picker_time; } @Override protected List provideWheelViews() { return Arrays.asList(hourWheelView, minuteWheelView, secondWheelView, meridiemWheelView); } @Override protected void onInit(@NonNull Context context) { hourWheelView = findViewById(R.id.wheel_picker_time_hour_wheel); minuteWheelView = findViewById(R.id.wheel_picker_time_minute_wheel); secondWheelView = findViewById(R.id.wheel_picker_time_second_wheel); hourLabelView = findViewById(R.id.wheel_picker_time_hour_label); minuteLabelView = findViewById(R.id.wheel_picker_time_minute_label); secondLabelView = findViewById(R.id.wheel_picker_time_second_label); meridiemWheelView = findViewById(R.id.wheel_picker_time_meridiem_wheel); } @Override protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TimeWheelLayout); setTimeMode(typedArray.getInt(R.styleable.TimeWheelLayout_wheel_timeMode, TimeMode.HOUR_24_NO_SECOND)); String hourLabel = typedArray.getString(R.styleable.TimeWheelLayout_wheel_hourLabel); String minuteLabel = typedArray.getString(R.styleable.TimeWheelLayout_wheel_minuteLabel); String secondLabel = typedArray.getString(R.styleable.TimeWheelLayout_wheel_secondLabel); typedArray.recycle(); setTimeLabel(hourLabel, minuteLabel, secondLabel); setTimeFormatter(new SimpleTimeFormatter(this)); } @Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (visibility == VISIBLE && startValue == null && endValue == null) { setRange(TimeEntity.target(0, 0, 0), TimeEntity.target(23, 59, 59), TimeEntity.now()); } } @Override public void onWheelSelected(WheelView view, int position) { int id = view.getId(); if (id == R.id.wheel_picker_time_hour_wheel) { selectedHour = hourWheelView.getItem(position); if (resetWhenLinkage) { selectedMinute = null; selectedSecond = null; } changeMinute(selectedHour); timeSelectedCallback(); return; } if (id == R.id.wheel_picker_time_minute_wheel) { selectedMinute = minuteWheelView.getItem(position); if (resetWhenLinkage) { selectedSecond = null; } changeSecond(); timeSelectedCallback(); return; } if (id == R.id.wheel_picker_time_second_wheel) { selectedSecond = secondWheelView.getItem(position); timeSelectedCallback(); return; } if (id == R.id.wheel_picker_time_meridiem_wheel) { isAnteMeridiem = "AM".equalsIgnoreCase(meridiemWheelView.getItem(position)); timeSelectedCallback(); } } @Override public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) { int id = view.getId(); if (id == R.id.wheel_picker_time_hour_wheel) { minuteWheelView.setEnabled(state == ScrollState.IDLE); secondWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_time_minute_wheel) { hourWheelView.setEnabled(state == ScrollState.IDLE); secondWheelView.setEnabled(state == ScrollState.IDLE); return; } if (id == R.id.wheel_picker_time_second_wheel) { hourWheelView.setEnabled(state == ScrollState.IDLE); minuteWheelView.setEnabled(state == ScrollState.IDLE); } } private void timeSelectedCallback() { if (onTimeSelectedListener != null) { secondWheelView.post(new Runnable() { @Override public void run() { onTimeSelectedListener.onTimeSelected(selectedHour, selectedMinute, selectedSecond); } }); } if (onTimeMeridiemSelectedListener != null) { secondWheelView.post(new Runnable() { @Override public void run() { onTimeMeridiemSelectedListener.onTimeSelected(selectedHour, selectedMinute, selectedSecond, isAnteMeridiem()); } }); } } public void setTimeMode(@TimeMode int timeMode) { this.timeMode = timeMode; hourWheelView.setVisibility(View.VISIBLE); hourLabelView.setVisibility(View.VISIBLE); minuteWheelView.setVisibility(View.VISIBLE); minuteLabelView.setVisibility(View.VISIBLE); secondWheelView.setVisibility(View.VISIBLE); secondLabelView.setVisibility(View.VISIBLE); meridiemWheelView.setVisibility(View.GONE); if (timeMode == TimeMode.NONE) { hourWheelView.setVisibility(View.GONE); hourLabelView.setVisibility(View.GONE); minuteWheelView.setVisibility(View.GONE); minuteLabelView.setVisibility(View.GONE); secondWheelView.setVisibility(View.GONE); secondLabelView.setVisibility(View.GONE); this.timeMode = timeMode; return; } if (timeMode == TimeMode.HOUR_12_NO_SECOND || timeMode == TimeMode.HOUR_24_NO_SECOND) { secondWheelView.setVisibility(View.GONE); secondLabelView.setVisibility(View.GONE); } if (isHour12Mode()) { meridiemWheelView.setVisibility(View.VISIBLE); meridiemWheelView.setData(Arrays.asList("AM", "PM")); } } public boolean isHour12Mode() { return timeMode == TimeMode.HOUR_12_NO_SECOND || timeMode == TimeMode.HOUR_12_HAS_SECOND; } /** * 设置日期时间范围 */ public void setRange(TimeEntity startValue, TimeEntity endValue) { setRange(startValue, endValue, null); } /** * 设置日期时间范围 */ public void setRange(TimeEntity startValue, TimeEntity endValue, TimeEntity defaultValue) { if (startValue == null) { startValue = TimeEntity.target(isHour12Mode() ? 1 : 0, 0, 0); } if (endValue == null) { endValue = TimeEntity.target(isHour12Mode() ? 12 : 23, 59, 59); } if (endValue.toTimeInMillis() < startValue.toTimeInMillis()) { throw new IllegalArgumentException("Ensure the start time is less than the time date"); } this.startValue = startValue; this.endValue = endValue; if (defaultValue == null) { defaultValue = startValue; } this.defaultValue = defaultValue; isAnteMeridiem = defaultValue.getHour() < 12 || defaultValue.getHour() == 24; selectedHour = fixHour(defaultValue.getHour()); selectedMinute = defaultValue.getMinute(); selectedSecond = defaultValue.getSecond(); changeHour(); changeAnteMeridiem(); } public void setDefaultValue(@NonNull final TimeEntity defaultValue) { setRange(startValue, endValue, defaultValue); } public void setTimeFormatter(final TimeFormatter timeFormatter) { if (timeFormatter == null) { return; } hourWheelView.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object value) { return timeFormatter.formatHour((Integer) value); } }); minuteWheelView.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object value) { return timeFormatter.formatMinute((Integer) value); } }); secondWheelView.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object value) { return timeFormatter.formatSecond((Integer) value); } }); } public void setTimeLabel(CharSequence hour, CharSequence minute, CharSequence second) { hourLabelView.setText(hour); minuteLabelView.setText(minute); secondLabelView.setText(second); } public void setOnTimeSelectedListener(OnTimeSelectedListener onTimeSelectedListener) { this.onTimeSelectedListener = onTimeSelectedListener; } public void setOnTimeMeridiemSelectedListener(OnTimeMeridiemSelectedListener onTimeMeridiemSelectedListener) { this.onTimeMeridiemSelectedListener = onTimeMeridiemSelectedListener; } public void setResetWhenLinkage(boolean resetWhenLinkage) { this.resetWhenLinkage = resetWhenLinkage; } public void setTimeStep(int hourStep, int minuteStep, int secondStep) { this.hourStep = hourStep; this.minuteStep = minuteStep; this.secondStep = secondStep; if (isDataAlready()) { setRange(startValue, endValue, defaultValue); } } protected boolean isDataAlready() { return startValue != null && endValue != null; } public final TimeEntity getStartValue() { return startValue; } public final TimeEntity getEndValue() { return endValue; } public final NumberWheelView getHourWheelView() { return hourWheelView; } public final NumberWheelView getMinuteWheelView() { return minuteWheelView; } public final NumberWheelView getSecondWheelView() { return secondWheelView; } public final TextView getHourLabelView() { return hourLabelView; } public final TextView getMinuteLabelView() { return minuteLabelView; } public final TextView getSecondLabelView() { return secondLabelView; } public final WheelView getMeridiemWheelView() { return meridiemWheelView; } @Deprecated public final TextView getMeridiemLabelView() { throw new UnsupportedOperationException("Use getMeridiemWheelView instead"); } public final int getSelectedHour() { int hour = hourWheelView.getCurrentItem(); return fixHour(hour); } private int fixHour(int hour) { if (isHour12Mode()) { if (hour == 0) { hour = 24; } if (hour > 12) { hour = hour - 12; } } return hour; } public final int getSelectedMinute() { return minuteWheelView.getCurrentItem(); } public final int getSelectedSecond() { if (timeMode == TimeMode.HOUR_12_NO_SECOND || timeMode == TimeMode.HOUR_24_NO_SECOND) { return 0; } return secondWheelView.getCurrentItem(); } public final boolean isAnteMeridiem() { Object currentItem = meridiemWheelView.getCurrentItem(); if (currentItem == null) { return isAnteMeridiem; } return "AM".equalsIgnoreCase(currentItem.toString()); } private void changeHour() { int min = Math.min(startValue.getHour(), endValue.getHour()); int max = Math.max(startValue.getHour(), endValue.getHour()); int minHour = isHour12Mode() ? 1 : 0; int maxHour = isHour12Mode() ? 12 : 23; min = Math.max(minHour, min); max = Math.min(maxHour, max); if (selectedHour == null) { selectedHour = min; } else { selectedHour = Math.max(selectedHour, min); selectedHour = Math.min(selectedHour, max); } hourWheelView.setRange(min, max, hourStep); hourWheelView.setDefaultValue(selectedHour); changeMinute(selectedHour); } private void changeMinute(int hour) { final int min, max; //开始时及结束时相同情况 if (hour == startValue.getHour() && hour == endValue.getHour()) { min = startValue.getMinute(); max = endValue.getMinute(); } //开始时相同情况 else if (hour == startValue.getHour()) { min = startValue.getMinute(); max = 59; } //结束时相同情况 else if (hour == endValue.getHour()) { min = 0; max = endValue.getMinute(); } else { min = 0; max = 59; } if (selectedMinute == null) { selectedMinute = min; } else { selectedMinute = Math.max(selectedMinute, min); selectedMinute = Math.min(selectedMinute, max); } minuteWheelView.setRange(min, max, minuteStep); minuteWheelView.setDefaultValue(selectedMinute); changeSecond(); } private void changeSecond() { if (selectedSecond == null) { selectedSecond = 0; } secondWheelView.setRange(0, 59, secondStep); secondWheelView.setDefaultValue(selectedSecond); } private void changeAnteMeridiem() { meridiemWheelView.setDefaultValue(isAnteMeridiem ? "AM" : "PM"); } } ================================================ FILE: WheelPicker/src/main/res/layout/wheel_picker_date.xml ================================================ ================================================ FILE: WheelPicker/src/main/res/layout/wheel_picker_datime.xml ================================================ ================================================ FILE: WheelPicker/src/main/res/layout/wheel_picker_linkage.xml ================================================ ================================================ FILE: WheelPicker/src/main/res/layout/wheel_picker_number.xml ================================================ ================================================ FILE: WheelPicker/src/main/res/layout/wheel_picker_option.xml ================================================ ================================================ FILE: WheelPicker/src/main/res/layout/wheel_picker_time.xml ================================================ ================================================ FILE: WheelPicker/src/main/res/values/wheel_attrs.xml ================================================ ================================================ FILE: WheelView/README.md ================================================ # 滚轮 仿 IOS 风格的滚轮控件。 ================================================ FILE: WheelView/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/library.gradle" apply from: "${rootDir}/gradle/publish.gradle" dependencies { implementation androidxLibrary.annotation } ================================================ FILE: WheelView/consumer-rules.pro ================================================ # 本库模块专用的混淆规则 ================================================ FILE: WheelView/src/main/AndroidManifest.xml ================================================ ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/CurtainCorner.java ================================================ /* * 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; } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/ItemTextAlign.java ================================================ /* * 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 2019/6/19 12:04 */ @Retention(RetentionPolicy.SOURCE) public @interface ItemTextAlign { int CENTER = 0; int LEFT = 1; int RIGHT = 2; } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/annotation/ScrollState.java ================================================ /* * 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; } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/OnWheelChangedListener.java ================================================ /* * 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.contract; import com.github.gzuliyujiang.wheelview.annotation.ScrollState; import com.github.gzuliyujiang.wheelview.widget.WheelView; /** * 滚轮滑动接口 * * @author Florent Champigny * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 20:03 */ public interface OnWheelChangedListener { /** * Invoke when scroll stopped * Will return a distance offset which between current scroll position and * initial position, this offset is a positive or a negative, positive means * scrolling from bottom to top, negative means scrolling from top to bottom * * @param view wheel view * @param offset Distance offset which between current scroll position and initial position */ void onWheelScrolled(WheelView view, int offset); /** * Invoke when scroll stopped * This method will be called when wheel stop and return current selected item data's * position in list * * @param view wheel view * @param position Current selected item data's position in list */ void onWheelSelected(WheelView view, int position); /** * Invoke when scroll state changed * The state always between idle, dragging, and scrolling, this method will * be called when they switch * * @param view wheel view * @param state {@link ScrollState#IDLE} * {@link ScrollState#DRAGGING} * {@link ScrollState#SCROLLING} *

* State only one of the following * {@link ScrollState#IDLE} * Express WheelPicker in state of idle * {@link ScrollState#DRAGGING} * Express WheelPicker in state of dragging * {@link ScrollState#SCROLLING} * Express WheelPicker in state of scrolling */ void onWheelScrollStateChanged(WheelView view, @ScrollState int state); /** * Invoke when loop finished * * @param view wheel view */ void onWheelLoopFinished(WheelView view); } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/TextProvider.java ================================================ /* * 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.contract; /** * 提供显示的文本 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 20:01 */ public interface TextProvider { /** * 提供显示的文本 * * @return 显示的文本 */ String provideText(); } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/contract/WheelFormatter.java ================================================ /* * 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.contract; import androidx.annotation.NonNull; /** * 滚轮条目显示文本格式化接口 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/14 20:02 */ public interface WheelFormatter { /** * 格式化滚轮条目显示文本 * * @param item 滚轮条目的内容 * @return 格式化后最终显示的文本 */ String formatItem(@NonNull Object item); } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/NumberWheelView.java ================================================ /* * 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.widget; import android.content.Context; import android.util.AttributeSet; import java.util.ArrayList; import java.util.List; /** * 数字滚轮控件 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/5/13 19:13 */ public class NumberWheelView extends WheelView { public NumberWheelView(Context context) { super(context); } public NumberWheelView(Context context, AttributeSet attrs) { super(context, attrs); } public NumberWheelView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected List generatePreviewData() { List data = new ArrayList<>(); for (int i = 1; i <= 10; i = i + 1) { data.add(i); } return data; } /** * @deprecated 使用 {@link #setRange} 代替 */ @Deprecated @Override public void setData(List data) { if (isInEditMode()) { super.setData(generatePreviewData()); } else { throw new UnsupportedOperationException("Use setRange instead"); } } public void setRange(int min, int max, int step) { int minValue = Math.min(min, max); int maxValue = Math.max(min, max); // 指定初始容量,避免OutOfMemory int capacity = (maxValue - minValue) / step; List data = new ArrayList<>(capacity); for (int i = minValue; i <= maxValue; i = i + step) { data.add(i); } super.setData(data); } public void setRange(float min, float max, float step) { float minValue = Math.min(min, max); float maxValue = Math.max(min, max); // 指定初始容量,避免OutOfMemory int capacity = (int) ((maxValue - minValue) / step); List data = new ArrayList<>(capacity); for (float i = minValue; i <= maxValue; i = i + step) { data.add(i); } super.setData(data); } } ================================================ FILE: WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java ================================================ /* * 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.widget; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Camera; import android.graphics.Canvas; 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; import android.os.Handler; import android.text.TextUtils; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.widget.Scroller; import androidx.annotation.ColorInt; import androidx.annotation.IntRange; import androidx.annotation.Px; 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; import java.util.ArrayList; import java.util.List; /** * 滚轮控件。Adapted from https://github.com/florent37/SingleDateAndTimePicker/.../WheelPicker.java * * @author 贵州山野羡民(1032694760@qq.com) * @see TextProvider * @see OnWheelChangedListener * @since 2019/5/8 11:11 */ @SuppressWarnings({"unused"}) public class WheelView extends View implements Runnable { @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; protected Object defaultItem; protected int visibleItemCount; protected int defaultItemPosition; protected int currentPosition; protected String maxWidthText; protected int textColor; protected int selectedTextColor; protected float textSize, selectedTextSize; protected boolean selectedTextBold; protected float indicatorSize; protected int indicatorColor; protected int curtainColor; protected int curtainCorner; protected float curtainRadius; protected int itemSpace; protected int textAlign; protected boolean sameWidthEnabled; protected boolean indicatorEnabled; protected boolean curtainEnabled; protected boolean atmosphericEnabled; protected boolean cyclicEnabled; protected boolean curvedEnabled; protected int curvedMaxAngle = 90; protected int curvedIndicatorSpace; private final Handler handler = new Handler(); private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); private final Scroller scroller; private VelocityTracker tracker; private OnWheelChangedListener onWheelChangedListener; private final Rect rectDrawn = new Rect(); private final Rect rectIndicatorHead = new Rect(); private final Rect rectIndicatorFoot = new Rect(); private final Rect rectCurrentItem = new Rect(); private final Camera camera = new Camera(); private final Matrix matrixRotate = new Matrix(); private final Matrix matrixDepth = new Matrix(); private int lastScrollPosition; private int drawnItemCount; private int halfDrawnItemCount; private int textMaxWidth, textMaxHeight; private int itemHeight, halfItemHeight; private int halfWheelHeight; private int minFlingYCoordinate, maxFlingYCoordinate; private int wheelCenterXCoordinate, wheelCenterYCoordinate; private int drawnCenterXCoordinate, drawnCenterYCoordinate; private int scrollOffsetYCoordinate; private int lastPointYCoordinate; private int downPointYCoordinate; private final int minimumVelocity; private final int maximumVelocity; private final int touchSlop; private boolean isClick; private boolean isForceFinishScroll; public WheelView(Context context) { this(context, null); } public WheelView(Context context, AttributeSet attrs) { this(context, attrs, R.attr.WheelStyle); } public WheelView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initAttrs(context, attrs, defStyleAttr, R.style.WheelDefault); initTextPaint(); updateVisibleItemCount(); scroller = new Scroller(context); ViewConfiguration configuration = ViewConfiguration.get(context); minimumVelocity = configuration.getScaledMinimumFlingVelocity(); maximumVelocity = configuration.getScaledMaximumFlingVelocity(); touchSlop = configuration.getScaledTouchSlop(); if (isInEditMode()) { setData(generatePreviewData()); } } private void initTextPaint() { paint.setColor(textColor); paint.setTextSize(textSize); paint.setFakeBoldText(false); paint.setStyle(Paint.Style.FILL); } public void setStyle(@StyleRes int style) { initAttrs(getContext(), null, R.attr.WheelStyle, style); initTextPaint(); updatePaintTextAlign(); computeTextWidthAndHeight(); computeFlingLimitYCoordinate(); computeIndicatorRect(); computeCurrentItemRect(); requestLayout(); invalidate(); } private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { float density = context.getResources().getDisplayMetrics().density; float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity; TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.WheelView, defStyleAttr, defStyleRes); visibleItemCount = typedArray.getInt(R.styleable.WheelView_wheel_visibleItemCount, 5); sameWidthEnabled = typedArray.getBoolean(R.styleable.WheelView_wheel_sameWidthEnabled, false); maxWidthText = typedArray.getString(R.styleable.WheelView_wheel_maxWidthText); textColor = typedArray.getColor(R.styleable.WheelView_wheel_itemTextColor, 0xFF888888); selectedTextColor = typedArray.getColor(R.styleable.WheelView_wheel_itemTextColorSelected, 0xFF000000); textSize = typedArray.getDimension(R.styleable.WheelView_wheel_itemTextSize, 15 * scaledDensity); selectedTextSize = typedArray.getDimension(R.styleable.WheelView_wheel_itemTextSizeSelected, textSize); selectedTextBold = typedArray.getBoolean(R.styleable.WheelView_wheel_itemTextBoldSelected, false); textAlign = typedArray.getInt(R.styleable.WheelView_wheel_itemTextAlign, ItemTextAlign.CENTER); itemSpace = typedArray.getDimensionPixelSize(R.styleable.WheelView_wheel_itemSpace, (int) (20 * density)); cyclicEnabled = typedArray.getBoolean(R.styleable.WheelView_wheel_cyclicEnabled, false); indicatorEnabled = typedArray.getBoolean(R.styleable.WheelView_wheel_indicatorEnabled, true); indicatorColor = typedArray.getColor(R.styleable.WheelView_wheel_indicatorColor, 0xFFC9C9C9); indicatorSize = typedArray.getDimension(R.styleable.WheelView_wheel_indicatorSize, 1 * density); 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 = typedArray.getInt(R.styleable.WheelView_wheel_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); typedArray.recycle(); } protected List generatePreviewData() { List data = new ArrayList<>(); data.add("贵州穿青人"); data.add("大定府羡民"); data.add("不在五十六个民族之内"); data.add("已识别待定民族"); data.add("穿青山魈人马"); data.add("李裕江"); return data; } private void updateVisibleItemCount() { final int minCount = 2; if (visibleItemCount < minCount) { throw new ArithmeticException("Visible item count can not be less than " + minCount); } //可见条目只能是奇数个,设置可见条目时偶数个将自动矫正为奇数个 int evenNumberFlag = 2; if (visibleItemCount % evenNumberFlag == 0) { visibleItemCount += 1; } drawnItemCount = visibleItemCount + 2; halfDrawnItemCount = drawnItemCount / 2; } private void computeTextWidthAndHeight() { textMaxWidth = textMaxHeight = 0; if (sameWidthEnabled) { textMaxWidth = (int) paint.measureText(formatItem(0)); } else if (!TextUtils.isEmpty(maxWidthText)) { textMaxWidth = (int) paint.measureText(maxWidthText); } else { // 未指定最宽的文本,须遍历测量查找最宽的作为基准 int itemCount = getItemCount(); for (int i = 0; i < itemCount; ++i) { int width = (int) paint.measureText(formatItem(i)); textMaxWidth = Math.max(textMaxWidth, width); } } Paint.FontMetrics metrics = paint.getFontMetrics(); textMaxHeight = (int) (metrics.bottom - metrics.top); } public int getItemCount() { return data.size(); } public T getItem(int position) { final int size = data.size(); if (size == 0) { return null; } int index = (position + size) % size; if (index >= 0 && index <= size - 1) { //noinspection unchecked return (T) data.get(index); } return null; } public int getPosition(Object item) { if (item == null) { return 0; } return data.indexOf(item); } public int getCurrentPosition() { return currentPosition; } public T getCurrentItem() { return getItem(currentPosition); } public int getVisibleItemCount() { return visibleItemCount; } public void setVisibleItemCount(@IntRange(from = 2) int count) { visibleItemCount = count; updateVisibleItemCount(); requestLayout(); } public boolean isCyclicEnabled() { return cyclicEnabled; } public void setCyclicEnabled(boolean isCyclic) { this.cyclicEnabled = isCyclic; computeFlingLimitYCoordinate(); invalidate(); } public void setOnWheelChangedListener(OnWheelChangedListener listener) { onWheelChangedListener = listener; } public void setFormatter(WheelFormatter formatter) { this.formatter = formatter; } public List getData() { return data; } public void setData(List newData) { setData(newData, 0); } public void setData(List newData, Object defaultValue) { setData(newData, findPosition(defaultValue)); } public void setData(List newData, int defaultPosition) { if (newData == null) { newData = new ArrayList<>(); } data = newData; notifyDataSetChanged(defaultPosition); } public void setDefaultValue(Object value) { setDefaultPosition(findPosition(value)); } public void setDefaultPosition(int position) { notifyDataSetChanged(position); } private int findPosition(Object value) { if (value == null) { return 0; } boolean found = false; int position = 0; for (Object item : data) { if (item == null) { continue; } if (item.equals(value)) { found = true; break; } if (formatter != null && formatter.formatItem(item).equals(formatter.formatItem(value))) { found = true; break; } if (item instanceof TextProvider) { String text = ((TextProvider) item).provideText(); if (text.equals(value.toString())) { found = true; break; } } if (item.toString().equals(value.toString())) { found = true; break; } position++; } if (!found) { position = 0; } return position; } public boolean isSameWidthEnabled() { return sameWidthEnabled; } public void setSameWidthEnabled(boolean sameWidthEnabled) { this.sameWidthEnabled = sameWidthEnabled; computeTextWidthAndHeight(); requestLayout(); invalidate(); } public String getMaxWidthText() { return maxWidthText; } public void setMaxWidthText(String text) { if (null == text) { throw new NullPointerException("Maximum width text can not be null!"); } maxWidthText = text; computeTextWidthAndHeight(); requestLayout(); invalidate(); } @ColorInt public int getTextColor() { return textColor; } public void setTextColor(@ColorInt int color) { textColor = color; invalidate(); } @ColorInt public int getSelectedTextColor() { return selectedTextColor; } public void setSelectedTextColor(@ColorInt int color) { selectedTextColor = color; computeCurrentItemRect(); invalidate(); } @Px public float getTextSize() { return textSize; } public void setTextSize(@Px float size) { textSize = size; computeTextWidthAndHeight(); requestLayout(); invalidate(); } @Px public float getSelectedTextSize() { return selectedTextSize; } public void setSelectedTextSize(@Px float size) { selectedTextSize = size; computeTextWidthAndHeight(); requestLayout(); invalidate(); } public boolean getSelectedTextBold() { return selectedTextBold; } public void setSelectedTextBold(boolean bold) { this.selectedTextBold = bold; computeTextWidthAndHeight(); requestLayout(); invalidate(); } @Px public int getItemSpace() { return itemSpace; } public void setItemSpace(@Px int space) { itemSpace = space; requestLayout(); invalidate(); } public boolean isIndicatorEnabled() { return indicatorEnabled; } public void setIndicatorEnabled(boolean indicatorEnabled) { this.indicatorEnabled = indicatorEnabled; computeIndicatorRect(); invalidate(); } @Px public float getIndicatorSize() { return indicatorSize; } public void setIndicatorSize(@Px float size) { indicatorSize = size; computeIndicatorRect(); invalidate(); } @ColorInt public int getIndicatorColor() { return indicatorColor; } public void setIndicatorColor(@ColorInt int color) { indicatorColor = color; invalidate(); } @Px public int getCurvedIndicatorSpace() { return curvedIndicatorSpace; } public void setCurvedIndicatorSpace(@Px int space) { curvedIndicatorSpace = space; computeIndicatorRect(); invalidate(); } public boolean isCurtainEnabled() { return curtainEnabled; } public void setCurtainEnabled(boolean curtainEnabled) { this.curtainEnabled = curtainEnabled; if (curtainEnabled) { indicatorEnabled = false; } computeCurrentItemRect(); invalidate(); } @ColorInt public int getCurtainColor() { return curtainColor; } public void setCurtainColor(@ColorInt int color) { curtainColor = 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; } public void setAtmosphericEnabled(boolean atmosphericEnabled) { this.atmosphericEnabled = atmosphericEnabled; invalidate(); } public boolean isCurvedEnabled() { return curvedEnabled; } public void setCurvedEnabled(boolean isCurved) { this.curvedEnabled = isCurved; requestLayout(); invalidate(); } public int getCurvedMaxAngle() { return curvedMaxAngle; } public void setCurvedMaxAngle(int curvedMaxAngle) { this.curvedMaxAngle = curvedMaxAngle; requestLayout(); invalidate(); } @ItemTextAlign public int getTextAlign() { return textAlign; } public void setTextAlign(@ItemTextAlign int align) { textAlign = align; updatePaintTextAlign(); computeDrawnCenterCoordinate(); invalidate(); } private void updatePaintTextAlign() { switch (textAlign) { case ItemTextAlign.LEFT: paint.setTextAlign(Paint.Align.LEFT); break; case ItemTextAlign.RIGHT: paint.setTextAlign(Paint.Align.RIGHT); break; case ItemTextAlign.CENTER: default: paint.setTextAlign(Paint.Align.CENTER); break; } } public Typeface getTypeface() { return paint.getTypeface(); } public void setTypeface(Typeface typeface) { if (typeface == null) { return; } paint.setTypeface(typeface); computeTextWidthAndHeight(); requestLayout(); invalidate(); } private void notifyDataSetChanged(int position) { position = Math.min(position, getItemCount() - 1); position = Math.max(position, 0); scrollOffsetYCoordinate = 0; defaultItem = getItem(position); defaultItemPosition = position; currentPosition = position; updatePaintTextAlign(); //当设置了选中项文字加大加粗,此处重新计算文字宽高的话滑动会导致其他条目错位 //computeTextWidthAndHeight(); computeFlingLimitYCoordinate(); computeIndicatorRect(); computeCurrentItemRect(); requestLayout(); invalidate(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int modeWidth = MeasureSpec.getMode(widthMeasureSpec); final int modeHeight = MeasureSpec.getMode(heightMeasureSpec); final int sizeWidth = MeasureSpec.getSize(widthMeasureSpec); final int sizeHeight = MeasureSpec.getSize(heightMeasureSpec); // Correct sizes of original content int resultWidth = textMaxWidth; int resultHeight = textMaxHeight * visibleItemCount + itemSpace * (visibleItemCount - 1); // Correct view sizes again if curved is enable if (curvedEnabled) { resultHeight = (int) (2 * resultHeight / Math.PI); } // Consideration padding influence the view sizes resultWidth += getPaddingLeft() + getPaddingRight(); resultHeight += getPaddingTop() + getPaddingBottom(); // Consideration sizes of parent can influence the view sizes resultWidth = measureSize(modeWidth, sizeWidth, resultWidth); resultHeight = measureSize(modeHeight, sizeHeight, resultHeight); setMeasuredDimension(resultWidth, resultHeight); } private int measureSize(int mode, int sizeExpect, int sizeActual) { int realSize; if (mode == MeasureSpec.EXACTLY) { realSize = sizeExpect; } else { realSize = sizeActual; if (mode == MeasureSpec.AT_MOST) { realSize = Math.min(realSize, sizeExpect); } } return realSize; } @Override protected void onSizeChanged(int w, int h, int ow, int oh) { // Set content region rectDrawn.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); // Get the center coordinates of content region wheelCenterXCoordinate = rectDrawn.centerX(); wheelCenterYCoordinate = rectDrawn.centerY(); // Correct item drawn center computeDrawnCenterCoordinate(); halfWheelHeight = rectDrawn.height() / 2; itemHeight = rectDrawn.height() / visibleItemCount; halfItemHeight = itemHeight / 2; // Initialize fling max Y-coordinates computeFlingLimitYCoordinate(); // Correct region of indicator computeIndicatorRect(); // Correct region of current select item computeCurrentItemRect(); } private void computeDrawnCenterCoordinate() { switch (textAlign) { case ItemTextAlign.LEFT: drawnCenterXCoordinate = rectDrawn.left; break; case ItemTextAlign.RIGHT: drawnCenterXCoordinate = rectDrawn.right; break; case ItemTextAlign.CENTER: default: drawnCenterXCoordinate = wheelCenterXCoordinate; break; } drawnCenterYCoordinate = (int) (wheelCenterYCoordinate - ((paint.ascent() + paint.descent()) / 2)); } private void computeFlingLimitYCoordinate() { int currentItemOffset = defaultItemPosition * itemHeight; minFlingYCoordinate = cyclicEnabled ? Integer.MIN_VALUE : -itemHeight * (getItemCount() - 1) + currentItemOffset; maxFlingYCoordinate = cyclicEnabled ? Integer.MAX_VALUE : currentItemOffset; } private void computeIndicatorRect() { if (!indicatorEnabled) { return; } int indicatorSpace = curvedEnabled ? curvedIndicatorSpace : 0; int halfIndicatorSize = (int) (indicatorSize / 2f); int indicatorHeadCenterYCoordinate = wheelCenterYCoordinate + halfItemHeight + indicatorSpace; int indicatorFootCenterYCoordinate = wheelCenterYCoordinate - halfItemHeight - indicatorSpace; rectIndicatorHead.set(rectDrawn.left, indicatorHeadCenterYCoordinate - halfIndicatorSize, rectDrawn.right, indicatorHeadCenterYCoordinate + halfIndicatorSize); rectIndicatorFoot.set(rectDrawn.left, indicatorFootCenterYCoordinate - halfIndicatorSize, rectDrawn.right, indicatorFootCenterYCoordinate + halfIndicatorSize); } private void computeCurrentItemRect() { if (!curtainEnabled && selectedTextColor == 0/* Color.TRANSPARENT */) { return; } rectCurrentItem.set(rectDrawn.left, wheelCenterYCoordinate - halfItemHeight, rectDrawn.right, wheelCenterYCoordinate + halfItemHeight); } @Override protected void onDraw(Canvas canvas) { if (null != onWheelChangedListener) { onWheelChangedListener.onWheelScrolled(this, scrollOffsetYCoordinate); } if (itemHeight - halfDrawnItemCount <= 0) { return; } drawCurtain(canvas); drawIndicator(canvas); drawAllItem(canvas); } private void drawAllItem(Canvas canvas) { int drawnDataStartPos = -1 * scrollOffsetYCoordinate / itemHeight - halfDrawnItemCount; for (int drawnDataPosition = drawnDataStartPos + defaultItemPosition, drawnOffsetPos = -1 * halfDrawnItemCount; drawnDataPosition < drawnDataStartPos + defaultItemPosition + drawnItemCount; drawnDataPosition++, drawnOffsetPos++) { initTextPaint(); boolean isCenterItem = drawnDataPosition == drawnDataStartPos + defaultItemPosition + drawnItemCount / 2; int drawnItemCenterYCoordinate = drawnCenterYCoordinate + (drawnOffsetPos * itemHeight) + scrollOffsetYCoordinate % itemHeight; int centerYCoordinateAbs = Math.abs(drawnCenterYCoordinate - drawnItemCenterYCoordinate); // Correct ratio of item's drawn center to wheel center float ratio = (drawnCenterYCoordinate - centerYCoordinateAbs - rectDrawn.top) * 1f / (drawnCenterYCoordinate - rectDrawn.top); float degree = computeDegree(drawnItemCenterYCoordinate, ratio); float distanceToCenter = computeYCoordinateAtAngle(degree); if (curvedEnabled) { int transXCoordinate = wheelCenterXCoordinate; switch (textAlign) { case ItemTextAlign.LEFT: transXCoordinate = rectDrawn.left; break; case ItemTextAlign.RIGHT: transXCoordinate = rectDrawn.right; break; case ItemTextAlign.CENTER: default: break; } float transYCoordinate = wheelCenterYCoordinate - distanceToCenter; camera.save(); camera.rotateX(degree); camera.getMatrix(matrixRotate); camera.restore(); matrixRotate.preTranslate(-transXCoordinate, -transYCoordinate); matrixRotate.postTranslate(transXCoordinate, transYCoordinate); camera.save(); camera.translate(0, 0, computeDepth(degree)); camera.getMatrix(matrixDepth); camera.restore(); matrixDepth.preTranslate(-transXCoordinate, -transYCoordinate); matrixDepth.postTranslate(transXCoordinate, transYCoordinate); matrixRotate.postConcat(matrixDepth); } computeAndSetAtmospheric(centerYCoordinateAbs); // Correct item's drawn center Y coordinate base on curved state float drawCenterYCoordinate = curvedEnabled ? drawnCenterYCoordinate - distanceToCenter : drawnItemCenterYCoordinate; drawItemRect(canvas, drawnDataPosition, isCenterItem, drawCenterYCoordinate); } } private void drawItemRect(Canvas canvas, int dataPosition, boolean isCenterItem, float drawCenterYCoordinate) { // Judges need to draw different color for current item or not if (selectedTextColor == 0/* Color.TRANSPARENT */) { //没有设置选中项颜色,绘制所有项 canvas.save(); canvas.clipRect(rectDrawn); if (curvedEnabled) { canvas.concat(matrixRotate); } drawItemText(canvas, dataPosition, drawCenterYCoordinate); canvas.restore(); return; } if (textSize == selectedTextSize && !selectedTextBold) { //没有设置选中项的加大加粗,绘制所有项 canvas.save(); if (curvedEnabled) { canvas.concat(matrixRotate); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { canvas.clipOutRect(rectCurrentItem); } else { canvas.clipRect(rectCurrentItem, Region.Op.DIFFERENCE); } drawItemText(canvas, dataPosition, drawCenterYCoordinate); canvas.restore(); paint.setColor(selectedTextColor); canvas.save(); if (curvedEnabled) { canvas.concat(matrixRotate); } canvas.clipRect(rectCurrentItem); drawItemText(canvas, dataPosition, drawCenterYCoordinate); canvas.restore(); return; } if (!isCenterItem) { // 绘制非选中项 canvas.save(); if (curvedEnabled) { canvas.concat(matrixRotate); } drawItemText(canvas, dataPosition, drawCenterYCoordinate); canvas.restore(); return; } // 绘制选中项 paint.setColor(selectedTextColor); paint.setTextSize(selectedTextSize); paint.setFakeBoldText(selectedTextBold); canvas.save(); if (curvedEnabled) { canvas.concat(matrixRotate); } drawItemText(canvas, dataPosition, drawCenterYCoordinate); canvas.restore(); } private void drawItemText(Canvas canvas, int dataPosition, float drawCenterYCoordinate) { boolean hasCut = false; String ellipsis = "..."; int measuredWidth = getMeasuredWidth(); float ellipsisWidth = paint.measureText(ellipsis); String data = obtainItemText(dataPosition); while (paint.measureText(data) + ellipsisWidth - measuredWidth > 0) { // 超出控件宽度则省略部分文字 int length = data.length(); if (length > 1) { data = data.substring(0, length - 1); hasCut = true; } else { break; } } if (hasCut) { data = data + ellipsis; } canvas.drawText(data, drawnCenterXCoordinate, drawCenterYCoordinate, paint); } private float computeDegree(int drawnItemCenterYCoordinate, float ratio) { // Correct unit int unit = 0; if (drawnItemCenterYCoordinate > drawnCenterYCoordinate) { unit = 1; } else if (drawnItemCenterYCoordinate < drawnCenterYCoordinate) { unit = -1; } return clamp((-(1 - ratio) * curvedMaxAngle * unit), -curvedMaxAngle, curvedMaxAngle); } private float clamp(float value, float min, float max) { if (value < min) { return min; } return Math.min(value, max); } private String obtainItemText(int drawnDataPosition) { String data = ""; final int itemCount = getItemCount(); if (cyclicEnabled) { if (itemCount != 0) { int actualPosition = drawnDataPosition % itemCount; actualPosition = actualPosition < 0 ? (actualPosition + itemCount) : actualPosition; data = formatItem(actualPosition); } } else { if (isPositionInRange(drawnDataPosition, itemCount)) { data = formatItem(drawnDataPosition); } } return data; } public String formatItem(int position) { return formatItem(getItem(position)); } public String formatItem(Object item) { if (item == null) { return ""; } if (item instanceof TextProvider) { return ((TextProvider) item).provideText(); } if (formatter != null) { return formatter.formatItem(item); } return item.toString(); } private void computeAndSetAtmospheric(int abs) { if (atmosphericEnabled) { int alpha = (int) ((drawnCenterYCoordinate - abs) * 1.0F / drawnCenterYCoordinate * 255); alpha = Math.max(alpha, 0); paint.setAlpha(alpha); } } private void drawCurtain(Canvas canvas) { // Need to draw curtain or not if (!curtainEnabled) { return; } paint.setColor(curtainColor); paint.setStyle(Paint.Style.FILL); if (curtainRadius > 0) { 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) { return; } paint.setColor(indicatorColor); paint.setStyle(Paint.Style.FILL); canvas.drawRect(rectIndicatorHead, paint); canvas.drawRect(rectIndicatorFoot, paint); } private boolean isPositionInRange(int position, int itemCount) { return position >= 0 && position < itemCount; } private float computeYCoordinateAtAngle(float degree) { // Compute y-coordinate for item at degree. return sinDegree(degree) / sinDegree(curvedMaxAngle) * halfWheelHeight; } private float sinDegree(float degree) { return (float) Math.sin(Math.toRadians(degree)); } private int computeDepth(float degree) { return (int) (halfWheelHeight - Math.cos(Math.toRadians(degree)) * halfWheelHeight); } @Override public boolean onTouchEvent(MotionEvent event) { if (isEnabled()) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: handleActionDown(event); break; case MotionEvent.ACTION_MOVE: handleActionMove(event); break; case MotionEvent.ACTION_UP: handleActionUp(event); break; case MotionEvent.ACTION_CANCEL: handleActionCancel(event); break; default: break; } } if (isClick) { //onTouchEvent should call performClick when a click is detected performClick(); } return true; } private void handleActionDown(MotionEvent event) { if (null != getParent()) { getParent().requestDisallowInterceptTouchEvent(true); } obtainOrClearTracker(); tracker.addMovement(event); if (!scroller.isFinished()) { scroller.abortAnimation(); isForceFinishScroll = true; } downPointYCoordinate = lastPointYCoordinate = (int) event.getY(); } private void handleActionMove(MotionEvent event) { int endPoint = computeDistanceToEndPoint(scroller.getFinalY() % itemHeight); if (Math.abs(downPointYCoordinate - event.getY()) < touchSlop && endPoint > 0) { isClick = true; return; } isClick = false; if (null != tracker) { tracker.addMovement(event); } if (null != onWheelChangedListener) { onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.DRAGGING); } // Scroll WheelPicker's content float move = event.getY() - lastPointYCoordinate; if (Math.abs(move) < 1) { return; } // Scroll limit float topLimit = (defaultItemPosition) * itemHeight; float bottomLimit = -(getItemCount() - 1 - defaultItemPosition) * itemHeight; boolean disableScrollTop = scrollOffsetYCoordinate >=topLimit && move > 0; boolean disableScrollBottom = scrollOffsetYCoordinate <= bottomLimit && move < 0; if(!cyclicEnabled) { if(!disableScrollBottom && !disableScrollTop) { scrollOffsetYCoordinate += move; } }else { scrollOffsetYCoordinate += move; } // lastPointYCoordinate = (int) event.getY(); invalidate(); } private void handleActionUp(MotionEvent event) { if (null != getParent()) { getParent().requestDisallowInterceptTouchEvent(false); } if (isClick) { return; } int yVelocity = 0; if (null != tracker) { tracker.addMovement(event); tracker.computeCurrentVelocity(1000, maximumVelocity); yVelocity = (int) tracker.getYVelocity(); } // Judge scroll or fling base on current velocity isForceFinishScroll = false; if (Math.abs(yVelocity) > minimumVelocity) { scroller.fling(0, scrollOffsetYCoordinate, 0, yVelocity, 0, 0, minFlingYCoordinate, maxFlingYCoordinate); int endPoint = computeDistanceToEndPoint(scroller.getFinalY() % itemHeight); scroller.setFinalY(scroller.getFinalY() + endPoint); } else { int endPoint = computeDistanceToEndPoint(scrollOffsetYCoordinate % itemHeight); scroller.startScroll(0, scrollOffsetYCoordinate, 0, endPoint); } // Correct coordinates if (!cyclicEnabled) { if (scroller.getFinalY() > maxFlingYCoordinate) { scroller.setFinalY(maxFlingYCoordinate); } else if (scroller.getFinalY() < minFlingYCoordinate) { scroller.setFinalY(minFlingYCoordinate); } } handler.post(this); cancelTracker(); } private void handleActionCancel(MotionEvent event) { if (null != getParent()) { getParent().requestDisallowInterceptTouchEvent(false); } cancelTracker(); } private void obtainOrClearTracker() { if (null == tracker) { tracker = VelocityTracker.obtain(); } else { tracker.clear(); } } private void cancelTracker() { if (null != tracker) { tracker.recycle(); tracker = null; } } @Override public boolean performClick() { return super.performClick(); } private int computeDistanceToEndPoint(int remainder) { if (Math.abs(remainder) > halfItemHeight) { if (scrollOffsetYCoordinate < 0) { return -itemHeight - remainder; } else { return itemHeight - remainder; } } else { return -1 * remainder; } } @Override public void run() { if (itemHeight == 0) { return; } int itemCount = getItemCount(); if (itemCount == 0) { if (null != onWheelChangedListener) { onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.IDLE); } return; } if (scroller.isFinished() && !isForceFinishScroll) { int position = computePosition(itemCount); position = position < 0 ? position + itemCount : position; currentPosition = position; if (null != onWheelChangedListener) { onWheelChangedListener.onWheelSelected(this, position); onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.IDLE); } postInvalidate(); return; } // Scroll not finished if (scroller.computeScrollOffset()) { if (null != onWheelChangedListener) { onWheelChangedListener.onWheelScrollStateChanged(this, ScrollState.SCROLLING); } scrollOffsetYCoordinate = scroller.getCurrY(); int position = computePosition(itemCount); if (lastScrollPosition != position) { if (position == 0 && lastScrollPosition == itemCount - 1) { if (null != onWheelChangedListener) { onWheelChangedListener.onWheelLoopFinished(this); } } lastScrollPosition = position; } postInvalidate(); handler.postDelayed(this, 20); } } private int computePosition(int itemCount) { return (-1 * scrollOffsetYCoordinate / itemHeight + defaultItemPosition) % itemCount; } public void scrollTo(final int position) { post(new Runnable() { @Override public void run() { notifyDataSetChanged(position); } }); } public final void smoothScrollTo(final int position) { if (isInEditMode()) { scrollTo(position); return; } int differencesLines = currentPosition - position; int newScrollOffsetYCoordinate = scrollOffsetYCoordinate + (differencesLines * itemHeight); ValueAnimator animator = ValueAnimator.ofInt(scrollOffsetYCoordinate, newScrollOffsetYCoordinate); animator.setDuration(300); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scrollOffsetYCoordinate = (int) animation.getAnimatedValue(); invalidate(); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { scrollTo(position); } }); animator.start(); } } ================================================ FILE: WheelView/src/main/res/values/wheel_attrs.xml ================================================ ================================================ FILE: WheelView/src/main/res/values/wheel_styles.xml ================================================ ================================================ FILE: _config.yml ================================================ theme: jekyll-theme-merlot ================================================ FILE: app/build.gradle ================================================ /* * 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. */ apply from: "${rootDir}/gradle/app.gradle" dependencies { implementation androidxLibrary.multidex implementation androidxLibrary.appcompat implementation library.material implementation project(':Common') implementation project(':WheelView') implementation project(':WheelPicker') implementation project(':AddressPicker') implementation project(':ColorPicker') implementation project(':FilePicker') implementation project(':CalendarPicker') implementation project(':ImagePicker') debugRuntimeOnly library.orhanobut_logger debugRuntimeOnly library.xcrash compileOnly library.xcrash } android { defaultConfig { //应用的实际包名 applicationId "com.github.gzuliyujiang.demo.picker" // 配合 productFlavors 节点按不同维度打包 flavorDimensions "MODE" // 修改 AndroidManifest.xml 里的变量,占位值无法覆盖的坑可参阅 https://www.jianshu.com/p/1d5271c2c366 manifestPlaceholders = [ MY_CHANNEL: "unknown", ] } // 打包维度列表,会按维度名字母顺序执行,最终发布的具体渠道包的生成可以借助360加固等工具 productFlavors { // 发布模式/正式环境 pub { dimension "MODE" // 服务端接口地址 buildConfigField "String", "API_BASE_URL", '"https://api.example.com"' // 修改 AndroidManifest.xml 里的变量 manifestPlaceholders = [ MY_CHANNEL: "publisher-default", ] } // 开发模式/测试环境 dev { dimension "MODE" // 服务端接口地址 buildConfigField "String", "API_BASE_URL", '"https://test.example.com"' // 修改 AndroidManifest.xml 里的变量 manifestPlaceholders = [ MY_CHANNEL: "developer-default", ] } } } ================================================ FILE: app/gradle.properties ================================================ # # 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. # signingStoreFile=app/debug.keystore signingStorePassword=android signingKeyAlias=androiddebugkey signingKeyPassword=android ================================================ FILE: app/proguard-common.pro ================================================ #################################################################################################### # 系统通用混淆配置,参见 android-sdk/tools/proguard/proguard-android-optimize.txt #################################################################################################### # ProGuard的介绍以及参数说明,参阅 https://blog.csdn.net/hibit521/article/details/79709659 # -keep 指定需要被保留的类和成员。 # -keepclassmembers 指定需要被保留的类成员,如果他们的类也有被保留。如保留一个序列化类中的所有成员和方法 # -keepclasseswithmembers 指定保留那些含有指定类成员的类,如保留所有包含main方法的类 # -keepnames 指定那些需要被保留名字的类和类成员,如保留那些实现了Serializable接口的类的名字 # -keepclassmembernames 指定那些希望被保留的类成员的名字 # -keepclasseswithmembernames 保留含有指定名字的类和类成员。 # class可以指向任何接口或类。interface只能指向接口,enum只能指向枚举 # 接口或者枚举前面的!表示相对应的非枚举或者接口 # 每个类都必须是全路径指定或者由?、*、**这三个通配符指定 # 类通配符:?任意匹配类名中的一个字符,但是不匹配包名分隔符 # 类通配符:*匹配类名的任何部分除了包名分隔符 # 类通配符:**匹配所有类名的所有部分,包括报名分隔符 # 匹配任何构造函数,匹配任何域,匹配任何方法,*匹配任何方法和域 # 方法和域通配符:?任意匹配方法名中的单个字符,*匹配方法命中的任意部分 # 数据类型通配符:%匹配任何原生类型,?任意匹配单个字符,*匹配类名的任何部分除了包名分隔符 # 数据类型通配符:**匹配所有类名的所有部分,包括报名分隔符,***匹配任何类型,…匹配任意参数个数 #################################################################################################### -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* # 谷歌推荐的混淆算法及过滤器,一般不做更改 -allowaccessmodification # 混淆时是否允许改变作用域 -optimizationpasses 5 # 指定代码的压缩级别 -ignorewarnings # 忽略警告 -verbose # 混淆时是否记录日志(混淆后生产映射文件,包含有类名->混淆后类名的映射关系) -dontpreverify # 不做预校验,preverify是混淆步骤之一,Android不需要preverify,去掉以便加快混淆速度。 #-dontoptimize # 不优化输入的类文件,需要优化才能过滤代码中的日志 #-dontshrink # 不启用压缩,需要压缩才能移除未用到的资源 -dontusemixedcaseclassnames # 混淆时不使用大小写混合,混淆后的类名为小写 -dontskipnonpubliclibraryclasses # 指定不去忽略非公共库的类 -dontskipnonpubliclibraryclassmembers # 指定不去忽略非公共库的类成员 -printseeds proguard/seeds.txt # 未混淆的类和成员 -printusage proguard/unused.txt # 列出从 apk 中删除的代码 -printmapping proguard/mapping.txt # 混淆前后的映射 #-printconfiguration proguard/configuration.txt # 混淆规则融合 -keepattributes Exceptions # 保留异常类 -keepattributes InnerClasses # 保留匿名内部类 -keepattributes SourceFile,LineNumberTable # 保留代码行号 -renamesourcefileattribute SourceFile -keepattributes Signature,EnclosingMethod #保留泛型与反射 # 不混淆注解 -keepattributes *Annotation* -keep class * extends java.lang.annotation.Annotation { *; } -keep interface * extends java.lang.annotation.Annotation { *; } # 不混淆明确通过`@Keep`注解标记的类、方法或属性 -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclasseswithmembers class * { @android.support.annotation.Keep ; } -keepclasseswithmembers class * { @android.support.annotation.Keep ; } -keepclasseswithmembers class * { @android.support.annotation.Keep (...); } -keep class androidx.annotation.Keep -keep @androidx.annotation.Keep class * {*;} -keepclasseswithmembers class * { @androidx.annotation.Keep (...); } -keepclasseswithmembers class * { @androidx.annotation.Keep ; } -keepclasseswithmembers class * { @androidx.annotation.Keep ; } # 不混淆继承自安卓的四大组件的类名 -keep public class * extends android.app.Fragment -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Dialog -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keep public class com.android.vending.licensing.ILicensingService -keep public class com.google.vending.licensing.ILicensingService -keep public class * extends android.view.View -keep public class * extends com.android.layoutlib.bridge.MockView -keep public class * extends androidx.fragment.app.Fragment # 不混淆布局文件中为控件配置的onClick方法 -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # 不混淆C/C++底层库暴露的方法 # see http://proguard.sourceforge.net/manual/examples.html#native -keepclasseswithmembernames class * { native ; } # 不混淆所有View的子类及其子类的get、set方法 # see http://proguard.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } -keep public class * extends android.view.View { *** get*(); void set*(***); public (android.content.Context); public (android.content.Context, android.util.AttributeSet); public (android.content.Context, android.util.AttributeSet, int); } # 不混淆资源索引类,以便通过资源名称获取资源 -keep class **.R$* -keepclassmembers class **.R$* { public static ; } # 不混淆构建配置类,以便通过反射字段获取值 -keep class **.BuildConfig -keepclassmembers class **.BuildConfig { public static ; } # 不混淆带有回调函数的**Event、**Listener -keepclassmembers class * { void *(**Event); void *(**Listener); void gt**; } # 不混淆JS于Java的交互桥梁 -keepattributes *JavascriptInterface* # 如果你的项目中用到了WebView的复杂操作 ,最好加入,对WebView简单说明下: # 经过实战检验,做腾讯QQ登录,如果引用他们提供的jar,若不加防止WebChromeClient混淆的代码,OAuth认证无法回调, # 反编译代码后可看到他们有用到WebChromeClient。 -keepclassmembers class * extends android.webkit.WebViewClient { public void *(android.webkit.WebView,java.lang.String,android.graphics.Bitmap); public boolean *(android.webkit.WebView,java.lang.String); } -keepclassmembers class * extends android.webkit.WebChromeClient { public void *(android.webkit.WebView,java.lang.String); } -keep public class * extends android.webkit.WebView # 不混淆枚举类 -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } # 不混淆实体类,需要通过JSON进行序列化和反序列化的类(注: Java反射用到的类也不能被混淆) -keep class * implements android.os.Parcelable { *; } -keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator CREATOR; } -keepnames class * implements java.io.Serializable -keep public class * implements java.io.Serializable { public *; } -keep public class * implements java.io.Serializable { public *; } -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; !static !transient ; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } -keepclassmembers class * { public (org.json.JSONObject); } # 不混淆AndroidX及Material,以便使用反射进行破解 -dontwarn android.support.** -dontwarn androidx.** -dontwarn com.google.android.material.** -keep class androidx.** {*;} -keep public class * extends androidx.** -keep interface androidx.** {*;} -keep class android.support.** {*;} -keep public class * extends android.support.** -keep interface android.support.** {*;} -keep class com.google.android.material.** {*;} # XML映射问题,一些控件无法Inflate -keep class org.xmlpull.v1.** {*;} # 删除控制台日志打印 -assumenosideeffects class android.util.Log { public static boolean isLoggable(java.lang.String, int); public static int v(...); public static int i(...); public static int w(...); public static int d(...); public static int e(...); } -assumenosideeffects class java.io.PrintStream { public *** println(...); public *** print(...); } # okhttp3 -dontwarn okhttp3.** -dontwarn okio.** -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase ================================================ FILE: app/proguard-rules.pro ================================================ ################# #项目自定义混淆配置 ################# ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/assets/china_address_guizhou.json ================================================ [ { "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" } ] } ] } ] ================================================ FILE: app/src/main/assets/china_address_guizhou_city.json ================================================ [ { "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": [] } ] } ] ================================================ FILE: app/src/main/assets/city.json ================================================ [ { "id": "1", "name": "北京市", "code": "110000", "deep": "1", "pid": "0", "city": [ { "id": "2", "name": "北京市市辖区", "code": "110100", "deep": "2", "pid": "1", "area": [ { "id": "3", "name": "东城区", "code": "110101", "deep": "3", "pid": "2" }, { "id": "4", "name": "西城区", "code": "110102", "deep": "3", "pid": "2" }, { "id": "5", "name": "朝阳区", "code": "110105", "deep": "3", "pid": "2" }, { "id": "6", "name": "丰台区", "code": "110106", "deep": "3", "pid": "2" }, { "id": "7", "name": "石景山区", "code": "110107", "deep": "3", "pid": "2" }, { "id": "8", "name": "海淀区", "code": "110108", "deep": "3", "pid": "2" }, { "id": "9", "name": "门头沟区", "code": "110109", "deep": "3", "pid": "2" }, { "id": "10", "name": "房山区", "code": "110111", "deep": "3", "pid": "2" }, { "id": "11", "name": "通州区", "code": "110112", "deep": "3", "pid": "2" }, { "id": "12", "name": "顺义区", "code": "110113", "deep": "3", "pid": "2" }, { "id": "13", "name": "昌平区", "code": "110114", "deep": "3", "pid": "2" }, { "id": "14", "name": "大兴区", "code": "110115", "deep": "3", "pid": "2" }, { "id": "15", "name": "怀柔区", "code": "110116", "deep": "3", "pid": "2" }, { "id": "16", "name": "平谷区", "code": "110117", "deep": "3", "pid": "2" }, { "id": "17", "name": "密云区", "code": "110118", "deep": "3", "pid": "2" }, { "id": "18", "name": "延庆区", "code": "110119", "deep": "3", "pid": "2" } ] } ] }, { "id": "19", "name": "天津市", "code": "120000", "deep": "1", "pid": "0", "city": [ { "id": "20", "name": "天津市市辖区", "code": "120100", "deep": "2", "pid": "19", "area": [ { "id": "21", "name": "和平区", "code": "120101", "deep": "3", "pid": "20" }, { "id": "22", "name": "河东区", "code": "120102", "deep": "3", "pid": "20" }, { "id": "23", "name": "河西区", "code": "120103", "deep": "3", "pid": "20" }, { "id": "24", "name": "南开区", "code": "120104", "deep": "3", "pid": "20" }, { "id": "25", "name": "河北区", "code": "120105", "deep": "3", "pid": "20" }, { "id": "26", "name": "红桥区", "code": "120106", "deep": "3", "pid": "20" }, { "id": "27", "name": "东丽区", "code": "120110", "deep": "3", "pid": "20" }, { "id": "28", "name": "西青区", "code": "120111", "deep": "3", "pid": "20" }, { "id": "29", "name": "津南区", "code": "120112", "deep": "3", "pid": "20" }, { "id": "30", "name": "北辰区", "code": "120113", "deep": "3", "pid": "20" }, { "id": "31", "name": "武清区", "code": "120114", "deep": "3", "pid": "20" }, { "id": "32", "name": "宝坻区", "code": "120115", "deep": "3", "pid": "20" }, { "id": "33", "name": "滨海新区", "code": "120116", "deep": "3", "pid": "20" }, { "id": "34", "name": "宁河区", "code": "120117", "deep": "3", "pid": "20" }, { "id": "35", "name": "静海区", "code": "120118", "deep": "3", "pid": "20" }, { "id": "36", "name": "蓟县", "code": "120225", "deep": "3", "pid": "20" }, { "id": "3260", "name": "蓟州区", "code": "120119", "deep": "3", "pid": "20" } ] }, { "id": "37", "name": "天津市郊县", "code": "120200", "deep": "2", "pid": "19" } ] }, { "id": "38", "name": "河北省", "code": "130000", "deep": "1", "pid": "0", "city": [ { "id": "39", "name": "石家庄市", "code": "130100", "deep": "2", "pid": "38", "area": [ { "id": "40", "name": "长安区", "code": "130102", "deep": "3", "pid": "39" }, { "id": "41", "name": "桥西区", "code": "130104", "deep": "3", "pid": "39" }, { "id": "42", "name": "新华区", "code": "130105", "deep": "3", "pid": "39" }, { "id": "43", "name": "井陉矿区", "code": "130107", "deep": "3", "pid": "39" }, { "id": "44", "name": "裕华区", "code": "130108", "deep": "3", "pid": "39" }, { "id": "45", "name": "藁城区", "code": "130109", "deep": "3", "pid": "39" }, { "id": "46", "name": "鹿泉区", "code": "130110", "deep": "3", "pid": "39" }, { "id": "47", "name": "栾城区", "code": "130111", "deep": "3", "pid": "39" }, { "id": "48", "name": "井陉县", "code": "130121", "deep": "3", "pid": "39" }, { "id": "49", "name": "正定县", "code": "130123", "deep": "3", "pid": "39" }, { "id": "50", "name": "行唐县", "code": "130125", "deep": "3", "pid": "39" }, { "id": "51", "name": "灵寿县", "code": "130126", "deep": "3", "pid": "39" }, { "id": "52", "name": "高邑县", "code": "130127", "deep": "3", "pid": "39" }, { "id": "53", "name": "深泽县", "code": "130128", "deep": "3", "pid": "39" }, { "id": "54", "name": "赞皇县", "code": "130129", "deep": "3", "pid": "39" }, { "id": "55", "name": "无极县", "code": "130130", "deep": "3", "pid": "39" }, { "id": "56", "name": "平山县", "code": "130131", "deep": "3", "pid": "39" }, { "id": "57", "name": "元氏县", "code": "130132", "deep": "3", "pid": "39" }, { "id": "58", "name": "赵县", "code": "130133", "deep": "3", "pid": "39" }, { "id": "59", "name": "辛集市", "code": "130181", "deep": "3", "pid": "39" }, { "id": "60", "name": "晋州市", "code": "130183", "deep": "3", "pid": "39" }, { "id": "61", "name": "新乐市", "code": "130184", "deep": "3", "pid": "39" } ] }, { "id": "62", "name": "唐山市", "code": "130200", "deep": "2", "pid": "38", "area": [ { "id": "63", "name": "路南区", "code": "130202", "deep": "3", "pid": "62" }, { "id": "64", "name": "路北区", "code": "130203", "deep": "3", "pid": "62" }, { "id": "65", "name": "古冶区", "code": "130204", "deep": "3", "pid": "62" }, { "id": "66", "name": "开平区", "code": "130205", "deep": "3", "pid": "62" }, { "id": "67", "name": "丰南区", "code": "130207", "deep": "3", "pid": "62" }, { "id": "68", "name": "丰润区", "code": "130208", "deep": "3", "pid": "62" }, { "id": "69", "name": "曹妃甸区", "code": "130209", "deep": "3", "pid": "62" }, { "id": "70", "name": "滦县", "code": "130223", "deep": "3", "pid": "62" }, { "id": "71", "name": "滦南县", "code": "130224", "deep": "3", "pid": "62" }, { "id": "72", "name": "乐亭县", "code": "130225", "deep": "3", "pid": "62" }, { "id": "73", "name": "迁西县", "code": "130227", "deep": "3", "pid": "62" }, { "id": "74", "name": "玉田县", "code": "130229", "deep": "3", "pid": "62" }, { "id": "75", "name": "遵化市", "code": "130281", "deep": "3", "pid": "62" }, { "id": "76", "name": "迁安市", "code": "130283", "deep": "3", "pid": "62" } ] }, { "id": "77", "name": "秦皇岛市", "code": "130300", "deep": "2", "pid": "38", "area": [ { "id": "78", "name": "海港区", "code": "130302", "deep": "3", "pid": "77" }, { "id": "79", "name": "山海关区", "code": "130303", "deep": "3", "pid": "77" }, { "id": "80", "name": "北戴河区", "code": "130304", "deep": "3", "pid": "77" }, { "id": "81", "name": "抚宁区", "code": "130306", "deep": "3", "pid": "77" }, { "id": "82", "name": "青龙满族自治县", "code": "130321", "deep": "3", "pid": "77" }, { "id": "83", "name": "昌黎县", "code": "130322", "deep": "3", "pid": "77" }, { "id": "84", "name": "卢龙县", "code": "130324", "deep": "3", "pid": "77" } ] }, { "id": "85", "name": "邯郸市", "code": "130400", "deep": "2", "pid": "38", "area": [ { "id": "86", "name": "邯山区", "code": "130402", "deep": "3", "pid": "85" }, { "id": "87", "name": "丛台区", "code": "130403", "deep": "3", "pid": "85" }, { "id": "88", "name": "复兴区", "code": "130404", "deep": "3", "pid": "85" }, { "id": "89", "name": "峰峰矿区", "code": "130406", "deep": "3", "pid": "85" }, { "id": "90", "name": "邯郸县", "code": "130421", "deep": "3", "pid": "85" }, { "id": "91", "name": "临漳县", "code": "130423", "deep": "3", "pid": "85" }, { "id": "92", "name": "成安县", "code": "130424", "deep": "3", "pid": "85" }, { "id": "93", "name": "大名县", "code": "130425", "deep": "3", "pid": "85" }, { "id": "94", "name": "涉县", "code": "130426", "deep": "3", "pid": "85" }, { "id": "95", "name": "磁县", "code": "130427", "deep": "3", "pid": "85" }, { "id": "96", "name": "肥乡县", "code": "130428", "deep": "3", "pid": "85" }, { "id": "97", "name": "永年区", "code": "130429", "deep": "3", "pid": "85" }, { "id": "98", "name": "邱县", "code": "130430", "deep": "3", "pid": "85" }, { "id": "99", "name": "鸡泽县", "code": "130431", "deep": "3", "pid": "85" }, { "id": "100", "name": "广平县", "code": "130432", "deep": "3", "pid": "85" }, { "id": "101", "name": "馆陶县", "code": "130433", "deep": "3", "pid": "85" }, { "id": "102", "name": "魏县", "code": "130434", "deep": "3", "pid": "85" }, { "id": "103", "name": "曲周县", "code": "130435", "deep": "3", "pid": "85" }, { "id": "104", "name": "武安市", "code": "130481", "deep": "3", "pid": "85" }, { "id": "3261", "name": "肥乡区", "code": "130407", "deep": "3", "pid": "85" } ] }, { "id": "105", "name": "邢台市", "code": "130500", "deep": "2", "pid": "38", "area": [ { "id": "106", "name": "桥东区", "code": "130502", "deep": "3", "pid": "105" }, { "id": "107", "name": "桥西区", "code": "130503", "deep": "3", "pid": "105" }, { "id": "108", "name": "邢台县", "code": "130521", "deep": "3", "pid": "105" }, { "id": "109", "name": "临城县", "code": "130522", "deep": "3", "pid": "105" }, { "id": "110", "name": "内丘县", "code": "130523", "deep": "3", "pid": "105" }, { "id": "111", "name": "柏乡县", "code": "130524", "deep": "3", "pid": "105" }, { "id": "112", "name": "隆尧县", "code": "130525", "deep": "3", "pid": "105" }, { "id": "113", "name": "任县", "code": "130526", "deep": "3", "pid": "105" }, { "id": "114", "name": "南和县", "code": "130527", "deep": "3", "pid": "105" }, { "id": "115", "name": "宁晋县", "code": "130528", "deep": "3", "pid": "105" }, { "id": "116", "name": "巨鹿县", "code": "130529", "deep": "3", "pid": "105" }, { "id": "117", "name": "新河县", "code": "130530", "deep": "3", "pid": "105" }, { "id": "118", "name": "广宗县", "code": "130531", "deep": "3", "pid": "105" }, { "id": "119", "name": "平乡县", "code": "130532", "deep": "3", "pid": "105" }, { "id": "120", "name": "威县", "code": "130533", "deep": "3", "pid": "105" }, { "id": "121", "name": "清河县", "code": "130534", "deep": "3", "pid": "105" }, { "id": "122", "name": "临西县", "code": "130535", "deep": "3", "pid": "105" }, { "id": "123", "name": "南宫市", "code": "130581", "deep": "3", "pid": "105" }, { "id": "124", "name": "沙河市", "code": "130582", "deep": "3", "pid": "105" } ] }, { "id": "125", "name": "保定市", "code": "130600", "deep": "2", "pid": "38", "area": [ { "id": "126", "name": "竞秀区", "code": "130602", "deep": "3", "pid": "125" }, { "id": "127", "name": "莲池区", "code": "130606", "deep": "3", "pid": "125" }, { "id": "128", "name": "满城区", "code": "130607", "deep": "3", "pid": "125" }, { "id": "129", "name": "清苑区", "code": "130608", "deep": "3", "pid": "125" }, { "id": "130", "name": "徐水区", "code": "130609", "deep": "3", "pid": "125" }, { "id": "131", "name": "涞水县", "code": "130623", "deep": "3", "pid": "125" }, { "id": "132", "name": "阜平县", "code": "130624", "deep": "3", "pid": "125" }, { "id": "133", "name": "定兴县", "code": "130626", "deep": "3", "pid": "125" }, { "id": "134", "name": "唐县", "code": "130627", "deep": "3", "pid": "125" }, { "id": "135", "name": "高阳县", "code": "130628", "deep": "3", "pid": "125" }, { "id": "136", "name": "容城县", "code": "130629", "deep": "3", "pid": "125" }, { "id": "137", "name": "涞源县", "code": "130630", "deep": "3", "pid": "125" }, { "id": "138", "name": "望都县", "code": "130631", "deep": "3", "pid": "125" }, { "id": "139", "name": "安新县", "code": "130632", "deep": "3", "pid": "125" }, { "id": "140", "name": "易县", "code": "130633", "deep": "3", "pid": "125" }, { "id": "141", "name": "曲阳县", "code": "130634", "deep": "3", "pid": "125" }, { "id": "142", "name": "蠡县", "code": "130635", "deep": "3", "pid": "125" }, { "id": "143", "name": "顺平县", "code": "130636", "deep": "3", "pid": "125" }, { "id": "144", "name": "博野县", "code": "130637", "deep": "3", "pid": "125" }, { "id": "145", "name": "雄县", "code": "130638", "deep": "3", "pid": "125" }, { "id": "146", "name": "涿州市", "code": "130681", "deep": "3", "pid": "125" }, { "id": "147", "name": "定州市", "code": "130682", "deep": "3", "pid": "125" }, { "id": "148", "name": "安国市", "code": "130683", "deep": "3", "pid": "125" }, { "id": "149", "name": "高碑店市", "code": "130684", "deep": "3", "pid": "125" } ] }, { "id": "150", "name": "张家口市", "code": "130700", "deep": "2", "pid": "38", "area": [ { "id": "151", "name": "桥东区", "code": "130702", "deep": "3", "pid": "150" }, { "id": "152", "name": "桥西区", "code": "130703", "deep": "3", "pid": "150" }, { "id": "153", "name": "宣化区", "code": "130705", "deep": "3", "pid": "150" }, { "id": "154", "name": "下花园区", "code": "130706", "deep": "3", "pid": "150" }, { "id": "155", "name": "宣化县", "code": "130721", "deep": "3", "pid": "150" }, { "id": "156", "name": "张北县", "code": "130722", "deep": "3", "pid": "150" }, { "id": "157", "name": "康保县", "code": "130723", "deep": "3", "pid": "150" }, { "id": "158", "name": "沽源县", "code": "130724", "deep": "3", "pid": "150" }, { "id": "159", "name": "尚义县", "code": "130725", "deep": "3", "pid": "150" }, { "id": "160", "name": "蔚县", "code": "130726", "deep": "3", "pid": "150" }, { "id": "161", "name": "阳原县", "code": "130727", "deep": "3", "pid": "150" }, { "id": "162", "name": "怀安县", "code": "130728", "deep": "3", "pid": "150" }, { "id": "163", "name": "万全区", "code": "130708", "deep": "3", "pid": "150" }, { "id": "164", "name": "怀来县", "code": "130730", "deep": "3", "pid": "150" }, { "id": "165", "name": "涿鹿县", "code": "130731", "deep": "3", "pid": "150" }, { "id": "166", "name": "赤城县", "code": "130732", "deep": "3", "pid": "150" }, { "id": "167", "name": "崇礼区", "code": "130709", "deep": "3", "pid": "150" } ] }, { "id": "168", "name": "承德市", "code": "130800", "deep": "2", "pid": "38", "area": [ { "id": "169", "name": "双桥区", "code": "130802", "deep": "3", "pid": "168" }, { "id": "170", "name": "双滦区", "code": "130803", "deep": "3", "pid": "168" }, { "id": "171", "name": "鹰手营子矿区", "code": "130804", "deep": "3", "pid": "168" }, { "id": "172", "name": "承德县", "code": "130821", "deep": "3", "pid": "168" }, { "id": "173", "name": "兴隆县", "code": "130822", "deep": "3", "pid": "168" }, { "id": "174", "name": "平泉市", "code": "130881", "deep": "3", "pid": "168" }, { "id": "175", "name": "滦平县", "code": "130824", "deep": "3", "pid": "168" }, { "id": "176", "name": "隆化县", "code": "130825", "deep": "3", "pid": "168" }, { "id": "177", "name": "丰宁满族自治县", "code": "130826", "deep": "3", "pid": "168" }, { "id": "178", "name": "宽城满族自治县", "code": "130827", "deep": "3", "pid": "168" }, { "id": "179", "name": "围场满族蒙古族自治县", "code": "130828", "deep": "3", "pid": "168" }, { "id": "3377", "name": "平泉县", "code": "130823", "deep": "3", "pid": "168" } ] }, { "id": "180", "name": "沧州市", "code": "130900", "deep": "2", "pid": "38", "area": [ { "id": "181", "name": "新华区", "code": "130902", "deep": "3", "pid": "180" }, { "id": "182", "name": "运河区", "code": "130903", "deep": "3", "pid": "180" }, { "id": "183", "name": "沧县", "code": "130921", "deep": "3", "pid": "180" }, { "id": "184", "name": "青县", "code": "130922", "deep": "3", "pid": "180" }, { "id": "185", "name": "东光县", "code": "130923", "deep": "3", "pid": "180" }, { "id": "186", "name": "海兴县", "code": "130924", "deep": "3", "pid": "180" }, { "id": "187", "name": "盐山县", "code": "130925", "deep": "3", "pid": "180" }, { "id": "188", "name": "肃宁县", "code": "130926", "deep": "3", "pid": "180" }, { "id": "189", "name": "南皮县", "code": "130927", "deep": "3", "pid": "180" }, { "id": "190", "name": "吴桥县", "code": "130928", "deep": "3", "pid": "180" }, { "id": "191", "name": "献县", "code": "130929", "deep": "3", "pid": "180" }, { "id": "192", "name": "孟村回族自治县", "code": "130930", "deep": "3", "pid": "180" }, { "id": "193", "name": "泊头市", "code": "130981", "deep": "3", "pid": "180" }, { "id": "194", "name": "任丘市", "code": "130982", "deep": "3", "pid": "180" }, { "id": "195", "name": "黄骅市", "code": "130983", "deep": "3", "pid": "180" }, { "id": "196", "name": "河间市", "code": "130984", "deep": "3", "pid": "180" } ] }, { "id": "197", "name": "廊坊市", "code": "131000", "deep": "2", "pid": "38", "area": [ { "id": "198", "name": "安次区", "code": "131002", "deep": "3", "pid": "197" }, { "id": "199", "name": "广阳区", "code": "131003", "deep": "3", "pid": "197" }, { "id": "200", "name": "固安县", "code": "131022", "deep": "3", "pid": "197" }, { "id": "201", "name": "永清县", "code": "131023", "deep": "3", "pid": "197" }, { "id": "202", "name": "香河县", "code": "131024", "deep": "3", "pid": "197" }, { "id": "203", "name": "大城县", "code": "131025", "deep": "3", "pid": "197" }, { "id": "204", "name": "文安县", "code": "131026", "deep": "3", "pid": "197" }, { "id": "205", "name": "大厂回族自治县", "code": "131028", "deep": "3", "pid": "197" }, { "id": "206", "name": "霸州市", "code": "131081", "deep": "3", "pid": "197" }, { "id": "207", "name": "三河市", "code": "131082", "deep": "3", "pid": "197" } ] }, { "id": "208", "name": "衡水市", "code": "131100", "deep": "2", "pid": "38", "area": [ { "id": "209", "name": "桃城区", "code": "131102", "deep": "3", "pid": "208" }, { "id": "210", "name": "枣强县", "code": "131121", "deep": "3", "pid": "208" }, { "id": "211", "name": "武邑县", "code": "131122", "deep": "3", "pid": "208" }, { "id": "212", "name": "武强县", "code": "131123", "deep": "3", "pid": "208" }, { "id": "213", "name": "饶阳县", "code": "131124", "deep": "3", "pid": "208" }, { "id": "214", "name": "安平县", "code": "131125", "deep": "3", "pid": "208" }, { "id": "215", "name": "故城县", "code": "131126", "deep": "3", "pid": "208" }, { "id": "216", "name": "景县", "code": "131127", "deep": "3", "pid": "208" }, { "id": "217", "name": "阜城县", "code": "131128", "deep": "3", "pid": "208" }, { "id": "218", "name": "冀州区", "code": "131103", "deep": "3", "pid": "208" }, { "id": "219", "name": "深州市", "code": "131182", "deep": "3", "pid": "208" } ] }, { "id": "3378", "name": "省直辖县级行政区划", "code": "139000", "deep": "2", "pid": "38", "area": [ { "id": "3379", "name": "定州市", "code": "139001", "deep": "3", "pid": "3378" }, { "id": "3380", "name": "辛集市", "code": "139002", "deep": "3", "pid": "3378" } ] } ] }, { "id": "220", "name": "山西省", "code": "140000", "deep": "1", "pid": "0", "city": [ { "id": "221", "name": "太原市", "code": "140100", "deep": "2", "pid": "220", "area": [ { "id": "222", "name": "小店区", "code": "140105", "deep": "3", "pid": "221" }, { "id": "223", "name": "迎泽区", "code": "140106", "deep": "3", "pid": "221" }, { "id": "224", "name": "杏花岭区", "code": "140107", "deep": "3", "pid": "221" }, { "id": "225", "name": "尖草坪区", "code": "140108", "deep": "3", "pid": "221" }, { "id": "226", "name": "万柏林区", "code": "140109", "deep": "3", "pid": "221" }, { "id": "227", "name": "晋源区", "code": "140110", "deep": "3", "pid": "221" }, { "id": "228", "name": "清徐县", "code": "140121", "deep": "3", "pid": "221" }, { "id": "229", "name": "阳曲县", "code": "140122", "deep": "3", "pid": "221" }, { "id": "230", "name": "娄烦县", "code": "140123", "deep": "3", "pid": "221" }, { "id": "231", "name": "古交市", "code": "140181", "deep": "3", "pid": "221" } ] }, { "id": "232", "name": "大同市", "code": "140200", "deep": "2", "pid": "220", "area": [ { "id": "233", "name": "城区", "code": "140202", "deep": "3", "pid": "232" }, { "id": "234", "name": "矿区", "code": "140203", "deep": "3", "pid": "232" }, { "id": "235", "name": "南郊区", "code": "140211", "deep": "3", "pid": "232" }, { "id": "236", "name": "新荣区", "code": "140212", "deep": "3", "pid": "232" }, { "id": "237", "name": "阳高县", "code": "140221", "deep": "3", "pid": "232" }, { "id": "238", "name": "天镇县", "code": "140222", "deep": "3", "pid": "232" }, { "id": "239", "name": "广灵县", "code": "140223", "deep": "3", "pid": "232" }, { "id": "240", "name": "灵丘县", "code": "140224", "deep": "3", "pid": "232" }, { "id": "241", "name": "浑源县", "code": "140225", "deep": "3", "pid": "232" }, { "id": "242", "name": "左云县", "code": "140226", "deep": "3", "pid": "232" }, { "id": "243", "name": "大同县", "code": "140227", "deep": "3", "pid": "232" } ] }, { "id": "244", "name": "阳泉市", "code": "140300", "deep": "2", "pid": "220", "area": [ { "id": "245", "name": "城区", "code": "140302", "deep": "3", "pid": "244" }, { "id": "246", "name": "矿区", "code": "140303", "deep": "3", "pid": "244" }, { "id": "247", "name": "郊区", "code": "140311", "deep": "3", "pid": "244" }, { "id": "248", "name": "平定县", "code": "140321", "deep": "3", "pid": "244" }, { "id": "249", "name": "盂县", "code": "140322", "deep": "3", "pid": "244" } ] }, { "id": "250", "name": "长治市", "code": "140400", "deep": "2", "pid": "220", "area": [ { "id": "251", "name": "城区", "code": "140402", "deep": "3", "pid": "250" }, { "id": "252", "name": "郊区", "code": "140411", "deep": "3", "pid": "250" }, { "id": "253", "name": "长治县", "code": "140421", "deep": "3", "pid": "250" }, { "id": "254", "name": "襄垣县", "code": "140423", "deep": "3", "pid": "250" }, { "id": "255", "name": "屯留县", "code": "140424", "deep": "3", "pid": "250" }, { "id": "256", "name": "平顺县", "code": "140425", "deep": "3", "pid": "250" }, { "id": "257", "name": "黎城县", "code": "140426", "deep": "3", "pid": "250" }, { "id": "258", "name": "壶关县", "code": "140427", "deep": "3", "pid": "250" }, { "id": "259", "name": "长子县", "code": "140428", "deep": "3", "pid": "250" }, { "id": "260", "name": "武乡县", "code": "140429", "deep": "3", "pid": "250" }, { "id": "261", "name": "沁县", "code": "140430", "deep": "3", "pid": "250" }, { "id": "262", "name": "沁源县", "code": "140431", "deep": "3", "pid": "250" }, { "id": "263", "name": "潞城市", "code": "140481", "deep": "3", "pid": "250" } ] }, { "id": "264", "name": "晋城市", "code": "140500", "deep": "2", "pid": "220", "area": [ { "id": "265", "name": "城区", "code": "140502", "deep": "3", "pid": "264" }, { "id": "266", "name": "沁水县", "code": "140521", "deep": "3", "pid": "264" }, { "id": "267", "name": "阳城县", "code": "140522", "deep": "3", "pid": "264" }, { "id": "268", "name": "陵川县", "code": "140524", "deep": "3", "pid": "264" }, { "id": "269", "name": "泽州县", "code": "140525", "deep": "3", "pid": "264" }, { "id": "270", "name": "高平市", "code": "140581", "deep": "3", "pid": "264" } ] }, { "id": "271", "name": "朔州市", "code": "140600", "deep": "2", "pid": "220", "area": [ { "id": "272", "name": "朔城区", "code": "140602", "deep": "3", "pid": "271" }, { "id": "273", "name": "平鲁区", "code": "140603", "deep": "3", "pid": "271" }, { "id": "274", "name": "山阴县", "code": "140621", "deep": "3", "pid": "271" }, { "id": "275", "name": "应县", "code": "140622", "deep": "3", "pid": "271" }, { "id": "276", "name": "右玉县", "code": "140623", "deep": "3", "pid": "271" }, { "id": "277", "name": "怀仁县", "code": "140624", "deep": "3", "pid": "271" } ] }, { "id": "278", "name": "晋中市", "code": "140700", "deep": "2", "pid": "220", "area": [ { "id": "279", "name": "榆次区", "code": "140702", "deep": "3", "pid": "278" }, { "id": "280", "name": "榆社县", "code": "140721", "deep": "3", "pid": "278" }, { "id": "281", "name": "左权县", "code": "140722", "deep": "3", "pid": "278" }, { "id": "282", "name": "和顺县", "code": "140723", "deep": "3", "pid": "278" }, { "id": "283", "name": "昔阳县", "code": "140724", "deep": "3", "pid": "278" }, { "id": "284", "name": "寿阳县", "code": "140725", "deep": "3", "pid": "278" }, { "id": "285", "name": "太谷县", "code": "140726", "deep": "3", "pid": "278" }, { "id": "286", "name": "祁县", "code": "140727", "deep": "3", "pid": "278" }, { "id": "287", "name": "平遥县", "code": "140728", "deep": "3", "pid": "278" }, { "id": "288", "name": "灵石县", "code": "140729", "deep": "3", "pid": "278" }, { "id": "289", "name": "介休市", "code": "140781", "deep": "3", "pid": "278" } ] }, { "id": "290", "name": "运城市", "code": "140800", "deep": "2", "pid": "220", "area": [ { "id": "291", "name": "盐湖区", "code": "140802", "deep": "3", "pid": "290" }, { "id": "292", "name": "临猗县", "code": "140821", "deep": "3", "pid": "290" }, { "id": "293", "name": "万荣县", "code": "140822", "deep": "3", "pid": "290" }, { "id": "294", "name": "闻喜县", "code": "140823", "deep": "3", "pid": "290" }, { "id": "295", "name": "稷山县", "code": "140824", "deep": "3", "pid": "290" }, { "id": "296", "name": "新绛县", "code": "140825", "deep": "3", "pid": "290" }, { "id": "297", "name": "绛县", "code": "140826", "deep": "3", "pid": "290" }, { "id": "298", "name": "垣曲县", "code": "140827", "deep": "3", "pid": "290" }, { "id": "299", "name": "夏县", "code": "140828", "deep": "3", "pid": "290" }, { "id": "300", "name": "平陆县", "code": "140829", "deep": "3", "pid": "290" }, { "id": "301", "name": "芮城县", "code": "140830", "deep": "3", "pid": "290" }, { "id": "302", "name": "永济市", "code": "140881", "deep": "3", "pid": "290" }, { "id": "303", "name": "河津市", "code": "140882", "deep": "3", "pid": "290" } ] }, { "id": "304", "name": "忻州市", "code": "140900", "deep": "2", "pid": "220", "area": [ { "id": "305", "name": "忻府区", "code": "140902", "deep": "3", "pid": "304" }, { "id": "306", "name": "定襄县", "code": "140921", "deep": "3", "pid": "304" }, { "id": "307", "name": "五台县", "code": "140922", "deep": "3", "pid": "304" }, { "id": "308", "name": "代县", "code": "140923", "deep": "3", "pid": "304" }, { "id": "309", "name": "繁峙县", "code": "140924", "deep": "3", "pid": "304" }, { "id": "310", "name": "宁武县", "code": "140925", "deep": "3", "pid": "304" }, { "id": "311", "name": "静乐县", "code": "140926", "deep": "3", "pid": "304" }, { "id": "312", "name": "神池县", "code": "140927", "deep": "3", "pid": "304" }, { "id": "313", "name": "五寨县", "code": "140928", "deep": "3", "pid": "304" }, { "id": "314", "name": "岢岚县", "code": "140929", "deep": "3", "pid": "304" }, { "id": "315", "name": "河曲县", "code": "140930", "deep": "3", "pid": "304" }, { "id": "316", "name": "保德县", "code": "140931", "deep": "3", "pid": "304" }, { "id": "317", "name": "偏关县", "code": "140932", "deep": "3", "pid": "304" }, { "id": "318", "name": "原平市", "code": "140981", "deep": "3", "pid": "304" } ] }, { "id": "319", "name": "临汾市", "code": "141000", "deep": "2", "pid": "220", "area": [ { "id": "320", "name": "尧都区", "code": "141002", "deep": "3", "pid": "319" }, { "id": "321", "name": "曲沃县", "code": "141021", "deep": "3", "pid": "319" }, { "id": "322", "name": "翼城县", "code": "141022", "deep": "3", "pid": "319" }, { "id": "323", "name": "襄汾县", "code": "141023", "deep": "3", "pid": "319" }, { "id": "324", "name": "洪洞县", "code": "141024", "deep": "3", "pid": "319" }, { "id": "325", "name": "古县", "code": "141025", "deep": "3", "pid": "319" }, { "id": "326", "name": "安泽县", "code": "141026", "deep": "3", "pid": "319" }, { "id": "327", "name": "浮山县", "code": "141027", "deep": "3", "pid": "319" }, { "id": "328", "name": "吉县", "code": "141028", "deep": "3", "pid": "319" }, { "id": "329", "name": "乡宁县", "code": "141029", "deep": "3", "pid": "319" }, { "id": "330", "name": "大宁县", "code": "141030", "deep": "3", "pid": "319" }, { "id": "331", "name": "隰县", "code": "141031", "deep": "3", "pid": "319" }, { "id": "332", "name": "永和县", "code": "141032", "deep": "3", "pid": "319" }, { "id": "333", "name": "蒲县", "code": "141033", "deep": "3", "pid": "319" }, { "id": "334", "name": "汾西县", "code": "141034", "deep": "3", "pid": "319" }, { "id": "335", "name": "侯马市", "code": "141081", "deep": "3", "pid": "319" }, { "id": "336", "name": "霍州市", "code": "141082", "deep": "3", "pid": "319" } ] }, { "id": "337", "name": "吕梁市", "code": "141100", "deep": "2", "pid": "220", "area": [ { "id": "338", "name": "离石区", "code": "141102", "deep": "3", "pid": "337" }, { "id": "339", "name": "文水县", "code": "141121", "deep": "3", "pid": "337" }, { "id": "340", "name": "交城县", "code": "141122", "deep": "3", "pid": "337" }, { "id": "341", "name": "兴县", "code": "141123", "deep": "3", "pid": "337" }, { "id": "342", "name": "临县", "code": "141124", "deep": "3", "pid": "337" }, { "id": "343", "name": "柳林县", "code": "141125", "deep": "3", "pid": "337" }, { "id": "344", "name": "石楼县", "code": "141126", "deep": "3", "pid": "337" }, { "id": "345", "name": "岚县", "code": "141127", "deep": "3", "pid": "337" }, { "id": "346", "name": "方山县", "code": "141128", "deep": "3", "pid": "337" }, { "id": "347", "name": "中阳县", "code": "141129", "deep": "3", "pid": "337" }, { "id": "348", "name": "交口县", "code": "141130", "deep": "3", "pid": "337" }, { "id": "349", "name": "孝义市", "code": "141181", "deep": "3", "pid": "337" }, { "id": "350", "name": "汾阳市", "code": "141182", "deep": "3", "pid": "337" } ] } ] }, { "id": "351", "name": "内蒙古自治区", "code": "150000", "deep": "1", "pid": "0", "city": [ { "id": "352", "name": "呼和浩特市", "code": "150100", "deep": "2", "pid": "351", "area": [ { "id": "353", "name": "新城区", "code": "150102", "deep": "3", "pid": "352" }, { "id": "354", "name": "回民区", "code": "150103", "deep": "3", "pid": "352" }, { "id": "355", "name": "玉泉区", "code": "150104", "deep": "3", "pid": "352" }, { "id": "356", "name": "赛罕区", "code": "150105", "deep": "3", "pid": "352" }, { "id": "357", "name": "土默特左旗", "code": "150121", "deep": "3", "pid": "352" }, { "id": "358", "name": "托克托县", "code": "150122", "deep": "3", "pid": "352" }, { "id": "359", "name": "和林格尔县", "code": "150123", "deep": "3", "pid": "352" }, { "id": "360", "name": "清水河县", "code": "150124", "deep": "3", "pid": "352" }, { "id": "361", "name": "武川县", "code": "150125", "deep": "3", "pid": "352" } ] }, { "id": "362", "name": "包头市", "code": "150200", "deep": "2", "pid": "351", "area": [ { "id": "363", "name": "东河区", "code": "150202", "deep": "3", "pid": "362" }, { "id": "364", "name": "昆都仑区", "code": "150203", "deep": "3", "pid": "362" }, { "id": "365", "name": "青山区", "code": "150204", "deep": "3", "pid": "362" }, { "id": "366", "name": "石拐区", "code": "150205", "deep": "3", "pid": "362" }, { "id": "367", "name": "白云鄂博矿区", "code": "150206", "deep": "3", "pid": "362" }, { "id": "368", "name": "九原区", "code": "150207", "deep": "3", "pid": "362" }, { "id": "369", "name": "土默特右旗", "code": "150221", "deep": "3", "pid": "362" }, { "id": "370", "name": "固阳县", "code": "150222", "deep": "3", "pid": "362" }, { "id": "371", "name": "达尔罕茂明安联合旗", "code": "150223", "deep": "3", "pid": "362" } ] }, { "id": "372", "name": "乌海市", "code": "150300", "deep": "2", "pid": "351", "area": [ { "id": "373", "name": "海勃湾区", "code": "150302", "deep": "3", "pid": "372" }, { "id": "374", "name": "海南区", "code": "150303", "deep": "3", "pid": "372" }, { "id": "375", "name": "乌达区", "code": "150304", "deep": "3", "pid": "372" } ] }, { "id": "376", "name": "赤峰市", "code": "150400", "deep": "2", "pid": "351", "area": [ { "id": "377", "name": "红山区", "code": "150402", "deep": "3", "pid": "376" }, { "id": "378", "name": "元宝山区", "code": "150403", "deep": "3", "pid": "376" }, { "id": "379", "name": "松山区", "code": "150404", "deep": "3", "pid": "376" }, { "id": "380", "name": "阿鲁科尔沁旗", "code": "150421", "deep": "3", "pid": "376" }, { "id": "381", "name": "巴林左旗", "code": "150422", "deep": "3", "pid": "376" }, { "id": "382", "name": "巴林右旗", "code": "150423", "deep": "3", "pid": "376" }, { "id": "383", "name": "林西县", "code": "150424", "deep": "3", "pid": "376" }, { "id": "384", "name": "克什克腾旗", "code": "150425", "deep": "3", "pid": "376" }, { "id": "385", "name": "翁牛特旗", "code": "150426", "deep": "3", "pid": "376" }, { "id": "386", "name": "喀喇沁旗", "code": "150428", "deep": "3", "pid": "376" }, { "id": "387", "name": "宁城县", "code": "150429", "deep": "3", "pid": "376" }, { "id": "388", "name": "敖汉旗", "code": "150430", "deep": "3", "pid": "376" } ] }, { "id": "389", "name": "通辽市", "code": "150500", "deep": "2", "pid": "351", "area": [ { "id": "390", "name": "科尔沁区", "code": "150502", "deep": "3", "pid": "389" }, { "id": "391", "name": "科尔沁左翼中旗", "code": "150521", "deep": "3", "pid": "389" }, { "id": "392", "name": "科尔沁左翼后旗", "code": "150522", "deep": "3", "pid": "389" }, { "id": "393", "name": "开鲁县", "code": "150523", "deep": "3", "pid": "389" }, { "id": "394", "name": "库伦旗", "code": "150524", "deep": "3", "pid": "389" }, { "id": "395", "name": "奈曼旗", "code": "150525", "deep": "3", "pid": "389" }, { "id": "396", "name": "扎鲁特旗", "code": "150526", "deep": "3", "pid": "389" }, { "id": "397", "name": "霍林郭勒市", "code": "150581", "deep": "3", "pid": "389" } ] }, { "id": "398", "name": "鄂尔多斯市", "code": "150600", "deep": "2", "pid": "351", "area": [ { "id": "399", "name": "东胜区", "code": "150602", "deep": "3", "pid": "398" }, { "id": "400", "name": "达拉特旗", "code": "150621", "deep": "3", "pid": "398" }, { "id": "401", "name": "准格尔旗", "code": "150622", "deep": "3", "pid": "398" }, { "id": "402", "name": "鄂托克前旗", "code": "150623", "deep": "3", "pid": "398" }, { "id": "403", "name": "鄂托克旗", "code": "150624", "deep": "3", "pid": "398" }, { "id": "404", "name": "杭锦旗", "code": "150625", "deep": "3", "pid": "398" }, { "id": "405", "name": "乌审旗", "code": "150626", "deep": "3", "pid": "398" }, { "id": "406", "name": "伊金霍洛旗", "code": "150627", "deep": "3", "pid": "398" }, { "id": "3262", "name": "康巴什区", "code": "150603", "deep": "3", "pid": "398" } ] }, { "id": "407", "name": "呼伦贝尔市", "code": "150700", "deep": "2", "pid": "351", "area": [ { "id": "408", "name": "海拉尔区", "code": "150702", "deep": "3", "pid": "407" }, { "id": "409", "name": "扎赉诺尔区", "code": "150703", "deep": "3", "pid": "407" }, { "id": "410", "name": "阿荣旗", "code": "150721", "deep": "3", "pid": "407" }, { "id": "411", "name": "莫力达瓦达斡尔族自治旗", "code": "150722", "deep": "3", "pid": "407" }, { "id": "412", "name": "鄂伦春自治旗", "code": "150723", "deep": "3", "pid": "407" }, { "id": "413", "name": "鄂温克族自治旗", "code": "150724", "deep": "3", "pid": "407" }, { "id": "414", "name": "陈巴尔虎旗", "code": "150725", "deep": "3", "pid": "407" }, { "id": "415", "name": "新巴尔虎左旗", "code": "150726", "deep": "3", "pid": "407" }, { "id": "416", "name": "新巴尔虎右旗", "code": "150727", "deep": "3", "pid": "407" }, { "id": "417", "name": "满洲里市", "code": "150781", "deep": "3", "pid": "407" }, { "id": "418", "name": "牙克石市", "code": "150782", "deep": "3", "pid": "407" }, { "id": "419", "name": "扎兰屯市", "code": "150783", "deep": "3", "pid": "407" }, { "id": "420", "name": "额尔古纳市", "code": "150784", "deep": "3", "pid": "407" }, { "id": "421", "name": "根河市", "code": "150785", "deep": "3", "pid": "407" } ] }, { "id": "422", "name": "巴彦淖尔市", "code": "150800", "deep": "2", "pid": "351", "area": [ { "id": "423", "name": "临河区", "code": "150802", "deep": "3", "pid": "422" }, { "id": "424", "name": "五原县", "code": "150821", "deep": "3", "pid": "422" }, { "id": "425", "name": "磴口县", "code": "150822", "deep": "3", "pid": "422" }, { "id": "426", "name": "乌拉特前旗", "code": "150823", "deep": "3", "pid": "422" }, { "id": "427", "name": "乌拉特中旗", "code": "150824", "deep": "3", "pid": "422" }, { "id": "428", "name": "乌拉特后旗", "code": "150825", "deep": "3", "pid": "422" }, { "id": "429", "name": "杭锦后旗", "code": "150826", "deep": "3", "pid": "422" } ] }, { "id": "430", "name": "乌兰察布市", "code": "150900", "deep": "2", "pid": "351", "area": [ { "id": "431", "name": "集宁区", "code": "150902", "deep": "3", "pid": "430" }, { "id": "432", "name": "卓资县", "code": "150921", "deep": "3", "pid": "430" }, { "id": "433", "name": "化德县", "code": "150922", "deep": "3", "pid": "430" }, { "id": "434", "name": "商都县", "code": "150923", "deep": "3", "pid": "430" }, { "id": "435", "name": "兴和县", "code": "150924", "deep": "3", "pid": "430" }, { "id": "436", "name": "凉城县", "code": "150925", "deep": "3", "pid": "430" }, { "id": "437", "name": "察哈尔右翼前旗", "code": "150926", "deep": "3", "pid": "430" }, { "id": "438", "name": "察哈尔右翼中旗", "code": "150927", "deep": "3", "pid": "430" }, { "id": "439", "name": "察哈尔右翼后旗", "code": "150928", "deep": "3", "pid": "430" }, { "id": "440", "name": "四子王旗", "code": "150929", "deep": "3", "pid": "430" }, { "id": "441", "name": "丰镇市", "code": "150981", "deep": "3", "pid": "430" } ] }, { "id": "442", "name": "兴安盟", "code": "152200", "deep": "2", "pid": "351", "area": [ { "id": "443", "name": "乌兰浩特市", "code": "152201", "deep": "3", "pid": "442" }, { "id": "444", "name": "阿尔山市", "code": "152202", "deep": "3", "pid": "442" }, { "id": "445", "name": "科尔沁右翼前旗", "code": "152221", "deep": "3", "pid": "442" }, { "id": "446", "name": "科尔沁右翼中旗", "code": "152222", "deep": "3", "pid": "442" }, { "id": "447", "name": "扎赉特旗", "code": "152223", "deep": "3", "pid": "442" }, { "id": "448", "name": "突泉县", "code": "152224", "deep": "3", "pid": "442" } ] }, { "id": "449", "name": "锡林郭勒盟", "code": "152500", "deep": "2", "pid": "351", "area": [ { "id": "450", "name": "二连浩特市", "code": "152501", "deep": "3", "pid": "449" }, { "id": "451", "name": "锡林浩特市", "code": "152502", "deep": "3", "pid": "449" }, { "id": "452", "name": "阿巴嘎旗", "code": "152522", "deep": "3", "pid": "449" }, { "id": "453", "name": "苏尼特左旗", "code": "152523", "deep": "3", "pid": "449" }, { "id": "454", "name": "苏尼特右旗", "code": "152524", "deep": "3", "pid": "449" }, { "id": "455", "name": "东乌珠穆沁旗", "code": "152525", "deep": "3", "pid": "449" }, { "id": "456", "name": "西乌珠穆沁旗", "code": "152526", "deep": "3", "pid": "449" }, { "id": "457", "name": "太仆寺旗", "code": "152527", "deep": "3", "pid": "449" }, { "id": "458", "name": "镶黄旗", "code": "152528", "deep": "3", "pid": "449" }, { "id": "459", "name": "正镶白旗", "code": "152529", "deep": "3", "pid": "449" }, { "id": "460", "name": "正蓝旗", "code": "152530", "deep": "3", "pid": "449" }, { "id": "461", "name": "多伦县", "code": "152531", "deep": "3", "pid": "449" } ] }, { "id": "462", "name": "阿拉善盟", "code": "152900", "deep": "2", "pid": "351", "area": [ { "id": "463", "name": "阿拉善左旗", "code": "152921", "deep": "3", "pid": "462" }, { "id": "464", "name": "阿拉善右旗", "code": "152922", "deep": "3", "pid": "462" }, { "id": "465", "name": "额济纳旗", "code": "152923", "deep": "3", "pid": "462" } ] } ] }, { "id": "466", "name": "辽宁省", "code": "210000", "deep": "1", "pid": "0", "city": [ { "id": "467", "name": "沈阳市", "code": "210100", "deep": "2", "pid": "466", "area": [ { "id": "468", "name": "和平区", "code": "210102", "deep": "3", "pid": "467" }, { "id": "469", "name": "沈河区", "code": "210103", "deep": "3", "pid": "467" }, { "id": "470", "name": "大东区", "code": "210104", "deep": "3", "pid": "467" }, { "id": "471", "name": "皇姑区", "code": "210105", "deep": "3", "pid": "467" }, { "id": "472", "name": "铁西区", "code": "210106", "deep": "3", "pid": "467" }, { "id": "473", "name": "苏家屯区", "code": "210111", "deep": "3", "pid": "467" }, { "id": "474", "name": "浑南区", "code": "210112", "deep": "3", "pid": "467" }, { "id": "475", "name": "沈北新区", "code": "210113", "deep": "3", "pid": "467" }, { "id": "476", "name": "于洪区", "code": "210114", "deep": "3", "pid": "467" }, { "id": "477", "name": "辽中区", "code": "210115", "deep": "3", "pid": "467" }, { "id": "478", "name": "康平县", "code": "210123", "deep": "3", "pid": "467" }, { "id": "479", "name": "法库县", "code": "210124", "deep": "3", "pid": "467" }, { "id": "480", "name": "新民市", "code": "210181", "deep": "3", "pid": "467" } ] }, { "id": "481", "name": "大连市", "code": "210200", "deep": "2", "pid": "466", "area": [ { "id": "482", "name": "中山区", "code": "210202", "deep": "3", "pid": "481" }, { "id": "483", "name": "西岗区", "code": "210203", "deep": "3", "pid": "481" }, { "id": "484", "name": "沙河口区", "code": "210204", "deep": "3", "pid": "481" }, { "id": "485", "name": "甘井子区", "code": "210211", "deep": "3", "pid": "481" }, { "id": "486", "name": "旅顺口区", "code": "210212", "deep": "3", "pid": "481" }, { "id": "487", "name": "金州区", "code": "210213", "deep": "3", "pid": "481" }, { "id": "488", "name": "普兰店区", "code": "210214", "deep": "3", "pid": "481" }, { "id": "489", "name": "长海县", "code": "210224", "deep": "3", "pid": "481" }, { "id": "490", "name": "瓦房店市", "code": "210281", "deep": "3", "pid": "481" }, { "id": "491", "name": "庄河市", "code": "210283", "deep": "3", "pid": "481" } ] }, { "id": "492", "name": "鞍山市", "code": "210300", "deep": "2", "pid": "466", "area": [ { "id": "493", "name": "铁东区", "code": "210302", "deep": "3", "pid": "492" }, { "id": "494", "name": "铁西区", "code": "210303", "deep": "3", "pid": "492" }, { "id": "495", "name": "立山区", "code": "210304", "deep": "3", "pid": "492" }, { "id": "496", "name": "千山区", "code": "210311", "deep": "3", "pid": "492" }, { "id": "497", "name": "台安县", "code": "210321", "deep": "3", "pid": "492" }, { "id": "498", "name": "岫岩满族自治县", "code": "210323", "deep": "3", "pid": "492" }, { "id": "499", "name": "海城市", "code": "210381", "deep": "3", "pid": "492" } ] }, { "id": "500", "name": "抚顺市", "code": "210400", "deep": "2", "pid": "466", "area": [ { "id": "501", "name": "新抚区", "code": "210402", "deep": "3", "pid": "500" }, { "id": "502", "name": "东洲区", "code": "210403", "deep": "3", "pid": "500" }, { "id": "503", "name": "望花区", "code": "210404", "deep": "3", "pid": "500" }, { "id": "504", "name": "顺城区", "code": "210411", "deep": "3", "pid": "500" }, { "id": "505", "name": "抚顺县", "code": "210421", "deep": "3", "pid": "500" }, { "id": "506", "name": "新宾满族自治县", "code": "210422", "deep": "3", "pid": "500" }, { "id": "507", "name": "清原满族自治县", "code": "210423", "deep": "3", "pid": "500" } ] }, { "id": "508", "name": "本溪市", "code": "210500", "deep": "2", "pid": "466", "area": [ { "id": "509", "name": "平山区", "code": "210502", "deep": "3", "pid": "508" }, { "id": "510", "name": "溪湖区", "code": "210503", "deep": "3", "pid": "508" }, { "id": "511", "name": "明山区", "code": "210504", "deep": "3", "pid": "508" }, { "id": "512", "name": "南芬区", "code": "210505", "deep": "3", "pid": "508" }, { "id": "513", "name": "本溪满族自治县", "code": "210521", "deep": "3", "pid": "508" }, { "id": "514", "name": "桓仁满族自治县", "code": "210522", "deep": "3", "pid": "508" } ] }, { "id": "515", "name": "丹东市", "code": "210600", "deep": "2", "pid": "466", "area": [ { "id": "516", "name": "元宝区", "code": "210602", "deep": "3", "pid": "515" }, { "id": "517", "name": "振兴区", "code": "210603", "deep": "3", "pid": "515" }, { "id": "518", "name": "振安区", "code": "210604", "deep": "3", "pid": "515" }, { "id": "519", "name": "宽甸满族自治县", "code": "210624", "deep": "3", "pid": "515" }, { "id": "520", "name": "东港市", "code": "210681", "deep": "3", "pid": "515" }, { "id": "521", "name": "凤城市", "code": "210682", "deep": "3", "pid": "515" } ] }, { "id": "522", "name": "锦州市", "code": "210700", "deep": "2", "pid": "466", "area": [ { "id": "523", "name": "古塔区", "code": "210702", "deep": "3", "pid": "522" }, { "id": "524", "name": "凌河区", "code": "210703", "deep": "3", "pid": "522" }, { "id": "525", "name": "太和区", "code": "210711", "deep": "3", "pid": "522" }, { "id": "526", "name": "黑山县", "code": "210726", "deep": "3", "pid": "522" }, { "id": "527", "name": "义县", "code": "210727", "deep": "3", "pid": "522" }, { "id": "528", "name": "凌海市", "code": "210781", "deep": "3", "pid": "522" }, { "id": "529", "name": "北镇市", "code": "210782", "deep": "3", "pid": "522" } ] }, { "id": "530", "name": "营口市", "code": "210800", "deep": "2", "pid": "466", "area": [ { "id": "531", "name": "站前区", "code": "210802", "deep": "3", "pid": "530" }, { "id": "532", "name": "西市区", "code": "210803", "deep": "3", "pid": "530" }, { "id": "533", "name": "鲅鱼圈区", "code": "210804", "deep": "3", "pid": "530" }, { "id": "534", "name": "老边区", "code": "210811", "deep": "3", "pid": "530" }, { "id": "535", "name": "盖州市", "code": "210881", "deep": "3", "pid": "530" }, { "id": "536", "name": "大石桥市", "code": "210882", "deep": "3", "pid": "530" } ] }, { "id": "537", "name": "阜新市", "code": "210900", "deep": "2", "pid": "466", "area": [ { "id": "538", "name": "海州区", "code": "210902", "deep": "3", "pid": "537" }, { "id": "539", "name": "新邱区", "code": "210903", "deep": "3", "pid": "537" }, { "id": "540", "name": "太平区", "code": "210904", "deep": "3", "pid": "537" }, { "id": "541", "name": "清河门区", "code": "210905", "deep": "3", "pid": "537" }, { "id": "542", "name": "细河区", "code": "210911", "deep": "3", "pid": "537" }, { "id": "543", "name": "阜新蒙古族自治县", "code": "210921", "deep": "3", "pid": "537" }, { "id": "544", "name": "彰武县", "code": "210922", "deep": "3", "pid": "537" } ] }, { "id": "545", "name": "辽阳市", "code": "211000", "deep": "2", "pid": "466", "area": [ { "id": "546", "name": "白塔区", "code": "211002", "deep": "3", "pid": "545" }, { "id": "547", "name": "文圣区", "code": "211003", "deep": "3", "pid": "545" }, { "id": "548", "name": "宏伟区", "code": "211004", "deep": "3", "pid": "545" }, { "id": "549", "name": "弓长岭区", "code": "211005", "deep": "3", "pid": "545" }, { "id": "550", "name": "太子河区", "code": "211011", "deep": "3", "pid": "545" }, { "id": "551", "name": "辽阳县", "code": "211021", "deep": "3", "pid": "545" }, { "id": "552", "name": "灯塔市", "code": "211081", "deep": "3", "pid": "545" } ] }, { "id": "553", "name": "盘锦市", "code": "211100", "deep": "2", "pid": "466", "area": [ { "id": "554", "name": "双台子区", "code": "211102", "deep": "3", "pid": "553" }, { "id": "555", "name": "兴隆台区", "code": "211103", "deep": "3", "pid": "553" }, { "id": "556", "name": "大洼区", "code": "211104", "deep": "3", "pid": "553" }, { "id": "557", "name": "盘山县", "code": "211122", "deep": "3", "pid": "553" } ] }, { "id": "558", "name": "铁岭市", "code": "211200", "deep": "2", "pid": "466", "area": [ { "id": "559", "name": "银州区", "code": "211202", "deep": "3", "pid": "558" }, { "id": "560", "name": "清河区", "code": "211204", "deep": "3", "pid": "558" }, { "id": "561", "name": "铁岭县", "code": "211221", "deep": "3", "pid": "558" }, { "id": "562", "name": "西丰县", "code": "211223", "deep": "3", "pid": "558" }, { "id": "563", "name": "昌图县", "code": "211224", "deep": "3", "pid": "558" }, { "id": "564", "name": "调兵山市", "code": "211281", "deep": "3", "pid": "558" }, { "id": "565", "name": "开原市", "code": "211282", "deep": "3", "pid": "558" } ] }, { "id": "566", "name": "朝阳市", "code": "211300", "deep": "2", "pid": "466", "area": [ { "id": "567", "name": "双塔区", "code": "211302", "deep": "3", "pid": "566" }, { "id": "568", "name": "龙城区", "code": "211303", "deep": "3", "pid": "566" }, { "id": "569", "name": "朝阳县", "code": "211321", "deep": "3", "pid": "566" }, { "id": "570", "name": "建平县", "code": "211322", "deep": "3", "pid": "566" }, { "id": "571", "name": "喀喇沁左翼蒙古族自治县", "code": "211324", "deep": "3", "pid": "566" }, { "id": "572", "name": "北票市", "code": "211381", "deep": "3", "pid": "566" }, { "id": "573", "name": "凌源市", "code": "211382", "deep": "3", "pid": "566" } ] }, { "id": "574", "name": "葫芦岛市", "code": "211400", "deep": "2", "pid": "466", "area": [ { "id": "575", "name": "连山区", "code": "211402", "deep": "3", "pid": "574" }, { "id": "576", "name": "龙港区", "code": "211403", "deep": "3", "pid": "574" }, { "id": "577", "name": "南票区", "code": "211404", "deep": "3", "pid": "574" }, { "id": "578", "name": "绥中县", "code": "211421", "deep": "3", "pid": "574" }, { "id": "579", "name": "建昌县", "code": "211422", "deep": "3", "pid": "574" }, { "id": "580", "name": "兴城市", "code": "211481", "deep": "3", "pid": "574" } ] } ] }, { "id": "581", "name": "吉林省", "code": "220000", "deep": "1", "pid": "0", "city": [ { "id": "582", "name": "长春市", "code": "220100", "deep": "2", "pid": "581", "area": [ { "id": "583", "name": "南关区", "code": "220102", "deep": "3", "pid": "582" }, { "id": "584", "name": "宽城区", "code": "220103", "deep": "3", "pid": "582" }, { "id": "585", "name": "朝阳区", "code": "220104", "deep": "3", "pid": "582" }, { "id": "586", "name": "二道区", "code": "220105", "deep": "3", "pid": "582" }, { "id": "587", "name": "绿园区", "code": "220106", "deep": "3", "pid": "582" }, { "id": "588", "name": "双阳区", "code": "220112", "deep": "3", "pid": "582" }, { "id": "589", "name": "九台区", "code": "220113", "deep": "3", "pid": "582" }, { "id": "590", "name": "农安县", "code": "220122", "deep": "3", "pid": "582" }, { "id": "591", "name": "榆树市", "code": "220182", "deep": "3", "pid": "582" }, { "id": "592", "name": "德惠市", "code": "220183", "deep": "3", "pid": "582" } ] }, { "id": "593", "name": "吉林市", "code": "220200", "deep": "2", "pid": "581", "area": [ { "id": "594", "name": "昌邑区", "code": "220202", "deep": "3", "pid": "593" }, { "id": "595", "name": "龙潭区", "code": "220203", "deep": "3", "pid": "593" }, { "id": "596", "name": "船营区", "code": "220204", "deep": "3", "pid": "593" }, { "id": "597", "name": "丰满区", "code": "220211", "deep": "3", "pid": "593" }, { "id": "598", "name": "永吉县", "code": "220221", "deep": "3", "pid": "593" }, { "id": "599", "name": "蛟河市", "code": "220281", "deep": "3", "pid": "593" }, { "id": "600", "name": "桦甸市", "code": "220282", "deep": "3", "pid": "593" }, { "id": "601", "name": "舒兰市", "code": "220283", "deep": "3", "pid": "593" }, { "id": "602", "name": "磐石市", "code": "220284", "deep": "3", "pid": "593" } ] }, { "id": "603", "name": "四平市", "code": "220300", "deep": "2", "pid": "581", "area": [ { "id": "604", "name": "铁西区", "code": "220302", "deep": "3", "pid": "603" }, { "id": "605", "name": "铁东区", "code": "220303", "deep": "3", "pid": "603" }, { "id": "606", "name": "梨树县", "code": "220322", "deep": "3", "pid": "603" }, { "id": "607", "name": "伊通满族自治县", "code": "220323", "deep": "3", "pid": "603" }, { "id": "608", "name": "公主岭市", "code": "220381", "deep": "3", "pid": "603" }, { "id": "609", "name": "双辽市", "code": "220382", "deep": "3", "pid": "603" } ] }, { "id": "610", "name": "辽源市", "code": "220400", "deep": "2", "pid": "581", "area": [ { "id": "611", "name": "龙山区", "code": "220402", "deep": "3", "pid": "610" }, { "id": "612", "name": "西安区", "code": "220403", "deep": "3", "pid": "610" }, { "id": "613", "name": "东丰县", "code": "220421", "deep": "3", "pid": "610" }, { "id": "614", "name": "东辽县", "code": "220422", "deep": "3", "pid": "610" } ] }, { "id": "615", "name": "通化市", "code": "220500", "deep": "2", "pid": "581", "area": [ { "id": "616", "name": "东昌区", "code": "220502", "deep": "3", "pid": "615" }, { "id": "617", "name": "二道江区", "code": "220503", "deep": "3", "pid": "615" }, { "id": "618", "name": "通化县", "code": "220521", "deep": "3", "pid": "615" }, { "id": "619", "name": "辉南县", "code": "220523", "deep": "3", "pid": "615" }, { "id": "620", "name": "柳河县", "code": "220524", "deep": "3", "pid": "615" }, { "id": "621", "name": "梅河口市", "code": "220581", "deep": "3", "pid": "615" }, { "id": "622", "name": "集安市", "code": "220582", "deep": "3", "pid": "615" } ] }, { "id": "623", "name": "白山市", "code": "220600", "deep": "2", "pid": "581", "area": [ { "id": "624", "name": "浑江区", "code": "220602", "deep": "3", "pid": "623" }, { "id": "625", "name": "江源区", "code": "220605", "deep": "3", "pid": "623" }, { "id": "626", "name": "抚松县", "code": "220621", "deep": "3", "pid": "623" }, { "id": "627", "name": "靖宇县", "code": "220622", "deep": "3", "pid": "623" }, { "id": "628", "name": "长白朝鲜族自治县", "code": "220623", "deep": "3", "pid": "623" }, { "id": "629", "name": "临江市", "code": "220681", "deep": "3", "pid": "623" } ] }, { "id": "630", "name": "松原市", "code": "220700", "deep": "2", "pid": "581", "area": [ { "id": "631", "name": "宁江区", "code": "220702", "deep": "3", "pid": "630" }, { "id": "632", "name": "前郭尔罗斯蒙古族自治县", "code": "220721", "deep": "3", "pid": "630" }, { "id": "633", "name": "长岭县", "code": "220722", "deep": "3", "pid": "630" }, { "id": "634", "name": "乾安县", "code": "220723", "deep": "3", "pid": "630" }, { "id": "635", "name": "扶余市", "code": "220781", "deep": "3", "pid": "630" } ] }, { "id": "636", "name": "白城市", "code": "220800", "deep": "2", "pid": "581", "area": [ { "id": "637", "name": "洮北区", "code": "220802", "deep": "3", "pid": "636" }, { "id": "638", "name": "镇赉县", "code": "220821", "deep": "3", "pid": "636" }, { "id": "639", "name": "通榆县", "code": "220822", "deep": "3", "pid": "636" }, { "id": "640", "name": "洮南市", "code": "220881", "deep": "3", "pid": "636" }, { "id": "641", "name": "大安市", "code": "220882", "deep": "3", "pid": "636" } ] }, { "id": "642", "name": "延边朝鲜族自治州", "code": "222400", "deep": "2", "pid": "581", "area": [ { "id": "643", "name": "延吉市", "code": "222401", "deep": "3", "pid": "642" }, { "id": "644", "name": "图们市", "code": "222402", "deep": "3", "pid": "642" }, { "id": "645", "name": "敦化市", "code": "222403", "deep": "3", "pid": "642" }, { "id": "646", "name": "珲春市", "code": "222404", "deep": "3", "pid": "642" }, { "id": "647", "name": "龙井市", "code": "222405", "deep": "3", "pid": "642" }, { "id": "648", "name": "和龙市", "code": "222406", "deep": "3", "pid": "642" }, { "id": "649", "name": "汪清县", "code": "222424", "deep": "3", "pid": "642" }, { "id": "650", "name": "安图县", "code": "222426", "deep": "3", "pid": "642" } ] } ] }, { "id": "651", "name": "黑龙江省", "code": "230000", "deep": "1", "pid": "0", "city": [ { "id": "652", "name": "哈尔滨市", "code": "230100", "deep": "2", "pid": "651", "area": [ { "id": "653", "name": "道里区", "code": "230102", "deep": "3", "pid": "652" }, { "id": "654", "name": "南岗区", "code": "230103", "deep": "3", "pid": "652" }, { "id": "655", "name": "道外区", "code": "230104", "deep": "3", "pid": "652" }, { "id": "656", "name": "平房区", "code": "230108", "deep": "3", "pid": "652" }, { "id": "657", "name": "松北区", "code": "230109", "deep": "3", "pid": "652" }, { "id": "658", "name": "香坊区", "code": "230110", "deep": "3", "pid": "652" }, { "id": "659", "name": "呼兰区", "code": "230111", "deep": "3", "pid": "652" }, { "id": "660", "name": "阿城区", "code": "230112", "deep": "3", "pid": "652" }, { "id": "661", "name": "双城区", "code": "230113", "deep": "3", "pid": "652" }, { "id": "662", "name": "依兰县", "code": "230123", "deep": "3", "pid": "652" }, { "id": "663", "name": "方正县", "code": "230124", "deep": "3", "pid": "652" }, { "id": "664", "name": "宾县", "code": "230125", "deep": "3", "pid": "652" }, { "id": "665", "name": "巴彦县", "code": "230126", "deep": "3", "pid": "652" }, { "id": "666", "name": "木兰县", "code": "230127", "deep": "3", "pid": "652" }, { "id": "667", "name": "通河县", "code": "230128", "deep": "3", "pid": "652" }, { "id": "668", "name": "延寿县", "code": "230129", "deep": "3", "pid": "652" }, { "id": "669", "name": "尚志市", "code": "230183", "deep": "3", "pid": "652" }, { "id": "670", "name": "五常市", "code": "230184", "deep": "3", "pid": "652" } ] }, { "id": "671", "name": "齐齐哈尔市", "code": "230200", "deep": "2", "pid": "651", "area": [ { "id": "672", "name": "龙沙区", "code": "230202", "deep": "3", "pid": "671" }, { "id": "673", "name": "建华区", "code": "230203", "deep": "3", "pid": "671" }, { "id": "674", "name": "铁锋区", "code": "230204", "deep": "3", "pid": "671" }, { "id": "675", "name": "昂昂溪区", "code": "230205", "deep": "3", "pid": "671" }, { "id": "676", "name": "富拉尔基区", "code": "230206", "deep": "3", "pid": "671" }, { "id": "677", "name": "碾子山区", "code": "230207", "deep": "3", "pid": "671" }, { "id": "678", "name": "梅里斯达斡尔族区", "code": "230208", "deep": "3", "pid": "671" }, { "id": "679", "name": "龙江县", "code": "230221", "deep": "3", "pid": "671" }, { "id": "680", "name": "依安县", "code": "230223", "deep": "3", "pid": "671" }, { "id": "681", "name": "泰来县", "code": "230224", "deep": "3", "pid": "671" }, { "id": "682", "name": "甘南县", "code": "230225", "deep": "3", "pid": "671" }, { "id": "683", "name": "富裕县", "code": "230227", "deep": "3", "pid": "671" }, { "id": "684", "name": "克山县", "code": "230229", "deep": "3", "pid": "671" }, { "id": "685", "name": "克东县", "code": "230230", "deep": "3", "pid": "671" }, { "id": "686", "name": "拜泉县", "code": "230231", "deep": "3", "pid": "671" }, { "id": "687", "name": "讷河市", "code": "230281", "deep": "3", "pid": "671" } ] }, { "id": "688", "name": "鸡西市", "code": "230300", "deep": "2", "pid": "651", "area": [ { "id": "689", "name": "鸡冠区", "code": "230302", "deep": "3", "pid": "688" }, { "id": "690", "name": "恒山区", "code": "230303", "deep": "3", "pid": "688" }, { "id": "691", "name": "滴道区", "code": "230304", "deep": "3", "pid": "688" }, { "id": "692", "name": "梨树区", "code": "230305", "deep": "3", "pid": "688" }, { "id": "693", "name": "城子河区", "code": "230306", "deep": "3", "pid": "688" }, { "id": "694", "name": "麻山区", "code": "230307", "deep": "3", "pid": "688" }, { "id": "695", "name": "鸡东县", "code": "230321", "deep": "3", "pid": "688" }, { "id": "696", "name": "虎林市", "code": "230381", "deep": "3", "pid": "688" }, { "id": "697", "name": "密山市", "code": "230382", "deep": "3", "pid": "688" } ] }, { "id": "698", "name": "鹤岗市", "code": "230400", "deep": "2", "pid": "651", "area": [ { "id": "699", "name": "向阳区", "code": "230402", "deep": "3", "pid": "698" }, { "id": "700", "name": "工农区", "code": "230403", "deep": "3", "pid": "698" }, { "id": "701", "name": "南山区", "code": "230404", "deep": "3", "pid": "698" }, { "id": "702", "name": "兴安区", "code": "230405", "deep": "3", "pid": "698" }, { "id": "703", "name": "东山区", "code": "230406", "deep": "3", "pid": "698" }, { "id": "704", "name": "兴山区", "code": "230407", "deep": "3", "pid": "698" }, { "id": "705", "name": "萝北县", "code": "230421", "deep": "3", "pid": "698" }, { "id": "706", "name": "绥滨县", "code": "230422", "deep": "3", "pid": "698" } ] }, { "id": "707", "name": "双鸭山市", "code": "230500", "deep": "2", "pid": "651", "area": [ { "id": "708", "name": "尖山区", "code": "230502", "deep": "3", "pid": "707" }, { "id": "709", "name": "岭东区", "code": "230503", "deep": "3", "pid": "707" }, { "id": "710", "name": "四方台区", "code": "230505", "deep": "3", "pid": "707" }, { "id": "711", "name": "宝山区", "code": "230506", "deep": "3", "pid": "707" }, { "id": "712", "name": "集贤县", "code": "230521", "deep": "3", "pid": "707" }, { "id": "713", "name": "友谊县", "code": "230522", "deep": "3", "pid": "707" }, { "id": "714", "name": "宝清县", "code": "230523", "deep": "3", "pid": "707" }, { "id": "715", "name": "饶河县", "code": "230524", "deep": "3", "pid": "707" } ] }, { "id": "716", "name": "大庆市", "code": "230600", "deep": "2", "pid": "651", "area": [ { "id": "717", "name": "萨尔图区", "code": "230602", "deep": "3", "pid": "716" }, { "id": "718", "name": "龙凤区", "code": "230603", "deep": "3", "pid": "716" }, { "id": "719", "name": "让胡路区", "code": "230604", "deep": "3", "pid": "716" }, { "id": "720", "name": "红岗区", "code": "230605", "deep": "3", "pid": "716" }, { "id": "721", "name": "大同区", "code": "230606", "deep": "3", "pid": "716" }, { "id": "722", "name": "肇州县", "code": "230621", "deep": "3", "pid": "716" }, { "id": "723", "name": "肇源县", "code": "230622", "deep": "3", "pid": "716" }, { "id": "724", "name": "林甸县", "code": "230623", "deep": "3", "pid": "716" }, { "id": "725", "name": "杜尔伯特蒙古族自治县", "code": "230624", "deep": "3", "pid": "716" } ] }, { "id": "726", "name": "伊春市", "code": "230700", "deep": "2", "pid": "651", "area": [ { "id": "727", "name": "伊春区", "code": "230702", "deep": "3", "pid": "726" }, { "id": "728", "name": "南岔区", "code": "230703", "deep": "3", "pid": "726" }, { "id": "729", "name": "友好区", "code": "230704", "deep": "3", "pid": "726" }, { "id": "730", "name": "西林区", "code": "230705", "deep": "3", "pid": "726" }, { "id": "731", "name": "翠峦区", "code": "230706", "deep": "3", "pid": "726" }, { "id": "732", "name": "新青区", "code": "230707", "deep": "3", "pid": "726" }, { "id": "733", "name": "美溪区", "code": "230708", "deep": "3", "pid": "726" }, { "id": "734", "name": "金山屯区", "code": "230709", "deep": "3", "pid": "726" }, { "id": "735", "name": "五营区", "code": "230710", "deep": "3", "pid": "726" }, { "id": "736", "name": "乌马河区", "code": "230711", "deep": "3", "pid": "726" }, { "id": "737", "name": "汤旺河区", "code": "230712", "deep": "3", "pid": "726" }, { "id": "738", "name": "带岭区", "code": "230713", "deep": "3", "pid": "726" }, { "id": "739", "name": "乌伊岭区", "code": "230714", "deep": "3", "pid": "726" }, { "id": "740", "name": "红星区", "code": "230715", "deep": "3", "pid": "726" }, { "id": "741", "name": "上甘岭区", "code": "230716", "deep": "3", "pid": "726" }, { "id": "742", "name": "嘉荫县", "code": "230722", "deep": "3", "pid": "726" }, { "id": "743", "name": "铁力市", "code": "230781", "deep": "3", "pid": "726" } ] }, { "id": "744", "name": "佳木斯市", "code": "230800", "deep": "2", "pid": "651", "area": [ { "id": "745", "name": "向阳区", "code": "230803", "deep": "3", "pid": "744" }, { "id": "746", "name": "前进区", "code": "230804", "deep": "3", "pid": "744" }, { "id": "747", "name": "东风区", "code": "230805", "deep": "3", "pid": "744" }, { "id": "748", "name": "郊区", "code": "230811", "deep": "3", "pid": "744" }, { "id": "749", "name": "桦南县", "code": "230822", "deep": "3", "pid": "744" }, { "id": "750", "name": "桦川县", "code": "230826", "deep": "3", "pid": "744" }, { "id": "751", "name": "汤原县", "code": "230828", "deep": "3", "pid": "744" }, { "id": "752", "name": "抚远市", "code": "230833", "deep": "3", "pid": "744" }, { "id": "753", "name": "同江市", "code": "230881", "deep": "3", "pid": "744" }, { "id": "754", "name": "富锦市", "code": "230882", "deep": "3", "pid": "744" }, { "id": "3381", "name": "抚远市", "code": "230883", "deep": "3", "pid": "744" } ] }, { "id": "755", "name": "七台河市", "code": "230900", "deep": "2", "pid": "651", "area": [ { "id": "756", "name": "新兴区", "code": "230902", "deep": "3", "pid": "755" }, { "id": "757", "name": "桃山区", "code": "230903", "deep": "3", "pid": "755" }, { "id": "758", "name": "茄子河区", "code": "230904", "deep": "3", "pid": "755" }, { "id": "759", "name": "勃利县", "code": "230921", "deep": "3", "pid": "755" } ] }, { "id": "760", "name": "牡丹江市", "code": "231000", "deep": "2", "pid": "651", "area": [ { "id": "761", "name": "东安区", "code": "231002", "deep": "3", "pid": "760" }, { "id": "762", "name": "阳明区", "code": "231003", "deep": "3", "pid": "760" }, { "id": "763", "name": "爱民区", "code": "231004", "deep": "3", "pid": "760" }, { "id": "764", "name": "西安区", "code": "231005", "deep": "3", "pid": "760" }, { "id": "765", "name": "林口县", "code": "231025", "deep": "3", "pid": "760" }, { "id": "766", "name": "绥芬河市", "code": "231081", "deep": "3", "pid": "760" }, { "id": "767", "name": "海林市", "code": "231083", "deep": "3", "pid": "760" }, { "id": "768", "name": "宁安市", "code": "231084", "deep": "3", "pid": "760" }, { "id": "769", "name": "穆棱市", "code": "231085", "deep": "3", "pid": "760" }, { "id": "770", "name": "东宁市", "code": "231086", "deep": "3", "pid": "760" } ] }, { "id": "771", "name": "黑河市", "code": "231100", "deep": "2", "pid": "651", "area": [ { "id": "772", "name": "爱辉区", "code": "231102", "deep": "3", "pid": "771" }, { "id": "773", "name": "嫩江县", "code": "231121", "deep": "3", "pid": "771" }, { "id": "774", "name": "逊克县", "code": "231123", "deep": "3", "pid": "771" }, { "id": "775", "name": "孙吴县", "code": "231124", "deep": "3", "pid": "771" }, { "id": "776", "name": "北安市", "code": "231181", "deep": "3", "pid": "771" }, { "id": "777", "name": "五大连池市", "code": "231182", "deep": "3", "pid": "771" } ] }, { "id": "778", "name": "绥化市", "code": "231200", "deep": "2", "pid": "651", "area": [ { "id": "779", "name": "北林区", "code": "231202", "deep": "3", "pid": "778" }, { "id": "780", "name": "望奎县", "code": "231221", "deep": "3", "pid": "778" }, { "id": "781", "name": "兰西县", "code": "231222", "deep": "3", "pid": "778" }, { "id": "782", "name": "青冈县", "code": "231223", "deep": "3", "pid": "778" }, { "id": "783", "name": "庆安县", "code": "231224", "deep": "3", "pid": "778" }, { "id": "784", "name": "明水县", "code": "231225", "deep": "3", "pid": "778" }, { "id": "785", "name": "绥棱县", "code": "231226", "deep": "3", "pid": "778" }, { "id": "786", "name": "安达市", "code": "231281", "deep": "3", "pid": "778" }, { "id": "787", "name": "肇东市", "code": "231282", "deep": "3", "pid": "778" }, { "id": "788", "name": "海伦市", "code": "231283", "deep": "3", "pid": "778" } ] }, { "id": "789", "name": "大兴安岭地区", "code": "232700", "deep": "2", "pid": "651", "area": [ { "id": "790", "name": "加格达奇区", "code": "232701", "deep": "3", "pid": "789" }, { "id": "791", "name": "呼玛县", "code": "232721", "deep": "3", "pid": "789" }, { "id": "792", "name": "塔河县", "code": "232722", "deep": "3", "pid": "789" }, { "id": "793", "name": "漠河县", "code": "232723", "deep": "3", "pid": "789" } ] } ] }, { "id": "794", "name": "上海市", "code": "310000", "deep": "1", "pid": "0", "city": [ { "id": "795", "name": "上海市市辖区", "code": "310100", "deep": "2", "pid": "794", "area": [ { "id": "796", "name": "黄浦区", "code": "310101", "deep": "3", "pid": "795" }, { "id": "797", "name": "徐汇区", "code": "310104", "deep": "3", "pid": "795" }, { "id": "798", "name": "长宁区", "code": "310105", "deep": "3", "pid": "795" }, { "id": "799", "name": "静安区", "code": "310106", "deep": "3", "pid": "795" }, { "id": "800", "name": "普陀区", "code": "310107", "deep": "3", "pid": "795" }, { "id": "801", "name": "虹口区", "code": "310109", "deep": "3", "pid": "795" }, { "id": "802", "name": "杨浦区", "code": "310110", "deep": "3", "pid": "795" }, { "id": "803", "name": "闵行区", "code": "310112", "deep": "3", "pid": "795" }, { "id": "804", "name": "宝山区", "code": "310113", "deep": "3", "pid": "795" }, { "id": "805", "name": "嘉定区", "code": "310114", "deep": "3", "pid": "795" }, { "id": "806", "name": "浦东新区", "code": "310115", "deep": "3", "pid": "795" }, { "id": "807", "name": "金山区", "code": "310116", "deep": "3", "pid": "795" }, { "id": "808", "name": "松江区", "code": "310117", "deep": "3", "pid": "795" }, { "id": "809", "name": "青浦区", "code": "310118", "deep": "3", "pid": "795" }, { "id": "810", "name": "奉贤区", "code": "310120", "deep": "3", "pid": "795" }, { "id": "811", "name": "崇明区", "code": "310151", "deep": "3", "pid": "795" } ] }, { "id": "812", "name": "上海市郊县", "code": "310200", "deep": "2", "pid": "794" } ] }, { "id": "813", "name": "江苏省", "code": "320000", "deep": "1", "pid": "0", "city": [ { "id": "814", "name": "南京市", "code": "320100", "deep": "2", "pid": "813", "area": [ { "id": "815", "name": "玄武区", "code": "320102", "deep": "3", "pid": "814" }, { "id": "816", "name": "秦淮区", "code": "320104", "deep": "3", "pid": "814" }, { "id": "817", "name": "建邺区", "code": "320105", "deep": "3", "pid": "814" }, { "id": "818", "name": "鼓楼区", "code": "320106", "deep": "3", "pid": "814" }, { "id": "819", "name": "浦口区", "code": "320111", "deep": "3", "pid": "814" }, { "id": "820", "name": "栖霞区", "code": "320113", "deep": "3", "pid": "814" }, { "id": "821", "name": "雨花台区", "code": "320114", "deep": "3", "pid": "814" }, { "id": "822", "name": "江宁区", "code": "320115", "deep": "3", "pid": "814" }, { "id": "823", "name": "六合区", "code": "320116", "deep": "3", "pid": "814" }, { "id": "824", "name": "溧水区", "code": "320117", "deep": "3", "pid": "814" }, { "id": "825", "name": "高淳区", "code": "320118", "deep": "3", "pid": "814" } ] }, { "id": "826", "name": "无锡市", "code": "320200", "deep": "2", "pid": "813", "area": [ { "id": "827", "name": "锡山区", "code": "320205", "deep": "3", "pid": "826" }, { "id": "828", "name": "惠山区", "code": "320206", "deep": "3", "pid": "826" }, { "id": "829", "name": "滨湖区", "code": "320211", "deep": "3", "pid": "826" }, { "id": "830", "name": "梁溪区", "code": "320213", "deep": "3", "pid": "826" }, { "id": "831", "name": "新吴区", "code": "320214", "deep": "3", "pid": "826" }, { "id": "832", "name": "江阴市", "code": "320281", "deep": "3", "pid": "826" }, { "id": "833", "name": "宜兴市", "code": "320282", "deep": "3", "pid": "826" } ] }, { "id": "834", "name": "徐州市", "code": "320300", "deep": "2", "pid": "813", "area": [ { "id": "835", "name": "鼓楼区", "code": "320302", "deep": "3", "pid": "834" }, { "id": "836", "name": "云龙区", "code": "320303", "deep": "3", "pid": "834" }, { "id": "837", "name": "贾汪区", "code": "320305", "deep": "3", "pid": "834" }, { "id": "838", "name": "泉山区", "code": "320311", "deep": "3", "pid": "834" }, { "id": "839", "name": "铜山区", "code": "320312", "deep": "3", "pid": "834" }, { "id": "840", "name": "丰县", "code": "320321", "deep": "3", "pid": "834" }, { "id": "841", "name": "沛县", "code": "320322", "deep": "3", "pid": "834" }, { "id": "842", "name": "睢宁县", "code": "320324", "deep": "3", "pid": "834" }, { "id": "843", "name": "新沂市", "code": "320381", "deep": "3", "pid": "834" }, { "id": "844", "name": "邳州市", "code": "320382", "deep": "3", "pid": "834" } ] }, { "id": "845", "name": "常州市", "code": "320400", "deep": "2", "pid": "813", "area": [ { "id": "846", "name": "天宁区", "code": "320402", "deep": "3", "pid": "845" }, { "id": "847", "name": "钟楼区", "code": "320404", "deep": "3", "pid": "845" }, { "id": "848", "name": "新北区", "code": "320411", "deep": "3", "pid": "845" }, { "id": "849", "name": "武进区", "code": "320412", "deep": "3", "pid": "845" }, { "id": "850", "name": "金坛区", "code": "320413", "deep": "3", "pid": "845" }, { "id": "851", "name": "溧阳市", "code": "320481", "deep": "3", "pid": "845" } ] }, { "id": "852", "name": "苏州市", "code": "320500", "deep": "2", "pid": "813", "area": [ { "id": "853", "name": "虎丘区", "code": "320505", "deep": "3", "pid": "852" }, { "id": "854", "name": "吴中区", "code": "320506", "deep": "3", "pid": "852" }, { "id": "855", "name": "相城区", "code": "320507", "deep": "3", "pid": "852" }, { "id": "856", "name": "姑苏区", "code": "320508", "deep": "3", "pid": "852" }, { "id": "857", "name": "吴江区", "code": "320509", "deep": "3", "pid": "852" }, { "id": "858", "name": "常熟市", "code": "320581", "deep": "3", "pid": "852" }, { "id": "859", "name": "张家港市", "code": "320582", "deep": "3", "pid": "852" }, { "id": "860", "name": "昆山市", "code": "320583", "deep": "3", "pid": "852" }, { "id": "861", "name": "太仓市", "code": "320585", "deep": "3", "pid": "852" } ] }, { "id": "862", "name": "南通市", "code": "320600", "deep": "2", "pid": "813", "area": [ { "id": "863", "name": "崇川区", "code": "320602", "deep": "3", "pid": "862" }, { "id": "864", "name": "港闸区", "code": "320611", "deep": "3", "pid": "862" }, { "id": "865", "name": "通州区", "code": "320612", "deep": "3", "pid": "862" }, { "id": "866", "name": "海安县", "code": "320621", "deep": "3", "pid": "862" }, { "id": "867", "name": "如东县", "code": "320623", "deep": "3", "pid": "862" }, { "id": "868", "name": "启东市", "code": "320681", "deep": "3", "pid": "862" }, { "id": "869", "name": "如皋市", "code": "320682", "deep": "3", "pid": "862" }, { "id": "870", "name": "海门市", "code": "320684", "deep": "3", "pid": "862" } ] }, { "id": "871", "name": "连云港市", "code": "320700", "deep": "2", "pid": "813", "area": [ { "id": "872", "name": "连云区", "code": "320703", "deep": "3", "pid": "871" }, { "id": "873", "name": "海州区", "code": "320706", "deep": "3", "pid": "871" }, { "id": "874", "name": "赣榆区", "code": "320707", "deep": "3", "pid": "871" }, { "id": "875", "name": "东海县", "code": "320722", "deep": "3", "pid": "871" }, { "id": "876", "name": "灌云县", "code": "320723", "deep": "3", "pid": "871" }, { "id": "877", "name": "灌南县", "code": "320724", "deep": "3", "pid": "871" } ] }, { "id": "878", "name": "淮安市", "code": "320800", "deep": "2", "pid": "813", "area": [ { "id": "879", "name": "清河区", "code": "320802", "deep": "3", "pid": "878" }, { "id": "880", "name": "淮安区", "code": "320803", "deep": "3", "pid": "878" }, { "id": "881", "name": "淮阴区", "code": "320804", "deep": "3", "pid": "878" }, { "id": "882", "name": "清江浦区", "code": "320812", "deep": "3", "pid": "878" }, { "id": "883", "name": "涟水县", "code": "320826", "deep": "3", "pid": "878" }, { "id": "884", "name": "洪泽区", "code": "320813", "deep": "3", "pid": "878" }, { "id": "885", "name": "盱眙县", "code": "320830", "deep": "3", "pid": "878" }, { "id": "886", "name": "金湖县", "code": "320831", "deep": "3", "pid": "878" } ] }, { "id": "887", "name": "盐城市", "code": "320900", "deep": "2", "pid": "813", "area": [ { "id": "888", "name": "亭湖区", "code": "320902", "deep": "3", "pid": "887" }, { "id": "889", "name": "盐都区", "code": "320903", "deep": "3", "pid": "887" }, { "id": "890", "name": "大丰区", "code": "320904", "deep": "3", "pid": "887" }, { "id": "891", "name": "响水县", "code": "320921", "deep": "3", "pid": "887" }, { "id": "892", "name": "滨海县", "code": "320922", "deep": "3", "pid": "887" }, { "id": "893", "name": "阜宁县", "code": "320923", "deep": "3", "pid": "887" }, { "id": "894", "name": "射阳县", "code": "320924", "deep": "3", "pid": "887" }, { "id": "895", "name": "建湖县", "code": "320925", "deep": "3", "pid": "887" }, { "id": "896", "name": "东台市", "code": "320981", "deep": "3", "pid": "887" } ] }, { "id": "897", "name": "扬州市", "code": "321000", "deep": "2", "pid": "813", "area": [ { "id": "898", "name": "广陵区", "code": "321002", "deep": "3", "pid": "897" }, { "id": "899", "name": "邗江区", "code": "321003", "deep": "3", "pid": "897" }, { "id": "900", "name": "江都区", "code": "321012", "deep": "3", "pid": "897" }, { "id": "901", "name": "宝应县", "code": "321023", "deep": "3", "pid": "897" }, { "id": "902", "name": "仪征市", "code": "321081", "deep": "3", "pid": "897" }, { "id": "903", "name": "高邮市", "code": "321084", "deep": "3", "pid": "897" } ] }, { "id": "904", "name": "镇江市", "code": "321100", "deep": "2", "pid": "813", "area": [ { "id": "905", "name": "京口区", "code": "321102", "deep": "3", "pid": "904" }, { "id": "906", "name": "润州区", "code": "321111", "deep": "3", "pid": "904" }, { "id": "907", "name": "丹徒区", "code": "321112", "deep": "3", "pid": "904" }, { "id": "908", "name": "丹阳市", "code": "321181", "deep": "3", "pid": "904" }, { "id": "909", "name": "扬中市", "code": "321182", "deep": "3", "pid": "904" }, { "id": "910", "name": "句容市", "code": "321183", "deep": "3", "pid": "904" } ] }, { "id": "911", "name": "泰州市", "code": "321200", "deep": "2", "pid": "813", "area": [ { "id": "912", "name": "海陵区", "code": "321202", "deep": "3", "pid": "911" }, { "id": "913", "name": "高港区", "code": "321203", "deep": "3", "pid": "911" }, { "id": "914", "name": "姜堰区", "code": "321204", "deep": "3", "pid": "911" }, { "id": "915", "name": "兴化市", "code": "321281", "deep": "3", "pid": "911" }, { "id": "916", "name": "靖江市", "code": "321282", "deep": "3", "pid": "911" }, { "id": "917", "name": "泰兴市", "code": "321283", "deep": "3", "pid": "911" } ] }, { "id": "918", "name": "宿迁市", "code": "321300", "deep": "2", "pid": "813", "area": [ { "id": "919", "name": "宿城区", "code": "321302", "deep": "3", "pid": "918" }, { "id": "920", "name": "宿豫区", "code": "321311", "deep": "3", "pid": "918" }, { "id": "921", "name": "沭阳县", "code": "321322", "deep": "3", "pid": "918" }, { "id": "922", "name": "泗阳县", "code": "321323", "deep": "3", "pid": "918" }, { "id": "923", "name": "泗洪县", "code": "321324", "deep": "3", "pid": "918" } ] } ] }, { "id": "924", "name": "浙江省", "code": "330000", "deep": "1", "pid": "0", "city": [ { "id": "925", "name": "杭州市", "code": "330100", "deep": "2", "pid": "924", "area": [ { "id": "926", "name": "上城区", "code": "330102", "deep": "3", "pid": "925" }, { "id": "927", "name": "下城区", "code": "330103", "deep": "3", "pid": "925" }, { "id": "928", "name": "江干区", "code": "330104", "deep": "3", "pid": "925" }, { "id": "929", "name": "拱墅区", "code": "330105", "deep": "3", "pid": "925" }, { "id": "930", "name": "西湖区", "code": "330106", "deep": "3", "pid": "925" }, { "id": "931", "name": "滨江区", "code": "330108", "deep": "3", "pid": "925" }, { "id": "932", "name": "萧山区", "code": "330109", "deep": "3", "pid": "925" }, { "id": "933", "name": "余杭区", "code": "330110", "deep": "3", "pid": "925" }, { "id": "934", "name": "富阳区", "code": "330111", "deep": "3", "pid": "925" }, { "id": "935", "name": "桐庐县", "code": "330122", "deep": "3", "pid": "925" }, { "id": "936", "name": "淳安县", "code": "330127", "deep": "3", "pid": "925" }, { "id": "937", "name": "建德市", "code": "330182", "deep": "3", "pid": "925" }, { "id": "938", "name": "临安市", "code": "330185", "deep": "3", "pid": "925" } ] }, { "id": "939", "name": "宁波市", "code": "330200", "deep": "2", "pid": "924", "area": [ { "id": "940", "name": "海曙区", "code": "330203", "deep": "3", "pid": "939" }, { "id": "941", "name": "江东区", "code": "330204", "deep": "3", "pid": "939" }, { "id": "942", "name": "江北区", "code": "330205", "deep": "3", "pid": "939" }, { "id": "943", "name": "北仑区", "code": "330206", "deep": "3", "pid": "939" }, { "id": "944", "name": "镇海区", "code": "330211", "deep": "3", "pid": "939" }, { "id": "945", "name": "鄞州区", "code": "330212", "deep": "3", "pid": "939" }, { "id": "946", "name": "象山县", "code": "330225", "deep": "3", "pid": "939" }, { "id": "947", "name": "宁海县", "code": "330226", "deep": "3", "pid": "939" }, { "id": "948", "name": "余姚市", "code": "330281", "deep": "3", "pid": "939" }, { "id": "949", "name": "慈溪市", "code": "330282", "deep": "3", "pid": "939" }, { "id": "950", "name": "奉化区", "code": "330213", "deep": "3", "pid": "939" }, { "id": "3383", "name": "奉化市", "code": "330283", "deep": "3", "pid": "939" } ] }, { "id": "951", "name": "温州市", "code": "330300", "deep": "2", "pid": "924", "area": [ { "id": "952", "name": "鹿城区", "code": "330302", "deep": "3", "pid": "951" }, { "id": "953", "name": "龙湾区", "code": "330303", "deep": "3", "pid": "951" }, { "id": "954", "name": "瓯海区", "code": "330304", "deep": "3", "pid": "951" }, { "id": "955", "name": "洞头区", "code": "330305", "deep": "3", "pid": "951" }, { "id": "956", "name": "永嘉县", "code": "330324", "deep": "3", "pid": "951" }, { "id": "957", "name": "平阳县", "code": "330326", "deep": "3", "pid": "951" }, { "id": "958", "name": "苍南县", "code": "330327", "deep": "3", "pid": "951" }, { "id": "959", "name": "文成县", "code": "330328", "deep": "3", "pid": "951" }, { "id": "960", "name": "泰顺县", "code": "330329", "deep": "3", "pid": "951" }, { "id": "961", "name": "瑞安市", "code": "330381", "deep": "3", "pid": "951" }, { "id": "962", "name": "乐清市", "code": "330382", "deep": "3", "pid": "951" } ] }, { "id": "963", "name": "嘉兴市", "code": "330400", "deep": "2", "pid": "924", "area": [ { "id": "964", "name": "南湖区", "code": "330402", "deep": "3", "pid": "963" }, { "id": "965", "name": "秀洲区", "code": "330411", "deep": "3", "pid": "963" }, { "id": "966", "name": "嘉善县", "code": "330421", "deep": "3", "pid": "963" }, { "id": "967", "name": "海盐县", "code": "330424", "deep": "3", "pid": "963" }, { "id": "968", "name": "海宁市", "code": "330481", "deep": "3", "pid": "963" }, { "id": "969", "name": "平湖市", "code": "330482", "deep": "3", "pid": "963" }, { "id": "970", "name": "桐乡市", "code": "330483", "deep": "3", "pid": "963" } ] }, { "id": "971", "name": "湖州市", "code": "330500", "deep": "2", "pid": "924", "area": [ { "id": "972", "name": "吴兴区", "code": "330502", "deep": "3", "pid": "971" }, { "id": "973", "name": "南浔区", "code": "330503", "deep": "3", "pid": "971" }, { "id": "974", "name": "德清县", "code": "330521", "deep": "3", "pid": "971" }, { "id": "975", "name": "长兴县", "code": "330522", "deep": "3", "pid": "971" }, { "id": "976", "name": "安吉县", "code": "330523", "deep": "3", "pid": "971" } ] }, { "id": "977", "name": "绍兴市", "code": "330600", "deep": "2", "pid": "924", "area": [ { "id": "978", "name": "越城区", "code": "330602", "deep": "3", "pid": "977" }, { "id": "979", "name": "柯桥区", "code": "330603", "deep": "3", "pid": "977" }, { "id": "980", "name": "上虞区", "code": "330604", "deep": "3", "pid": "977" }, { "id": "981", "name": "新昌县", "code": "330624", "deep": "3", "pid": "977" }, { "id": "982", "name": "诸暨市", "code": "330681", "deep": "3", "pid": "977" }, { "id": "983", "name": "嵊州市", "code": "330683", "deep": "3", "pid": "977" } ] }, { "id": "984", "name": "金华市", "code": "330700", "deep": "2", "pid": "924", "area": [ { "id": "985", "name": "婺城区", "code": "330702", "deep": "3", "pid": "984" }, { "id": "986", "name": "金东区", "code": "330703", "deep": "3", "pid": "984" }, { "id": "987", "name": "武义县", "code": "330723", "deep": "3", "pid": "984" }, { "id": "988", "name": "浦江县", "code": "330726", "deep": "3", "pid": "984" }, { "id": "989", "name": "磐安县", "code": "330727", "deep": "3", "pid": "984" }, { "id": "990", "name": "兰溪市", "code": "330781", "deep": "3", "pid": "984" }, { "id": "991", "name": "义乌市", "code": "330782", "deep": "3", "pid": "984" }, { "id": "992", "name": "东阳市", "code": "330783", "deep": "3", "pid": "984" }, { "id": "993", "name": "永康市", "code": "330784", "deep": "3", "pid": "984" } ] }, { "id": "994", "name": "衢州市", "code": "330800", "deep": "2", "pid": "924", "area": [ { "id": "995", "name": "柯城区", "code": "330802", "deep": "3", "pid": "994" }, { "id": "996", "name": "衢江区", "code": "330803", "deep": "3", "pid": "994" }, { "id": "997", "name": "常山县", "code": "330822", "deep": "3", "pid": "994" }, { "id": "998", "name": "开化县", "code": "330824", "deep": "3", "pid": "994" }, { "id": "999", "name": "龙游县", "code": "330825", "deep": "3", "pid": "994" }, { "id": "1000", "name": "江山市", "code": "330881", "deep": "3", "pid": "994" } ] }, { "id": "1001", "name": "舟山市", "code": "330900", "deep": "2", "pid": "924", "area": [ { "id": "1002", "name": "定海区", "code": "330902", "deep": "3", "pid": "1001" }, { "id": "1003", "name": "普陀区", "code": "330903", "deep": "3", "pid": "1001" }, { "id": "1004", "name": "岱山县", "code": "330921", "deep": "3", "pid": "1001" }, { "id": "1005", "name": "嵊泗县", "code": "330922", "deep": "3", "pid": "1001" } ] }, { "id": "1006", "name": "台州市", "code": "331000", "deep": "2", "pid": "924", "area": [ { "id": "1007", "name": "椒江区", "code": "331002", "deep": "3", "pid": "1006" }, { "id": "1008", "name": "黄岩区", "code": "331003", "deep": "3", "pid": "1006" }, { "id": "1009", "name": "路桥区", "code": "331004", "deep": "3", "pid": "1006" }, { "id": "1010", "name": "玉环市", "code": "331083", "deep": "3", "pid": "1006" }, { "id": "1011", "name": "三门县", "code": "331022", "deep": "3", "pid": "1006" }, { "id": "1012", "name": "天台县", "code": "331023", "deep": "3", "pid": "1006" }, { "id": "1013", "name": "仙居县", "code": "331024", "deep": "3", "pid": "1006" }, { "id": "1014", "name": "温岭市", "code": "331081", "deep": "3", "pid": "1006" }, { "id": "1015", "name": "临海市", "code": "331082", "deep": "3", "pid": "1006" }, { "id": "3384", "name": "玉环县", "code": "331021", "deep": "3", "pid": "1006" } ] }, { "id": "1016", "name": "丽水市", "code": "331100", "deep": "2", "pid": "924", "area": [ { "id": "1017", "name": "莲都区", "code": "331102", "deep": "3", "pid": "1016" }, { "id": "1018", "name": "青田县", "code": "331121", "deep": "3", "pid": "1016" }, { "id": "1019", "name": "缙云县", "code": "331122", "deep": "3", "pid": "1016" }, { "id": "1020", "name": "遂昌县", "code": "331123", "deep": "3", "pid": "1016" }, { "id": "1021", "name": "松阳县", "code": "331124", "deep": "3", "pid": "1016" }, { "id": "1022", "name": "云和县", "code": "331125", "deep": "3", "pid": "1016" }, { "id": "1023", "name": "庆元县", "code": "331126", "deep": "3", "pid": "1016" }, { "id": "1024", "name": "景宁畲族自治县", "code": "331127", "deep": "3", "pid": "1016" }, { "id": "1025", "name": "龙泉市", "code": "331181", "deep": "3", "pid": "1016" } ] } ] }, { "id": "1026", "name": "安徽省", "code": "340000", "deep": "1", "pid": "0", "city": [ { "id": "1027", "name": "合肥市", "code": "340100", "deep": "2", "pid": "1026", "area": [ { "id": "1028", "name": "瑶海区", "code": "340102", "deep": "3", "pid": "1027" }, { "id": "1029", "name": "庐阳区", "code": "340103", "deep": "3", "pid": "1027" }, { "id": "1030", "name": "蜀山区", "code": "340104", "deep": "3", "pid": "1027" }, { "id": "1031", "name": "包河区", "code": "340111", "deep": "3", "pid": "1027" }, { "id": "1032", "name": "长丰县", "code": "340121", "deep": "3", "pid": "1027" }, { "id": "1033", "name": "肥东县", "code": "340122", "deep": "3", "pid": "1027" }, { "id": "1034", "name": "肥西县", "code": "340123", "deep": "3", "pid": "1027" }, { "id": "1035", "name": "庐江县", "code": "340124", "deep": "3", "pid": "1027" }, { "id": "1036", "name": "巢湖市", "code": "340181", "deep": "3", "pid": "1027" } ] }, { "id": "1037", "name": "芜湖市", "code": "340200", "deep": "2", "pid": "1026", "area": [ { "id": "1038", "name": "镜湖区", "code": "340202", "deep": "3", "pid": "1037" }, { "id": "1039", "name": "弋江区", "code": "340203", "deep": "3", "pid": "1037" }, { "id": "1040", "name": "鸠江区", "code": "340207", "deep": "3", "pid": "1037" }, { "id": "1041", "name": "三山区", "code": "340208", "deep": "3", "pid": "1037" }, { "id": "1042", "name": "芜湖县", "code": "340221", "deep": "3", "pid": "1037" }, { "id": "1043", "name": "繁昌县", "code": "340222", "deep": "3", "pid": "1037" }, { "id": "1044", "name": "南陵县", "code": "340223", "deep": "3", "pid": "1037" }, { "id": "1045", "name": "无为县", "code": "340225", "deep": "3", "pid": "1037" } ] }, { "id": "1046", "name": "蚌埠市", "code": "340300", "deep": "2", "pid": "1026", "area": [ { "id": "1047", "name": "龙子湖区", "code": "340302", "deep": "3", "pid": "1046" }, { "id": "1048", "name": "蚌山区", "code": "340303", "deep": "3", "pid": "1046" }, { "id": "1049", "name": "禹会区", "code": "340304", "deep": "3", "pid": "1046" }, { "id": "1050", "name": "淮上区", "code": "340311", "deep": "3", "pid": "1046" }, { "id": "1051", "name": "怀远县", "code": "340321", "deep": "3", "pid": "1046" }, { "id": "1052", "name": "五河县", "code": "340322", "deep": "3", "pid": "1046" }, { "id": "1053", "name": "固镇县", "code": "340323", "deep": "3", "pid": "1046" } ] }, { "id": "1054", "name": "淮南市", "code": "340400", "deep": "2", "pid": "1026", "area": [ { "id": "1055", "name": "大通区", "code": "340402", "deep": "3", "pid": "1054" }, { "id": "1056", "name": "田家庵区", "code": "340403", "deep": "3", "pid": "1054" }, { "id": "1057", "name": "谢家集区", "code": "340404", "deep": "3", "pid": "1054" }, { "id": "1058", "name": "八公山区", "code": "340405", "deep": "3", "pid": "1054" }, { "id": "1059", "name": "潘集区", "code": "340406", "deep": "3", "pid": "1054" }, { "id": "1060", "name": "凤台县", "code": "340421", "deep": "3", "pid": "1054" }, { "id": "1061", "name": "寿县", "code": "340422", "deep": "3", "pid": "1054" } ] }, { "id": "1062", "name": "马鞍山市", "code": "340500", "deep": "2", "pid": "1026", "area": [ { "id": "1063", "name": "花山区", "code": "340503", "deep": "3", "pid": "1062" }, { "id": "1064", "name": "雨山区", "code": "340504", "deep": "3", "pid": "1062" }, { "id": "1065", "name": "博望区", "code": "340506", "deep": "3", "pid": "1062" }, { "id": "1066", "name": "当涂县", "code": "340521", "deep": "3", "pid": "1062" }, { "id": "1067", "name": "含山县", "code": "340522", "deep": "3", "pid": "1062" }, { "id": "1068", "name": "和县", "code": "340523", "deep": "3", "pid": "1062" } ] }, { "id": "1069", "name": "淮北市", "code": "340600", "deep": "2", "pid": "1026", "area": [ { "id": "1070", "name": "杜集区", "code": "340602", "deep": "3", "pid": "1069" }, { "id": "1071", "name": "相山区", "code": "340603", "deep": "3", "pid": "1069" }, { "id": "1072", "name": "烈山区", "code": "340604", "deep": "3", "pid": "1069" }, { "id": "1073", "name": "濉溪县", "code": "340621", "deep": "3", "pid": "1069" } ] }, { "id": "1074", "name": "铜陵市", "code": "340700", "deep": "2", "pid": "1026", "area": [ { "id": "1075", "name": "铜官区", "code": "340705", "deep": "3", "pid": "1074" }, { "id": "1076", "name": "义安区", "code": "340706", "deep": "3", "pid": "1074" }, { "id": "1077", "name": "郊区", "code": "340711", "deep": "3", "pid": "1074" }, { "id": "1078", "name": "枞阳县", "code": "340722", "deep": "3", "pid": "1074" } ] }, { "id": "1079", "name": "安庆市", "code": "340800", "deep": "2", "pid": "1026", "area": [ { "id": "1080", "name": "迎江区", "code": "340802", "deep": "3", "pid": "1079" }, { "id": "1081", "name": "大观区", "code": "340803", "deep": "3", "pid": "1079" }, { "id": "1082", "name": "宜秀区", "code": "340811", "deep": "3", "pid": "1079" }, { "id": "1083", "name": "怀宁县", "code": "340822", "deep": "3", "pid": "1079" }, { "id": "1084", "name": "潜山县", "code": "340824", "deep": "3", "pid": "1079" }, { "id": "1085", "name": "太湖县", "code": "340825", "deep": "3", "pid": "1079" }, { "id": "1086", "name": "宿松县", "code": "340826", "deep": "3", "pid": "1079" }, { "id": "1087", "name": "望江县", "code": "340827", "deep": "3", "pid": "1079" }, { "id": "1088", "name": "岳西县", "code": "340828", "deep": "3", "pid": "1079" }, { "id": "1089", "name": "桐城市", "code": "340881", "deep": "3", "pid": "1079" } ] }, { "id": "1090", "name": "黄山市", "code": "341000", "deep": "2", "pid": "1026", "area": [ { "id": "1091", "name": "屯溪区", "code": "341002", "deep": "3", "pid": "1090" }, { "id": "1092", "name": "黄山区", "code": "341003", "deep": "3", "pid": "1090" }, { "id": "1093", "name": "徽州区", "code": "341004", "deep": "3", "pid": "1090" }, { "id": "1094", "name": "歙县", "code": "341021", "deep": "3", "pid": "1090" }, { "id": "1095", "name": "休宁县", "code": "341022", "deep": "3", "pid": "1090" }, { "id": "1096", "name": "黟县", "code": "341023", "deep": "3", "pid": "1090" }, { "id": "1097", "name": "祁门县", "code": "341024", "deep": "3", "pid": "1090" } ] }, { "id": "1098", "name": "滁州市", "code": "341100", "deep": "2", "pid": "1026", "area": [ { "id": "1099", "name": "琅琊区", "code": "341102", "deep": "3", "pid": "1098" }, { "id": "1100", "name": "南谯区", "code": "341103", "deep": "3", "pid": "1098" }, { "id": "1101", "name": "来安县", "code": "341122", "deep": "3", "pid": "1098" }, { "id": "1102", "name": "全椒县", "code": "341124", "deep": "3", "pid": "1098" }, { "id": "1103", "name": "定远县", "code": "341125", "deep": "3", "pid": "1098" }, { "id": "1104", "name": "凤阳县", "code": "341126", "deep": "3", "pid": "1098" }, { "id": "1105", "name": "天长市", "code": "341181", "deep": "3", "pid": "1098" }, { "id": "1106", "name": "明光市", "code": "341182", "deep": "3", "pid": "1098" } ] }, { "id": "1107", "name": "阜阳市", "code": "341200", "deep": "2", "pid": "1026", "area": [ { "id": "1108", "name": "颍州区", "code": "341202", "deep": "3", "pid": "1107" }, { "id": "1109", "name": "颍东区", "code": "341203", "deep": "3", "pid": "1107" }, { "id": "1110", "name": "颍泉区", "code": "341204", "deep": "3", "pid": "1107" }, { "id": "1111", "name": "临泉县", "code": "341221", "deep": "3", "pid": "1107" }, { "id": "1112", "name": "太和县", "code": "341222", "deep": "3", "pid": "1107" }, { "id": "1113", "name": "阜南县", "code": "341225", "deep": "3", "pid": "1107" }, { "id": "1114", "name": "颍上县", "code": "341226", "deep": "3", "pid": "1107" }, { "id": "1115", "name": "界首市", "code": "341282", "deep": "3", "pid": "1107" } ] }, { "id": "1116", "name": "宿州市", "code": "341300", "deep": "2", "pid": "1026", "area": [ { "id": "1117", "name": "埇桥区", "code": "341302", "deep": "3", "pid": "1116" }, { "id": "1118", "name": "砀山县", "code": "341321", "deep": "3", "pid": "1116" }, { "id": "1119", "name": "萧县", "code": "341322", "deep": "3", "pid": "1116" }, { "id": "1120", "name": "灵璧县", "code": "341323", "deep": "3", "pid": "1116" }, { "id": "1121", "name": "泗县", "code": "341324", "deep": "3", "pid": "1116" } ] }, { "id": "1122", "name": "六安市", "code": "341500", "deep": "2", "pid": "1026", "area": [ { "id": "1123", "name": "金安区", "code": "341502", "deep": "3", "pid": "1122" }, { "id": "1124", "name": "裕安区", "code": "341503", "deep": "3", "pid": "1122" }, { "id": "1125", "name": "叶集区", "code": "341504", "deep": "3", "pid": "1122" }, { "id": "1126", "name": "霍邱县", "code": "341522", "deep": "3", "pid": "1122" }, { "id": "1127", "name": "舒城县", "code": "341523", "deep": "3", "pid": "1122" }, { "id": "1128", "name": "金寨县", "code": "341524", "deep": "3", "pid": "1122" }, { "id": "1129", "name": "霍山县", "code": "341525", "deep": "3", "pid": "1122" } ] }, { "id": "1130", "name": "亳州市", "code": "341600", "deep": "2", "pid": "1026", "area": [ { "id": "1131", "name": "谯城区", "code": "341602", "deep": "3", "pid": "1130" }, { "id": "1132", "name": "涡阳县", "code": "341621", "deep": "3", "pid": "1130" }, { "id": "1133", "name": "蒙城县", "code": "341622", "deep": "3", "pid": "1130" }, { "id": "1134", "name": "利辛县", "code": "341623", "deep": "3", "pid": "1130" } ] }, { "id": "1135", "name": "池州市", "code": "341700", "deep": "2", "pid": "1026", "area": [ { "id": "1136", "name": "贵池区", "code": "341702", "deep": "3", "pid": "1135" }, { "id": "1137", "name": "东至县", "code": "341721", "deep": "3", "pid": "1135" }, { "id": "1138", "name": "石台县", "code": "341722", "deep": "3", "pid": "1135" }, { "id": "1139", "name": "青阳县", "code": "341723", "deep": "3", "pid": "1135" } ] }, { "id": "1140", "name": "宣城市", "code": "341800", "deep": "2", "pid": "1026", "area": [ { "id": "1141", "name": "宣州区", "code": "341802", "deep": "3", "pid": "1140" }, { "id": "1142", "name": "郎溪县", "code": "341821", "deep": "3", "pid": "1140" }, { "id": "1143", "name": "广德县", "code": "341822", "deep": "3", "pid": "1140" }, { "id": "1144", "name": "泾县", "code": "341823", "deep": "3", "pid": "1140" }, { "id": "1145", "name": "绩溪县", "code": "341824", "deep": "3", "pid": "1140" }, { "id": "1146", "name": "旌德县", "code": "341825", "deep": "3", "pid": "1140" }, { "id": "1147", "name": "宁国市", "code": "341881", "deep": "3", "pid": "1140" } ] } ] }, { "id": "1148", "name": "福建省", "code": "350000", "deep": "1", "pid": "0", "city": [ { "id": "1149", "name": "福州市", "code": "350100", "deep": "2", "pid": "1148", "area": [ { "id": "1150", "name": "鼓楼区", "code": "350102", "deep": "3", "pid": "1149" }, { "id": "1151", "name": "台江区", "code": "350103", "deep": "3", "pid": "1149" }, { "id": "1152", "name": "仓山区", "code": "350104", "deep": "3", "pid": "1149" }, { "id": "1153", "name": "马尾区", "code": "350105", "deep": "3", "pid": "1149" }, { "id": "1154", "name": "晋安区", "code": "350111", "deep": "3", "pid": "1149" }, { "id": "1155", "name": "闽侯县", "code": "350121", "deep": "3", "pid": "1149" }, { "id": "1156", "name": "连江县", "code": "350122", "deep": "3", "pid": "1149" }, { "id": "1157", "name": "罗源县", "code": "350123", "deep": "3", "pid": "1149" }, { "id": "1158", "name": "闽清县", "code": "350124", "deep": "3", "pid": "1149" }, { "id": "1159", "name": "永泰县", "code": "350125", "deep": "3", "pid": "1149" }, { "id": "1160", "name": "平潭县", "code": "350128", "deep": "3", "pid": "1149" }, { "id": "1161", "name": "福清市", "code": "350181", "deep": "3", "pid": "1149" }, { "id": "1162", "name": "长乐市", "code": "350182", "deep": "3", "pid": "1149" } ] }, { "id": "1163", "name": "厦门市", "code": "350200", "deep": "2", "pid": "1148", "area": [ { "id": "1164", "name": "思明区", "code": "350203", "deep": "3", "pid": "1163" }, { "id": "1165", "name": "海沧区", "code": "350205", "deep": "3", "pid": "1163" }, { "id": "1166", "name": "湖里区", "code": "350206", "deep": "3", "pid": "1163" }, { "id": "1167", "name": "集美区", "code": "350211", "deep": "3", "pid": "1163" }, { "id": "1168", "name": "同安区", "code": "350212", "deep": "3", "pid": "1163" }, { "id": "1169", "name": "翔安区", "code": "350213", "deep": "3", "pid": "1163" } ] }, { "id": "1170", "name": "莆田市", "code": "350300", "deep": "2", "pid": "1148", "area": [ { "id": "1171", "name": "城厢区", "code": "350302", "deep": "3", "pid": "1170" }, { "id": "1172", "name": "涵江区", "code": "350303", "deep": "3", "pid": "1170" }, { "id": "1173", "name": "荔城区", "code": "350304", "deep": "3", "pid": "1170" }, { "id": "1174", "name": "秀屿区", "code": "350305", "deep": "3", "pid": "1170" }, { "id": "1175", "name": "仙游县", "code": "350322", "deep": "3", "pid": "1170" } ] }, { "id": "1176", "name": "三明市", "code": "350400", "deep": "2", "pid": "1148", "area": [ { "id": "1177", "name": "梅列区", "code": "350402", "deep": "3", "pid": "1176" }, { "id": "1178", "name": "三元区", "code": "350403", "deep": "3", "pid": "1176" }, { "id": "1179", "name": "明溪县", "code": "350421", "deep": "3", "pid": "1176" }, { "id": "1180", "name": "清流县", "code": "350423", "deep": "3", "pid": "1176" }, { "id": "1181", "name": "宁化县", "code": "350424", "deep": "3", "pid": "1176" }, { "id": "1182", "name": "大田县", "code": "350425", "deep": "3", "pid": "1176" }, { "id": "1183", "name": "尤溪县", "code": "350426", "deep": "3", "pid": "1176" }, { "id": "1184", "name": "沙县", "code": "350427", "deep": "3", "pid": "1176" }, { "id": "1185", "name": "将乐县", "code": "350428", "deep": "3", "pid": "1176" }, { "id": "1186", "name": "泰宁县", "code": "350429", "deep": "3", "pid": "1176" }, { "id": "1187", "name": "建宁县", "code": "350430", "deep": "3", "pid": "1176" }, { "id": "1188", "name": "永安市", "code": "350481", "deep": "3", "pid": "1176" } ] }, { "id": "1189", "name": "泉州市", "code": "350500", "deep": "2", "pid": "1148", "area": [ { "id": "1190", "name": "鲤城区", "code": "350502", "deep": "3", "pid": "1189" }, { "id": "1191", "name": "丰泽区", "code": "350503", "deep": "3", "pid": "1189" }, { "id": "1192", "name": "洛江区", "code": "350504", "deep": "3", "pid": "1189" }, { "id": "1193", "name": "泉港区", "code": "350505", "deep": "3", "pid": "1189" }, { "id": "1194", "name": "惠安县", "code": "350521", "deep": "3", "pid": "1189" }, { "id": "1195", "name": "安溪县", "code": "350524", "deep": "3", "pid": "1189" }, { "id": "1196", "name": "永春县", "code": "350525", "deep": "3", "pid": "1189" }, { "id": "1197", "name": "德化县", "code": "350526", "deep": "3", "pid": "1189" }, { "id": "1198", "name": "金门县", "code": "350527", "deep": "3", "pid": "1189" }, { "id": "1199", "name": "石狮市", "code": "350581", "deep": "3", "pid": "1189" }, { "id": "1200", "name": "晋江市", "code": "350582", "deep": "3", "pid": "1189" }, { "id": "1201", "name": "南安市", "code": "350583", "deep": "3", "pid": "1189" } ] }, { "id": "1202", "name": "漳州市", "code": "350600", "deep": "2", "pid": "1148", "area": [ { "id": "1203", "name": "芗城区", "code": "350602", "deep": "3", "pid": "1202" }, { "id": "1204", "name": "龙文区", "code": "350603", "deep": "3", "pid": "1202" }, { "id": "1205", "name": "云霄县", "code": "350622", "deep": "3", "pid": "1202" }, { "id": "1206", "name": "漳浦县", "code": "350623", "deep": "3", "pid": "1202" }, { "id": "1207", "name": "诏安县", "code": "350624", "deep": "3", "pid": "1202" }, { "id": "1208", "name": "长泰县", "code": "350625", "deep": "3", "pid": "1202" }, { "id": "1209", "name": "东山县", "code": "350626", "deep": "3", "pid": "1202" }, { "id": "1210", "name": "南靖县", "code": "350627", "deep": "3", "pid": "1202" }, { "id": "1211", "name": "平和县", "code": "350628", "deep": "3", "pid": "1202" }, { "id": "1212", "name": "华安县", "code": "350629", "deep": "3", "pid": "1202" }, { "id": "1213", "name": "龙海市", "code": "350681", "deep": "3", "pid": "1202" } ] }, { "id": "1214", "name": "南平市", "code": "350700", "deep": "2", "pid": "1148", "area": [ { "id": "1215", "name": "延平区", "code": "350702", "deep": "3", "pid": "1214" }, { "id": "1216", "name": "建阳区", "code": "350703", "deep": "3", "pid": "1214" }, { "id": "1217", "name": "顺昌县", "code": "350721", "deep": "3", "pid": "1214" }, { "id": "1218", "name": "浦城县", "code": "350722", "deep": "3", "pid": "1214" }, { "id": "1219", "name": "光泽县", "code": "350723", "deep": "3", "pid": "1214" }, { "id": "1220", "name": "松溪县", "code": "350724", "deep": "3", "pid": "1214" }, { "id": "1221", "name": "政和县", "code": "350725", "deep": "3", "pid": "1214" }, { "id": "1222", "name": "邵武市", "code": "350781", "deep": "3", "pid": "1214" }, { "id": "1223", "name": "武夷山市", "code": "350782", "deep": "3", "pid": "1214" }, { "id": "1224", "name": "建瓯市", "code": "350783", "deep": "3", "pid": "1214" } ] }, { "id": "1225", "name": "龙岩市", "code": "350800", "deep": "2", "pid": "1148", "area": [ { "id": "1226", "name": "新罗区", "code": "350802", "deep": "3", "pid": "1225" }, { "id": "1227", "name": "永定区", "code": "350803", "deep": "3", "pid": "1225" }, { "id": "1228", "name": "长汀县", "code": "350821", "deep": "3", "pid": "1225" }, { "id": "1229", "name": "上杭县", "code": "350823", "deep": "3", "pid": "1225" }, { "id": "1230", "name": "武平县", "code": "350824", "deep": "3", "pid": "1225" }, { "id": "1231", "name": "连城县", "code": "350825", "deep": "3", "pid": "1225" }, { "id": "1232", "name": "漳平市", "code": "350881", "deep": "3", "pid": "1225" } ] }, { "id": "1233", "name": "宁德市", "code": "350900", "deep": "2", "pid": "1148", "area": [ { "id": "1234", "name": "蕉城区", "code": "350902", "deep": "3", "pid": "1233" }, { "id": "1235", "name": "霞浦县", "code": "350921", "deep": "3", "pid": "1233" }, { "id": "1236", "name": "古田县", "code": "350922", "deep": "3", "pid": "1233" }, { "id": "1237", "name": "屏南县", "code": "350923", "deep": "3", "pid": "1233" }, { "id": "1238", "name": "寿宁县", "code": "350924", "deep": "3", "pid": "1233" }, { "id": "1239", "name": "周宁县", "code": "350925", "deep": "3", "pid": "1233" }, { "id": "1240", "name": "柘荣县", "code": "350926", "deep": "3", "pid": "1233" }, { "id": "1241", "name": "福安市", "code": "350981", "deep": "3", "pid": "1233" }, { "id": "1242", "name": "福鼎市", "code": "350982", "deep": "3", "pid": "1233" } ] } ] }, { "id": "1243", "name": "江西省", "code": "360000", "deep": "1", "pid": "0", "city": [ { "id": "1244", "name": "南昌市", "code": "360100", "deep": "2", "pid": "1243", "area": [ { "id": "1245", "name": "东湖区", "code": "360102", "deep": "3", "pid": "1244" }, { "id": "1246", "name": "西湖区", "code": "360103", "deep": "3", "pid": "1244" }, { "id": "1247", "name": "青云谱区", "code": "360104", "deep": "3", "pid": "1244" }, { "id": "1248", "name": "湾里区", "code": "360105", "deep": "3", "pid": "1244" }, { "id": "1249", "name": "青山湖区", "code": "360111", "deep": "3", "pid": "1244" }, { "id": "1250", "name": "新建区", "code": "360112", "deep": "3", "pid": "1244" }, { "id": "1251", "name": "南昌县", "code": "360121", "deep": "3", "pid": "1244" }, { "id": "1252", "name": "安义县", "code": "360123", "deep": "3", "pid": "1244" }, { "id": "1253", "name": "进贤县", "code": "360124", "deep": "3", "pid": "1244" } ] }, { "id": "1254", "name": "景德镇市", "code": "360200", "deep": "2", "pid": "1243", "area": [ { "id": "1255", "name": "昌江区", "code": "360202", "deep": "3", "pid": "1254" }, { "id": "1256", "name": "珠山区", "code": "360203", "deep": "3", "pid": "1254" }, { "id": "1257", "name": "浮梁县", "code": "360222", "deep": "3", "pid": "1254" }, { "id": "1258", "name": "乐平市", "code": "360281", "deep": "3", "pid": "1254" } ] }, { "id": "1259", "name": "萍乡市", "code": "360300", "deep": "2", "pid": "1243", "area": [ { "id": "1260", "name": "安源区", "code": "360302", "deep": "3", "pid": "1259" }, { "id": "1261", "name": "湘东区", "code": "360313", "deep": "3", "pid": "1259" }, { "id": "1262", "name": "莲花县", "code": "360321", "deep": "3", "pid": "1259" }, { "id": "1263", "name": "上栗县", "code": "360322", "deep": "3", "pid": "1259" }, { "id": "1264", "name": "芦溪县", "code": "360323", "deep": "3", "pid": "1259" } ] }, { "id": "1265", "name": "九江市", "code": "360400", "deep": "2", "pid": "1243", "area": [ { "id": "1266", "name": "庐山市", "code": "360483", "deep": "3", "pid": "1265" }, { "id": "1267", "name": "浔阳区", "code": "360403", "deep": "3", "pid": "1265" }, { "id": "1268", "name": "九江县", "code": "360421", "deep": "3", "pid": "1265" }, { "id": "1269", "name": "武宁县", "code": "360423", "deep": "3", "pid": "1265" }, { "id": "1270", "name": "修水县", "code": "360424", "deep": "3", "pid": "1265" }, { "id": "1271", "name": "永修县", "code": "360425", "deep": "3", "pid": "1265" }, { "id": "1272", "name": "德安县", "code": "360426", "deep": "3", "pid": "1265" }, { "id": "1273", "name": "星子县", "code": "360427", "deep": "3", "pid": "1265" }, { "id": "1274", "name": "都昌县", "code": "360428", "deep": "3", "pid": "1265" }, { "id": "1275", "name": "湖口县", "code": "360429", "deep": "3", "pid": "1265" }, { "id": "1276", "name": "彭泽县", "code": "360430", "deep": "3", "pid": "1265" }, { "id": "1277", "name": "瑞昌市", "code": "360481", "deep": "3", "pid": "1265" }, { "id": "1278", "name": "共青城市", "code": "360482", "deep": "3", "pid": "1265" }, { "id": "3263", "name": "濂溪区", "code": "360402", "deep": "3", "pid": "1265" } ] }, { "id": "1279", "name": "新余市", "code": "360500", "deep": "2", "pid": "1243", "area": [ { "id": "1280", "name": "渝水区", "code": "360502", "deep": "3", "pid": "1279" }, { "id": "1281", "name": "分宜县", "code": "360521", "deep": "3", "pid": "1279" } ] }, { "id": "1282", "name": "鹰潭市", "code": "360600", "deep": "2", "pid": "1243", "area": [ { "id": "1283", "name": "月湖区", "code": "360602", "deep": "3", "pid": "1282" }, { "id": "1284", "name": "余江县", "code": "360622", "deep": "3", "pid": "1282" }, { "id": "1285", "name": "贵溪市", "code": "360681", "deep": "3", "pid": "1282" } ] }, { "id": "1286", "name": "赣州市", "code": "360700", "deep": "2", "pid": "1243", "area": [ { "id": "1287", "name": "章贡区", "code": "360702", "deep": "3", "pid": "1286" }, { "id": "1288", "name": "南康区", "code": "360703", "deep": "3", "pid": "1286" }, { "id": "1289", "name": "赣县区", "code": "360704", "deep": "3", "pid": "1286" }, { "id": "1290", "name": "信丰县", "code": "360722", "deep": "3", "pid": "1286" }, { "id": "1291", "name": "大余县", "code": "360723", "deep": "3", "pid": "1286" }, { "id": "1292", "name": "上犹县", "code": "360724", "deep": "3", "pid": "1286" }, { "id": "1293", "name": "崇义县", "code": "360725", "deep": "3", "pid": "1286" }, { "id": "1294", "name": "安远县", "code": "360726", "deep": "3", "pid": "1286" }, { "id": "1295", "name": "龙南县", "code": "360727", "deep": "3", "pid": "1286" }, { "id": "1296", "name": "定南县", "code": "360728", "deep": "3", "pid": "1286" }, { "id": "1297", "name": "全南县", "code": "360729", "deep": "3", "pid": "1286" }, { "id": "1298", "name": "宁都县", "code": "360730", "deep": "3", "pid": "1286" }, { "id": "1299", "name": "于都县", "code": "360731", "deep": "3", "pid": "1286" }, { "id": "1300", "name": "兴国县", "code": "360732", "deep": "3", "pid": "1286" }, { "id": "1301", "name": "会昌县", "code": "360733", "deep": "3", "pid": "1286" }, { "id": "1302", "name": "寻乌县", "code": "360734", "deep": "3", "pid": "1286" }, { "id": "1303", "name": "石城县", "code": "360735", "deep": "3", "pid": "1286" }, { "id": "1304", "name": "瑞金市", "code": "360781", "deep": "3", "pid": "1286" }, { "id": "3385", "name": "赣县", "code": "360721", "deep": "3", "pid": "1286" } ] }, { "id": "1305", "name": "吉安市", "code": "360800", "deep": "2", "pid": "1243", "area": [ { "id": "1306", "name": "吉州区", "code": "360802", "deep": "3", "pid": "1305" }, { "id": "1307", "name": "青原区", "code": "360803", "deep": "3", "pid": "1305" }, { "id": "1308", "name": "吉安县", "code": "360821", "deep": "3", "pid": "1305" }, { "id": "1309", "name": "吉水县", "code": "360822", "deep": "3", "pid": "1305" }, { "id": "1310", "name": "峡江县", "code": "360823", "deep": "3", "pid": "1305" }, { "id": "1311", "name": "新干县", "code": "360824", "deep": "3", "pid": "1305" }, { "id": "1312", "name": "永丰县", "code": "360825", "deep": "3", "pid": "1305" }, { "id": "1313", "name": "泰和县", "code": "360826", "deep": "3", "pid": "1305" }, { "id": "1314", "name": "遂川县", "code": "360827", "deep": "3", "pid": "1305" }, { "id": "1315", "name": "万安县", "code": "360828", "deep": "3", "pid": "1305" }, { "id": "1316", "name": "安福县", "code": "360829", "deep": "3", "pid": "1305" }, { "id": "1317", "name": "永新县", "code": "360830", "deep": "3", "pid": "1305" }, { "id": "1318", "name": "井冈山市", "code": "360881", "deep": "3", "pid": "1305" } ] }, { "id": "1319", "name": "宜春市", "code": "360900", "deep": "2", "pid": "1243", "area": [ { "id": "1320", "name": "袁州区", "code": "360902", "deep": "3", "pid": "1319" }, { "id": "1321", "name": "奉新县", "code": "360921", "deep": "3", "pid": "1319" }, { "id": "1322", "name": "万载县", "code": "360922", "deep": "3", "pid": "1319" }, { "id": "1323", "name": "上高县", "code": "360923", "deep": "3", "pid": "1319" }, { "id": "1324", "name": "宜丰县", "code": "360924", "deep": "3", "pid": "1319" }, { "id": "1325", "name": "靖安县", "code": "360925", "deep": "3", "pid": "1319" }, { "id": "1326", "name": "铜鼓县", "code": "360926", "deep": "3", "pid": "1319" }, { "id": "1327", "name": "丰城市", "code": "360981", "deep": "3", "pid": "1319" }, { "id": "1328", "name": "樟树市", "code": "360982", "deep": "3", "pid": "1319" }, { "id": "1329", "name": "高安市", "code": "360983", "deep": "3", "pid": "1319" } ] }, { "id": "1330", "name": "抚州市", "code": "361000", "deep": "2", "pid": "1243", "area": [ { "id": "1331", "name": "临川区", "code": "361002", "deep": "3", "pid": "1330" }, { "id": "1332", "name": "南城县", "code": "361021", "deep": "3", "pid": "1330" }, { "id": "1333", "name": "黎川县", "code": "361022", "deep": "3", "pid": "1330" }, { "id": "1334", "name": "南丰县", "code": "361023", "deep": "3", "pid": "1330" }, { "id": "1335", "name": "崇仁县", "code": "361024", "deep": "3", "pid": "1330" }, { "id": "1336", "name": "乐安县", "code": "361025", "deep": "3", "pid": "1330" }, { "id": "1337", "name": "宜黄县", "code": "361026", "deep": "3", "pid": "1330" }, { "id": "1338", "name": "金溪县", "code": "361027", "deep": "3", "pid": "1330" }, { "id": "1339", "name": "资溪县", "code": "361028", "deep": "3", "pid": "1330" }, { "id": "1340", "name": "东乡区", "code": "361003", "deep": "3", "pid": "1330" }, { "id": "1341", "name": "广昌县", "code": "361030", "deep": "3", "pid": "1330" }, { "id": "3386", "name": "东乡县", "code": "361029", "deep": "3", "pid": "1330" } ] }, { "id": "1342", "name": "上饶市", "code": "361100", "deep": "2", "pid": "1243", "area": [ { "id": "1343", "name": "信州区", "code": "361102", "deep": "3", "pid": "1342" }, { "id": "1344", "name": "广丰区", "code": "361103", "deep": "3", "pid": "1342" }, { "id": "1345", "name": "上饶县", "code": "361121", "deep": "3", "pid": "1342" }, { "id": "1346", "name": "玉山县", "code": "361123", "deep": "3", "pid": "1342" }, { "id": "1347", "name": "铅山县", "code": "361124", "deep": "3", "pid": "1342" }, { "id": "1348", "name": "横峰县", "code": "361125", "deep": "3", "pid": "1342" }, { "id": "1349", "name": "弋阳县", "code": "361126", "deep": "3", "pid": "1342" }, { "id": "1350", "name": "余干县", "code": "361127", "deep": "3", "pid": "1342" }, { "id": "1351", "name": "鄱阳县", "code": "361128", "deep": "3", "pid": "1342" }, { "id": "1352", "name": "万年县", "code": "361129", "deep": "3", "pid": "1342" }, { "id": "1353", "name": "婺源县", "code": "361130", "deep": "3", "pid": "1342" }, { "id": "1354", "name": "德兴市", "code": "361181", "deep": "3", "pid": "1342" } ] } ] }, { "id": "1355", "name": "山东省", "code": "370000", "deep": "1", "pid": "0", "city": [ { "id": "1356", "name": "济南市", "code": "370100", "deep": "2", "pid": "1355", "area": [ { "id": "1357", "name": "历下区", "code": "370102", "deep": "3", "pid": "1356" }, { "id": "1358", "name": "市中区", "code": "370103", "deep": "3", "pid": "1356" }, { "id": "1359", "name": "槐荫区", "code": "370104", "deep": "3", "pid": "1356" }, { "id": "1360", "name": "天桥区", "code": "370105", "deep": "3", "pid": "1356" }, { "id": "1361", "name": "历城区", "code": "370112", "deep": "3", "pid": "1356" }, { "id": "1362", "name": "长清区", "code": "370113", "deep": "3", "pid": "1356" }, { "id": "1363", "name": "平阴县", "code": "370124", "deep": "3", "pid": "1356" }, { "id": "1364", "name": "济阳县", "code": "370125", "deep": "3", "pid": "1356" }, { "id": "1365", "name": "商河县", "code": "370126", "deep": "3", "pid": "1356" }, { "id": "1366", "name": "章丘区", "code": "370114", "deep": "3", "pid": "1356" }, { "id": "3387", "name": "章丘市", "code": "370181", "deep": "3", "pid": "1356" } ] }, { "id": "1367", "name": "青岛市", "code": "370200", "deep": "2", "pid": "1355", "area": [ { "id": "1368", "name": "市南区", "code": "370202", "deep": "3", "pid": "1367" }, { "id": "1369", "name": "市北区", "code": "370203", "deep": "3", "pid": "1367" }, { "id": "1370", "name": "黄岛区", "code": "370211", "deep": "3", "pid": "1367" }, { "id": "1371", "name": "崂山区", "code": "370212", "deep": "3", "pid": "1367" }, { "id": "1372", "name": "李沧区", "code": "370213", "deep": "3", "pid": "1367" }, { "id": "1373", "name": "城阳区", "code": "370214", "deep": "3", "pid": "1367" }, { "id": "1374", "name": "胶州市", "code": "370281", "deep": "3", "pid": "1367" }, { "id": "1375", "name": "即墨市", "code": "370282", "deep": "3", "pid": "1367" }, { "id": "1376", "name": "平度市", "code": "370283", "deep": "3", "pid": "1367" }, { "id": "1377", "name": "莱西市", "code": "370285", "deep": "3", "pid": "1367" } ] }, { "id": "1378", "name": "淄博市", "code": "370300", "deep": "2", "pid": "1355", "area": [ { "id": "1379", "name": "淄川区", "code": "370302", "deep": "3", "pid": "1378" }, { "id": "1380", "name": "张店区", "code": "370303", "deep": "3", "pid": "1378" }, { "id": "1381", "name": "博山区", "code": "370304", "deep": "3", "pid": "1378" }, { "id": "1382", "name": "临淄区", "code": "370305", "deep": "3", "pid": "1378" }, { "id": "1383", "name": "周村区", "code": "370306", "deep": "3", "pid": "1378" }, { "id": "1384", "name": "桓台县", "code": "370321", "deep": "3", "pid": "1378" }, { "id": "1385", "name": "高青县", "code": "370322", "deep": "3", "pid": "1378" }, { "id": "1386", "name": "沂源县", "code": "370323", "deep": "3", "pid": "1378" } ] }, { "id": "1387", "name": "枣庄市", "code": "370400", "deep": "2", "pid": "1355", "area": [ { "id": "1388", "name": "市中区", "code": "370402", "deep": "3", "pid": "1387" }, { "id": "1389", "name": "薛城区", "code": "370403", "deep": "3", "pid": "1387" }, { "id": "1390", "name": "峄城区", "code": "370404", "deep": "3", "pid": "1387" }, { "id": "1391", "name": "台儿庄区", "code": "370405", "deep": "3", "pid": "1387" }, { "id": "1392", "name": "山亭区", "code": "370406", "deep": "3", "pid": "1387" }, { "id": "1393", "name": "滕州市", "code": "370481", "deep": "3", "pid": "1387" } ] }, { "id": "1394", "name": "东营市", "code": "370500", "deep": "2", "pid": "1355", "area": [ { "id": "1395", "name": "东营区", "code": "370502", "deep": "3", "pid": "1394" }, { "id": "1396", "name": "河口区", "code": "370503", "deep": "3", "pid": "1394" }, { "id": "1397", "name": "垦利区", "code": "370505", "deep": "3", "pid": "1394" }, { "id": "1398", "name": "利津县", "code": "370522", "deep": "3", "pid": "1394" }, { "id": "1399", "name": "广饶县", "code": "370523", "deep": "3", "pid": "1394" } ] }, { "id": "1400", "name": "烟台市", "code": "370600", "deep": "2", "pid": "1355", "area": [ { "id": "1401", "name": "芝罘区", "code": "370602", "deep": "3", "pid": "1400" }, { "id": "1402", "name": "福山区", "code": "370611", "deep": "3", "pid": "1400" }, { "id": "1403", "name": "牟平区", "code": "370612", "deep": "3", "pid": "1400" }, { "id": "1404", "name": "莱山区", "code": "370613", "deep": "3", "pid": "1400" }, { "id": "1405", "name": "长岛县", "code": "370634", "deep": "3", "pid": "1400" }, { "id": "1406", "name": "龙口市", "code": "370681", "deep": "3", "pid": "1400" }, { "id": "1407", "name": "莱阳市", "code": "370682", "deep": "3", "pid": "1400" }, { "id": "1408", "name": "莱州市", "code": "370683", "deep": "3", "pid": "1400" }, { "id": "1409", "name": "蓬莱市", "code": "370684", "deep": "3", "pid": "1400" }, { "id": "1410", "name": "招远市", "code": "370685", "deep": "3", "pid": "1400" }, { "id": "1411", "name": "栖霞市", "code": "370686", "deep": "3", "pid": "1400" }, { "id": "1412", "name": "海阳市", "code": "370687", "deep": "3", "pid": "1400" } ] }, { "id": "1413", "name": "潍坊市", "code": "370700", "deep": "2", "pid": "1355", "area": [ { "id": "1414", "name": "潍城区", "code": "370702", "deep": "3", "pid": "1413" }, { "id": "1415", "name": "寒亭区", "code": "370703", "deep": "3", "pid": "1413" }, { "id": "1416", "name": "坊子区", "code": "370704", "deep": "3", "pid": "1413" }, { "id": "1417", "name": "奎文区", "code": "370705", "deep": "3", "pid": "1413" }, { "id": "1418", "name": "临朐县", "code": "370724", "deep": "3", "pid": "1413" }, { "id": "1419", "name": "昌乐县", "code": "370725", "deep": "3", "pid": "1413" }, { "id": "1420", "name": "青州市", "code": "370781", "deep": "3", "pid": "1413" }, { "id": "1421", "name": "诸城市", "code": "370782", "deep": "3", "pid": "1413" }, { "id": "1422", "name": "寿光市", "code": "370783", "deep": "3", "pid": "1413" }, { "id": "1423", "name": "安丘市", "code": "370784", "deep": "3", "pid": "1413" }, { "id": "1424", "name": "高密市", "code": "370785", "deep": "3", "pid": "1413" }, { "id": "1425", "name": "昌邑市", "code": "370786", "deep": "3", "pid": "1413" } ] }, { "id": "1426", "name": "济宁市", "code": "370800", "deep": "2", "pid": "1355", "area": [ { "id": "1427", "name": "任城区", "code": "370811", "deep": "3", "pid": "1426" }, { "id": "1428", "name": "兖州区", "code": "370812", "deep": "3", "pid": "1426" }, { "id": "1429", "name": "微山县", "code": "370826", "deep": "3", "pid": "1426" }, { "id": "1430", "name": "鱼台县", "code": "370827", "deep": "3", "pid": "1426" }, { "id": "1431", "name": "金乡县", "code": "370828", "deep": "3", "pid": "1426" }, { "id": "1432", "name": "嘉祥县", "code": "370829", "deep": "3", "pid": "1426" }, { "id": "1433", "name": "汶上县", "code": "370830", "deep": "3", "pid": "1426" }, { "id": "1434", "name": "泗水县", "code": "370831", "deep": "3", "pid": "1426" }, { "id": "1435", "name": "梁山县", "code": "370832", "deep": "3", "pid": "1426" }, { "id": "1436", "name": "曲阜市", "code": "370881", "deep": "3", "pid": "1426" }, { "id": "1437", "name": "邹城市", "code": "370883", "deep": "3", "pid": "1426" } ] }, { "id": "1438", "name": "泰安市", "code": "370900", "deep": "2", "pid": "1355", "area": [ { "id": "1439", "name": "泰山区", "code": "370902", "deep": "3", "pid": "1438" }, { "id": "1440", "name": "岱岳区", "code": "370911", "deep": "3", "pid": "1438" }, { "id": "1441", "name": "宁阳县", "code": "370921", "deep": "3", "pid": "1438" }, { "id": "1442", "name": "东平县", "code": "370923", "deep": "3", "pid": "1438" }, { "id": "1443", "name": "新泰市", "code": "370982", "deep": "3", "pid": "1438" }, { "id": "1444", "name": "肥城市", "code": "370983", "deep": "3", "pid": "1438" } ] }, { "id": "1445", "name": "威海市", "code": "371000", "deep": "2", "pid": "1355", "area": [ { "id": "1446", "name": "环翠区", "code": "371002", "deep": "3", "pid": "1445" }, { "id": "1447", "name": "文登区", "code": "371003", "deep": "3", "pid": "1445" }, { "id": "1448", "name": "荣成市", "code": "371082", "deep": "3", "pid": "1445" }, { "id": "1449", "name": "乳山市", "code": "371083", "deep": "3", "pid": "1445" } ] }, { "id": "1450", "name": "日照市", "code": "371100", "deep": "2", "pid": "1355", "area": [ { "id": "1451", "name": "东港区", "code": "371102", "deep": "3", "pid": "1450" }, { "id": "1452", "name": "岚山区", "code": "371103", "deep": "3", "pid": "1450" }, { "id": "1453", "name": "五莲县", "code": "371121", "deep": "3", "pid": "1450" }, { "id": "1454", "name": "莒县", "code": "371122", "deep": "3", "pid": "1450" } ] }, { "id": "1455", "name": "莱芜市", "code": "371200", "deep": "2", "pid": "1355", "area": [ { "id": "1456", "name": "莱城区", "code": "371202", "deep": "3", "pid": "1455" }, { "id": "1457", "name": "钢城区", "code": "371203", "deep": "3", "pid": "1455" } ] }, { "id": "1458", "name": "临沂市", "code": "371300", "deep": "2", "pid": "1355", "area": [ { "id": "1459", "name": "兰山区", "code": "371302", "deep": "3", "pid": "1458" }, { "id": "1460", "name": "罗庄区", "code": "371311", "deep": "3", "pid": "1458" }, { "id": "1461", "name": "河东区", "code": "371312", "deep": "3", "pid": "1458" }, { "id": "1462", "name": "沂南县", "code": "371321", "deep": "3", "pid": "1458" }, { "id": "1463", "name": "郯城县", "code": "371322", "deep": "3", "pid": "1458" }, { "id": "1464", "name": "沂水县", "code": "371323", "deep": "3", "pid": "1458" }, { "id": "1465", "name": "兰陵县", "code": "371324", "deep": "3", "pid": "1458" }, { "id": "1466", "name": "费县", "code": "371325", "deep": "3", "pid": "1458" }, { "id": "1467", "name": "平邑县", "code": "371326", "deep": "3", "pid": "1458" }, { "id": "1468", "name": "莒南县", "code": "371327", "deep": "3", "pid": "1458" }, { "id": "1469", "name": "蒙阴县", "code": "371328", "deep": "3", "pid": "1458" }, { "id": "1470", "name": "临沭县", "code": "371329", "deep": "3", "pid": "1458" } ] }, { "id": "1471", "name": "德州市", "code": "371400", "deep": "2", "pid": "1355", "area": [ { "id": "1472", "name": "德城区", "code": "371402", "deep": "3", "pid": "1471" }, { "id": "1473", "name": "陵城区", "code": "371403", "deep": "3", "pid": "1471" }, { "id": "1474", "name": "宁津县", "code": "371422", "deep": "3", "pid": "1471" }, { "id": "1475", "name": "庆云县", "code": "371423", "deep": "3", "pid": "1471" }, { "id": "1476", "name": "临邑县", "code": "371424", "deep": "3", "pid": "1471" }, { "id": "1477", "name": "齐河县", "code": "371425", "deep": "3", "pid": "1471" }, { "id": "1478", "name": "平原县", "code": "371426", "deep": "3", "pid": "1471" }, { "id": "1479", "name": "夏津县", "code": "371427", "deep": "3", "pid": "1471" }, { "id": "1480", "name": "武城县", "code": "371428", "deep": "3", "pid": "1471" }, { "id": "1481", "name": "乐陵市", "code": "371481", "deep": "3", "pid": "1471" }, { "id": "1482", "name": "禹城市", "code": "371482", "deep": "3", "pid": "1471" } ] }, { "id": "1483", "name": "聊城市", "code": "371500", "deep": "2", "pid": "1355", "area": [ { "id": "1484", "name": "东昌府区", "code": "371502", "deep": "3", "pid": "1483" }, { "id": "1485", "name": "阳谷县", "code": "371521", "deep": "3", "pid": "1483" }, { "id": "1486", "name": "莘县", "code": "371522", "deep": "3", "pid": "1483" }, { "id": "1487", "name": "茌平县", "code": "371523", "deep": "3", "pid": "1483" }, { "id": "1488", "name": "东阿县", "code": "371524", "deep": "3", "pid": "1483" }, { "id": "1489", "name": "冠县", "code": "371525", "deep": "3", "pid": "1483" }, { "id": "1490", "name": "高唐县", "code": "371526", "deep": "3", "pid": "1483" }, { "id": "1491", "name": "临清市", "code": "371581", "deep": "3", "pid": "1483" } ] }, { "id": "1492", "name": "滨州市", "code": "371600", "deep": "2", "pid": "1355", "area": [ { "id": "1493", "name": "滨城区", "code": "371602", "deep": "3", "pid": "1492" }, { "id": "1494", "name": "沾化区", "code": "371603", "deep": "3", "pid": "1492" }, { "id": "1495", "name": "惠民县", "code": "371621", "deep": "3", "pid": "1492" }, { "id": "1496", "name": "阳信县", "code": "371622", "deep": "3", "pid": "1492" }, { "id": "1497", "name": "无棣县", "code": "371623", "deep": "3", "pid": "1492" }, { "id": "1498", "name": "博兴县", "code": "371625", "deep": "3", "pid": "1492" }, { "id": "1499", "name": "邹平县", "code": "371626", "deep": "3", "pid": "1492" } ] }, { "id": "1500", "name": "菏泽市", "code": "371700", "deep": "2", "pid": "1355", "area": [ { "id": "1501", "name": "牡丹区", "code": "371702", "deep": "3", "pid": "1500" }, { "id": "1502", "name": "曹县", "code": "371721", "deep": "3", "pid": "1500" }, { "id": "1503", "name": "单县", "code": "371722", "deep": "3", "pid": "1500" }, { "id": "1504", "name": "成武县", "code": "371723", "deep": "3", "pid": "1500" }, { "id": "1505", "name": "巨野县", "code": "371724", "deep": "3", "pid": "1500" }, { "id": "1506", "name": "郓城县", "code": "371725", "deep": "3", "pid": "1500" }, { "id": "1507", "name": "鄄城县", "code": "371726", "deep": "3", "pid": "1500" }, { "id": "1508", "name": "定陶区", "code": "371703", "deep": "3", "pid": "1500" }, { "id": "1509", "name": "东明县", "code": "371728", "deep": "3", "pid": "1500" } ] } ] }, { "id": "1510", "name": "河南省", "code": "410000", "deep": "1", "pid": "0", "city": [ { "id": "1511", "name": "郑州市", "code": "410100", "deep": "2", "pid": "1510", "area": [ { "id": "1512", "name": "中原区", "code": "410102", "deep": "3", "pid": "1511" }, { "id": "1513", "name": "二七区", "code": "410103", "deep": "3", "pid": "1511" }, { "id": "1514", "name": "管城回族区", "code": "410104", "deep": "3", "pid": "1511" }, { "id": "1515", "name": "金水区", "code": "410105", "deep": "3", "pid": "1511" }, { "id": "1516", "name": "上街区", "code": "410106", "deep": "3", "pid": "1511" }, { "id": "1517", "name": "惠济区", "code": "410108", "deep": "3", "pid": "1511" }, { "id": "1518", "name": "中牟县", "code": "410122", "deep": "3", "pid": "1511" }, { "id": "1519", "name": "巩义市", "code": "410181", "deep": "3", "pid": "1511" }, { "id": "1520", "name": "荥阳市", "code": "410182", "deep": "3", "pid": "1511" }, { "id": "1521", "name": "新密市", "code": "410183", "deep": "3", "pid": "1511" }, { "id": "1522", "name": "新郑市", "code": "410184", "deep": "3", "pid": "1511" }, { "id": "1523", "name": "登封市", "code": "410185", "deep": "3", "pid": "1511" } ] }, { "id": "1524", "name": "开封市", "code": "410200", "deep": "2", "pid": "1510", "area": [ { "id": "1525", "name": "龙亭区", "code": "410202", "deep": "3", "pid": "1524" }, { "id": "1526", "name": "顺河回族区", "code": "410203", "deep": "3", "pid": "1524" }, { "id": "1527", "name": "鼓楼区", "code": "410204", "deep": "3", "pid": "1524" }, { "id": "1528", "name": "禹王台区", "code": "410205", "deep": "3", "pid": "1524" }, { "id": "1529", "name": "祥符区", "code": "410212", "deep": "3", "pid": "1524" }, { "id": "1530", "name": "杞县", "code": "410221", "deep": "3", "pid": "1524" }, { "id": "1531", "name": "通许县", "code": "410222", "deep": "3", "pid": "1524" }, { "id": "1532", "name": "尉氏县", "code": "410223", "deep": "3", "pid": "1524" }, { "id": "1533", "name": "兰考县", "code": "410225", "deep": "3", "pid": "1524" }, { "id": "3388", "name": "金明区", "code": "410211", "deep": "3", "pid": "1524" } ] }, { "id": "1534", "name": "洛阳市", "code": "410300", "deep": "2", "pid": "1510", "area": [ { "id": "1535", "name": "老城区", "code": "410302", "deep": "3", "pid": "1534" }, { "id": "1536", "name": "西工区", "code": "410303", "deep": "3", "pid": "1534" }, { "id": "1537", "name": "瀍河回族区", "code": "410304", "deep": "3", "pid": "1534" }, { "id": "1538", "name": "涧西区", "code": "410305", "deep": "3", "pid": "1534" }, { "id": "1539", "name": "吉利区", "code": "410306", "deep": "3", "pid": "1534" }, { "id": "1540", "name": "洛龙区", "code": "410311", "deep": "3", "pid": "1534" }, { "id": "1541", "name": "孟津县", "code": "410322", "deep": "3", "pid": "1534" }, { "id": "1542", "name": "新安县", "code": "410323", "deep": "3", "pid": "1534" }, { "id": "1543", "name": "栾川县", "code": "410324", "deep": "3", "pid": "1534" }, { "id": "1544", "name": "嵩县", "code": "410325", "deep": "3", "pid": "1534" }, { "id": "1545", "name": "汝阳县", "code": "410326", "deep": "3", "pid": "1534" }, { "id": "1546", "name": "宜阳县", "code": "410327", "deep": "3", "pid": "1534" }, { "id": "1547", "name": "洛宁县", "code": "410328", "deep": "3", "pid": "1534" }, { "id": "1548", "name": "伊川县", "code": "410329", "deep": "3", "pid": "1534" }, { "id": "1549", "name": "偃师市", "code": "410381", "deep": "3", "pid": "1534" } ] }, { "id": "1550", "name": "平顶山市", "code": "410400", "deep": "2", "pid": "1510", "area": [ { "id": "1551", "name": "新华区", "code": "410402", "deep": "3", "pid": "1550" }, { "id": "1552", "name": "卫东区", "code": "410403", "deep": "3", "pid": "1550" }, { "id": "1553", "name": "石龙区", "code": "410404", "deep": "3", "pid": "1550" }, { "id": "1554", "name": "湛河区", "code": "410411", "deep": "3", "pid": "1550" }, { "id": "1555", "name": "宝丰县", "code": "410421", "deep": "3", "pid": "1550" }, { "id": "1556", "name": "叶县", "code": "410422", "deep": "3", "pid": "1550" }, { "id": "1557", "name": "鲁山县", "code": "410423", "deep": "3", "pid": "1550" }, { "id": "1558", "name": "郏县", "code": "410425", "deep": "3", "pid": "1550" }, { "id": "1559", "name": "舞钢市", "code": "410481", "deep": "3", "pid": "1550" }, { "id": "1560", "name": "汝州市", "code": "410482", "deep": "3", "pid": "1550" } ] }, { "id": "1561", "name": "安阳市", "code": "410500", "deep": "2", "pid": "1510", "area": [ { "id": "1562", "name": "文峰区", "code": "410502", "deep": "3", "pid": "1561" }, { "id": "1563", "name": "北关区", "code": "410503", "deep": "3", "pid": "1561" }, { "id": "1564", "name": "殷都区", "code": "410505", "deep": "3", "pid": "1561" }, { "id": "1565", "name": "龙安区", "code": "410506", "deep": "3", "pid": "1561" }, { "id": "1566", "name": "安阳县", "code": "410522", "deep": "3", "pid": "1561" }, { "id": "1567", "name": "汤阴县", "code": "410523", "deep": "3", "pid": "1561" }, { "id": "1568", "name": "滑县", "code": "410526", "deep": "3", "pid": "1561" }, { "id": "1569", "name": "内黄县", "code": "410527", "deep": "3", "pid": "1561" }, { "id": "1570", "name": "林州市", "code": "410581", "deep": "3", "pid": "1561" } ] }, { "id": "1571", "name": "鹤壁市", "code": "410600", "deep": "2", "pid": "1510", "area": [ { "id": "1572", "name": "鹤山区", "code": "410602", "deep": "3", "pid": "1571" }, { "id": "1573", "name": "山城区", "code": "410603", "deep": "3", "pid": "1571" }, { "id": "1574", "name": "淇滨区", "code": "410611", "deep": "3", "pid": "1571" }, { "id": "1575", "name": "浚县", "code": "410621", "deep": "3", "pid": "1571" }, { "id": "1576", "name": "淇县", "code": "410622", "deep": "3", "pid": "1571" } ] }, { "id": "1577", "name": "新乡市", "code": "410700", "deep": "2", "pid": "1510", "area": [ { "id": "1578", "name": "红旗区", "code": "410702", "deep": "3", "pid": "1577" }, { "id": "1579", "name": "卫滨区", "code": "410703", "deep": "3", "pid": "1577" }, { "id": "1580", "name": "凤泉区", "code": "410704", "deep": "3", "pid": "1577" }, { "id": "1581", "name": "牧野区", "code": "410711", "deep": "3", "pid": "1577" }, { "id": "1582", "name": "新乡县", "code": "410721", "deep": "3", "pid": "1577" }, { "id": "1583", "name": "获嘉县", "code": "410724", "deep": "3", "pid": "1577" }, { "id": "1584", "name": "原阳县", "code": "410725", "deep": "3", "pid": "1577" }, { "id": "1585", "name": "延津县", "code": "410726", "deep": "3", "pid": "1577" }, { "id": "1586", "name": "封丘县", "code": "410727", "deep": "3", "pid": "1577" }, { "id": "1587", "name": "长垣县", "code": "410728", "deep": "3", "pid": "1577" }, { "id": "1588", "name": "卫辉市", "code": "410781", "deep": "3", "pid": "1577" }, { "id": "1589", "name": "辉县市", "code": "410782", "deep": "3", "pid": "1577" } ] }, { "id": "1590", "name": "焦作市", "code": "410800", "deep": "2", "pid": "1510", "area": [ { "id": "1591", "name": "解放区", "code": "410802", "deep": "3", "pid": "1590" }, { "id": "1592", "name": "中站区", "code": "410803", "deep": "3", "pid": "1590" }, { "id": "1593", "name": "马村区", "code": "410804", "deep": "3", "pid": "1590" }, { "id": "1594", "name": "山阳区", "code": "410811", "deep": "3", "pid": "1590" }, { "id": "1595", "name": "修武县", "code": "410821", "deep": "3", "pid": "1590" }, { "id": "1596", "name": "博爱县", "code": "410822", "deep": "3", "pid": "1590" }, { "id": "1597", "name": "武陟县", "code": "410823", "deep": "3", "pid": "1590" }, { "id": "1598", "name": "温县", "code": "410825", "deep": "3", "pid": "1590" }, { "id": "1599", "name": "沁阳市", "code": "410882", "deep": "3", "pid": "1590" }, { "id": "1600", "name": "孟州市", "code": "410883", "deep": "3", "pid": "1590" } ] }, { "id": "1601", "name": "濮阳市", "code": "410900", "deep": "2", "pid": "1510", "area": [ { "id": "1602", "name": "华龙区", "code": "410902", "deep": "3", "pid": "1601" }, { "id": "1603", "name": "清丰县", "code": "410922", "deep": "3", "pid": "1601" }, { "id": "1604", "name": "南乐县", "code": "410923", "deep": "3", "pid": "1601" }, { "id": "1605", "name": "范县", "code": "410926", "deep": "3", "pid": "1601" }, { "id": "1606", "name": "台前县", "code": "410927", "deep": "3", "pid": "1601" }, { "id": "1607", "name": "濮阳县", "code": "410928", "deep": "3", "pid": "1601" } ] }, { "id": "1608", "name": "许昌市", "code": "411000", "deep": "2", "pid": "1510", "area": [ { "id": "1609", "name": "魏都区", "code": "411002", "deep": "3", "pid": "1608" }, { "id": "1610", "name": "许昌县", "code": "411023", "deep": "3", "pid": "1608" }, { "id": "1611", "name": "鄢陵县", "code": "411024", "deep": "3", "pid": "1608" }, { "id": "1612", "name": "襄城县", "code": "411025", "deep": "3", "pid": "1608" }, { "id": "1613", "name": "禹州市", "code": "411081", "deep": "3", "pid": "1608" }, { "id": "1614", "name": "长葛市", "code": "411082", "deep": "3", "pid": "1608" }, { "id": "3264", "name": "建安区", "code": "411003", "deep": "3", "pid": "1608" } ] }, { "id": "1615", "name": "漯河市", "code": "411100", "deep": "2", "pid": "1510", "area": [ { "id": "1616", "name": "源汇区", "code": "411102", "deep": "3", "pid": "1615" }, { "id": "1617", "name": "郾城区", "code": "411103", "deep": "3", "pid": "1615" }, { "id": "1618", "name": "召陵区", "code": "411104", "deep": "3", "pid": "1615" }, { "id": "1619", "name": "舞阳县", "code": "411121", "deep": "3", "pid": "1615" }, { "id": "1620", "name": "临颍县", "code": "411122", "deep": "3", "pid": "1615" } ] }, { "id": "1621", "name": "三门峡市", "code": "411200", "deep": "2", "pid": "1510", "area": [ { "id": "1622", "name": "湖滨区", "code": "411202", "deep": "3", "pid": "1621" }, { "id": "1623", "name": "陕州区", "code": "411203", "deep": "3", "pid": "1621" }, { "id": "1624", "name": "渑池县", "code": "411221", "deep": "3", "pid": "1621" }, { "id": "1625", "name": "卢氏县", "code": "411224", "deep": "3", "pid": "1621" }, { "id": "1626", "name": "义马市", "code": "411281", "deep": "3", "pid": "1621" }, { "id": "1627", "name": "灵宝市", "code": "411282", "deep": "3", "pid": "1621" } ] }, { "id": "1628", "name": "南阳市", "code": "411300", "deep": "2", "pid": "1510", "area": [ { "id": "1629", "name": "宛城区", "code": "411302", "deep": "3", "pid": "1628" }, { "id": "1630", "name": "卧龙区", "code": "411303", "deep": "3", "pid": "1628" }, { "id": "1631", "name": "南召县", "code": "411321", "deep": "3", "pid": "1628" }, { "id": "1632", "name": "方城县", "code": "411322", "deep": "3", "pid": "1628" }, { "id": "1633", "name": "西峡县", "code": "411323", "deep": "3", "pid": "1628" }, { "id": "1634", "name": "镇平县", "code": "411324", "deep": "3", "pid": "1628" }, { "id": "1635", "name": "内乡县", "code": "411325", "deep": "3", "pid": "1628" }, { "id": "1636", "name": "淅川县", "code": "411326", "deep": "3", "pid": "1628" }, { "id": "1637", "name": "社旗县", "code": "411327", "deep": "3", "pid": "1628" }, { "id": "1638", "name": "唐河县", "code": "411328", "deep": "3", "pid": "1628" }, { "id": "1639", "name": "新野县", "code": "411329", "deep": "3", "pid": "1628" }, { "id": "1640", "name": "桐柏县", "code": "411330", "deep": "3", "pid": "1628" }, { "id": "1641", "name": "邓州市", "code": "411381", "deep": "3", "pid": "1628" } ] }, { "id": "1642", "name": "商丘市", "code": "411400", "deep": "2", "pid": "1510", "area": [ { "id": "1643", "name": "梁园区", "code": "411402", "deep": "3", "pid": "1642" }, { "id": "1644", "name": "睢阳区", "code": "411403", "deep": "3", "pid": "1642" }, { "id": "1645", "name": "民权县", "code": "411421", "deep": "3", "pid": "1642" }, { "id": "1646", "name": "睢县", "code": "411422", "deep": "3", "pid": "1642" }, { "id": "1647", "name": "宁陵县", "code": "411423", "deep": "3", "pid": "1642" }, { "id": "1648", "name": "柘城县", "code": "411424", "deep": "3", "pid": "1642" }, { "id": "1649", "name": "虞城县", "code": "411425", "deep": "3", "pid": "1642" }, { "id": "1650", "name": "夏邑县", "code": "411426", "deep": "3", "pid": "1642" }, { "id": "1651", "name": "永城市", "code": "411481", "deep": "3", "pid": "1642" } ] }, { "id": "1652", "name": "信阳市", "code": "411500", "deep": "2", "pid": "1510", "area": [ { "id": "1653", "name": "浉河区", "code": "411502", "deep": "3", "pid": "1652" }, { "id": "1654", "name": "平桥区", "code": "411503", "deep": "3", "pid": "1652" }, { "id": "1655", "name": "罗山县", "code": "411521", "deep": "3", "pid": "1652" }, { "id": "1656", "name": "光山县", "code": "411522", "deep": "3", "pid": "1652" }, { "id": "1657", "name": "新县", "code": "411523", "deep": "3", "pid": "1652" }, { "id": "1658", "name": "商城县", "code": "411524", "deep": "3", "pid": "1652" }, { "id": "1659", "name": "固始县", "code": "411525", "deep": "3", "pid": "1652" }, { "id": "1660", "name": "潢川县", "code": "411526", "deep": "3", "pid": "1652" }, { "id": "1661", "name": "淮滨县", "code": "411527", "deep": "3", "pid": "1652" }, { "id": "1662", "name": "息县", "code": "411528", "deep": "3", "pid": "1652" } ] }, { "id": "1663", "name": "周口市", "code": "411600", "deep": "2", "pid": "1510", "area": [ { "id": "1664", "name": "川汇区", "code": "411602", "deep": "3", "pid": "1663" }, { "id": "1665", "name": "扶沟县", "code": "411621", "deep": "3", "pid": "1663" }, { "id": "1666", "name": "西华县", "code": "411622", "deep": "3", "pid": "1663" }, { "id": "1667", "name": "商水县", "code": "411623", "deep": "3", "pid": "1663" }, { "id": "1668", "name": "沈丘县", "code": "411624", "deep": "3", "pid": "1663" }, { "id": "1669", "name": "郸城县", "code": "411625", "deep": "3", "pid": "1663" }, { "id": "1670", "name": "淮阳县", "code": "411626", "deep": "3", "pid": "1663" }, { "id": "1671", "name": "太康县", "code": "411627", "deep": "3", "pid": "1663" }, { "id": "1672", "name": "鹿邑县", "code": "411628", "deep": "3", "pid": "1663" }, { "id": "1673", "name": "项城市", "code": "411681", "deep": "3", "pid": "1663" } ] }, { "id": "1674", "name": "驻马店市", "code": "411700", "deep": "2", "pid": "1510", "area": [ { "id": "1675", "name": "驿城区", "code": "411702", "deep": "3", "pid": "1674" }, { "id": "1676", "name": "西平县", "code": "411721", "deep": "3", "pid": "1674" }, { "id": "1677", "name": "上蔡县", "code": "411722", "deep": "3", "pid": "1674" }, { "id": "1678", "name": "平舆县", "code": "411723", "deep": "3", "pid": "1674" }, { "id": "1679", "name": "正阳县", "code": "411724", "deep": "3", "pid": "1674" }, { "id": "1680", "name": "确山县", "code": "411725", "deep": "3", "pid": "1674" }, { "id": "1681", "name": "泌阳县", "code": "411726", "deep": "3", "pid": "1674" }, { "id": "1682", "name": "汝南县", "code": "411727", "deep": "3", "pid": "1674" }, { "id": "1683", "name": "遂平县", "code": "411728", "deep": "3", "pid": "1674" }, { "id": "1684", "name": "新蔡县", "code": "411729", "deep": "3", "pid": "1674" } ] }, { "id": "1685", "name": "济源市", "code": "419001", "deep": "2", "pid": "1510" }, { "id": "3389", "name": "省直辖县级行政区划", "code": "419000", "deep": "2", "pid": "1510" } ] }, { "id": "1686", "name": "湖北省", "code": "420000", "deep": "1", "pid": "0", "city": [ { "id": "1687", "name": "武汉市", "code": "420100", "deep": "2", "pid": "1686", "area": [ { "id": "1688", "name": "江岸区", "code": "420102", "deep": "3", "pid": "1687" }, { "id": "1689", "name": "江汉区", "code": "420103", "deep": "3", "pid": "1687" }, { "id": "1690", "name": "硚口区", "code": "420104", "deep": "3", "pid": "1687" }, { "id": "1691", "name": "汉阳区", "code": "420105", "deep": "3", "pid": "1687" }, { "id": "1692", "name": "武昌区", "code": "420106", "deep": "3", "pid": "1687" }, { "id": "1693", "name": "青山区", "code": "420107", "deep": "3", "pid": "1687" }, { "id": "1694", "name": "洪山区", "code": "420111", "deep": "3", "pid": "1687" }, { "id": "1695", "name": "东西湖区", "code": "420112", "deep": "3", "pid": "1687" }, { "id": "1696", "name": "汉南区", "code": "420113", "deep": "3", "pid": "1687" }, { "id": "1697", "name": "蔡甸区", "code": "420114", "deep": "3", "pid": "1687" }, { "id": "1698", "name": "江夏区", "code": "420115", "deep": "3", "pid": "1687" }, { "id": "1699", "name": "黄陂区", "code": "420116", "deep": "3", "pid": "1687" }, { "id": "1700", "name": "新洲区", "code": "420117", "deep": "3", "pid": "1687" } ] }, { "id": "1701", "name": "黄石市", "code": "420200", "deep": "2", "pid": "1686", "area": [ { "id": "1702", "name": "黄石港区", "code": "420202", "deep": "3", "pid": "1701" }, { "id": "1703", "name": "西塞山区", "code": "420203", "deep": "3", "pid": "1701" }, { "id": "1704", "name": "下陆区", "code": "420204", "deep": "3", "pid": "1701" }, { "id": "1705", "name": "铁山区", "code": "420205", "deep": "3", "pid": "1701" }, { "id": "1706", "name": "阳新县", "code": "420222", "deep": "3", "pid": "1701" }, { "id": "1707", "name": "大冶市", "code": "420281", "deep": "3", "pid": "1701" } ] }, { "id": "1708", "name": "十堰市", "code": "420300", "deep": "2", "pid": "1686", "area": [ { "id": "1709", "name": "茅箭区", "code": "420302", "deep": "3", "pid": "1708" }, { "id": "1710", "name": "张湾区", "code": "420303", "deep": "3", "pid": "1708" }, { "id": "1711", "name": "郧阳区", "code": "420304", "deep": "3", "pid": "1708" }, { "id": "1712", "name": "郧西县", "code": "420322", "deep": "3", "pid": "1708" }, { "id": "1713", "name": "竹山县", "code": "420323", "deep": "3", "pid": "1708" }, { "id": "1714", "name": "竹溪县", "code": "420324", "deep": "3", "pid": "1708" }, { "id": "1715", "name": "房县", "code": "420325", "deep": "3", "pid": "1708" }, { "id": "1716", "name": "丹江口市", "code": "420381", "deep": "3", "pid": "1708" } ] }, { "id": "1717", "name": "宜昌市", "code": "420500", "deep": "2", "pid": "1686", "area": [ { "id": "1718", "name": "西陵区", "code": "420502", "deep": "3", "pid": "1717" }, { "id": "1719", "name": "伍家岗区", "code": "420503", "deep": "3", "pid": "1717" }, { "id": "1720", "name": "点军区", "code": "420504", "deep": "3", "pid": "1717" }, { "id": "1721", "name": "猇亭区", "code": "420505", "deep": "3", "pid": "1717" }, { "id": "1722", "name": "夷陵区", "code": "420506", "deep": "3", "pid": "1717" }, { "id": "1723", "name": "远安县", "code": "420525", "deep": "3", "pid": "1717" }, { "id": "1724", "name": "兴山县", "code": "420526", "deep": "3", "pid": "1717" }, { "id": "1725", "name": "秭归县", "code": "420527", "deep": "3", "pid": "1717" }, { "id": "1726", "name": "长阳土家族自治县", "code": "420528", "deep": "3", "pid": "1717" }, { "id": "1727", "name": "五峰土家族自治县", "code": "420529", "deep": "3", "pid": "1717" }, { "id": "1728", "name": "宜都市", "code": "420581", "deep": "3", "pid": "1717" }, { "id": "1729", "name": "当阳市", "code": "420582", "deep": "3", "pid": "1717" }, { "id": "1730", "name": "枝江市", "code": "420583", "deep": "3", "pid": "1717" } ] }, { "id": "1731", "name": "襄阳市", "code": "420600", "deep": "2", "pid": "1686", "area": [ { "id": "1732", "name": "襄城区", "code": "420602", "deep": "3", "pid": "1731" }, { "id": "1733", "name": "樊城区", "code": "420606", "deep": "3", "pid": "1731" }, { "id": "1734", "name": "襄州区", "code": "420607", "deep": "3", "pid": "1731" }, { "id": "1735", "name": "南漳县", "code": "420624", "deep": "3", "pid": "1731" }, { "id": "1736", "name": "谷城县", "code": "420625", "deep": "3", "pid": "1731" }, { "id": "1737", "name": "保康县", "code": "420626", "deep": "3", "pid": "1731" }, { "id": "1738", "name": "老河口市", "code": "420682", "deep": "3", "pid": "1731" }, { "id": "1739", "name": "枣阳市", "code": "420683", "deep": "3", "pid": "1731" }, { "id": "1740", "name": "宜城市", "code": "420684", "deep": "3", "pid": "1731" } ] }, { "id": "1741", "name": "鄂州市", "code": "420700", "deep": "2", "pid": "1686", "area": [ { "id": "1742", "name": "梁子湖区", "code": "420702", "deep": "3", "pid": "1741" }, { "id": "1743", "name": "华容区", "code": "420703", "deep": "3", "pid": "1741" }, { "id": "1744", "name": "鄂城区", "code": "420704", "deep": "3", "pid": "1741" } ] }, { "id": "1745", "name": "荆门市", "code": "420800", "deep": "2", "pid": "1686", "area": [ { "id": "1746", "name": "东宝区", "code": "420802", "deep": "3", "pid": "1745" }, { "id": "1747", "name": "掇刀区", "code": "420804", "deep": "3", "pid": "1745" }, { "id": "1748", "name": "京山县", "code": "420821", "deep": "3", "pid": "1745" }, { "id": "1749", "name": "沙洋县", "code": "420822", "deep": "3", "pid": "1745" }, { "id": "1750", "name": "钟祥市", "code": "420881", "deep": "3", "pid": "1745" } ] }, { "id": "1751", "name": "孝感市", "code": "420900", "deep": "2", "pid": "1686", "area": [ { "id": "1752", "name": "孝南区", "code": "420902", "deep": "3", "pid": "1751" }, { "id": "1753", "name": "孝昌县", "code": "420921", "deep": "3", "pid": "1751" }, { "id": "1754", "name": "大悟县", "code": "420922", "deep": "3", "pid": "1751" }, { "id": "1755", "name": "云梦县", "code": "420923", "deep": "3", "pid": "1751" }, { "id": "1756", "name": "应城市", "code": "420981", "deep": "3", "pid": "1751" }, { "id": "1757", "name": "安陆市", "code": "420982", "deep": "3", "pid": "1751" }, { "id": "1758", "name": "汉川市", "code": "420984", "deep": "3", "pid": "1751" } ] }, { "id": "1759", "name": "荆州市", "code": "421000", "deep": "2", "pid": "1686", "area": [ { "id": "1760", "name": "沙市区", "code": "421002", "deep": "3", "pid": "1759" }, { "id": "1761", "name": "荆州区", "code": "421003", "deep": "3", "pid": "1759" }, { "id": "1762", "name": "公安县", "code": "421022", "deep": "3", "pid": "1759" }, { "id": "1763", "name": "监利县", "code": "421023", "deep": "3", "pid": "1759" }, { "id": "1764", "name": "江陵县", "code": "421024", "deep": "3", "pid": "1759" }, { "id": "1765", "name": "石首市", "code": "421081", "deep": "3", "pid": "1759" }, { "id": "1766", "name": "洪湖市", "code": "421083", "deep": "3", "pid": "1759" }, { "id": "1767", "name": "松滋市", "code": "421087", "deep": "3", "pid": "1759" } ] }, { "id": "1768", "name": "黄冈市", "code": "421100", "deep": "2", "pid": "1686", "area": [ { "id": "1769", "name": "黄州区", "code": "421102", "deep": "3", "pid": "1768" }, { "id": "1770", "name": "团风县", "code": "421121", "deep": "3", "pid": "1768" }, { "id": "1771", "name": "红安县", "code": "421122", "deep": "3", "pid": "1768" }, { "id": "1772", "name": "罗田县", "code": "421123", "deep": "3", "pid": "1768" }, { "id": "1773", "name": "英山县", "code": "421124", "deep": "3", "pid": "1768" }, { "id": "1774", "name": "浠水县", "code": "421125", "deep": "3", "pid": "1768" }, { "id": "1775", "name": "蕲春县", "code": "421126", "deep": "3", "pid": "1768" }, { "id": "1776", "name": "黄梅县", "code": "421127", "deep": "3", "pid": "1768" }, { "id": "1777", "name": "麻城市", "code": "421181", "deep": "3", "pid": "1768" }, { "id": "1778", "name": "武穴市", "code": "421182", "deep": "3", "pid": "1768" } ] }, { "id": "1779", "name": "咸宁市", "code": "421200", "deep": "2", "pid": "1686", "area": [ { "id": "1780", "name": "咸安区", "code": "421202", "deep": "3", "pid": "1779" }, { "id": "1781", "name": "嘉鱼县", "code": "421221", "deep": "3", "pid": "1779" }, { "id": "1782", "name": "通城县", "code": "421222", "deep": "3", "pid": "1779" }, { "id": "1783", "name": "崇阳县", "code": "421223", "deep": "3", "pid": "1779" }, { "id": "1784", "name": "通山县", "code": "421224", "deep": "3", "pid": "1779" }, { "id": "1785", "name": "赤壁市", "code": "421281", "deep": "3", "pid": "1779" } ] }, { "id": "1786", "name": "随州市", "code": "421300", "deep": "2", "pid": "1686", "area": [ { "id": "1787", "name": "曾都区", "code": "421303", "deep": "3", "pid": "1786" }, { "id": "1788", "name": "随县", "code": "421321", "deep": "3", "pid": "1786" }, { "id": "1789", "name": "广水市", "code": "421381", "deep": "3", "pid": "1786" } ] }, { "id": "1790", "name": "恩施土家族苗族自治州", "code": "422800", "deep": "2", "pid": "1686", "area": [ { "id": "1791", "name": "恩施市", "code": "422801", "deep": "3", "pid": "1790" }, { "id": "1792", "name": "利川市", "code": "422802", "deep": "3", "pid": "1790" }, { "id": "1793", "name": "建始县", "code": "422822", "deep": "3", "pid": "1790" }, { "id": "1794", "name": "巴东县", "code": "422823", "deep": "3", "pid": "1790" }, { "id": "1795", "name": "宣恩县", "code": "422825", "deep": "3", "pid": "1790" }, { "id": "1796", "name": "咸丰县", "code": "422826", "deep": "3", "pid": "1790" }, { "id": "1797", "name": "来凤县", "code": "422827", "deep": "3", "pid": "1790" }, { "id": "1798", "name": "鹤峰县", "code": "422828", "deep": "3", "pid": "1790" } ] }, { "id": "1799", "name": "仙桃市", "code": "429004", "deep": "2", "pid": "1686" }, { "id": "1800", "name": "潜江市", "code": "429005", "deep": "2", "pid": "1686" }, { "id": "1801", "name": "天门市", "code": "429006", "deep": "2", "pid": "1686" }, { "id": "1802", "name": "神农架林区", "code": "429021", "deep": "2", "pid": "1686" }, { "id": "3390", "name": "省直辖县级行政区划", "code": "429000", "deep": "2", "pid": "1686" } ] }, { "id": "1803", "name": "湖南省", "code": "430000", "deep": "1", "pid": "0", "city": [ { "id": "1804", "name": "长沙市", "code": "430100", "deep": "2", "pid": "1803", "area": [ { "id": "1805", "name": "芙蓉区", "code": "430102", "deep": "3", "pid": "1804" }, { "id": "1806", "name": "天心区", "code": "430103", "deep": "3", "pid": "1804" }, { "id": "1807", "name": "岳麓区", "code": "430104", "deep": "3", "pid": "1804" }, { "id": "1808", "name": "开福区", "code": "430105", "deep": "3", "pid": "1804" }, { "id": "1809", "name": "雨花区", "code": "430111", "deep": "3", "pid": "1804" }, { "id": "1810", "name": "望城区", "code": "430112", "deep": "3", "pid": "1804" }, { "id": "1811", "name": "长沙县", "code": "430121", "deep": "3", "pid": "1804" }, { "id": "1812", "name": "宁乡市", "code": "430182", "deep": "3", "pid": "1804" }, { "id": "1813", "name": "浏阳市", "code": "430181", "deep": "3", "pid": "1804" }, { "id": "3391", "name": "宁乡县", "code": "430124", "deep": "3", "pid": "1804" } ] }, { "id": "1814", "name": "株洲市", "code": "430200", "deep": "2", "pid": "1803", "area": [ { "id": "1815", "name": "荷塘区", "code": "430202", "deep": "3", "pid": "1814" }, { "id": "1816", "name": "芦淞区", "code": "430203", "deep": "3", "pid": "1814" }, { "id": "1817", "name": "石峰区", "code": "430204", "deep": "3", "pid": "1814" }, { "id": "1818", "name": "天元区", "code": "430211", "deep": "3", "pid": "1814" }, { "id": "1819", "name": "株洲县", "code": "430221", "deep": "3", "pid": "1814" }, { "id": "1820", "name": "攸县", "code": "430223", "deep": "3", "pid": "1814" }, { "id": "1821", "name": "茶陵县", "code": "430224", "deep": "3", "pid": "1814" }, { "id": "1822", "name": "炎陵县", "code": "430225", "deep": "3", "pid": "1814" }, { "id": "1823", "name": "醴陵市", "code": "430281", "deep": "3", "pid": "1814" } ] }, { "id": "1824", "name": "湘潭市", "code": "430300", "deep": "2", "pid": "1803", "area": [ { "id": "1825", "name": "雨湖区", "code": "430302", "deep": "3", "pid": "1824" }, { "id": "1826", "name": "岳塘区", "code": "430304", "deep": "3", "pid": "1824" }, { "id": "1827", "name": "湘潭县", "code": "430321", "deep": "3", "pid": "1824" }, { "id": "1828", "name": "湘乡市", "code": "430381", "deep": "3", "pid": "1824" }, { "id": "1829", "name": "韶山市", "code": "430382", "deep": "3", "pid": "1824" } ] }, { "id": "1830", "name": "衡阳市", "code": "430400", "deep": "2", "pid": "1803", "area": [ { "id": "1831", "name": "珠晖区", "code": "430405", "deep": "3", "pid": "1830" }, { "id": "1832", "name": "雁峰区", "code": "430406", "deep": "3", "pid": "1830" }, { "id": "1833", "name": "石鼓区", "code": "430407", "deep": "3", "pid": "1830" }, { "id": "1834", "name": "蒸湘区", "code": "430408", "deep": "3", "pid": "1830" }, { "id": "1835", "name": "南岳区", "code": "430412", "deep": "3", "pid": "1830" }, { "id": "1836", "name": "衡阳县", "code": "430421", "deep": "3", "pid": "1830" }, { "id": "1837", "name": "衡南县", "code": "430422", "deep": "3", "pid": "1830" }, { "id": "1838", "name": "衡山县", "code": "430423", "deep": "3", "pid": "1830" }, { "id": "1839", "name": "衡东县", "code": "430424", "deep": "3", "pid": "1830" }, { "id": "1840", "name": "祁东县", "code": "430426", "deep": "3", "pid": "1830" }, { "id": "1841", "name": "耒阳市", "code": "430481", "deep": "3", "pid": "1830" }, { "id": "1842", "name": "常宁市", "code": "430482", "deep": "3", "pid": "1830" } ] }, { "id": "1843", "name": "邵阳市", "code": "430500", "deep": "2", "pid": "1803", "area": [ { "id": "1844", "name": "双清区", "code": "430502", "deep": "3", "pid": "1843" }, { "id": "1845", "name": "大祥区", "code": "430503", "deep": "3", "pid": "1843" }, { "id": "1846", "name": "北塔区", "code": "430511", "deep": "3", "pid": "1843" }, { "id": "1847", "name": "邵东县", "code": "430521", "deep": "3", "pid": "1843" }, { "id": "1848", "name": "新邵县", "code": "430522", "deep": "3", "pid": "1843" }, { "id": "1849", "name": "邵阳县", "code": "430523", "deep": "3", "pid": "1843" }, { "id": "1850", "name": "隆回县", "code": "430524", "deep": "3", "pid": "1843" }, { "id": "1851", "name": "洞口县", "code": "430525", "deep": "3", "pid": "1843" }, { "id": "1852", "name": "绥宁县", "code": "430527", "deep": "3", "pid": "1843" }, { "id": "1853", "name": "新宁县", "code": "430528", "deep": "3", "pid": "1843" }, { "id": "1854", "name": "城步苗族自治县", "code": "430529", "deep": "3", "pid": "1843" }, { "id": "1855", "name": "武冈市", "code": "430581", "deep": "3", "pid": "1843" } ] }, { "id": "1856", "name": "岳阳市", "code": "430600", "deep": "2", "pid": "1803", "area": [ { "id": "1857", "name": "岳阳楼区", "code": "430602", "deep": "3", "pid": "1856" }, { "id": "1858", "name": "云溪区", "code": "430603", "deep": "3", "pid": "1856" }, { "id": "1859", "name": "君山区", "code": "430611", "deep": "3", "pid": "1856" }, { "id": "1860", "name": "岳阳县", "code": "430621", "deep": "3", "pid": "1856" }, { "id": "1861", "name": "华容县", "code": "430623", "deep": "3", "pid": "1856" }, { "id": "1862", "name": "湘阴县", "code": "430624", "deep": "3", "pid": "1856" }, { "id": "1863", "name": "平江县", "code": "430626", "deep": "3", "pid": "1856" }, { "id": "1864", "name": "汨罗市", "code": "430681", "deep": "3", "pid": "1856" }, { "id": "1865", "name": "临湘市", "code": "430682", "deep": "3", "pid": "1856" } ] }, { "id": "1866", "name": "常德市", "code": "430700", "deep": "2", "pid": "1803", "area": [ { "id": "1867", "name": "武陵区", "code": "430702", "deep": "3", "pid": "1866" }, { "id": "1868", "name": "鼎城区", "code": "430703", "deep": "3", "pid": "1866" }, { "id": "1869", "name": "安乡县", "code": "430721", "deep": "3", "pid": "1866" }, { "id": "1870", "name": "汉寿县", "code": "430722", "deep": "3", "pid": "1866" }, { "id": "1871", "name": "澧县", "code": "430723", "deep": "3", "pid": "1866" }, { "id": "1872", "name": "临澧县", "code": "430724", "deep": "3", "pid": "1866" }, { "id": "1873", "name": "桃源县", "code": "430725", "deep": "3", "pid": "1866" }, { "id": "1874", "name": "石门县", "code": "430726", "deep": "3", "pid": "1866" }, { "id": "1875", "name": "津市市", "code": "430781", "deep": "3", "pid": "1866" } ] }, { "id": "1876", "name": "张家界市", "code": "430800", "deep": "2", "pid": "1803", "area": [ { "id": "1877", "name": "永定区", "code": "430802", "deep": "3", "pid": "1876" }, { "id": "1878", "name": "武陵源区", "code": "430811", "deep": "3", "pid": "1876" }, { "id": "1879", "name": "慈利县", "code": "430821", "deep": "3", "pid": "1876" }, { "id": "1880", "name": "桑植县", "code": "430822", "deep": "3", "pid": "1876" } ] }, { "id": "1881", "name": "益阳市", "code": "430900", "deep": "2", "pid": "1803", "area": [ { "id": "1882", "name": "资阳区", "code": "430902", "deep": "3", "pid": "1881" }, { "id": "1883", "name": "赫山区", "code": "430903", "deep": "3", "pid": "1881" }, { "id": "1884", "name": "南县", "code": "430921", "deep": "3", "pid": "1881" }, { "id": "1885", "name": "桃江县", "code": "430922", "deep": "3", "pid": "1881" }, { "id": "1886", "name": "安化县", "code": "430923", "deep": "3", "pid": "1881" }, { "id": "1887", "name": "沅江市", "code": "430981", "deep": "3", "pid": "1881" } ] }, { "id": "1888", "name": "郴州市", "code": "431000", "deep": "2", "pid": "1803", "area": [ { "id": "1889", "name": "北湖区", "code": "431002", "deep": "3", "pid": "1888" }, { "id": "1890", "name": "苏仙区", "code": "431003", "deep": "3", "pid": "1888" }, { "id": "1891", "name": "桂阳县", "code": "431021", "deep": "3", "pid": "1888" }, { "id": "1892", "name": "宜章县", "code": "431022", "deep": "3", "pid": "1888" }, { "id": "1893", "name": "永兴县", "code": "431023", "deep": "3", "pid": "1888" }, { "id": "1894", "name": "嘉禾县", "code": "431024", "deep": "3", "pid": "1888" }, { "id": "1895", "name": "临武县", "code": "431025", "deep": "3", "pid": "1888" }, { "id": "1896", "name": "汝城县", "code": "431026", "deep": "3", "pid": "1888" }, { "id": "1897", "name": "桂东县", "code": "431027", "deep": "3", "pid": "1888" }, { "id": "1898", "name": "安仁县", "code": "431028", "deep": "3", "pid": "1888" }, { "id": "1899", "name": "资兴市", "code": "431081", "deep": "3", "pid": "1888" } ] }, { "id": "1900", "name": "永州市", "code": "431100", "deep": "2", "pid": "1803", "area": [ { "id": "1901", "name": "零陵区", "code": "431102", "deep": "3", "pid": "1900" }, { "id": "1902", "name": "冷水滩区", "code": "431103", "deep": "3", "pid": "1900" }, { "id": "1903", "name": "祁阳县", "code": "431121", "deep": "3", "pid": "1900" }, { "id": "1904", "name": "东安县", "code": "431122", "deep": "3", "pid": "1900" }, { "id": "1905", "name": "双牌县", "code": "431123", "deep": "3", "pid": "1900" }, { "id": "1906", "name": "道县", "code": "431124", "deep": "3", "pid": "1900" }, { "id": "1907", "name": "江永县", "code": "431125", "deep": "3", "pid": "1900" }, { "id": "1908", "name": "宁远县", "code": "431126", "deep": "3", "pid": "1900" }, { "id": "1909", "name": "蓝山县", "code": "431127", "deep": "3", "pid": "1900" }, { "id": "1910", "name": "新田县", "code": "431128", "deep": "3", "pid": "1900" }, { "id": "1911", "name": "江华瑶族自治县", "code": "431129", "deep": "3", "pid": "1900" } ] }, { "id": "1912", "name": "怀化市", "code": "431200", "deep": "2", "pid": "1803", "area": [ { "id": "1913", "name": "鹤城区", "code": "431202", "deep": "3", "pid": "1912" }, { "id": "1914", "name": "中方县", "code": "431221", "deep": "3", "pid": "1912" }, { "id": "1915", "name": "沅陵县", "code": "431222", "deep": "3", "pid": "1912" }, { "id": "1916", "name": "辰溪县", "code": "431223", "deep": "3", "pid": "1912" }, { "id": "1917", "name": "溆浦县", "code": "431224", "deep": "3", "pid": "1912" }, { "id": "1918", "name": "会同县", "code": "431225", "deep": "3", "pid": "1912" }, { "id": "1919", "name": "麻阳苗族自治县", "code": "431226", "deep": "3", "pid": "1912" }, { "id": "1920", "name": "新晃侗族自治县", "code": "431227", "deep": "3", "pid": "1912" }, { "id": "1921", "name": "芷江侗族自治县", "code": "431228", "deep": "3", "pid": "1912" }, { "id": "1922", "name": "靖州苗族侗族自治县", "code": "431229", "deep": "3", "pid": "1912" }, { "id": "1923", "name": "通道侗族自治县", "code": "431230", "deep": "3", "pid": "1912" }, { "id": "1924", "name": "洪江市", "code": "431281", "deep": "3", "pid": "1912" } ] }, { "id": "1925", "name": "娄底市", "code": "431300", "deep": "2", "pid": "1803", "area": [ { "id": "1926", "name": "娄星区", "code": "431302", "deep": "3", "pid": "1925" }, { "id": "1927", "name": "双峰县", "code": "431321", "deep": "3", "pid": "1925" }, { "id": "1928", "name": "新化县", "code": "431322", "deep": "3", "pid": "1925" }, { "id": "1929", "name": "冷水江市", "code": "431381", "deep": "3", "pid": "1925" }, { "id": "1930", "name": "涟源市", "code": "431382", "deep": "3", "pid": "1925" } ] }, { "id": "1931", "name": "湘西土家族苗族自治州", "code": "433100", "deep": "2", "pid": "1803", "area": [ { "id": "1932", "name": "吉首市", "code": "433101", "deep": "3", "pid": "1931" }, { "id": "1933", "name": "泸溪县", "code": "433122", "deep": "3", "pid": "1931" }, { "id": "1934", "name": "凤凰县", "code": "433123", "deep": "3", "pid": "1931" }, { "id": "1935", "name": "花垣县", "code": "433124", "deep": "3", "pid": "1931" }, { "id": "1936", "name": "保靖县", "code": "433125", "deep": "3", "pid": "1931" }, { "id": "1937", "name": "古丈县", "code": "433126", "deep": "3", "pid": "1931" }, { "id": "1938", "name": "永顺县", "code": "433127", "deep": "3", "pid": "1931" }, { "id": "1939", "name": "龙山县", "code": "433130", "deep": "3", "pid": "1931" } ] } ] }, { "id": "1940", "name": "广东省", "code": "440000", "deep": "1", "pid": "0", "city": [ { "id": "1941", "name": "广州市", "code": "440100", "deep": "2", "pid": "1940", "area": [ { "id": "1942", "name": "荔湾区", "code": "440103", "deep": "3", "pid": "1941" }, { "id": "1943", "name": "越秀区", "code": "440104", "deep": "3", "pid": "1941" }, { "id": "1944", "name": "海珠区", "code": "440105", "deep": "3", "pid": "1941" }, { "id": "1945", "name": "天河区", "code": "440106", "deep": "3", "pid": "1941" }, { "id": "1946", "name": "白云区", "code": "440111", "deep": "3", "pid": "1941" }, { "id": "1947", "name": "黄埔区", "code": "440112", "deep": "3", "pid": "1941" }, { "id": "1948", "name": "番禺区", "code": "440113", "deep": "3", "pid": "1941" }, { "id": "1949", "name": "花都区", "code": "440114", "deep": "3", "pid": "1941" }, { "id": "1950", "name": "南沙区", "code": "440115", "deep": "3", "pid": "1941" }, { "id": "1951", "name": "从化区", "code": "440117", "deep": "3", "pid": "1941" }, { "id": "1952", "name": "增城区", "code": "440118", "deep": "3", "pid": "1941" } ] }, { "id": "1953", "name": "韶关市", "code": "440200", "deep": "2", "pid": "1940", "area": [ { "id": "1954", "name": "武江区", "code": "440203", "deep": "3", "pid": "1953" }, { "id": "1955", "name": "浈江区", "code": "440204", "deep": "3", "pid": "1953" }, { "id": "1956", "name": "曲江区", "code": "440205", "deep": "3", "pid": "1953" }, { "id": "1957", "name": "始兴县", "code": "440222", "deep": "3", "pid": "1953" }, { "id": "1958", "name": "仁化县", "code": "440224", "deep": "3", "pid": "1953" }, { "id": "1959", "name": "翁源县", "code": "440229", "deep": "3", "pid": "1953" }, { "id": "1960", "name": "乳源瑶族自治县", "code": "440232", "deep": "3", "pid": "1953" }, { "id": "1961", "name": "新丰县", "code": "440233", "deep": "3", "pid": "1953" }, { "id": "1962", "name": "乐昌市", "code": "440281", "deep": "3", "pid": "1953" }, { "id": "1963", "name": "南雄市", "code": "440282", "deep": "3", "pid": "1953" } ] }, { "id": "1964", "name": "深圳市", "code": "440300", "deep": "2", "pid": "1940", "area": [ { "id": "1965", "name": "罗湖区", "code": "440303", "deep": "3", "pid": "1964" }, { "id": "1966", "name": "福田区", "code": "440304", "deep": "3", "pid": "1964" }, { "id": "1967", "name": "南山区", "code": "440305", "deep": "3", "pid": "1964" }, { "id": "1968", "name": "宝安区", "code": "440306", "deep": "3", "pid": "1964" }, { "id": "1969", "name": "龙岗区", "code": "440307", "deep": "3", "pid": "1964" }, { "id": "1970", "name": "盐田区", "code": "440308", "deep": "3", "pid": "1964" }, { "id": "3265", "name": "坪山区", "code": "440310", "deep": "3", "pid": "1964" }, { "id": "10049", "name": "龙华区", "code": "440309", "deep": "3", "pid": "1964" } ] }, { "id": "1971", "name": "珠海市", "code": "440400", "deep": "2", "pid": "1940", "area": [ { "id": "1972", "name": "香洲区", "code": "440402", "deep": "3", "pid": "1971" }, { "id": "1973", "name": "斗门区", "code": "440403", "deep": "3", "pid": "1971" }, { "id": "1974", "name": "金湾区", "code": "440404", "deep": "3", "pid": "1971" } ] }, { "id": "1975", "name": "汕头市", "code": "440500", "deep": "2", "pid": "1940", "area": [ { "id": "1976", "name": "龙湖区", "code": "440507", "deep": "3", "pid": "1975" }, { "id": "1977", "name": "金平区", "code": "440511", "deep": "3", "pid": "1975" }, { "id": "1978", "name": "濠江区", "code": "440512", "deep": "3", "pid": "1975" }, { "id": "1979", "name": "潮阳区", "code": "440513", "deep": "3", "pid": "1975" }, { "id": "1980", "name": "潮南区", "code": "440514", "deep": "3", "pid": "1975" }, { "id": "1981", "name": "澄海区", "code": "440515", "deep": "3", "pid": "1975" }, { "id": "1982", "name": "南澳县", "code": "440523", "deep": "3", "pid": "1975" } ] }, { "id": "1983", "name": "佛山市", "code": "440600", "deep": "2", "pid": "1940", "area": [ { "id": "1984", "name": "禅城区", "code": "440604", "deep": "3", "pid": "1983" }, { "id": "1985", "name": "南海区", "code": "440605", "deep": "3", "pid": "1983" }, { "id": "1986", "name": "顺德区", "code": "440606", "deep": "3", "pid": "1983" }, { "id": "1987", "name": "三水区", "code": "440607", "deep": "3", "pid": "1983" }, { "id": "1988", "name": "高明区", "code": "440608", "deep": "3", "pid": "1983" } ] }, { "id": "1989", "name": "江门市", "code": "440700", "deep": "2", "pid": "1940", "area": [ { "id": "1990", "name": "蓬江区", "code": "440703", "deep": "3", "pid": "1989" }, { "id": "1991", "name": "江海区", "code": "440704", "deep": "3", "pid": "1989" }, { "id": "1992", "name": "新会区", "code": "440705", "deep": "3", "pid": "1989" }, { "id": "1993", "name": "台山市", "code": "440781", "deep": "3", "pid": "1989" }, { "id": "1994", "name": "开平市", "code": "440783", "deep": "3", "pid": "1989" }, { "id": "1995", "name": "鹤山市", "code": "440784", "deep": "3", "pid": "1989" }, { "id": "1996", "name": "恩平市", "code": "440785", "deep": "3", "pid": "1989" } ] }, { "id": "1997", "name": "湛江市", "code": "440800", "deep": "2", "pid": "1940", "area": [ { "id": "1998", "name": "赤坎区", "code": "440802", "deep": "3", "pid": "1997" }, { "id": "1999", "name": "霞山区", "code": "440803", "deep": "3", "pid": "1997" }, { "id": "2000", "name": "坡头区", "code": "440804", "deep": "3", "pid": "1997" }, { "id": "2001", "name": "麻章区", "code": "440811", "deep": "3", "pid": "1997" }, { "id": "2002", "name": "遂溪县", "code": "440823", "deep": "3", "pid": "1997" }, { "id": "2003", "name": "徐闻县", "code": "440825", "deep": "3", "pid": "1997" }, { "id": "2004", "name": "廉江市", "code": "440881", "deep": "3", "pid": "1997" }, { "id": "2005", "name": "雷州市", "code": "440882", "deep": "3", "pid": "1997" }, { "id": "2006", "name": "吴川市", "code": "440883", "deep": "3", "pid": "1997" } ] }, { "id": "2007", "name": "茂名市", "code": "440900", "deep": "2", "pid": "1940", "area": [ { "id": "2008", "name": "茂南区", "code": "440902", "deep": "3", "pid": "2007" }, { "id": "2009", "name": "电白区", "code": "440904", "deep": "3", "pid": "2007" }, { "id": "2010", "name": "高州市", "code": "440981", "deep": "3", "pid": "2007" }, { "id": "2011", "name": "化州市", "code": "440982", "deep": "3", "pid": "2007" }, { "id": "2012", "name": "信宜市", "code": "440983", "deep": "3", "pid": "2007" } ] }, { "id": "2013", "name": "肇庆市", "code": "441200", "deep": "2", "pid": "1940", "area": [ { "id": "2014", "name": "端州区", "code": "441202", "deep": "3", "pid": "2013" }, { "id": "2015", "name": "鼎湖区", "code": "441203", "deep": "3", "pid": "2013" }, { "id": "2016", "name": "高要区", "code": "441204", "deep": "3", "pid": "2013" }, { "id": "2017", "name": "广宁县", "code": "441223", "deep": "3", "pid": "2013" }, { "id": "2018", "name": "怀集县", "code": "441224", "deep": "3", "pid": "2013" }, { "id": "2019", "name": "封开县", "code": "441225", "deep": "3", "pid": "2013" }, { "id": "2020", "name": "德庆县", "code": "441226", "deep": "3", "pid": "2013" }, { "id": "2021", "name": "四会市", "code": "441284", "deep": "3", "pid": "2013" } ] }, { "id": "2022", "name": "惠州市", "code": "441300", "deep": "2", "pid": "1940", "area": [ { "id": "2023", "name": "惠城区", "code": "441302", "deep": "3", "pid": "2022" }, { "id": "2024", "name": "惠阳区", "code": "441303", "deep": "3", "pid": "2022" }, { "id": "2025", "name": "博罗县", "code": "441322", "deep": "3", "pid": "2022" }, { "id": "2026", "name": "惠东县", "code": "441323", "deep": "3", "pid": "2022" }, { "id": "2027", "name": "龙门县", "code": "441324", "deep": "3", "pid": "2022" } ] }, { "id": "2028", "name": "梅州市", "code": "441400", "deep": "2", "pid": "1940", "area": [ { "id": "2029", "name": "梅江区", "code": "441402", "deep": "3", "pid": "2028" }, { "id": "2030", "name": "梅县区", "code": "441403", "deep": "3", "pid": "2028" }, { "id": "2031", "name": "大埔县", "code": "441422", "deep": "3", "pid": "2028" }, { "id": "2032", "name": "丰顺县", "code": "441423", "deep": "3", "pid": "2028" }, { "id": "2033", "name": "五华县", "code": "441424", "deep": "3", "pid": "2028" }, { "id": "2034", "name": "平远县", "code": "441426", "deep": "3", "pid": "2028" }, { "id": "2035", "name": "蕉岭县", "code": "441427", "deep": "3", "pid": "2028" }, { "id": "2036", "name": "兴宁市", "code": "441481", "deep": "3", "pid": "2028" } ] }, { "id": "2037", "name": "汕尾市", "code": "441500", "deep": "2", "pid": "1940", "area": [ { "id": "2038", "name": "城区", "code": "441502", "deep": "3", "pid": "2037" }, { "id": "2039", "name": "海丰县", "code": "441521", "deep": "3", "pid": "2037" }, { "id": "2040", "name": "陆河县", "code": "441523", "deep": "3", "pid": "2037" }, { "id": "2041", "name": "陆丰市", "code": "441581", "deep": "3", "pid": "2037" } ] }, { "id": "2042", "name": "河源市", "code": "441600", "deep": "2", "pid": "1940", "area": [ { "id": "2043", "name": "源城区", "code": "441602", "deep": "3", "pid": "2042" }, { "id": "2044", "name": "紫金县", "code": "441621", "deep": "3", "pid": "2042" }, { "id": "2045", "name": "龙川县", "code": "441622", "deep": "3", "pid": "2042" }, { "id": "2046", "name": "连平县", "code": "441623", "deep": "3", "pid": "2042" }, { "id": "2047", "name": "和平县", "code": "441624", "deep": "3", "pid": "2042" }, { "id": "2048", "name": "东源县", "code": "441625", "deep": "3", "pid": "2042" } ] }, { "id": "2049", "name": "阳江市", "code": "441700", "deep": "2", "pid": "1940", "area": [ { "id": "2050", "name": "江城区", "code": "441702", "deep": "3", "pid": "2049" }, { "id": "2051", "name": "阳东区", "code": "441704", "deep": "3", "pid": "2049" }, { "id": "2052", "name": "阳西县", "code": "441721", "deep": "3", "pid": "2049" }, { "id": "2053", "name": "阳春市", "code": "441781", "deep": "3", "pid": "2049" } ] }, { "id": "2054", "name": "清远市", "code": "441800", "deep": "2", "pid": "1940", "area": [ { "id": "2055", "name": "清城区", "code": "441802", "deep": "3", "pid": "2054" }, { "id": "2056", "name": "清新区", "code": "441803", "deep": "3", "pid": "2054" }, { "id": "2057", "name": "佛冈县", "code": "441821", "deep": "3", "pid": "2054" }, { "id": "2058", "name": "阳山县", "code": "441823", "deep": "3", "pid": "2054" }, { "id": "2059", "name": "连山壮族瑶族自治县", "code": "441825", "deep": "3", "pid": "2054" }, { "id": "2060", "name": "连南瑶族自治县", "code": "441826", "deep": "3", "pid": "2054" }, { "id": "2061", "name": "英德市", "code": "441881", "deep": "3", "pid": "2054" }, { "id": "2062", "name": "连州市", "code": "441882", "deep": "3", "pid": "2054" } ] }, { "id": "2063", "name": "东莞市", "code": "441900", "deep": "2", "pid": "1940", "area": [ { "id": "3392", "name": "东城街道", "code": "441900003", "deep": "3", "pid": "2063" }, { "id": "3393", "name": "南城街道", "code": "441900004", "deep": "3", "pid": "2063" }, { "id": "3394", "name": "万江街道", "code": "441900005", "deep": "3", "pid": "2063" }, { "id": "3395", "name": "莞城街道", "code": "441900006", "deep": "3", "pid": "2063" }, { "id": "3396", "name": "石碣镇", "code": "441900101", "deep": "3", "pid": "2063" }, { "id": "3397", "name": "石龙镇", "code": "441900102", "deep": "3", "pid": "2063" }, { "id": "3398", "name": "茶山镇", "code": "441900103", "deep": "3", "pid": "2063" }, { "id": "3399", "name": "石排镇", "code": "441900104", "deep": "3", "pid": "2063" }, { "id": "3400", "name": "企石镇", "code": "441900105", "deep": "3", "pid": "2063" }, { "id": "3401", "name": "横沥镇", "code": "441900106", "deep": "3", "pid": "2063" }, { "id": "3402", "name": "桥头镇", "code": "441900107", "deep": "3", "pid": "2063" }, { "id": "3403", "name": "谢岗镇", "code": "441900108", "deep": "3", "pid": "2063" }, { "id": "3404", "name": "东坑镇", "code": "441900109", "deep": "3", "pid": "2063" }, { "id": "3405", "name": "常平镇", "code": "441900110", "deep": "3", "pid": "2063" }, { "id": "3406", "name": "寮步镇", "code": "441900111", "deep": "3", "pid": "2063" }, { "id": "3407", "name": "樟木头镇", "code": "441900112", "deep": "3", "pid": "2063" }, { "id": "3408", "name": "大朗镇", "code": "441900113", "deep": "3", "pid": "2063" }, { "id": "3409", "name": "黄江镇", "code": "441900114", "deep": "3", "pid": "2063" }, { "id": "3410", "name": "清溪镇", "code": "441900115", "deep": "3", "pid": "2063" }, { "id": "3411", "name": "塘厦镇", "code": "441900116", "deep": "3", "pid": "2063" }, { "id": "3412", "name": "凤岗镇", "code": "441900117", "deep": "3", "pid": "2063" }, { "id": "3413", "name": "大岭山镇", "code": "441900118", "deep": "3", "pid": "2063" }, { "id": "3414", "name": "长安镇", "code": "441900119", "deep": "3", "pid": "2063" }, { "id": "3415", "name": "虎门镇", "code": "441900121", "deep": "3", "pid": "2063" }, { "id": "3416", "name": "厚街镇", "code": "441900122", "deep": "3", "pid": "2063" }, { "id": "3417", "name": "沙田镇", "code": "441900123", "deep": "3", "pid": "2063" }, { "id": "3418", "name": "道滘镇", "code": "441900124", "deep": "3", "pid": "2063" }, { "id": "3419", "name": "洪梅镇", "code": "441900125", "deep": "3", "pid": "2063" }, { "id": "3420", "name": "麻涌镇", "code": "441900126", "deep": "3", "pid": "2063" }, { "id": "3421", "name": "望牛墩镇", "code": "441900127", "deep": "3", "pid": "2063" }, { "id": "3422", "name": "中堂镇", "code": "441900128", "deep": "3", "pid": "2063" }, { "id": "3423", "name": "高埗镇", "code": "441900129", "deep": "3", "pid": "2063" }, { "id": "3424", "name": "松山湖管委会", "code": "441900401", "deep": "3", "pid": "2063" }, { "id": "3425", "name": "虎门港管委会", "code": "441900402", "deep": "3", "pid": "2063" }, { "id": "3426", "name": "东莞生态园", "code": "441900403", "deep": "3", "pid": "2063" } ] }, { "id": "2065", "name": "中山市", "code": "442000", "deep": "2", "pid": "1940", "area": [ { "id": "2066", "name": "湖滨北路", "code": "528402", "deep": "3", "pid": "2065" }, { "id": "3427", "name": "石岐区街道办事处", "code": "442000001", "deep": "3", "pid": "2065" }, { "id": "3428", "name": "东区街道办事处", "code": "442000002", "deep": "3", "pid": "2065" }, { "id": "3429", "name": "火炬开发区街道办事处", "code": "442000003", "deep": "3", "pid": "2065" }, { "id": "3430", "name": "西区街道办事处", "code": "442000004", "deep": "3", "pid": "2065" }, { "id": "3431", "name": "南区街道办事处", "code": "442000005", "deep": "3", "pid": "2065" }, { "id": "3432", "name": "五桂山街道办事处", "code": "442000006", "deep": "3", "pid": "2065" }, { "id": "3433", "name": "小榄镇", "code": "442000100", "deep": "3", "pid": "2065" }, { "id": "3434", "name": "黄圃镇", "code": "442000101", "deep": "3", "pid": "2065" }, { "id": "3435", "name": "民众镇", "code": "442000102", "deep": "3", "pid": "2065" }, { "id": "3436", "name": "东凤镇", "code": "442000103", "deep": "3", "pid": "2065" }, { "id": "3437", "name": "东升镇", "code": "442000104", "deep": "3", "pid": "2065" }, { "id": "3438", "name": "古镇镇", "code": "442000105", "deep": "3", "pid": "2065" }, { "id": "3439", "name": "沙溪镇", "code": "442000106", "deep": "3", "pid": "2065" }, { "id": "3440", "name": "坦洲镇", "code": "442000107", "deep": "3", "pid": "2065" }, { "id": "3441", "name": "港口镇", "code": "442000108", "deep": "3", "pid": "2065" }, { "id": "3442", "name": "三角镇", "code": "442000109", "deep": "3", "pid": "2065" }, { "id": "3443", "name": "横栏镇", "code": "442000110", "deep": "3", "pid": "2065" }, { "id": "3444", "name": "南头镇", "code": "442000111", "deep": "3", "pid": "2065" }, { "id": "3445", "name": "阜沙镇", "code": "442000112", "deep": "3", "pid": "2065" }, { "id": "3446", "name": "南朗镇", "code": "442000113", "deep": "3", "pid": "2065" }, { "id": "3447", "name": "三乡镇", "code": "442000114", "deep": "3", "pid": "2065" }, { "id": "3448", "name": "板芙镇", "code": "442000115", "deep": "3", "pid": "2065" }, { "id": "3449", "name": "大涌镇", "code": "442000116", "deep": "3", "pid": "2065" }, { "id": "3450", "name": "神湾镇", "code": "442000117", "deep": "3", "pid": "2065" } ] }, { "id": "2067", "name": "潮州市", "code": "445100", "deep": "2", "pid": "1940", "area": [ { "id": "2068", "name": "湘桥区", "code": "445102", "deep": "3", "pid": "2067" }, { "id": "2069", "name": "潮安区", "code": "445103", "deep": "3", "pid": "2067" }, { "id": "2070", "name": "饶平县", "code": "445122", "deep": "3", "pid": "2067" } ] }, { "id": "2071", "name": "揭阳市", "code": "445200", "deep": "2", "pid": "1940", "area": [ { "id": "2072", "name": "榕城区", "code": "445202", "deep": "3", "pid": "2071" }, { "id": "2073", "name": "揭东区", "code": "445203", "deep": "3", "pid": "2071" }, { "id": "2074", "name": "揭西县", "code": "445222", "deep": "3", "pid": "2071" }, { "id": "2075", "name": "惠来县", "code": "445224", "deep": "3", "pid": "2071" }, { "id": "2076", "name": "普宁市", "code": "445281", "deep": "3", "pid": "2071" } ] }, { "id": "2077", "name": "云浮市", "code": "445300", "deep": "2", "pid": "1940", "area": [ { "id": "2078", "name": "云城区", "code": "445302", "deep": "3", "pid": "2077" }, { "id": "2079", "name": "云安区", "code": "445303", "deep": "3", "pid": "2077" }, { "id": "2080", "name": "新兴县", "code": "445321", "deep": "3", "pid": "2077" }, { "id": "2081", "name": "郁南县", "code": "445322", "deep": "3", "pid": "2077" }, { "id": "2082", "name": "罗定市", "code": "445381", "deep": "3", "pid": "2077" } ] } ] }, { "id": "2083", "name": "广西壮族自治区", "code": "450000", "deep": "1", "pid": "0", "city": [ { "id": "2084", "name": "南宁市", "code": "450100", "deep": "2", "pid": "2083", "area": [ { "id": "2085", "name": "兴宁区", "code": "450102", "deep": "3", "pid": "2084" }, { "id": "2086", "name": "青秀区", "code": "450103", "deep": "3", "pid": "2084" }, { "id": "2087", "name": "江南区", "code": "450105", "deep": "3", "pid": "2084" }, { "id": "2088", "name": "西乡塘区", "code": "450107", "deep": "3", "pid": "2084" }, { "id": "2089", "name": "良庆区", "code": "450108", "deep": "3", "pid": "2084" }, { "id": "2090", "name": "邕宁区", "code": "450109", "deep": "3", "pid": "2084" }, { "id": "2091", "name": "武鸣区", "code": "450110", "deep": "3", "pid": "2084" }, { "id": "2092", "name": "隆安县", "code": "450123", "deep": "3", "pid": "2084" }, { "id": "2093", "name": "马山县", "code": "450124", "deep": "3", "pid": "2084" }, { "id": "2094", "name": "上林县", "code": "450125", "deep": "3", "pid": "2084" }, { "id": "2095", "name": "宾阳县", "code": "450126", "deep": "3", "pid": "2084" }, { "id": "2096", "name": "横县", "code": "450127", "deep": "3", "pid": "2084" } ] }, { "id": "2097", "name": "柳州市", "code": "450200", "deep": "2", "pid": "2083", "area": [ { "id": "2098", "name": "城中区", "code": "450202", "deep": "3", "pid": "2097" }, { "id": "2099", "name": "鱼峰区", "code": "450203", "deep": "3", "pid": "2097" }, { "id": "2100", "name": "柳南区", "code": "450204", "deep": "3", "pid": "2097" }, { "id": "2101", "name": "柳北区", "code": "450205", "deep": "3", "pid": "2097" }, { "id": "2102", "name": "柳江区", "code": "450206", "deep": "3", "pid": "2097" }, { "id": "2103", "name": "柳城县", "code": "450222", "deep": "3", "pid": "2097" }, { "id": "2104", "name": "鹿寨县", "code": "450223", "deep": "3", "pid": "2097" }, { "id": "2105", "name": "融安县", "code": "450224", "deep": "3", "pid": "2097" }, { "id": "2106", "name": "融水苗族自治县", "code": "450225", "deep": "3", "pid": "2097" }, { "id": "2107", "name": "三江侗族自治县", "code": "450226", "deep": "3", "pid": "2097" } ] }, { "id": "2108", "name": "桂林市", "code": "450300", "deep": "2", "pid": "2083", "area": [ { "id": "2109", "name": "秀峰区", "code": "450302", "deep": "3", "pid": "2108" }, { "id": "2110", "name": "叠彩区", "code": "450303", "deep": "3", "pid": "2108" }, { "id": "2111", "name": "象山区", "code": "450304", "deep": "3", "pid": "2108" }, { "id": "2112", "name": "七星区", "code": "450305", "deep": "3", "pid": "2108" }, { "id": "2113", "name": "雁山区", "code": "450311", "deep": "3", "pid": "2108" }, { "id": "2114", "name": "临桂区", "code": "450312", "deep": "3", "pid": "2108" }, { "id": "2115", "name": "阳朔县", "code": "450321", "deep": "3", "pid": "2108" }, { "id": "2116", "name": "灵川县", "code": "450323", "deep": "3", "pid": "2108" }, { "id": "2117", "name": "全州县", "code": "450324", "deep": "3", "pid": "2108" }, { "id": "2118", "name": "兴安县", "code": "450325", "deep": "3", "pid": "2108" }, { "id": "2119", "name": "永福县", "code": "450326", "deep": "3", "pid": "2108" }, { "id": "2120", "name": "灌阳县", "code": "450327", "deep": "3", "pid": "2108" }, { "id": "2121", "name": "龙胜各族自治县", "code": "450328", "deep": "3", "pid": "2108" }, { "id": "2122", "name": "资源县", "code": "450329", "deep": "3", "pid": "2108" }, { "id": "2123", "name": "平乐县", "code": "450330", "deep": "3", "pid": "2108" }, { "id": "2124", "name": "荔浦县", "code": "450331", "deep": "3", "pid": "2108" }, { "id": "2125", "name": "恭城瑶族自治县", "code": "450332", "deep": "3", "pid": "2108" } ] }, { "id": "2126", "name": "梧州市", "code": "450400", "deep": "2", "pid": "2083", "area": [ { "id": "2127", "name": "万秀区", "code": "450403", "deep": "3", "pid": "2126" }, { "id": "2128", "name": "长洲区", "code": "450405", "deep": "3", "pid": "2126" }, { "id": "2129", "name": "龙圩区", "code": "450406", "deep": "3", "pid": "2126" }, { "id": "2130", "name": "苍梧县", "code": "450421", "deep": "3", "pid": "2126" }, { "id": "2131", "name": "藤县", "code": "450422", "deep": "3", "pid": "2126" }, { "id": "2132", "name": "蒙山县", "code": "450423", "deep": "3", "pid": "2126" }, { "id": "2133", "name": "岑溪市", "code": "450481", "deep": "3", "pid": "2126" } ] }, { "id": "2134", "name": "北海市", "code": "450500", "deep": "2", "pid": "2083", "area": [ { "id": "2135", "name": "海城区", "code": "450502", "deep": "3", "pid": "2134" }, { "id": "2136", "name": "银海区", "code": "450503", "deep": "3", "pid": "2134" }, { "id": "2137", "name": "铁山港区", "code": "450512", "deep": "3", "pid": "2134" }, { "id": "2138", "name": "合浦县", "code": "450521", "deep": "3", "pid": "2134" } ] }, { "id": "2139", "name": "防城港市", "code": "450600", "deep": "2", "pid": "2083", "area": [ { "id": "2140", "name": "港口区", "code": "450602", "deep": "3", "pid": "2139" }, { "id": "2141", "name": "防城区", "code": "450603", "deep": "3", "pid": "2139" }, { "id": "2142", "name": "上思县", "code": "450621", "deep": "3", "pid": "2139" }, { "id": "2143", "name": "东兴市", "code": "450681", "deep": "3", "pid": "2139" } ] }, { "id": "2144", "name": "钦州市", "code": "450700", "deep": "2", "pid": "2083", "area": [ { "id": "2145", "name": "钦南区", "code": "450702", "deep": "3", "pid": "2144" }, { "id": "2146", "name": "钦北区", "code": "450703", "deep": "3", "pid": "2144" }, { "id": "2147", "name": "灵山县", "code": "450721", "deep": "3", "pid": "2144" }, { "id": "2148", "name": "浦北县", "code": "450722", "deep": "3", "pid": "2144" } ] }, { "id": "2149", "name": "贵港市", "code": "450800", "deep": "2", "pid": "2083", "area": [ { "id": "2150", "name": "港北区", "code": "450802", "deep": "3", "pid": "2149" }, { "id": "2151", "name": "港南区", "code": "450803", "deep": "3", "pid": "2149" }, { "id": "2152", "name": "覃塘区", "code": "450804", "deep": "3", "pid": "2149" }, { "id": "2153", "name": "平南县", "code": "450821", "deep": "3", "pid": "2149" }, { "id": "2154", "name": "桂平市", "code": "450881", "deep": "3", "pid": "2149" } ] }, { "id": "2155", "name": "玉林市", "code": "450900", "deep": "2", "pid": "2083", "area": [ { "id": "2156", "name": "玉州区", "code": "450902", "deep": "3", "pid": "2155" }, { "id": "2157", "name": "福绵区", "code": "450903", "deep": "3", "pid": "2155" }, { "id": "2158", "name": "容县", "code": "450921", "deep": "3", "pid": "2155" }, { "id": "2159", "name": "陆川县", "code": "450922", "deep": "3", "pid": "2155" }, { "id": "2160", "name": "博白县", "code": "450923", "deep": "3", "pid": "2155" }, { "id": "2161", "name": "兴业县", "code": "450924", "deep": "3", "pid": "2155" }, { "id": "2162", "name": "北流市", "code": "450981", "deep": "3", "pid": "2155" } ] }, { "id": "2163", "name": "百色市", "code": "451000", "deep": "2", "pid": "2083", "area": [ { "id": "2164", "name": "右江区", "code": "451002", "deep": "3", "pid": "2163" }, { "id": "2165", "name": "田阳县", "code": "451021", "deep": "3", "pid": "2163" }, { "id": "2166", "name": "田东县", "code": "451022", "deep": "3", "pid": "2163" }, { "id": "2167", "name": "平果县", "code": "451023", "deep": "3", "pid": "2163" }, { "id": "2168", "name": "德保县", "code": "451024", "deep": "3", "pid": "2163" }, { "id": "2169", "name": "那坡县", "code": "451026", "deep": "3", "pid": "2163" }, { "id": "2170", "name": "凌云县", "code": "451027", "deep": "3", "pid": "2163" }, { "id": "2171", "name": "乐业县", "code": "451028", "deep": "3", "pid": "2163" }, { "id": "2172", "name": "田林县", "code": "451029", "deep": "3", "pid": "2163" }, { "id": "2173", "name": "西林县", "code": "451030", "deep": "3", "pid": "2163" }, { "id": "2174", "name": "隆林各族自治县", "code": "451031", "deep": "3", "pid": "2163" }, { "id": "2175", "name": "靖西市", "code": "451081", "deep": "3", "pid": "2163" } ] }, { "id": "2176", "name": "贺州市", "code": "451100", "deep": "2", "pid": "2083", "area": [ { "id": "2177", "name": "八步区", "code": "451102", "deep": "3", "pid": "2176" }, { "id": "2178", "name": "昭平县", "code": "451121", "deep": "3", "pid": "2176" }, { "id": "2179", "name": "钟山县", "code": "451122", "deep": "3", "pid": "2176" }, { "id": "2180", "name": "富川瑶族自治县", "code": "451123", "deep": "3", "pid": "2176" }, { "id": "3365", "name": "平桂区", "code": "451103", "deep": "3", "pid": "2176" } ] }, { "id": "2181", "name": "河池市", "code": "451200", "deep": "2", "pid": "2083", "area": [ { "id": "2182", "name": "金城江区", "code": "451202", "deep": "3", "pid": "2181" }, { "id": "2183", "name": "南丹县", "code": "451221", "deep": "3", "pid": "2181" }, { "id": "2184", "name": "天峨县", "code": "451222", "deep": "3", "pid": "2181" }, { "id": "2185", "name": "凤山县", "code": "451223", "deep": "3", "pid": "2181" }, { "id": "2186", "name": "东兰县", "code": "451224", "deep": "3", "pid": "2181" }, { "id": "2187", "name": "罗城仫佬族自治县", "code": "451225", "deep": "3", "pid": "2181" }, { "id": "2188", "name": "环江毛南族自治县", "code": "451226", "deep": "3", "pid": "2181" }, { "id": "2189", "name": "巴马瑶族自治县", "code": "451227", "deep": "3", "pid": "2181" }, { "id": "2190", "name": "都安瑶族自治县", "code": "451228", "deep": "3", "pid": "2181" }, { "id": "2191", "name": "大化瑶族自治县", "code": "451229", "deep": "3", "pid": "2181" }, { "id": "2192", "name": "宜州区", "code": "451203", "deep": "3", "pid": "2181" }, { "id": "3451", "name": "宜州市", "code": "451281", "deep": "3", "pid": "2181" }, { "id": "3452", "name": "那大镇", "code": "460400100", "deep": "3", "pid": "2181" }, { "id": "3453", "name": "和庆镇", "code": "460400101", "deep": "3", "pid": "2181" }, { "id": "3454", "name": "南丰镇", "code": "460400102", "deep": "3", "pid": "2181" }, { "id": "3455", "name": "大成镇", "code": "460400103", "deep": "3", "pid": "2181" }, { "id": "3456", "name": "雅星镇", "code": "460400104", "deep": "3", "pid": "2181" }, { "id": "3457", "name": "兰洋镇", "code": "460400105", "deep": "3", "pid": "2181" }, { "id": "3458", "name": "光村镇", "code": "460400106", "deep": "3", "pid": "2181" }, { "id": "3459", "name": "木棠镇", "code": "460400107", "deep": "3", "pid": "2181" }, { "id": "3460", "name": "海头镇", "code": "460400108", "deep": "3", "pid": "2181" }, { "id": "3461", "name": "峨蔓镇", "code": "460400109", "deep": "3", "pid": "2181" }, { "id": "3462", "name": "三都镇", "code": "460400110", "deep": "3", "pid": "2181" }, { "id": "3463", "name": "王五镇", "code": "460400111", "deep": "3", "pid": "2181" }, { "id": "3464", "name": "白马井镇", "code": "460400112", "deep": "3", "pid": "2181" }, { "id": "3465", "name": "中和镇", "code": "460400113", "deep": "3", "pid": "2181" }, { "id": "3466", "name": "排浦镇", "code": "460400114", "deep": "3", "pid": "2181" }, { "id": "3467", "name": "东成镇", "code": "460400115", "deep": "3", "pid": "2181" }, { "id": "3468", "name": "新州镇", "code": "460400116", "deep": "3", "pid": "2181" }, { "id": "3469", "name": "国营西培农场", "code": "460400400", "deep": "3", "pid": "2181" }, { "id": "3470", "name": "国营西联农场", "code": "460400404", "deep": "3", "pid": "2181" }, { "id": "3471", "name": "国营蓝洋农场", "code": "460400405", "deep": "3", "pid": "2181" }, { "id": "3472", "name": "国营八一农场", "code": "460400407", "deep": "3", "pid": "2181" }, { "id": "3473", "name": "洋浦经济开发区", "code": "460400499", "deep": "3", "pid": "2181" }, { "id": "3474", "name": "华南热作学院", "code": "460400500", "deep": "3", "pid": "2181" } ] }, { "id": "2193", "name": "来宾市", "code": "451300", "deep": "2", "pid": "2083", "area": [ { "id": "2194", "name": "兴宾区", "code": "451302", "deep": "3", "pid": "2193" }, { "id": "2195", "name": "忻城县", "code": "451321", "deep": "3", "pid": "2193" }, { "id": "2196", "name": "象州县", "code": "451322", "deep": "3", "pid": "2193" }, { "id": "2197", "name": "武宣县", "code": "451323", "deep": "3", "pid": "2193" }, { "id": "2198", "name": "金秀瑶族自治县", "code": "451324", "deep": "3", "pid": "2193" }, { "id": "2199", "name": "合山市", "code": "451381", "deep": "3", "pid": "2193" } ] }, { "id": "2200", "name": "崇左市", "code": "451400", "deep": "2", "pid": "2083", "area": [ { "id": "2201", "name": "江州区", "code": "451402", "deep": "3", "pid": "2200" }, { "id": "2202", "name": "扶绥县", "code": "451421", "deep": "3", "pid": "2200" }, { "id": "2203", "name": "宁明县", "code": "451422", "deep": "3", "pid": "2200" }, { "id": "2204", "name": "龙州县", "code": "451423", "deep": "3", "pid": "2200" }, { "id": "2205", "name": "大新县", "code": "451424", "deep": "3", "pid": "2200" }, { "id": "2206", "name": "天等县", "code": "451425", "deep": "3", "pid": "2200" }, { "id": "2207", "name": "凭祥市", "code": "451481", "deep": "3", "pid": "2200" } ] } ] }, { "id": "2208", "name": "海南省", "code": "460000", "deep": "1", "pid": "0", "city": [ { "id": "2209", "name": "海口市", "code": "460100", "deep": "2", "pid": "2208", "area": [ { "id": "2210", "name": "秀英区", "code": "460105", "deep": "3", "pid": "2209" }, { "id": "2211", "name": "龙华区", "code": "460106", "deep": "3", "pid": "2209" }, { "id": "2212", "name": "琼山区", "code": "460107", "deep": "3", "pid": "2209" }, { "id": "2213", "name": "美兰区", "code": "460108", "deep": "3", "pid": "2209" } ] }, { "id": "2214", "name": "三亚市", "code": "460200", "deep": "2", "pid": "2208", "area": [ { "id": "2216", "name": "海棠区", "code": "460202", "deep": "3", "pid": "2214" }, { "id": "2217", "name": "吉阳区", "code": "460203", "deep": "3", "pid": "2214" }, { "id": "2218", "name": "天涯区", "code": "460204", "deep": "3", "pid": "2214" }, { "id": "2219", "name": "崖州区", "code": "460205", "deep": "3", "pid": "2214" } ] }, { "id": "2220", "name": "三沙市", "code": "460300", "deep": "2", "pid": "2208", "area": [ { "id": "2221", "name": "西沙群岛", "code": "460321", "deep": "3", "pid": "2220" }, { "id": "2222", "name": "南沙群岛", "code": "460322", "deep": "3", "pid": "2220" }, { "id": "2223", "name": "中沙群岛的岛礁及其海域", "code": "460323", "deep": "3", "pid": "2220" } ] }, { "id": "2224", "name": "儋州市", "code": "460400", "deep": "2", "pid": "2208" }, { "id": "2225", "name": "五指山市", "code": "469001", "deep": "2", "pid": "2208" }, { "id": "2226", "name": "琼海市", "code": "469002", "deep": "2", "pid": "2208" }, { "id": "2227", "name": "文昌市", "code": "469005", "deep": "2", "pid": "2208" }, { "id": "2228", "name": "万宁市", "code": "469006", "deep": "2", "pid": "2208" }, { "id": "2229", "name": "东方市", "code": "469007", "deep": "2", "pid": "2208" }, { "id": "2230", "name": "定安县", "code": "469021", "deep": "2", "pid": "2208" }, { "id": "2231", "name": "屯昌县", "code": "469022", "deep": "2", "pid": "2208" }, { "id": "2232", "name": "澄迈县", "code": "469023", "deep": "2", "pid": "2208" }, { "id": "2233", "name": "临高县", "code": "469024", "deep": "2", "pid": "2208" }, { "id": "2234", "name": "白沙黎族自治县", "code": "469025", "deep": "2", "pid": "2208" }, { "id": "2235", "name": "昌江黎族自治县", "code": "469026", "deep": "2", "pid": "2208" }, { "id": "2236", "name": "乐东黎族自治县", "code": "469027", "deep": "2", "pid": "2208" }, { "id": "2237", "name": "陵水黎族自治县", "code": "469028", "deep": "2", "pid": "2208" }, { "id": "2238", "name": "保亭黎族苗族自治县", "code": "469029", "deep": "2", "pid": "2208" }, { "id": "2239", "name": "琼中黎族苗族自治县", "code": "469030", "deep": "2", "pid": "2208" }, { "id": "3475", "name": "省直辖县级行政区划", "code": "469000", "deep": "2", "pid": "2208" } ] }, { "id": "2240", "name": "重庆市", "code": "500000", "deep": "1", "pid": "0", "city": [ { "id": "2241", "name": "重庆市市辖区", "code": "500100", "deep": "2", "pid": "2240", "area": [ { "id": "2242", "name": "万州区", "code": "500101", "deep": "3", "pid": "2241" }, { "id": "2243", "name": "涪陵区", "code": "500102", "deep": "3", "pid": "2241" }, { "id": "2244", "name": "渝中区", "code": "500103", "deep": "3", "pid": "2241" }, { "id": "2245", "name": "大渡口区", "code": "500104", "deep": "3", "pid": "2241" }, { "id": "2246", "name": "江北区", "code": "500105", "deep": "3", "pid": "2241" }, { "id": "2247", "name": "沙坪坝区", "code": "500106", "deep": "3", "pid": "2241" }, { "id": "2248", "name": "九龙坡区", "code": "500107", "deep": "3", "pid": "2241" }, { "id": "2249", "name": "南岸区", "code": "500108", "deep": "3", "pid": "2241" }, { "id": "2250", "name": "北碚区", "code": "500109", "deep": "3", "pid": "2241" }, { "id": "2251", "name": "綦江区", "code": "500110", "deep": "3", "pid": "2241" }, { "id": "2252", "name": "大足区", "code": "500111", "deep": "3", "pid": "2241" }, { "id": "2253", "name": "渝北区", "code": "500112", "deep": "3", "pid": "2241" }, { "id": "2254", "name": "巴南区", "code": "500113", "deep": "3", "pid": "2241" }, { "id": "2255", "name": "黔江区", "code": "500114", "deep": "3", "pid": "2241" }, { "id": "2256", "name": "长寿区", "code": "500115", "deep": "3", "pid": "2241" }, { "id": "2257", "name": "江津区", "code": "500116", "deep": "3", "pid": "2241" }, { "id": "2258", "name": "合川区", "code": "500117", "deep": "3", "pid": "2241" }, { "id": "2259", "name": "永川区", "code": "500118", "deep": "3", "pid": "2241" }, { "id": "2260", "name": "南川区", "code": "500119", "deep": "3", "pid": "2241" }, { "id": "2261", "name": "璧山区", "code": "500120", "deep": "3", "pid": "2241" }, { "id": "2262", "name": "铜梁区", "code": "500151", "deep": "3", "pid": "2241" }, { "id": "2263", "name": "潼南区", "code": "500152", "deep": "3", "pid": "2241" }, { "id": "2264", "name": "荣昌区", "code": "500153", "deep": "3", "pid": "2241" }, { "id": "2265", "name": "梁平区", "code": "500155", "deep": "3", "pid": "2241" }, { "id": "2266", "name": "城口县", "code": "500229", "deep": "3", "pid": "2241" }, { "id": "2267", "name": "丰都县", "code": "500230", "deep": "3", "pid": "2241" }, { "id": "2268", "name": "垫江县", "code": "500231", "deep": "3", "pid": "2241" }, { "id": "2269", "name": "武隆区", "code": "500156", "deep": "3", "pid": "2241" }, { "id": "2270", "name": "忠县", "code": "500233", "deep": "3", "pid": "2241" }, { "id": "2271", "name": "开县", "code": "500234", "deep": "3", "pid": "2241" }, { "id": "2272", "name": "云阳县", "code": "500235", "deep": "3", "pid": "2241" }, { "id": "2273", "name": "奉节县", "code": "500236", "deep": "3", "pid": "2241" }, { "id": "2274", "name": "巫山县", "code": "500237", "deep": "3", "pid": "2241" }, { "id": "2275", "name": "巫溪县", "code": "500238", "deep": "3", "pid": "2241" }, { "id": "2276", "name": "石柱土家族自治县", "code": "500240", "deep": "3", "pid": "2241" }, { "id": "2277", "name": "秀山土家族苗族自治县", "code": "500241", "deep": "3", "pid": "2241" }, { "id": "2278", "name": "酉阳土家族苗族自治县", "code": "500242", "deep": "3", "pid": "2241" }, { "id": "2279", "name": "彭水苗族土家族自治县", "code": "500243", "deep": "3", "pid": "2241" }, { "id": "3366", "name": "开州区", "code": "500154", "deep": "3", "pid": "2241" } ] }, { "id": "2280", "name": "重庆市郊县", "code": "500200", "deep": "2", "pid": "2240", "area": [ { "id": "3476", "name": "梁平县", "code": "500228", "deep": "3", "pid": "2280" }, { "id": "3477", "name": "武隆县", "code": "500232", "deep": "3", "pid": "2280" } ] } ] }, { "id": "2281", "name": "四川省", "code": "510000", "deep": "1", "pid": "0", "city": [ { "id": "2282", "name": "成都市", "code": "510100", "deep": "2", "pid": "2281", "area": [ { "id": "2283", "name": "锦江区", "code": "510104", "deep": "3", "pid": "2282" }, { "id": "2284", "name": "青羊区", "code": "510105", "deep": "3", "pid": "2282" }, { "id": "2285", "name": "金牛区", "code": "510106", "deep": "3", "pid": "2282" }, { "id": "2286", "name": "武侯区", "code": "510107", "deep": "3", "pid": "2282" }, { "id": "2287", "name": "成华区", "code": "510108", "deep": "3", "pid": "2282" }, { "id": "2288", "name": "龙泉驿区", "code": "510112", "deep": "3", "pid": "2282" }, { "id": "2289", "name": "青白江区", "code": "510113", "deep": "3", "pid": "2282" }, { "id": "2290", "name": "新都区", "code": "510114", "deep": "3", "pid": "2282" }, { "id": "2291", "name": "温江区", "code": "510115", "deep": "3", "pid": "2282" }, { "id": "2292", "name": "双流区", "code": "510116", "deep": "3", "pid": "2282" }, { "id": "2293", "name": "金堂县", "code": "510121", "deep": "3", "pid": "2282" }, { "id": "2294", "name": "郫都区", "code": "510117", "deep": "3", "pid": "2282" }, { "id": "2295", "name": "大邑县", "code": "510129", "deep": "3", "pid": "2282" }, { "id": "2296", "name": "蒲江县", "code": "510131", "deep": "3", "pid": "2282" }, { "id": "2297", "name": "新津县", "code": "510132", "deep": "3", "pid": "2282" }, { "id": "2298", "name": "都江堰市", "code": "510181", "deep": "3", "pid": "2282" }, { "id": "2299", "name": "彭州市", "code": "510182", "deep": "3", "pid": "2282" }, { "id": "2300", "name": "邛崃市", "code": "510183", "deep": "3", "pid": "2282" }, { "id": "2301", "name": "崇州市", "code": "510184", "deep": "3", "pid": "2282" }, { "id": "3478", "name": "郫县", "code": "510124", "deep": "3", "pid": "2282" }, { "id": "3479", "name": "简阳市", "code": "510185", "deep": "3", "pid": "2282" }, { "id": "3480", "name": "隆昌县", "code": "511028", "deep": "3", "pid": "2282" } ] }, { "id": "2302", "name": "自贡市", "code": "510300", "deep": "2", "pid": "2281", "area": [ { "id": "2303", "name": "自流井区", "code": "510302", "deep": "3", "pid": "2302" }, { "id": "2304", "name": "贡井区", "code": "510303", "deep": "3", "pid": "2302" }, { "id": "2305", "name": "大安区", "code": "510304", "deep": "3", "pid": "2302" }, { "id": "2306", "name": "沿滩区", "code": "510311", "deep": "3", "pid": "2302" }, { "id": "2307", "name": "荣县", "code": "510321", "deep": "3", "pid": "2302" }, { "id": "2308", "name": "富顺县", "code": "510322", "deep": "3", "pid": "2302" } ] }, { "id": "2309", "name": "攀枝花市", "code": "510400", "deep": "2", "pid": "2281", "area": [ { "id": "2310", "name": "东区", "code": "510402", "deep": "3", "pid": "2309" }, { "id": "2311", "name": "西区", "code": "510403", "deep": "3", "pid": "2309" }, { "id": "2312", "name": "仁和区", "code": "510411", "deep": "3", "pid": "2309" }, { "id": "2313", "name": "米易县", "code": "510421", "deep": "3", "pid": "2309" }, { "id": "2314", "name": "盐边县", "code": "510422", "deep": "3", "pid": "2309" } ] }, { "id": "2315", "name": "泸州市", "code": "510500", "deep": "2", "pid": "2281", "area": [ { "id": "2316", "name": "江阳区", "code": "510502", "deep": "3", "pid": "2315" }, { "id": "2317", "name": "纳溪区", "code": "510503", "deep": "3", "pid": "2315" }, { "id": "2318", "name": "龙马潭区", "code": "510504", "deep": "3", "pid": "2315" }, { "id": "2319", "name": "泸县", "code": "510521", "deep": "3", "pid": "2315" }, { "id": "2320", "name": "合江县", "code": "510522", "deep": "3", "pid": "2315" }, { "id": "2321", "name": "叙永县", "code": "510524", "deep": "3", "pid": "2315" }, { "id": "2322", "name": "古蔺县", "code": "510525", "deep": "3", "pid": "2315" } ] }, { "id": "2323", "name": "德阳市", "code": "510600", "deep": "2", "pid": "2281", "area": [ { "id": "2324", "name": "旌阳区", "code": "510603", "deep": "3", "pid": "2323" }, { "id": "2325", "name": "中江县", "code": "510623", "deep": "3", "pid": "2323" }, { "id": "2326", "name": "罗江县", "code": "510626", "deep": "3", "pid": "2323" }, { "id": "2327", "name": "广汉市", "code": "510681", "deep": "3", "pid": "2323" }, { "id": "2328", "name": "什邡市", "code": "510682", "deep": "3", "pid": "2323" }, { "id": "2329", "name": "绵竹市", "code": "510683", "deep": "3", "pid": "2323" } ] }, { "id": "2330", "name": "绵阳市", "code": "510700", "deep": "2", "pid": "2281", "area": [ { "id": "2331", "name": "涪城区", "code": "510703", "deep": "3", "pid": "2330" }, { "id": "2332", "name": "游仙区", "code": "510704", "deep": "3", "pid": "2330" }, { "id": "2333", "name": "三台县", "code": "510722", "deep": "3", "pid": "2330" }, { "id": "2334", "name": "盐亭县", "code": "510723", "deep": "3", "pid": "2330" }, { "id": "2335", "name": "安县", "code": "510724", "deep": "3", "pid": "2330" }, { "id": "2336", "name": "梓潼县", "code": "510725", "deep": "3", "pid": "2330" }, { "id": "2337", "name": "北川羌族自治县", "code": "510726", "deep": "3", "pid": "2330" }, { "id": "2338", "name": "平武县", "code": "510727", "deep": "3", "pid": "2330" }, { "id": "2339", "name": "江油市", "code": "510781", "deep": "3", "pid": "2330" }, { "id": "3367", "name": "安州区", "code": "510705", "deep": "3", "pid": "2330" } ] }, { "id": "2340", "name": "广元市", "code": "510800", "deep": "2", "pid": "2281", "area": [ { "id": "2341", "name": "利州区", "code": "510802", "deep": "3", "pid": "2340" }, { "id": "2342", "name": "昭化区", "code": "510811", "deep": "3", "pid": "2340" }, { "id": "2343", "name": "朝天区", "code": "510812", "deep": "3", "pid": "2340" }, { "id": "2344", "name": "旺苍县", "code": "510821", "deep": "3", "pid": "2340" }, { "id": "2345", "name": "青川县", "code": "510822", "deep": "3", "pid": "2340" }, { "id": "2346", "name": "剑阁县", "code": "510823", "deep": "3", "pid": "2340" }, { "id": "2347", "name": "苍溪县", "code": "510824", "deep": "3", "pid": "2340" } ] }, { "id": "2348", "name": "遂宁市", "code": "510900", "deep": "2", "pid": "2281", "area": [ { "id": "2349", "name": "船山区", "code": "510903", "deep": "3", "pid": "2348" }, { "id": "2350", "name": "安居区", "code": "510904", "deep": "3", "pid": "2348" }, { "id": "2351", "name": "蓬溪县", "code": "510921", "deep": "3", "pid": "2348" }, { "id": "2352", "name": "射洪县", "code": "510922", "deep": "3", "pid": "2348" }, { "id": "2353", "name": "大英县", "code": "510923", "deep": "3", "pid": "2348" } ] }, { "id": "2354", "name": "内江市", "code": "511000", "deep": "2", "pid": "2281", "area": [ { "id": "2355", "name": "市中区", "code": "511002", "deep": "3", "pid": "2354" }, { "id": "2356", "name": "东兴区", "code": "511011", "deep": "3", "pid": "2354" }, { "id": "2357", "name": "威远县", "code": "511024", "deep": "3", "pid": "2354" }, { "id": "2358", "name": "资中县", "code": "511025", "deep": "3", "pid": "2354" }, { "id": "2359", "name": "隆昌区", "code": "511083", "deep": "3", "pid": "2354" } ] }, { "id": "2360", "name": "乐山市", "code": "511100", "deep": "2", "pid": "2281", "area": [ { "id": "2361", "name": "市中区", "code": "511102", "deep": "3", "pid": "2360" }, { "id": "2362", "name": "沙湾区", "code": "511111", "deep": "3", "pid": "2360" }, { "id": "2363", "name": "五通桥区", "code": "511112", "deep": "3", "pid": "2360" }, { "id": "2364", "name": "金口河区", "code": "511113", "deep": "3", "pid": "2360" }, { "id": "2365", "name": "犍为县", "code": "511123", "deep": "3", "pid": "2360" }, { "id": "2366", "name": "井研县", "code": "511124", "deep": "3", "pid": "2360" }, { "id": "2367", "name": "夹江县", "code": "511126", "deep": "3", "pid": "2360" }, { "id": "2368", "name": "沐川县", "code": "511129", "deep": "3", "pid": "2360" }, { "id": "2369", "name": "峨边彝族自治县", "code": "511132", "deep": "3", "pid": "2360" }, { "id": "2370", "name": "马边彝族自治县", "code": "511133", "deep": "3", "pid": "2360" }, { "id": "2371", "name": "峨眉山市", "code": "511181", "deep": "3", "pid": "2360" } ] }, { "id": "2372", "name": "南充市", "code": "511300", "deep": "2", "pid": "2281", "area": [ { "id": "2373", "name": "顺庆区", "code": "511302", "deep": "3", "pid": "2372" }, { "id": "2374", "name": "高坪区", "code": "511303", "deep": "3", "pid": "2372" }, { "id": "2375", "name": "嘉陵区", "code": "511304", "deep": "3", "pid": "2372" }, { "id": "2376", "name": "南部县", "code": "511321", "deep": "3", "pid": "2372" }, { "id": "2377", "name": "营山县", "code": "511322", "deep": "3", "pid": "2372" }, { "id": "2378", "name": "蓬安县", "code": "511323", "deep": "3", "pid": "2372" }, { "id": "2379", "name": "仪陇县", "code": "511324", "deep": "3", "pid": "2372" }, { "id": "2380", "name": "西充县", "code": "511325", "deep": "3", "pid": "2372" }, { "id": "2381", "name": "阆中市", "code": "511381", "deep": "3", "pid": "2372" } ] }, { "id": "2382", "name": "眉山市", "code": "511400", "deep": "2", "pid": "2281", "area": [ { "id": "2383", "name": "东坡区", "code": "511402", "deep": "3", "pid": "2382" }, { "id": "2384", "name": "彭山区", "code": "511403", "deep": "3", "pid": "2382" }, { "id": "2385", "name": "仁寿县", "code": "511421", "deep": "3", "pid": "2382" }, { "id": "2386", "name": "洪雅县", "code": "511423", "deep": "3", "pid": "2382" }, { "id": "2387", "name": "丹棱县", "code": "511424", "deep": "3", "pid": "2382" }, { "id": "2388", "name": "青神县", "code": "511425", "deep": "3", "pid": "2382" } ] }, { "id": "2389", "name": "宜宾市", "code": "511500", "deep": "2", "pid": "2281", "area": [ { "id": "2390", "name": "翠屏区", "code": "511502", "deep": "3", "pid": "2389" }, { "id": "2391", "name": "南溪区", "code": "511503", "deep": "3", "pid": "2389" }, { "id": "2392", "name": "宜宾县", "code": "511521", "deep": "3", "pid": "2389" }, { "id": "2393", "name": "江安县", "code": "511523", "deep": "3", "pid": "2389" }, { "id": "2394", "name": "长宁县", "code": "511524", "deep": "3", "pid": "2389" }, { "id": "2395", "name": "高县", "code": "511525", "deep": "3", "pid": "2389" }, { "id": "2396", "name": "珙县", "code": "511526", "deep": "3", "pid": "2389" }, { "id": "2397", "name": "筠连县", "code": "511527", "deep": "3", "pid": "2389" }, { "id": "2398", "name": "兴文县", "code": "511528", "deep": "3", "pid": "2389" }, { "id": "2399", "name": "屏山县", "code": "511529", "deep": "3", "pid": "2389" } ] }, { "id": "2400", "name": "广安市", "code": "511600", "deep": "2", "pid": "2281", "area": [ { "id": "2401", "name": "广安区", "code": "511602", "deep": "3", "pid": "2400" }, { "id": "2402", "name": "前锋区", "code": "511603", "deep": "3", "pid": "2400" }, { "id": "2403", "name": "岳池县", "code": "511621", "deep": "3", "pid": "2400" }, { "id": "2404", "name": "武胜县", "code": "511622", "deep": "3", "pid": "2400" }, { "id": "2405", "name": "邻水县", "code": "511623", "deep": "3", "pid": "2400" }, { "id": "2406", "name": "华蓥市", "code": "511681", "deep": "3", "pid": "2400" } ] }, { "id": "2407", "name": "达州市", "code": "511700", "deep": "2", "pid": "2281", "area": [ { "id": "2408", "name": "通川区", "code": "511702", "deep": "3", "pid": "2407" }, { "id": "2409", "name": "达川区", "code": "511703", "deep": "3", "pid": "2407" }, { "id": "2410", "name": "宣汉县", "code": "511722", "deep": "3", "pid": "2407" }, { "id": "2411", "name": "开江县", "code": "511723", "deep": "3", "pid": "2407" }, { "id": "2412", "name": "大竹县", "code": "511724", "deep": "3", "pid": "2407" }, { "id": "2413", "name": "渠县", "code": "511725", "deep": "3", "pid": "2407" }, { "id": "2414", "name": "万源市", "code": "511781", "deep": "3", "pid": "2407" } ] }, { "id": "2415", "name": "雅安市", "code": "511800", "deep": "2", "pid": "2281", "area": [ { "id": "2416", "name": "雨城区", "code": "511802", "deep": "3", "pid": "2415" }, { "id": "2417", "name": "名山区", "code": "511803", "deep": "3", "pid": "2415" }, { "id": "2418", "name": "荥经县", "code": "511822", "deep": "3", "pid": "2415" }, { "id": "2419", "name": "汉源县", "code": "511823", "deep": "3", "pid": "2415" }, { "id": "2420", "name": "石棉县", "code": "511824", "deep": "3", "pid": "2415" }, { "id": "2421", "name": "天全县", "code": "511825", "deep": "3", "pid": "2415" }, { "id": "2422", "name": "芦山县", "code": "511826", "deep": "3", "pid": "2415" }, { "id": "2423", "name": "宝兴县", "code": "511827", "deep": "3", "pid": "2415" } ] }, { "id": "2424", "name": "巴中市", "code": "511900", "deep": "2", "pid": "2281", "area": [ { "id": "2425", "name": "巴州区", "code": "511902", "deep": "3", "pid": "2424" }, { "id": "2426", "name": "恩阳区", "code": "511903", "deep": "3", "pid": "2424" }, { "id": "2427", "name": "通江县", "code": "511921", "deep": "3", "pid": "2424" }, { "id": "2428", "name": "南江县", "code": "511922", "deep": "3", "pid": "2424" }, { "id": "2429", "name": "平昌县", "code": "511923", "deep": "3", "pid": "2424" } ] }, { "id": "2430", "name": "资阳市", "code": "512000", "deep": "2", "pid": "2281", "area": [ { "id": "2431", "name": "雁江区", "code": "512002", "deep": "3", "pid": "2430" }, { "id": "2432", "name": "安岳县", "code": "512021", "deep": "3", "pid": "2430" }, { "id": "2433", "name": "乐至县", "code": "512022", "deep": "3", "pid": "2430" }, { "id": "2434", "name": "简阳市", "code": "512081", "deep": "3", "pid": "2430" } ] }, { "id": "2435", "name": "阿坝藏族羌族自治州", "code": "513200", "deep": "2", "pid": "2281", "area": [ { "id": "2436", "name": "马尔康市", "code": "513201", "deep": "3", "pid": "2435" }, { "id": "2437", "name": "汶川县", "code": "513221", "deep": "3", "pid": "2435" }, { "id": "2438", "name": "理县", "code": "513222", "deep": "3", "pid": "2435" }, { "id": "2439", "name": "茂县", "code": "513223", "deep": "3", "pid": "2435" }, { "id": "2440", "name": "松潘县", "code": "513224", "deep": "3", "pid": "2435" }, { "id": "2441", "name": "九寨沟县", "code": "513225", "deep": "3", "pid": "2435" }, { "id": "2442", "name": "金川县", "code": "513226", "deep": "3", "pid": "2435" }, { "id": "2443", "name": "小金县", "code": "513227", "deep": "3", "pid": "2435" }, { "id": "2444", "name": "黑水县", "code": "513228", "deep": "3", "pid": "2435" }, { "id": "2445", "name": "壤塘县", "code": "513230", "deep": "3", "pid": "2435" }, { "id": "2446", "name": "阿坝县", "code": "513231", "deep": "3", "pid": "2435" }, { "id": "2447", "name": "若尔盖县", "code": "513232", "deep": "3", "pid": "2435" }, { "id": "2448", "name": "红原县", "code": "513233", "deep": "3", "pid": "2435" } ] }, { "id": "2449", "name": "甘孜藏族自治州", "code": "513300", "deep": "2", "pid": "2281", "area": [ { "id": "2450", "name": "康定市", "code": "513301", "deep": "3", "pid": "2449" }, { "id": "2451", "name": "泸定县", "code": "513322", "deep": "3", "pid": "2449" }, { "id": "2452", "name": "丹巴县", "code": "513323", "deep": "3", "pid": "2449" }, { "id": "2453", "name": "九龙县", "code": "513324", "deep": "3", "pid": "2449" }, { "id": "2454", "name": "雅江县", "code": "513325", "deep": "3", "pid": "2449" }, { "id": "2455", "name": "道孚县", "code": "513326", "deep": "3", "pid": "2449" }, { "id": "2456", "name": "炉霍县", "code": "513327", "deep": "3", "pid": "2449" }, { "id": "2457", "name": "甘孜县", "code": "513328", "deep": "3", "pid": "2449" }, { "id": "2458", "name": "新龙县", "code": "513329", "deep": "3", "pid": "2449" }, { "id": "2459", "name": "德格县", "code": "513330", "deep": "3", "pid": "2449" }, { "id": "2460", "name": "白玉县", "code": "513331", "deep": "3", "pid": "2449" }, { "id": "2461", "name": "石渠县", "code": "513332", "deep": "3", "pid": "2449" }, { "id": "2462", "name": "色达县", "code": "513333", "deep": "3", "pid": "2449" }, { "id": "2463", "name": "理塘县", "code": "513334", "deep": "3", "pid": "2449" }, { "id": "2464", "name": "巴塘县", "code": "513335", "deep": "3", "pid": "2449" }, { "id": "2465", "name": "乡城县", "code": "513336", "deep": "3", "pid": "2449" }, { "id": "2466", "name": "稻城县", "code": "513337", "deep": "3", "pid": "2449" }, { "id": "2467", "name": "得荣县", "code": "513338", "deep": "3", "pid": "2449" } ] }, { "id": "2468", "name": "凉山彝族自治州", "code": "513400", "deep": "2", "pid": "2281", "area": [ { "id": "2469", "name": "西昌市", "code": "513401", "deep": "3", "pid": "2468" }, { "id": "2470", "name": "木里藏族自治县", "code": "513422", "deep": "3", "pid": "2468" }, { "id": "2471", "name": "盐源县", "code": "513423", "deep": "3", "pid": "2468" }, { "id": "2472", "name": "德昌县", "code": "513424", "deep": "3", "pid": "2468" }, { "id": "2473", "name": "会理县", "code": "513425", "deep": "3", "pid": "2468" }, { "id": "2474", "name": "会东县", "code": "513426", "deep": "3", "pid": "2468" }, { "id": "2475", "name": "宁南县", "code": "513427", "deep": "3", "pid": "2468" }, { "id": "2476", "name": "普格县", "code": "513428", "deep": "3", "pid": "2468" }, { "id": "2477", "name": "布拖县", "code": "513429", "deep": "3", "pid": "2468" }, { "id": "2478", "name": "金阳县", "code": "513430", "deep": "3", "pid": "2468" }, { "id": "2479", "name": "昭觉县", "code": "513431", "deep": "3", "pid": "2468" }, { "id": "2480", "name": "喜德县", "code": "513432", "deep": "3", "pid": "2468" }, { "id": "2481", "name": "冕宁县", "code": "513433", "deep": "3", "pid": "2468" }, { "id": "2482", "name": "越西县", "code": "513434", "deep": "3", "pid": "2468" }, { "id": "2483", "name": "甘洛县", "code": "513435", "deep": "3", "pid": "2468" }, { "id": "2484", "name": "美姑县", "code": "513436", "deep": "3", "pid": "2468" }, { "id": "2485", "name": "雷波县", "code": "513437", "deep": "3", "pid": "2468" } ] } ] }, { "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" } ] } ] }, { "id": "2584", "name": "云南省", "code": "530000", "deep": "1", "pid": "0", "city": [ { "id": "2585", "name": "昆明市", "code": "530100", "deep": "2", "pid": "2584", "area": [ { "id": "2586", "name": "五华区", "code": "530102", "deep": "3", "pid": "2585" }, { "id": "2587", "name": "盘龙区", "code": "530103", "deep": "3", "pid": "2585" }, { "id": "2588", "name": "官渡区", "code": "530111", "deep": "3", "pid": "2585" }, { "id": "2589", "name": "西山区", "code": "530112", "deep": "3", "pid": "2585" }, { "id": "2590", "name": "东川区", "code": "530113", "deep": "3", "pid": "2585" }, { "id": "2591", "name": "呈贡区", "code": "530114", "deep": "3", "pid": "2585" }, { "id": "2592", "name": "晋宁区", "code": "530115", "deep": "3", "pid": "2585" }, { "id": "2593", "name": "富民县", "code": "530124", "deep": "3", "pid": "2585" }, { "id": "2594", "name": "宜良县", "code": "530125", "deep": "3", "pid": "2585" }, { "id": "2595", "name": "石林彝族自治县", "code": "530126", "deep": "3", "pid": "2585" }, { "id": "2596", "name": "嵩明县", "code": "530127", "deep": "3", "pid": "2585" }, { "id": "2597", "name": "禄劝彝族苗族自治县", "code": "530128", "deep": "3", "pid": "2585" }, { "id": "2598", "name": "寻甸回族彝族自治县", "code": "530129", "deep": "3", "pid": "2585" }, { "id": "2599", "name": "安宁市", "code": "530181", "deep": "3", "pid": "2585" }, { "id": "3481", "name": "晋宁县", "code": "530122", "deep": "3", "pid": "2585" } ] }, { "id": "2600", "name": "曲靖市", "code": "530300", "deep": "2", "pid": "2584", "area": [ { "id": "2601", "name": "麒麟区", "code": "530302", "deep": "3", "pid": "2600" }, { "id": "2602", "name": "马龙县", "code": "530321", "deep": "3", "pid": "2600" }, { "id": "2603", "name": "陆良县", "code": "530322", "deep": "3", "pid": "2600" }, { "id": "2604", "name": "师宗县", "code": "530323", "deep": "3", "pid": "2600" }, { "id": "2605", "name": "罗平县", "code": "530324", "deep": "3", "pid": "2600" }, { "id": "2606", "name": "富源县", "code": "530325", "deep": "3", "pid": "2600" }, { "id": "2607", "name": "会泽县", "code": "530326", "deep": "3", "pid": "2600" }, { "id": "2608", "name": "沾益区", "code": "530303", "deep": "3", "pid": "2600" }, { "id": "2609", "name": "宣威市", "code": "530381", "deep": "3", "pid": "2600" } ] }, { "id": "2610", "name": "玉溪市", "code": "530400", "deep": "2", "pid": "2584", "area": [ { "id": "2611", "name": "红塔区", "code": "530402", "deep": "3", "pid": "2610" }, { "id": "2612", "name": "江川区", "code": "530403", "deep": "3", "pid": "2610" }, { "id": "2613", "name": "澄江县", "code": "530422", "deep": "3", "pid": "2610" }, { "id": "2614", "name": "通海县", "code": "530423", "deep": "3", "pid": "2610" }, { "id": "2615", "name": "华宁县", "code": "530424", "deep": "3", "pid": "2610" }, { "id": "2616", "name": "易门县", "code": "530425", "deep": "3", "pid": "2610" }, { "id": "2617", "name": "峨山彝族自治县", "code": "530426", "deep": "3", "pid": "2610" }, { "id": "2618", "name": "新平彝族傣族自治县", "code": "530427", "deep": "3", "pid": "2610" }, { "id": "2619", "name": "元江哈尼族彝族傣族自治县", "code": "530428", "deep": "3", "pid": "2610" } ] }, { "id": "2620", "name": "保山市", "code": "530500", "deep": "2", "pid": "2584", "area": [ { "id": "2621", "name": "隆阳区", "code": "530502", "deep": "3", "pid": "2620" }, { "id": "2622", "name": "施甸县", "code": "530521", "deep": "3", "pid": "2620" }, { "id": "2623", "name": "龙陵县", "code": "530523", "deep": "3", "pid": "2620" }, { "id": "2624", "name": "昌宁县", "code": "530524", "deep": "3", "pid": "2620" }, { "id": "2625", "name": "腾冲市", "code": "530581", "deep": "3", "pid": "2620" } ] }, { "id": "2626", "name": "昭通市", "code": "530600", "deep": "2", "pid": "2584", "area": [ { "id": "2627", "name": "昭阳区", "code": "530602", "deep": "3", "pid": "2626" }, { "id": "2628", "name": "鲁甸县", "code": "530621", "deep": "3", "pid": "2626" }, { "id": "2629", "name": "巧家县", "code": "530622", "deep": "3", "pid": "2626" }, { "id": "2630", "name": "盐津县", "code": "530623", "deep": "3", "pid": "2626" }, { "id": "2631", "name": "大关县", "code": "530624", "deep": "3", "pid": "2626" }, { "id": "2632", "name": "永善县", "code": "530625", "deep": "3", "pid": "2626" }, { "id": "2633", "name": "绥江县", "code": "530626", "deep": "3", "pid": "2626" }, { "id": "2634", "name": "镇雄县", "code": "530627", "deep": "3", "pid": "2626" }, { "id": "2635", "name": "彝良县", "code": "530628", "deep": "3", "pid": "2626" }, { "id": "2636", "name": "威信县", "code": "530629", "deep": "3", "pid": "2626" }, { "id": "2637", "name": "水富县", "code": "530630", "deep": "3", "pid": "2626" } ] }, { "id": "2638", "name": "丽江市", "code": "530700", "deep": "2", "pid": "2584", "area": [ { "id": "2639", "name": "古城区", "code": "530702", "deep": "3", "pid": "2638" }, { "id": "2640", "name": "玉龙纳西族自治县", "code": "530721", "deep": "3", "pid": "2638" }, { "id": "2641", "name": "永胜县", "code": "530722", "deep": "3", "pid": "2638" }, { "id": "2642", "name": "华坪县", "code": "530723", "deep": "3", "pid": "2638" }, { "id": "2643", "name": "宁蒗彝族自治县", "code": "530724", "deep": "3", "pid": "2638" } ] }, { "id": "2644", "name": "普洱市", "code": "530800", "deep": "2", "pid": "2584", "area": [ { "id": "2645", "name": "思茅区", "code": "530802", "deep": "3", "pid": "2644" }, { "id": "2646", "name": "宁洱哈尼族彝族自治县", "code": "530821", "deep": "3", "pid": "2644" }, { "id": "2647", "name": "墨江哈尼族自治县", "code": "530822", "deep": "3", "pid": "2644" }, { "id": "2648", "name": "景东彝族自治县", "code": "530823", "deep": "3", "pid": "2644" }, { "id": "2649", "name": "景谷傣族彝族自治县", "code": "530824", "deep": "3", "pid": "2644" }, { "id": "2650", "name": "镇沅彝族哈尼族拉祜族自治县", "code": "530825", "deep": "3", "pid": "2644" }, { "id": "2651", "name": "江城哈尼族彝族自治县", "code": "530826", "deep": "3", "pid": "2644" }, { "id": "2652", "name": "孟连傣族拉祜族佤族自治县", "code": "530827", "deep": "3", "pid": "2644" }, { "id": "2653", "name": "澜沧拉祜族自治县", "code": "530828", "deep": "3", "pid": "2644" }, { "id": "2654", "name": "西盟佤族自治县", "code": "530829", "deep": "3", "pid": "2644" } ] }, { "id": "2655", "name": "临沧市", "code": "530900", "deep": "2", "pid": "2584", "area": [ { "id": "2656", "name": "临翔区", "code": "530902", "deep": "3", "pid": "2655" }, { "id": "2657", "name": "凤庆县", "code": "530921", "deep": "3", "pid": "2655" }, { "id": "2658", "name": "云县", "code": "530922", "deep": "3", "pid": "2655" }, { "id": "2659", "name": "永德县", "code": "530923", "deep": "3", "pid": "2655" }, { "id": "2660", "name": "镇康县", "code": "530924", "deep": "3", "pid": "2655" }, { "id": "2661", "name": "双江拉祜族佤族布朗族傣族自治县", "code": "530925", "deep": "3", "pid": "2655" }, { "id": "2662", "name": "耿马傣族佤族自治县", "code": "530926", "deep": "3", "pid": "2655" }, { "id": "2663", "name": "沧源佤族自治县", "code": "530927", "deep": "3", "pid": "2655" } ] }, { "id": "2664", "name": "楚雄彝族自治州", "code": "532300", "deep": "2", "pid": "2584", "area": [ { "id": "2665", "name": "楚雄市", "code": "532301", "deep": "3", "pid": "2664" }, { "id": "2666", "name": "双柏县", "code": "532322", "deep": "3", "pid": "2664" }, { "id": "2667", "name": "牟定县", "code": "532323", "deep": "3", "pid": "2664" }, { "id": "2668", "name": "南华县", "code": "532324", "deep": "3", "pid": "2664" }, { "id": "2669", "name": "姚安县", "code": "532325", "deep": "3", "pid": "2664" }, { "id": "2670", "name": "大姚县", "code": "532326", "deep": "3", "pid": "2664" }, { "id": "2671", "name": "永仁县", "code": "532327", "deep": "3", "pid": "2664" }, { "id": "2672", "name": "元谋县", "code": "532328", "deep": "3", "pid": "2664" }, { "id": "2673", "name": "武定县", "code": "532329", "deep": "3", "pid": "2664" }, { "id": "2674", "name": "禄丰县", "code": "532331", "deep": "3", "pid": "2664" } ] }, { "id": "2675", "name": "红河哈尼族彝族自治州", "code": "532500", "deep": "2", "pid": "2584", "area": [ { "id": "2676", "name": "个旧市", "code": "532501", "deep": "3", "pid": "2675" }, { "id": "2677", "name": "开远市", "code": "532502", "deep": "3", "pid": "2675" }, { "id": "2678", "name": "蒙自市", "code": "532503", "deep": "3", "pid": "2675" }, { "id": "2679", "name": "弥勒市", "code": "532504", "deep": "3", "pid": "2675" }, { "id": "2680", "name": "屏边苗族自治县", "code": "532523", "deep": "3", "pid": "2675" }, { "id": "2681", "name": "建水县", "code": "532524", "deep": "3", "pid": "2675" }, { "id": "2682", "name": "石屏县", "code": "532525", "deep": "3", "pid": "2675" }, { "id": "2683", "name": "泸西县", "code": "532527", "deep": "3", "pid": "2675" }, { "id": "2684", "name": "元阳县", "code": "532528", "deep": "3", "pid": "2675" }, { "id": "2685", "name": "红河县", "code": "532529", "deep": "3", "pid": "2675" }, { "id": "2686", "name": "金平苗族瑶族傣族自治县", "code": "532530", "deep": "3", "pid": "2675" }, { "id": "2687", "name": "绿春县", "code": "532531", "deep": "3", "pid": "2675" }, { "id": "2688", "name": "河口瑶族自治县", "code": "532532", "deep": "3", "pid": "2675" } ] }, { "id": "2689", "name": "文山壮族苗族自治州", "code": "532600", "deep": "2", "pid": "2584", "area": [ { "id": "2690", "name": "文山市", "code": "532601", "deep": "3", "pid": "2689" }, { "id": "2691", "name": "砚山县", "code": "532622", "deep": "3", "pid": "2689" }, { "id": "2692", "name": "西畴县", "code": "532623", "deep": "3", "pid": "2689" }, { "id": "2693", "name": "麻栗坡县", "code": "532624", "deep": "3", "pid": "2689" }, { "id": "2694", "name": "马关县", "code": "532625", "deep": "3", "pid": "2689" }, { "id": "2695", "name": "丘北县", "code": "532626", "deep": "3", "pid": "2689" }, { "id": "2696", "name": "广南县", "code": "532627", "deep": "3", "pid": "2689" }, { "id": "2697", "name": "富宁县", "code": "532628", "deep": "3", "pid": "2689" } ] }, { "id": "2698", "name": "西双版纳傣族自治州", "code": "532800", "deep": "2", "pid": "2584", "area": [ { "id": "2699", "name": "景洪市", "code": "532801", "deep": "3", "pid": "2698" }, { "id": "2700", "name": "勐海县", "code": "532822", "deep": "3", "pid": "2698" }, { "id": "2701", "name": "勐腊县", "code": "532823", "deep": "3", "pid": "2698" } ] }, { "id": "2702", "name": "大理白族自治州", "code": "532900", "deep": "2", "pid": "2584", "area": [ { "id": "2703", "name": "大理市", "code": "532901", "deep": "3", "pid": "2702" }, { "id": "2704", "name": "漾濞彝族自治县", "code": "532922", "deep": "3", "pid": "2702" }, { "id": "2705", "name": "祥云县", "code": "532923", "deep": "3", "pid": "2702" }, { "id": "2706", "name": "宾川县", "code": "532924", "deep": "3", "pid": "2702" }, { "id": "2707", "name": "弥渡县", "code": "532925", "deep": "3", "pid": "2702" }, { "id": "2708", "name": "南涧彝族自治县", "code": "532926", "deep": "3", "pid": "2702" }, { "id": "2709", "name": "巍山彝族回族自治县", "code": "532927", "deep": "3", "pid": "2702" }, { "id": "2710", "name": "永平县", "code": "532928", "deep": "3", "pid": "2702" }, { "id": "2711", "name": "云龙县", "code": "532929", "deep": "3", "pid": "2702" }, { "id": "2712", "name": "洱源县", "code": "532930", "deep": "3", "pid": "2702" }, { "id": "2713", "name": "剑川县", "code": "532931", "deep": "3", "pid": "2702" }, { "id": "2714", "name": "鹤庆县", "code": "532932", "deep": "3", "pid": "2702" } ] }, { "id": "2715", "name": "德宏傣族景颇族自治州", "code": "533100", "deep": "2", "pid": "2584", "area": [ { "id": "2716", "name": "瑞丽市", "code": "533102", "deep": "3", "pid": "2715" }, { "id": "2717", "name": "芒市", "code": "533103", "deep": "3", "pid": "2715" }, { "id": "2718", "name": "梁河县", "code": "533122", "deep": "3", "pid": "2715" }, { "id": "2719", "name": "盈江县", "code": "533123", "deep": "3", "pid": "2715" }, { "id": "2720", "name": "陇川县", "code": "533124", "deep": "3", "pid": "2715" } ] }, { "id": "2721", "name": "怒江傈僳族自治州", "code": "533300", "deep": "2", "pid": "2584", "area": [ { "id": "2722", "name": "泸水市", "code": "533301", "deep": "3", "pid": "2721" }, { "id": "2723", "name": "福贡县", "code": "533323", "deep": "3", "pid": "2721" }, { "id": "2724", "name": "贡山独龙族怒族自治县", "code": "533324", "deep": "3", "pid": "2721" }, { "id": "2725", "name": "兰坪白族普米族自治县", "code": "533325", "deep": "3", "pid": "2721" } ] }, { "id": "2726", "name": "迪庆藏族自治州", "code": "533400", "deep": "2", "pid": "2584", "area": [ { "id": "2727", "name": "香格里拉市", "code": "533401", "deep": "3", "pid": "2726" }, { "id": "2728", "name": "德钦县", "code": "533422", "deep": "3", "pid": "2726" }, { "id": "2729", "name": "维西傈僳族自治县", "code": "533423", "deep": "3", "pid": "2726" } ] } ] }, { "id": "2730", "name": "西藏自治区", "code": "540000", "deep": "1", "pid": "0", "city": [ { "id": "2731", "name": "拉萨市", "code": "540100", "deep": "2", "pid": "2730", "area": [ { "id": "2732", "name": "城关区", "code": "540102", "deep": "3", "pid": "2731" }, { "id": "2733", "name": "堆龙德庆区", "code": "540103", "deep": "3", "pid": "2731" }, { "id": "2734", "name": "林周县", "code": "540121", "deep": "3", "pid": "2731" }, { "id": "2735", "name": "当雄县", "code": "540122", "deep": "3", "pid": "2731" }, { "id": "2736", "name": "尼木县", "code": "540123", "deep": "3", "pid": "2731" }, { "id": "2737", "name": "曲水县", "code": "540124", "deep": "3", "pid": "2731" }, { "id": "2738", "name": "达孜县", "code": "540126", "deep": "3", "pid": "2731" }, { "id": "2739", "name": "墨竹工卡县", "code": "540127", "deep": "3", "pid": "2731" } ] }, { "id": "2740", "name": "日喀则市", "code": "540200", "deep": "2", "pid": "2730", "area": [ { "id": "2741", "name": "桑珠孜区", "code": "540202", "deep": "3", "pid": "2740" }, { "id": "2742", "name": "南木林县", "code": "540221", "deep": "3", "pid": "2740" }, { "id": "2743", "name": "江孜县", "code": "540222", "deep": "3", "pid": "2740" }, { "id": "2744", "name": "定日县", "code": "540223", "deep": "3", "pid": "2740" }, { "id": "2745", "name": "萨迦县", "code": "540224", "deep": "3", "pid": "2740" }, { "id": "2746", "name": "拉孜县", "code": "540225", "deep": "3", "pid": "2740" }, { "id": "2747", "name": "昂仁县", "code": "540226", "deep": "3", "pid": "2740" }, { "id": "2748", "name": "谢通门县", "code": "540227", "deep": "3", "pid": "2740" }, { "id": "2749", "name": "白朗县", "code": "540228", "deep": "3", "pid": "2740" }, { "id": "2750", "name": "仁布县", "code": "540229", "deep": "3", "pid": "2740" }, { "id": "2751", "name": "康马县", "code": "540230", "deep": "3", "pid": "2740" }, { "id": "2752", "name": "定结县", "code": "540231", "deep": "3", "pid": "2740" }, { "id": "2753", "name": "仲巴县", "code": "540232", "deep": "3", "pid": "2740" }, { "id": "2754", "name": "亚东县", "code": "540233", "deep": "3", "pid": "2740" }, { "id": "2755", "name": "吉隆县", "code": "540234", "deep": "3", "pid": "2740" }, { "id": "2756", "name": "聂拉木县", "code": "540235", "deep": "3", "pid": "2740" }, { "id": "2757", "name": "萨嘎县", "code": "540236", "deep": "3", "pid": "2740" }, { "id": "2758", "name": "岗巴县", "code": "540237", "deep": "3", "pid": "2740" } ] }, { "id": "2759", "name": "昌都市", "code": "540300", "deep": "2", "pid": "2730", "area": [ { "id": "2760", "name": "卡若区", "code": "540302", "deep": "3", "pid": "2759" }, { "id": "2761", "name": "江达县", "code": "540321", "deep": "3", "pid": "2759" }, { "id": "2762", "name": "贡觉县", "code": "540322", "deep": "3", "pid": "2759" }, { "id": "2763", "name": "类乌齐县", "code": "540323", "deep": "3", "pid": "2759" }, { "id": "2764", "name": "丁青县", "code": "540324", "deep": "3", "pid": "2759" }, { "id": "2765", "name": "察雅县", "code": "540325", "deep": "3", "pid": "2759" }, { "id": "2766", "name": "八宿县", "code": "540326", "deep": "3", "pid": "2759" }, { "id": "2767", "name": "左贡县", "code": "540327", "deep": "3", "pid": "2759" }, { "id": "2768", "name": "芒康县", "code": "540328", "deep": "3", "pid": "2759" }, { "id": "2769", "name": "洛隆县", "code": "540329", "deep": "3", "pid": "2759" }, { "id": "2770", "name": "边坝县", "code": "540330", "deep": "3", "pid": "2759" } ] }, { "id": "2771", "name": "林芝市", "code": "540400", "deep": "2", "pid": "2730", "area": [ { "id": "2772", "name": "巴宜区", "code": "540402", "deep": "3", "pid": "2771" }, { "id": "2773", "name": "工布江达县", "code": "540421", "deep": "3", "pid": "2771" }, { "id": "2774", "name": "米林县", "code": "540422", "deep": "3", "pid": "2771" }, { "id": "2775", "name": "墨脱县", "code": "540423", "deep": "3", "pid": "2771" }, { "id": "2776", "name": "波密县", "code": "540424", "deep": "3", "pid": "2771" }, { "id": "2777", "name": "察隅县", "code": "540425", "deep": "3", "pid": "2771" }, { "id": "2778", "name": "朗县", "code": "540426", "deep": "3", "pid": "2771" } ] }, { "id": "2779", "name": "山南地区", "code": "542200", "deep": "2", "pid": "2730", "area": [ { "id": "2780", "name": "乃东区", "code": "540502", "deep": "3", "pid": "2779" }, { "id": "2781", "name": "扎囊县", "code": "542222", "deep": "3", "pid": "2779" }, { "id": "2782", "name": "贡嘎县", "code": "542223", "deep": "3", "pid": "2779" }, { "id": "2783", "name": "桑日县", "code": "542224", "deep": "3", "pid": "2779" }, { "id": "2784", "name": "琼结县", "code": "542225", "deep": "3", "pid": "2779" }, { "id": "2785", "name": "曲松县", "code": "542226", "deep": "3", "pid": "2779" }, { "id": "2786", "name": "措美县", "code": "542227", "deep": "3", "pid": "2779" }, { "id": "2787", "name": "洛扎县", "code": "542228", "deep": "3", "pid": "2779" }, { "id": "2788", "name": "加查县", "code": "542229", "deep": "3", "pid": "2779" }, { "id": "2789", "name": "隆子县", "code": "542231", "deep": "3", "pid": "2779" }, { "id": "2790", "name": "错那县", "code": "542232", "deep": "3", "pid": "2779" }, { "id": "2791", "name": "浪卡子县", "code": "542233", "deep": "3", "pid": "2779" } ] }, { "id": "2792", "name": "那曲地区", "code": "542400", "deep": "2", "pid": "2730", "area": [ { "id": "2793", "name": "那曲县", "code": "542421", "deep": "3", "pid": "2792" }, { "id": "2794", "name": "嘉黎县", "code": "542422", "deep": "3", "pid": "2792" }, { "id": "2795", "name": "比如县", "code": "542423", "deep": "3", "pid": "2792" }, { "id": "2796", "name": "聂荣县", "code": "542424", "deep": "3", "pid": "2792" }, { "id": "2797", "name": "安多县", "code": "542425", "deep": "3", "pid": "2792" }, { "id": "2798", "name": "申扎县", "code": "542426", "deep": "3", "pid": "2792" }, { "id": "2799", "name": "索县", "code": "542427", "deep": "3", "pid": "2792" }, { "id": "2800", "name": "班戈县", "code": "542428", "deep": "3", "pid": "2792" }, { "id": "2801", "name": "巴青县", "code": "542429", "deep": "3", "pid": "2792" }, { "id": "2802", "name": "尼玛县", "code": "542430", "deep": "3", "pid": "2792" }, { "id": "2803", "name": "双湖县", "code": "542431", "deep": "3", "pid": "2792" } ] }, { "id": "2804", "name": "阿里地区", "code": "542500", "deep": "2", "pid": "2730", "area": [ { "id": "2805", "name": "普兰县", "code": "542521", "deep": "3", "pid": "2804" }, { "id": "2806", "name": "札达县", "code": "542522", "deep": "3", "pid": "2804" }, { "id": "2807", "name": "噶尔县", "code": "542523", "deep": "3", "pid": "2804" }, { "id": "2808", "name": "日土县", "code": "542524", "deep": "3", "pid": "2804" }, { "id": "2809", "name": "革吉县", "code": "542525", "deep": "3", "pid": "2804" }, { "id": "2810", "name": "改则县", "code": "542526", "deep": "3", "pid": "2804" }, { "id": "2811", "name": "措勤县", "code": "542527", "deep": "3", "pid": "2804" } ] }, { "id": "3482", "name": "山南市", "code": "540500", "deep": "2", "pid": "2730", "area": [ { "id": "3483", "name": "扎囊县", "code": "540521", "deep": "3", "pid": "3482" }, { "id": "3484", "name": "贡嘎县", "code": "540522", "deep": "3", "pid": "3482" }, { "id": "3485", "name": "桑日县", "code": "540523", "deep": "3", "pid": "3482" }, { "id": "3486", "name": "琼结县", "code": "540524", "deep": "3", "pid": "3482" }, { "id": "3487", "name": "曲松县", "code": "540525", "deep": "3", "pid": "3482" }, { "id": "3488", "name": "措美县", "code": "540526", "deep": "3", "pid": "3482" }, { "id": "3489", "name": "洛扎县", "code": "540527", "deep": "3", "pid": "3482" }, { "id": "3490", "name": "加查县", "code": "540528", "deep": "3", "pid": "3482" }, { "id": "3491", "name": "隆子县", "code": "540529", "deep": "3", "pid": "3482" }, { "id": "3492", "name": "错那县", "code": "540530", "deep": "3", "pid": "3482" }, { "id": "3493", "name": "浪卡子县", "code": "540531", "deep": "3", "pid": "3482" } ] } ] }, { "id": "2812", "name": "陕西省", "code": "610000", "deep": "1", "pid": "0", "city": [ { "id": "2813", "name": "西安市", "code": "610100", "deep": "2", "pid": "2812", "area": [ { "id": "2814", "name": "新城区", "code": "610102", "deep": "3", "pid": "2813" }, { "id": "2815", "name": "碑林区", "code": "610103", "deep": "3", "pid": "2813" }, { "id": "2816", "name": "莲湖区", "code": "610104", "deep": "3", "pid": "2813" }, { "id": "2817", "name": "灞桥区", "code": "610111", "deep": "3", "pid": "2813" }, { "id": "2818", "name": "未央区", "code": "610112", "deep": "3", "pid": "2813" }, { "id": "2819", "name": "雁塔区", "code": "610113", "deep": "3", "pid": "2813" }, { "id": "2820", "name": "阎良区", "code": "610114", "deep": "3", "pid": "2813" }, { "id": "2821", "name": "临潼区", "code": "610115", "deep": "3", "pid": "2813" }, { "id": "2822", "name": "长安区", "code": "610116", "deep": "3", "pid": "2813" }, { "id": "2823", "name": "高陵区", "code": "610117", "deep": "3", "pid": "2813" }, { "id": "2824", "name": "蓝田县", "code": "610122", "deep": "3", "pid": "2813" }, { "id": "2825", "name": "周至县", "code": "610124", "deep": "3", "pid": "2813" }, { "id": "2826", "name": "户县", "code": "610125", "deep": "3", "pid": "2813" }, { "id": "3370", "name": "鄠邑区", "code": "610118", "deep": "3", "pid": "2813" } ] }, { "id": "2827", "name": "铜川市", "code": "610200", "deep": "2", "pid": "2812", "area": [ { "id": "2828", "name": "王益区", "code": "610202", "deep": "3", "pid": "2827" }, { "id": "2829", "name": "印台区", "code": "610203", "deep": "3", "pid": "2827" }, { "id": "2830", "name": "耀州区", "code": "610204", "deep": "3", "pid": "2827" }, { "id": "2831", "name": "宜君县", "code": "610222", "deep": "3", "pid": "2827" } ] }, { "id": "2832", "name": "宝鸡市", "code": "610300", "deep": "2", "pid": "2812", "area": [ { "id": "2833", "name": "渭滨区", "code": "610302", "deep": "3", "pid": "2832" }, { "id": "2834", "name": "金台区", "code": "610303", "deep": "3", "pid": "2832" }, { "id": "2835", "name": "陈仓区", "code": "610304", "deep": "3", "pid": "2832" }, { "id": "2836", "name": "凤翔县", "code": "610322", "deep": "3", "pid": "2832" }, { "id": "2837", "name": "岐山县", "code": "610323", "deep": "3", "pid": "2832" }, { "id": "2838", "name": "扶风县", "code": "610324", "deep": "3", "pid": "2832" }, { "id": "2839", "name": "眉县", "code": "610326", "deep": "3", "pid": "2832" }, { "id": "2840", "name": "陇县", "code": "610327", "deep": "3", "pid": "2832" }, { "id": "2841", "name": "千阳县", "code": "610328", "deep": "3", "pid": "2832" }, { "id": "2842", "name": "麟游县", "code": "610329", "deep": "3", "pid": "2832" }, { "id": "2843", "name": "凤县", "code": "610330", "deep": "3", "pid": "2832" }, { "id": "2844", "name": "太白县", "code": "610331", "deep": "3", "pid": "2832" } ] }, { "id": "2845", "name": "咸阳市", "code": "610400", "deep": "2", "pid": "2812", "area": [ { "id": "2846", "name": "秦都区", "code": "610402", "deep": "3", "pid": "2845" }, { "id": "2847", "name": "杨陵区", "code": "610403", "deep": "3", "pid": "2845" }, { "id": "2848", "name": "渭城区", "code": "610404", "deep": "3", "pid": "2845" }, { "id": "2849", "name": "三原县", "code": "610422", "deep": "3", "pid": "2845" }, { "id": "2850", "name": "泾阳县", "code": "610423", "deep": "3", "pid": "2845" }, { "id": "2851", "name": "乾县", "code": "610424", "deep": "3", "pid": "2845" }, { "id": "2852", "name": "礼泉县", "code": "610425", "deep": "3", "pid": "2845" }, { "id": "2853", "name": "永寿县", "code": "610426", "deep": "3", "pid": "2845" }, { "id": "2854", "name": "彬县", "code": "610427", "deep": "3", "pid": "2845" }, { "id": "2855", "name": "长武县", "code": "610428", "deep": "3", "pid": "2845" }, { "id": "2856", "name": "旬邑县", "code": "610429", "deep": "3", "pid": "2845" }, { "id": "2857", "name": "淳化县", "code": "610430", "deep": "3", "pid": "2845" }, { "id": "2858", "name": "武功县", "code": "610431", "deep": "3", "pid": "2845" }, { "id": "2859", "name": "兴平市", "code": "610481", "deep": "3", "pid": "2845" } ] }, { "id": "2860", "name": "渭南市", "code": "610500", "deep": "2", "pid": "2812", "area": [ { "id": "2861", "name": "临渭区", "code": "610502", "deep": "3", "pid": "2860" }, { "id": "2862", "name": "华州区", "code": "610503", "deep": "3", "pid": "2860" }, { "id": "2863", "name": "潼关县", "code": "610522", "deep": "3", "pid": "2860" }, { "id": "2864", "name": "大荔县", "code": "610523", "deep": "3", "pid": "2860" }, { "id": "2865", "name": "合阳县", "code": "610524", "deep": "3", "pid": "2860" }, { "id": "2866", "name": "澄城县", "code": "610525", "deep": "3", "pid": "2860" }, { "id": "2867", "name": "蒲城县", "code": "610526", "deep": "3", "pid": "2860" }, { "id": "2868", "name": "白水县", "code": "610527", "deep": "3", "pid": "2860" }, { "id": "2869", "name": "富平县", "code": "610528", "deep": "3", "pid": "2860" }, { "id": "2870", "name": "韩城市", "code": "610581", "deep": "3", "pid": "2860" }, { "id": "2871", "name": "华阴市", "code": "610582", "deep": "3", "pid": "2860" } ] }, { "id": "2872", "name": "延安市", "code": "610600", "deep": "2", "pid": "2812", "area": [ { "id": "2873", "name": "宝塔区", "code": "610602", "deep": "3", "pid": "2872" }, { "id": "2874", "name": "延长县", "code": "610621", "deep": "3", "pid": "2872" }, { "id": "2875", "name": "延川县", "code": "610622", "deep": "3", "pid": "2872" }, { "id": "2876", "name": "子长县", "code": "610623", "deep": "3", "pid": "2872" }, { "id": "2877", "name": "安塞区", "code": "610603", "deep": "3", "pid": "2872" }, { "id": "2878", "name": "志丹县", "code": "610625", "deep": "3", "pid": "2872" }, { "id": "2879", "name": "吴起县", "code": "610626", "deep": "3", "pid": "2872" }, { "id": "2880", "name": "甘泉县", "code": "610627", "deep": "3", "pid": "2872" }, { "id": "2881", "name": "富县", "code": "610628", "deep": "3", "pid": "2872" }, { "id": "2882", "name": "洛川县", "code": "610629", "deep": "3", "pid": "2872" }, { "id": "2883", "name": "宜川县", "code": "610630", "deep": "3", "pid": "2872" }, { "id": "2884", "name": "黄龙县", "code": "610631", "deep": "3", "pid": "2872" }, { "id": "2885", "name": "黄陵县", "code": "610632", "deep": "3", "pid": "2872" } ] }, { "id": "2886", "name": "汉中市", "code": "610700", "deep": "2", "pid": "2812", "area": [ { "id": "2887", "name": "汉台区", "code": "610702", "deep": "3", "pid": "2886" }, { "id": "2888", "name": "南郑县", "code": "610721", "deep": "3", "pid": "2886" }, { "id": "2889", "name": "城固县", "code": "610722", "deep": "3", "pid": "2886" }, { "id": "2890", "name": "洋县", "code": "610723", "deep": "3", "pid": "2886" }, { "id": "2891", "name": "西乡县", "code": "610724", "deep": "3", "pid": "2886" }, { "id": "2892", "name": "勉县", "code": "610725", "deep": "3", "pid": "2886" }, { "id": "2893", "name": "宁强县", "code": "610726", "deep": "3", "pid": "2886" }, { "id": "2894", "name": "略阳县", "code": "610727", "deep": "3", "pid": "2886" }, { "id": "2895", "name": "镇巴县", "code": "610728", "deep": "3", "pid": "2886" }, { "id": "2896", "name": "留坝县", "code": "610729", "deep": "3", "pid": "2886" }, { "id": "2897", "name": "佛坪县", "code": "610730", "deep": "3", "pid": "2886" } ] }, { "id": "2898", "name": "榆林市", "code": "610800", "deep": "2", "pid": "2812", "area": [ { "id": "2899", "name": "榆阳区", "code": "610802", "deep": "3", "pid": "2898" }, { "id": "2900", "name": "横山区", "code": "610803", "deep": "3", "pid": "2898" }, { "id": "2901", "name": "神木市", "code": "610881", "deep": "3", "pid": "2898" }, { "id": "2902", "name": "府谷县", "code": "610822", "deep": "3", "pid": "2898" }, { "id": "2903", "name": "靖边县", "code": "610824", "deep": "3", "pid": "2898" }, { "id": "2904", "name": "定边县", "code": "610825", "deep": "3", "pid": "2898" }, { "id": "2905", "name": "绥德县", "code": "610826", "deep": "3", "pid": "2898" }, { "id": "2906", "name": "米脂县", "code": "610827", "deep": "3", "pid": "2898" }, { "id": "2907", "name": "佳县", "code": "610828", "deep": "3", "pid": "2898" }, { "id": "2908", "name": "吴堡县", "code": "610829", "deep": "3", "pid": "2898" }, { "id": "2909", "name": "清涧县", "code": "610830", "deep": "3", "pid": "2898" }, { "id": "2910", "name": "子洲县", "code": "610831", "deep": "3", "pid": "2898" }, { "id": "3494", "name": "神木县", "code": "610821", "deep": "3", "pid": "2898" } ] }, { "id": "2911", "name": "安康市", "code": "610900", "deep": "2", "pid": "2812", "area": [ { "id": "2912", "name": "汉滨区", "code": "610902", "deep": "3", "pid": "2911" }, { "id": "2913", "name": "汉阴县", "code": "610921", "deep": "3", "pid": "2911" }, { "id": "2914", "name": "石泉县", "code": "610922", "deep": "3", "pid": "2911" }, { "id": "2915", "name": "宁陕县", "code": "610923", "deep": "3", "pid": "2911" }, { "id": "2916", "name": "紫阳县", "code": "610924", "deep": "3", "pid": "2911" }, { "id": "2917", "name": "岚皋县", "code": "610925", "deep": "3", "pid": "2911" }, { "id": "2918", "name": "平利县", "code": "610926", "deep": "3", "pid": "2911" }, { "id": "2919", "name": "镇坪县", "code": "610927", "deep": "3", "pid": "2911" }, { "id": "2920", "name": "旬阳县", "code": "610928", "deep": "3", "pid": "2911" }, { "id": "2921", "name": "白河县", "code": "610929", "deep": "3", "pid": "2911" } ] }, { "id": "2922", "name": "商洛市", "code": "611000", "deep": "2", "pid": "2812", "area": [ { "id": "2923", "name": "商州区", "code": "611002", "deep": "3", "pid": "2922" }, { "id": "2924", "name": "洛南县", "code": "611021", "deep": "3", "pid": "2922" }, { "id": "2925", "name": "丹凤县", "code": "611022", "deep": "3", "pid": "2922" }, { "id": "2926", "name": "商南县", "code": "611023", "deep": "3", "pid": "2922" }, { "id": "2927", "name": "山阳县", "code": "611024", "deep": "3", "pid": "2922" }, { "id": "2928", "name": "镇安县", "code": "611025", "deep": "3", "pid": "2922" }, { "id": "2929", "name": "柞水县", "code": "611026", "deep": "3", "pid": "2922" } ] } ] }, { "id": "2930", "name": "甘肃省", "code": "620000", "deep": "1", "pid": "0", "city": [ { "id": "2931", "name": "兰州市", "code": "620100", "deep": "2", "pid": "2930", "area": [ { "id": "2932", "name": "城关区", "code": "620102", "deep": "3", "pid": "2931" }, { "id": "2933", "name": "七里河区", "code": "620103", "deep": "3", "pid": "2931" }, { "id": "2934", "name": "西固区", "code": "620104", "deep": "3", "pid": "2931" }, { "id": "2935", "name": "安宁区", "code": "620105", "deep": "3", "pid": "2931" }, { "id": "2936", "name": "红古区", "code": "620111", "deep": "3", "pid": "2931" }, { "id": "2937", "name": "永登县", "code": "620121", "deep": "3", "pid": "2931" }, { "id": "2938", "name": "皋兰县", "code": "620122", "deep": "3", "pid": "2931" }, { "id": "2939", "name": "榆中县", "code": "620123", "deep": "3", "pid": "2931" } ] }, { "id": "2940", "name": "嘉峪关市", "code": "620200", "deep": "2", "pid": "2930" }, { "id": "2941", "name": "金昌市", "code": "620300", "deep": "2", "pid": "2930", "area": [ { "id": "2942", "name": "金川区", "code": "620302", "deep": "3", "pid": "2941" }, { "id": "2943", "name": "永昌县", "code": "620321", "deep": "3", "pid": "2941" } ] }, { "id": "2944", "name": "白银市", "code": "620400", "deep": "2", "pid": "2930", "area": [ { "id": "2945", "name": "白银区", "code": "620402", "deep": "3", "pid": "2944" }, { "id": "2946", "name": "平川区", "code": "620403", "deep": "3", "pid": "2944" }, { "id": "2947", "name": "靖远县", "code": "620421", "deep": "3", "pid": "2944" }, { "id": "2948", "name": "会宁县", "code": "620422", "deep": "3", "pid": "2944" }, { "id": "2949", "name": "景泰县", "code": "620423", "deep": "3", "pid": "2944" } ] }, { "id": "2950", "name": "天水市", "code": "620500", "deep": "2", "pid": "2930", "area": [ { "id": "2951", "name": "秦州区", "code": "620502", "deep": "3", "pid": "2950" }, { "id": "2952", "name": "麦积区", "code": "620503", "deep": "3", "pid": "2950" }, { "id": "2953", "name": "清水县", "code": "620521", "deep": "3", "pid": "2950" }, { "id": "2954", "name": "秦安县", "code": "620522", "deep": "3", "pid": "2950" }, { "id": "2955", "name": "甘谷县", "code": "620523", "deep": "3", "pid": "2950" }, { "id": "2956", "name": "武山县", "code": "620524", "deep": "3", "pid": "2950" }, { "id": "2957", "name": "张家川回族自治县", "code": "620525", "deep": "3", "pid": "2950" } ] }, { "id": "2958", "name": "武威市", "code": "620600", "deep": "2", "pid": "2930", "area": [ { "id": "2959", "name": "凉州区", "code": "620602", "deep": "3", "pid": "2958" }, { "id": "2960", "name": "民勤县", "code": "620621", "deep": "3", "pid": "2958" }, { "id": "2961", "name": "古浪县", "code": "620622", "deep": "3", "pid": "2958" }, { "id": "2962", "name": "天祝藏族自治县", "code": "620623", "deep": "3", "pid": "2958" } ] }, { "id": "2963", "name": "张掖市", "code": "620700", "deep": "2", "pid": "2930", "area": [ { "id": "2964", "name": "甘州区", "code": "620702", "deep": "3", "pid": "2963" }, { "id": "2965", "name": "肃南裕固族自治县", "code": "620721", "deep": "3", "pid": "2963" }, { "id": "2966", "name": "民乐县", "code": "620722", "deep": "3", "pid": "2963" }, { "id": "2967", "name": "临泽县", "code": "620723", "deep": "3", "pid": "2963" }, { "id": "2968", "name": "高台县", "code": "620724", "deep": "3", "pid": "2963" }, { "id": "2969", "name": "山丹县", "code": "620725", "deep": "3", "pid": "2963" } ] }, { "id": "2970", "name": "平凉市", "code": "620800", "deep": "2", "pid": "2930", "area": [ { "id": "2971", "name": "崆峒区", "code": "620802", "deep": "3", "pid": "2970" }, { "id": "2972", "name": "泾川县", "code": "620821", "deep": "3", "pid": "2970" }, { "id": "2973", "name": "灵台县", "code": "620822", "deep": "3", "pid": "2970" }, { "id": "2974", "name": "崇信县", "code": "620823", "deep": "3", "pid": "2970" }, { "id": "2975", "name": "华亭县", "code": "620824", "deep": "3", "pid": "2970" }, { "id": "2976", "name": "庄浪县", "code": "620825", "deep": "3", "pid": "2970" }, { "id": "2977", "name": "静宁县", "code": "620826", "deep": "3", "pid": "2970" } ] }, { "id": "2978", "name": "酒泉市", "code": "620900", "deep": "2", "pid": "2930", "area": [ { "id": "2979", "name": "肃州区", "code": "620902", "deep": "3", "pid": "2978" }, { "id": "2980", "name": "金塔县", "code": "620921", "deep": "3", "pid": "2978" }, { "id": "2981", "name": "瓜州县", "code": "620922", "deep": "3", "pid": "2978" }, { "id": "2982", "name": "肃北蒙古族自治县", "code": "620923", "deep": "3", "pid": "2978" }, { "id": "2983", "name": "阿克塞哈萨克族自治县", "code": "620924", "deep": "3", "pid": "2978" }, { "id": "2984", "name": "玉门市", "code": "620981", "deep": "3", "pid": "2978" }, { "id": "2985", "name": "敦煌市", "code": "620982", "deep": "3", "pid": "2978" } ] }, { "id": "2986", "name": "庆阳市", "code": "621000", "deep": "2", "pid": "2930", "area": [ { "id": "2987", "name": "西峰区", "code": "621002", "deep": "3", "pid": "2986" }, { "id": "2988", "name": "庆城县", "code": "621021", "deep": "3", "pid": "2986" }, { "id": "2989", "name": "环县", "code": "621022", "deep": "3", "pid": "2986" }, { "id": "2990", "name": "华池县", "code": "621023", "deep": "3", "pid": "2986" }, { "id": "2991", "name": "合水县", "code": "621024", "deep": "3", "pid": "2986" }, { "id": "2992", "name": "正宁县", "code": "621025", "deep": "3", "pid": "2986" }, { "id": "2993", "name": "宁县", "code": "621026", "deep": "3", "pid": "2986" }, { "id": "2994", "name": "镇原县", "code": "621027", "deep": "3", "pid": "2986" } ] }, { "id": "2995", "name": "定西市", "code": "621100", "deep": "2", "pid": "2930", "area": [ { "id": "2996", "name": "安定区", "code": "621102", "deep": "3", "pid": "2995" }, { "id": "2997", "name": "通渭县", "code": "621121", "deep": "3", "pid": "2995" }, { "id": "2998", "name": "陇西县", "code": "621122", "deep": "3", "pid": "2995" }, { "id": "2999", "name": "渭源县", "code": "621123", "deep": "3", "pid": "2995" }, { "id": "3000", "name": "临洮县", "code": "621124", "deep": "3", "pid": "2995" }, { "id": "3001", "name": "漳县", "code": "621125", "deep": "3", "pid": "2995" }, { "id": "3002", "name": "岷县", "code": "621126", "deep": "3", "pid": "2995" } ] }, { "id": "3003", "name": "陇南市", "code": "621200", "deep": "2", "pid": "2930", "area": [ { "id": "3004", "name": "武都区", "code": "621202", "deep": "3", "pid": "3003" }, { "id": "3005", "name": "成县", "code": "621221", "deep": "3", "pid": "3003" }, { "id": "3006", "name": "文县", "code": "621222", "deep": "3", "pid": "3003" }, { "id": "3007", "name": "宕昌县", "code": "621223", "deep": "3", "pid": "3003" }, { "id": "3008", "name": "康县", "code": "621224", "deep": "3", "pid": "3003" }, { "id": "3009", "name": "西和县", "code": "621225", "deep": "3", "pid": "3003" }, { "id": "3010", "name": "礼县", "code": "621226", "deep": "3", "pid": "3003" }, { "id": "3011", "name": "徽县", "code": "621227", "deep": "3", "pid": "3003" }, { "id": "3012", "name": "两当县", "code": "621228", "deep": "3", "pid": "3003" } ] }, { "id": "3013", "name": "临夏回族自治州", "code": "622900", "deep": "2", "pid": "2930", "area": [ { "id": "3014", "name": "临夏市", "code": "622901", "deep": "3", "pid": "3013" }, { "id": "3015", "name": "临夏县", "code": "622921", "deep": "3", "pid": "3013" }, { "id": "3016", "name": "康乐县", "code": "622922", "deep": "3", "pid": "3013" }, { "id": "3017", "name": "永靖县", "code": "622923", "deep": "3", "pid": "3013" }, { "id": "3018", "name": "广河县", "code": "622924", "deep": "3", "pid": "3013" }, { "id": "3019", "name": "和政县", "code": "622925", "deep": "3", "pid": "3013" }, { "id": "3020", "name": "东乡族自治县", "code": "622926", "deep": "3", "pid": "3013" }, { "id": "3021", "name": "积石山保安族东乡族撒拉族自治县", "code": "622927", "deep": "3", "pid": "3013" } ] }, { "id": "3022", "name": "甘南藏族自治州", "code": "623000", "deep": "2", "pid": "2930", "area": [ { "id": "3023", "name": "合作市", "code": "623001", "deep": "3", "pid": "3022" }, { "id": "3024", "name": "临潭县", "code": "623021", "deep": "3", "pid": "3022" }, { "id": "3025", "name": "卓尼县", "code": "623022", "deep": "3", "pid": "3022" }, { "id": "3026", "name": "舟曲县", "code": "623023", "deep": "3", "pid": "3022" }, { "id": "3027", "name": "迭部县", "code": "623024", "deep": "3", "pid": "3022" }, { "id": "3028", "name": "玛曲县", "code": "623025", "deep": "3", "pid": "3022" }, { "id": "3029", "name": "碌曲县", "code": "623026", "deep": "3", "pid": "3022" }, { "id": "3030", "name": "夏河县", "code": "623027", "deep": "3", "pid": "3022" } ] }, { "id": "3495", "name": "嘉峪关市", "code": "620201", "deep": "2", "pid": "2930", "area": [ { "id": "3496", "name": "新城镇", "code": "620201100", "deep": "3", "pid": "3495" }, { "id": "3497", "name": "峪泉镇", "code": "620201101", "deep": "3", "pid": "3495" }, { "id": "3498", "name": "文殊镇", "code": "620201102", "deep": "3", "pid": "3495" }, { "id": "3499", "name": "雄关区", "code": "620201401", "deep": "3", "pid": "3495" }, { "id": "3500", "name": "镜铁区", "code": "620201402", "deep": "3", "pid": "3495" }, { "id": "3501", "name": "长城区", "code": "620201403", "deep": "3", "pid": "3495" } ] } ] }, { "id": "3031", "name": "青海省", "code": "630000", "deep": "1", "pid": "0", "city": [ { "id": "3032", "name": "西宁市", "code": "630100", "deep": "2", "pid": "3031", "area": [ { "id": "3033", "name": "城东区", "code": "630102", "deep": "3", "pid": "3032" }, { "id": "3034", "name": "城中区", "code": "630103", "deep": "3", "pid": "3032" }, { "id": "3035", "name": "城西区", "code": "630104", "deep": "3", "pid": "3032" }, { "id": "3036", "name": "城北区", "code": "630105", "deep": "3", "pid": "3032" }, { "id": "3037", "name": "大通回族土族自治县", "code": "630121", "deep": "3", "pid": "3032" }, { "id": "3038", "name": "湟中县", "code": "630122", "deep": "3", "pid": "3032" }, { "id": "3039", "name": "湟源县", "code": "630123", "deep": "3", "pid": "3032" } ] }, { "id": "3040", "name": "海东市", "code": "630200", "deep": "2", "pid": "3031", "area": [ { "id": "3041", "name": "乐都区", "code": "630202", "deep": "3", "pid": "3040" }, { "id": "3042", "name": "平安区", "code": "630203", "deep": "3", "pid": "3040" }, { "id": "3043", "name": "民和回族土族自治县", "code": "630222", "deep": "3", "pid": "3040" }, { "id": "3044", "name": "互助土族自治县", "code": "630223", "deep": "3", "pid": "3040" }, { "id": "3045", "name": "化隆回族自治县", "code": "630224", "deep": "3", "pid": "3040" }, { "id": "3046", "name": "循化撒拉族自治县", "code": "630225", "deep": "3", "pid": "3040" } ] }, { "id": "3047", "name": "海北藏族自治州", "code": "632200", "deep": "2", "pid": "3031", "area": [ { "id": "3048", "name": "门源回族自治县", "code": "632221", "deep": "3", "pid": "3047" }, { "id": "3049", "name": "祁连县", "code": "632222", "deep": "3", "pid": "3047" }, { "id": "3050", "name": "海晏县", "code": "632223", "deep": "3", "pid": "3047" }, { "id": "3051", "name": "刚察县", "code": "632224", "deep": "3", "pid": "3047" } ] }, { "id": "3052", "name": "黄南藏族自治州", "code": "632300", "deep": "2", "pid": "3031", "area": [ { "id": "3053", "name": "同仁县", "code": "632321", "deep": "3", "pid": "3052" }, { "id": "3054", "name": "尖扎县", "code": "632322", "deep": "3", "pid": "3052" }, { "id": "3055", "name": "泽库县", "code": "632323", "deep": "3", "pid": "3052" }, { "id": "3056", "name": "河南蒙古族自治县", "code": "632324", "deep": "3", "pid": "3052" } ] }, { "id": "3057", "name": "海南藏族自治州", "code": "632500", "deep": "2", "pid": "3031", "area": [ { "id": "3058", "name": "共和县", "code": "632521", "deep": "3", "pid": "3057" }, { "id": "3059", "name": "同德县", "code": "632522", "deep": "3", "pid": "3057" }, { "id": "3060", "name": "贵德县", "code": "632523", "deep": "3", "pid": "3057" }, { "id": "3061", "name": "兴海县", "code": "632524", "deep": "3", "pid": "3057" }, { "id": "3062", "name": "贵南县", "code": "632525", "deep": "3", "pid": "3057" } ] }, { "id": "3063", "name": "果洛藏族自治州", "code": "632600", "deep": "2", "pid": "3031", "area": [ { "id": "3064", "name": "玛沁县", "code": "632621", "deep": "3", "pid": "3063" }, { "id": "3065", "name": "班玛县", "code": "632622", "deep": "3", "pid": "3063" }, { "id": "3066", "name": "甘德县", "code": "632623", "deep": "3", "pid": "3063" }, { "id": "3067", "name": "达日县", "code": "632624", "deep": "3", "pid": "3063" }, { "id": "3068", "name": "久治县", "code": "632625", "deep": "3", "pid": "3063" }, { "id": "3069", "name": "玛多县", "code": "632626", "deep": "3", "pid": "3063" } ] }, { "id": "3070", "name": "玉树藏族自治州", "code": "632700", "deep": "2", "pid": "3031", "area": [ { "id": "3071", "name": "玉树市", "code": "632701", "deep": "3", "pid": "3070" }, { "id": "3072", "name": "杂多县", "code": "632722", "deep": "3", "pid": "3070" }, { "id": "3073", "name": "称多县", "code": "632723", "deep": "3", "pid": "3070" }, { "id": "3074", "name": "治多县", "code": "632724", "deep": "3", "pid": "3070" }, { "id": "3075", "name": "囊谦县", "code": "632725", "deep": "3", "pid": "3070" }, { "id": "3076", "name": "曲麻莱县", "code": "632726", "deep": "3", "pid": "3070" } ] }, { "id": "3077", "name": "海西蒙古族藏族自治州", "code": "632800", "deep": "2", "pid": "3031", "area": [ { "id": "3078", "name": "格尔木市", "code": "632801", "deep": "3", "pid": "3077" }, { "id": "3079", "name": "德令哈市", "code": "632802", "deep": "3", "pid": "3077" }, { "id": "3080", "name": "乌兰县", "code": "632821", "deep": "3", "pid": "3077" }, { "id": "3081", "name": "都兰县", "code": "632822", "deep": "3", "pid": "3077" }, { "id": "3082", "name": "天峻县", "code": "632823", "deep": "3", "pid": "3077" }, { "id": "3083", "name": "海西蒙古族藏族自治州直辖", "code": "632825", "deep": "3", "pid": "3077" } ] } ] }, { "id": "3084", "name": "宁夏回族自治区", "code": "640000", "deep": "1", "pid": "0", "city": [ { "id": "3085", "name": "银川市", "code": "640100", "deep": "2", "pid": "3084", "area": [ { "id": "3086", "name": "兴庆区", "code": "640104", "deep": "3", "pid": "3085" }, { "id": "3087", "name": "西夏区", "code": "640105", "deep": "3", "pid": "3085" }, { "id": "3088", "name": "金凤区", "code": "640106", "deep": "3", "pid": "3085" }, { "id": "3089", "name": "永宁县", "code": "640121", "deep": "3", "pid": "3085" }, { "id": "3090", "name": "贺兰县", "code": "640122", "deep": "3", "pid": "3085" }, { "id": "3091", "name": "灵武市", "code": "640181", "deep": "3", "pid": "3085" } ] }, { "id": "3092", "name": "石嘴山市", "code": "640200", "deep": "2", "pid": "3084", "area": [ { "id": "3093", "name": "大武口区", "code": "640202", "deep": "3", "pid": "3092" }, { "id": "3094", "name": "惠农区", "code": "640205", "deep": "3", "pid": "3092" }, { "id": "3095", "name": "平罗县", "code": "640221", "deep": "3", "pid": "3092" } ] }, { "id": "3096", "name": "吴忠市", "code": "640300", "deep": "2", "pid": "3084", "area": [ { "id": "3097", "name": "利通区", "code": "640302", "deep": "3", "pid": "3096" }, { "id": "3098", "name": "红寺堡区", "code": "640303", "deep": "3", "pid": "3096" }, { "id": "3099", "name": "盐池县", "code": "640323", "deep": "3", "pid": "3096" }, { "id": "3100", "name": "同心县", "code": "640324", "deep": "3", "pid": "3096" }, { "id": "3101", "name": "青铜峡市", "code": "640381", "deep": "3", "pid": "3096" } ] }, { "id": "3102", "name": "固原市", "code": "640400", "deep": "2", "pid": "3084", "area": [ { "id": "3103", "name": "原州区", "code": "640402", "deep": "3", "pid": "3102" }, { "id": "3104", "name": "西吉县", "code": "640422", "deep": "3", "pid": "3102" }, { "id": "3105", "name": "隆德县", "code": "640423", "deep": "3", "pid": "3102" }, { "id": "3106", "name": "泾源县", "code": "640424", "deep": "3", "pid": "3102" }, { "id": "3107", "name": "彭阳县", "code": "640425", "deep": "3", "pid": "3102" } ] }, { "id": "3108", "name": "中卫市", "code": "640500", "deep": "2", "pid": "3084", "area": [ { "id": "3109", "name": "沙坡头区", "code": "640502", "deep": "3", "pid": "3108" }, { "id": "3110", "name": "中宁县", "code": "640521", "deep": "3", "pid": "3108" }, { "id": "3111", "name": "海原县", "code": "640522", "deep": "3", "pid": "3108" } ] } ] }, { "id": "3112", "name": "新疆维吾尔自治区", "code": "650000", "deep": "1", "pid": "0", "city": [ { "id": "3113", "name": "乌鲁木齐市", "code": "650100", "deep": "2", "pid": "3112", "area": [ { "id": "3114", "name": "天山区", "code": "650102", "deep": "3", "pid": "3113" }, { "id": "3115", "name": "沙依巴克区", "code": "650103", "deep": "3", "pid": "3113" }, { "id": "3116", "name": "新市区", "code": "650104", "deep": "3", "pid": "3113" }, { "id": "3117", "name": "水磨沟区", "code": "650105", "deep": "3", "pid": "3113" }, { "id": "3118", "name": "头屯河区", "code": "650106", "deep": "3", "pid": "3113" }, { "id": "3119", "name": "达坂城区", "code": "650107", "deep": "3", "pid": "3113" }, { "id": "3120", "name": "米东区", "code": "650109", "deep": "3", "pid": "3113" }, { "id": "3121", "name": "乌鲁木齐县", "code": "650121", "deep": "3", "pid": "3113" } ] }, { "id": "3122", "name": "克拉玛依市", "code": "650200", "deep": "2", "pid": "3112", "area": [ { "id": "3123", "name": "独山子区", "code": "650202", "deep": "3", "pid": "3122" }, { "id": "3124", "name": "克拉玛依区", "code": "650203", "deep": "3", "pid": "3122" }, { "id": "3125", "name": "白碱滩区", "code": "650204", "deep": "3", "pid": "3122" }, { "id": "3126", "name": "乌尔禾区", "code": "650205", "deep": "3", "pid": "3122" } ] }, { "id": "3127", "name": "吐鲁番市", "code": "650400", "deep": "2", "pid": "3112", "area": [ { "id": "3128", "name": "高昌区", "code": "650402", "deep": "3", "pid": "3127" }, { "id": "3129", "name": "鄯善县", "code": "650421", "deep": "3", "pid": "3127" }, { "id": "3130", "name": "托克逊县", "code": "650422", "deep": "3", "pid": "3127" } ] }, { "id": "3131", "name": "哈密地区", "code": "652200", "deep": "2", "pid": "3112", "area": [ { "id": "3132", "name": "哈密市", "code": "652201", "deep": "3", "pid": "3131", "area": [ { "id": "3371", "name": "伊州区", "code": "650502", "deep": "3", "pid": "3132" } ] }, { "id": "3133", "name": "巴里坤哈萨克自治县", "code": "652222", "deep": "3", "pid": "3131" }, { "id": "3134", "name": "伊吾县", "code": "652223", "deep": "3", "pid": "3131" } ] }, { "id": "3135", "name": "昌吉回族自治州", "code": "652300", "deep": "2", "pid": "3112", "area": [ { "id": "3136", "name": "昌吉市", "code": "652301", "deep": "3", "pid": "3135" }, { "id": "3137", "name": "阜康市", "code": "652302", "deep": "3", "pid": "3135" }, { "id": "3138", "name": "呼图壁县", "code": "652323", "deep": "3", "pid": "3135" }, { "id": "3139", "name": "玛纳斯县", "code": "652324", "deep": "3", "pid": "3135" }, { "id": "3140", "name": "奇台县", "code": "652325", "deep": "3", "pid": "3135" }, { "id": "3141", "name": "吉木萨尔县", "code": "652327", "deep": "3", "pid": "3135" }, { "id": "3142", "name": "木垒哈萨克自治县", "code": "652328", "deep": "3", "pid": "3135" } ] }, { "id": "3143", "name": "博尔塔拉蒙古自治州", "code": "652700", "deep": "2", "pid": "3112", "area": [ { "id": "3144", "name": "博乐市", "code": "652701", "deep": "3", "pid": "3143" }, { "id": "3145", "name": "阿拉山口市", "code": "652702", "deep": "3", "pid": "3143" }, { "id": "3146", "name": "精河县", "code": "652722", "deep": "3", "pid": "3143" }, { "id": "3147", "name": "温泉县", "code": "652723", "deep": "3", "pid": "3143" } ] }, { "id": "3148", "name": "巴音郭楞蒙古自治州", "code": "652800", "deep": "2", "pid": "3112", "area": [ { "id": "3149", "name": "库尔勒市", "code": "652801", "deep": "3", "pid": "3148" }, { "id": "3150", "name": "轮台县", "code": "652822", "deep": "3", "pid": "3148" }, { "id": "3151", "name": "尉犁县", "code": "652823", "deep": "3", "pid": "3148" }, { "id": "3152", "name": "若羌县", "code": "652824", "deep": "3", "pid": "3148" }, { "id": "3153", "name": "且末县", "code": "652825", "deep": "3", "pid": "3148" }, { "id": "3154", "name": "焉耆回族自治县", "code": "652826", "deep": "3", "pid": "3148" }, { "id": "3155", "name": "和静县", "code": "652827", "deep": "3", "pid": "3148" }, { "id": "3156", "name": "和硕县", "code": "652828", "deep": "3", "pid": "3148" }, { "id": "3157", "name": "博湖县", "code": "652829", "deep": "3", "pid": "3148" } ] }, { "id": "3158", "name": "阿克苏地区", "code": "652900", "deep": "2", "pid": "3112", "area": [ { "id": "3159", "name": "阿克苏市", "code": "652901", "deep": "3", "pid": "3158" }, { "id": "3160", "name": "温宿县", "code": "652922", "deep": "3", "pid": "3158" }, { "id": "3161", "name": "库车县", "code": "652923", "deep": "3", "pid": "3158" }, { "id": "3162", "name": "沙雅县", "code": "652924", "deep": "3", "pid": "3158" }, { "id": "3163", "name": "新和县", "code": "652925", "deep": "3", "pid": "3158" }, { "id": "3164", "name": "拜城县", "code": "652926", "deep": "3", "pid": "3158" }, { "id": "3165", "name": "乌什县", "code": "652927", "deep": "3", "pid": "3158" }, { "id": "3166", "name": "阿瓦提县", "code": "652928", "deep": "3", "pid": "3158" }, { "id": "3167", "name": "柯坪县", "code": "652929", "deep": "3", "pid": "3158" } ] }, { "id": "3168", "name": "克孜勒苏柯尔克孜自治州", "code": "653000", "deep": "2", "pid": "3112", "area": [ { "id": "3169", "name": "阿图什市", "code": "653001", "deep": "3", "pid": "3168" }, { "id": "3170", "name": "阿克陶县", "code": "653022", "deep": "3", "pid": "3168" }, { "id": "3171", "name": "阿合奇县", "code": "653023", "deep": "3", "pid": "3168" }, { "id": "3172", "name": "乌恰县", "code": "653024", "deep": "3", "pid": "3168" } ] }, { "id": "3173", "name": "喀什地区", "code": "653100", "deep": "2", "pid": "3112", "area": [ { "id": "3174", "name": "喀什市", "code": "653101", "deep": "3", "pid": "3173" }, { "id": "3175", "name": "疏附县", "code": "653121", "deep": "3", "pid": "3173" }, { "id": "3176", "name": "疏勒县", "code": "653122", "deep": "3", "pid": "3173" }, { "id": "3177", "name": "英吉沙县", "code": "653123", "deep": "3", "pid": "3173" }, { "id": "3178", "name": "泽普县", "code": "653124", "deep": "3", "pid": "3173" }, { "id": "3179", "name": "莎车县", "code": "653125", "deep": "3", "pid": "3173" }, { "id": "3180", "name": "叶城县", "code": "653126", "deep": "3", "pid": "3173" }, { "id": "3181", "name": "麦盖提县", "code": "653127", "deep": "3", "pid": "3173" }, { "id": "3182", "name": "岳普湖县", "code": "653128", "deep": "3", "pid": "3173" }, { "id": "3183", "name": "伽师县", "code": "653129", "deep": "3", "pid": "3173" }, { "id": "3184", "name": "巴楚县", "code": "653130", "deep": "3", "pid": "3173" }, { "id": "3185", "name": "塔什库尔干塔吉克自治县", "code": "653131", "deep": "3", "pid": "3173" } ] }, { "id": "3186", "name": "和田地区", "code": "653200", "deep": "2", "pid": "3112", "area": [ { "id": "3187", "name": "和田市", "code": "653201", "deep": "3", "pid": "3186" }, { "id": "3188", "name": "和田县", "code": "653221", "deep": "3", "pid": "3186" }, { "id": "3189", "name": "墨玉县", "code": "653222", "deep": "3", "pid": "3186" }, { "id": "3190", "name": "皮山县", "code": "653223", "deep": "3", "pid": "3186" }, { "id": "3191", "name": "洛浦县", "code": "653224", "deep": "3", "pid": "3186" }, { "id": "3192", "name": "策勒县", "code": "653225", "deep": "3", "pid": "3186" }, { "id": "3193", "name": "于田县", "code": "653226", "deep": "3", "pid": "3186" }, { "id": "3194", "name": "民丰县", "code": "653227", "deep": "3", "pid": "3186" } ] }, { "id": "3195", "name": "伊犁哈萨克自治州", "code": "654000", "deep": "2", "pid": "3112", "area": [ { "id": "3196", "name": "伊宁市", "code": "654002", "deep": "3", "pid": "3195" }, { "id": "3197", "name": "奎屯市", "code": "654003", "deep": "3", "pid": "3195" }, { "id": "3198", "name": "霍尔果斯市", "code": "654004", "deep": "3", "pid": "3195" }, { "id": "3199", "name": "伊宁县", "code": "654021", "deep": "3", "pid": "3195" }, { "id": "3200", "name": "察布查尔锡伯自治县", "code": "654022", "deep": "3", "pid": "3195" }, { "id": "3201", "name": "霍城县", "code": "654023", "deep": "3", "pid": "3195" }, { "id": "3202", "name": "巩留县", "code": "654024", "deep": "3", "pid": "3195" }, { "id": "3203", "name": "新源县", "code": "654025", "deep": "3", "pid": "3195" }, { "id": "3204", "name": "昭苏县", "code": "654026", "deep": "3", "pid": "3195" }, { "id": "3205", "name": "特克斯县", "code": "654027", "deep": "3", "pid": "3195" }, { "id": "3206", "name": "尼勒克县", "code": "654028", "deep": "3", "pid": "3195" } ] }, { "id": "3207", "name": "塔城地区", "code": "654200", "deep": "2", "pid": "3112", "area": [ { "id": "3208", "name": "塔城市", "code": "654201", "deep": "3", "pid": "3207" }, { "id": "3209", "name": "乌苏市", "code": "654202", "deep": "3", "pid": "3207" }, { "id": "3210", "name": "额敏县", "code": "654221", "deep": "3", "pid": "3207" }, { "id": "3211", "name": "沙湾县", "code": "654223", "deep": "3", "pid": "3207" }, { "id": "3212", "name": "托里县", "code": "654224", "deep": "3", "pid": "3207" }, { "id": "3213", "name": "裕民县", "code": "654225", "deep": "3", "pid": "3207" }, { "id": "3214", "name": "和布克赛尔蒙古自治县", "code": "654226", "deep": "3", "pid": "3207" } ] }, { "id": "3215", "name": "阿勒泰地区", "code": "654300", "deep": "2", "pid": "3112", "area": [ { "id": "3216", "name": "阿勒泰市", "code": "654301", "deep": "3", "pid": "3215" }, { "id": "3217", "name": "布尔津县", "code": "654321", "deep": "3", "pid": "3215" }, { "id": "3218", "name": "富蕴县", "code": "654322", "deep": "3", "pid": "3215" }, { "id": "3219", "name": "福海县", "code": "654323", "deep": "3", "pid": "3215" }, { "id": "3220", "name": "哈巴河县", "code": "654324", "deep": "3", "pid": "3215" }, { "id": "3221", "name": "青河县", "code": "654325", "deep": "3", "pid": "3215" }, { "id": "3222", "name": "吉木乃县", "code": "654326", "deep": "3", "pid": "3215" } ] }, { "id": "3223", "name": "石河子市", "code": "659001", "deep": "2", "pid": "3112" }, { "id": "3224", "name": "阿拉尔市", "code": "659002", "deep": "2", "pid": "3112" }, { "id": "3225", "name": "图木舒克市", "code": "659003", "deep": "2", "pid": "3112" }, { "id": "3226", "name": "五家渠市", "code": "659004", "deep": "2", "pid": "3112" }, { "id": "3227", "name": "北屯市", "code": "659005", "deep": "2", "pid": "3112" }, { "id": "3228", "name": "铁门关市", "code": "659006", "deep": "2", "pid": "3112" }, { "id": "3229", "name": "双河市", "code": "659007", "deep": "2", "pid": "3112" }, { "id": "3230", "name": "可克达拉市", "code": "659008", "deep": "2", "pid": "3112" }, { "id": "3372", "name": "昆玉市", "code": "659009", "deep": "2", "pid": "3112" }, { "id": "3502", "name": "哈密市", "code": "650500", "deep": "2", "pid": "3112", "area": [ { "id": "3503", "name": "巴里坤哈萨克自治县", "code": "650521", "deep": "3", "pid": "3502" }, { "id": "3504", "name": "伊吾县", "code": "650522", "deep": "3", "pid": "3502" } ] }, { "id": "3505", "name": "自治区直辖县级行政区划", "code": "659000", "deep": "2", "pid": "3112" } ] }, { "id": "3231", "name": "台湾省", "code": "710000", "deep": "1", "pid": "0", "city": [ { "id": "3507", "name": "新北市", "code": "71001", "deep": "2", "pid": "3231", "area": [ { "id": "10004", "name": "城区", "code": "10004", "deep": "3", "pid": "3507" } ] }, { "id": "3508", "name": "台北市", "code": "71002", "deep": "2", "pid": "3231", "area": [ { "id": "10005", "name": "城区", "code": "10005", "deep": "3", "pid": "3508" } ] }, { "id": "3509", "name": "台中市", "code": "71003", "deep": "2", "pid": "3231", "area": [ { "id": "10006", "name": "城区", "code": "10006", "deep": "3", "pid": "3509" } ] }, { "id": "3510", "name": "高雄市", "code": "71004", "deep": "2", "pid": "3231", "area": [ { "id": "10007", "name": "城区", "code": "10007", "deep": "3", "pid": "3510" } ] }, { "id": "3511", "name": "基隆市", "code": "71005", "deep": "2", "pid": "3231", "area": [ { "id": "10008", "name": "城区", "code": "10008", "deep": "3", "pid": "3511" } ] }, { "id": "3512", "name": "嘉义市", "code": "71006", "deep": "2", "pid": "3231", "area": [ { "id": "10009", "name": "城区", "code": "10009", "deep": "3", "pid": "3512" } ] }, { "id": "3513", "name": "台南市", "code": "71007", "deep": "2", "pid": "3231", "area": [ { "id": "10010", "name": "城区", "code": "10010", "deep": "3", "pid": "3513" } ] }, { "id": "3514", "name": "新竹市", "code": "71008", "deep": "2", "pid": "3231", "area": [ { "id": "3516", "name": "新竹县", "code": "71010", "deep": "3", "pid": "3514", "area": [ { "id": "10013", "name": "城区", "code": "10013", "deep": "3", "pid": "3516" } ] }, { "id": "10011", "name": "城区", "code": "10011", "deep": "3", "pid": "3514" } ] }, { "id": "3515", "name": "桃园市", "code": "71009", "deep": "2", "pid": "3231", "area": [ { "id": "10012", "name": "城区", "code": "10012", "deep": "3", "pid": "3515" } ] }, { "id": "3517", "name": "澎湖县", "code": "71011", "deep": "2", "pid": "3231", "area": [ { "id": "10014", "name": "城区", "code": "10014", "deep": "3", "pid": "3517" } ] }, { "id": "3518", "name": "宜兰县", "code": "71012", "deep": "2", "pid": "3231", "area": [ { "id": "10015", "name": "城区", "code": "10015", "deep": "3", "pid": "3518" } ] }, { "id": "3519", "name": "彰化县", "code": "71013", "deep": "2", "pid": "3231", "area": [ { "id": "10016", "name": "城区", "code": "10016", "deep": "3", "pid": "3519" } ] }, { "id": "3520", "name": "台东县", "code": "71014", "deep": "2", "pid": "3231", "area": [ { "id": "10017", "name": "城区", "code": "10017", "deep": "3", "pid": "3520" } ] }, { "id": "3521", "name": "屏东县", "code": "71015", "deep": "2", "pid": "3231", "area": [ { "id": "10018", "name": "城区", "code": "10018", "deep": "3", "pid": "3521" } ] }, { "id": "3522", "name": "花莲县", "code": "71016", "deep": "2", "pid": "3231", "area": [ { "id": "10019", "name": "城区", "code": "10019", "deep": "3", "pid": "3522" } ] }, { "id": "3523", "name": "苗栗县", "code": "71017", "deep": "2", "pid": "3231", "area": [ { "id": "10020", "name": "城区", "code": "10020", "deep": "3", "pid": "3523" } ] }, { "id": "3524", "name": "云林县", "code": "71018", "deep": "2", "pid": "3231", "area": [ { "id": "10021", "name": "城区", "code": "10021", "deep": "3", "pid": "3524" } ] }, { "id": "3525", "name": "南投县", "code": "71019", "deep": "2", "pid": "3231", "area": [ { "id": "10022", "name": "城区", "code": "10022", "deep": "3", "pid": "3525" } ] } ] }, { "id": "3232", "name": "香港特别行政区", "code": "810000", "deep": "1", "pid": "0", "city": [ { "id": "3233", "name": "中西区", "code": "810001", "deep": "2", "pid": "3232", "area": [ { "id": "10023", "name": "城区", "code": "10023", "deep": "3", "pid": "3233" } ] }, { "id": "3234", "name": "湾仔区", "code": "810002", "deep": "2", "pid": "3232", "area": [ { "id": "10024", "name": "城区", "code": "10024", "deep": "3", "pid": "3234" } ] }, { "id": "3235", "name": "东区", "code": "810003", "deep": "2", "pid": "3232", "area": [ { "id": "10025", "name": "城区", "code": "10025", "deep": "3", "pid": "3235" } ] }, { "id": "3236", "name": "南区", "code": "810004", "deep": "2", "pid": "3232", "area": [ { "id": "10026", "name": "城区", "code": "10026", "deep": "3", "pid": "3236" } ] }, { "id": "3237", "name": "油尖旺区", "code": "810005", "deep": "2", "pid": "3232", "area": [ { "id": "10027", "name": "城区", "code": "10027", "deep": "3", "pid": "3237" } ] }, { "id": "3238", "name": "深水埗区", "code": "810006", "deep": "2", "pid": "3232", "area": [ { "id": "10028", "name": "城区", "code": "10028", "deep": "3", "pid": "3238" } ] }, { "id": "3239", "name": "九龙城区", "code": "810007", "deep": "2", "pid": "3232", "area": [ { "id": "10029", "name": "城区", "code": "10029", "deep": "3", "pid": "3239" } ] }, { "id": "3240", "name": "黄大仙区", "code": "810008", "deep": "2", "pid": "3232", "area": [ { "id": "10030", "name": "城区", "code": "10030", "deep": "3", "pid": "3240" } ] }, { "id": "3241", "name": "观塘区", "code": "810009", "deep": "2", "pid": "3232", "area": [ { "id": "10031", "name": "城区", "code": "10031", "deep": "3", "pid": "3241" } ] }, { "id": "3242", "name": "荃湾区", "code": "810010", "deep": "2", "pid": "3232", "area": [ { "id": "10032", "name": "城区", "code": "10032", "deep": "3", "pid": "3242" } ] }, { "id": "3243", "name": "屯门区", "code": "810011", "deep": "2", "pid": "3232", "area": [ { "id": "10033", "name": "城区", "code": "10033", "deep": "3", "pid": "3243" } ] }, { "id": "3244", "name": "元朗区", "code": "810012", "deep": "2", "pid": "3232", "area": [ { "id": "10034", "name": "城区", "code": "10034", "deep": "3", "pid": "3244" } ] }, { "id": "3245", "name": "北区", "code": "810013", "deep": "2", "pid": "3232", "area": [ { "id": "10035", "name": "城区", "code": "10035", "deep": "3", "pid": "3245" } ] }, { "id": "3246", "name": "大埔区", "code": "810014", "deep": "2", "pid": "3232", "area": [ { "id": "10036", "name": "城区", "code": "10036", "deep": "3", "pid": "3246" } ] }, { "id": "3247", "name": "西贡区", "code": "810015", "deep": "2", "pid": "3232", "area": [ { "id": "10037", "name": "城区", "code": "10037", "deep": "3", "pid": "3247" } ] }, { "id": "3248", "name": "沙田区", "code": "810016", "deep": "2", "pid": "3232", "area": [ { "id": "10038", "name": "城区", "code": "10038", "deep": "3", "pid": "3248" } ] }, { "id": "3249", "name": "葵青区", "code": "810017", "deep": "2", "pid": "3232", "area": [ { "id": "10039", "name": "城区", "code": "10039", "deep": "3", "pid": "3249" } ] }, { "id": "3250", "name": "离岛区", "code": "810018", "deep": "2", "pid": "3232", "area": [ { "id": "10040", "name": "城区", "code": "10040", "deep": "3", "pid": "3250" } ] } ] }, { "id": "3251", "name": "澳门特别行政区", "code": "820000", "deep": "1", "pid": "0", "city": [ { "id": "3252", "name": "花地玛堂区", "code": "820001", "deep": "2", "pid": "3251", "area": [ { "id": "10041", "name": "城区", "code": "10041", "deep": "3", "pid": "3252" } ] }, { "id": "3253", "name": "花王堂区", "code": "820002", "deep": "2", "pid": "3251", "area": [ { "id": "10042", "name": "城区", "code": "10042", "deep": "3", "pid": "3253" } ] }, { "id": "3254", "name": "望德堂区", "code": "820003", "deep": "2", "pid": "3251", "area": [ { "id": "10043", "name": "城区", "code": "10043", "deep": "3", "pid": "3254" } ] }, { "id": "3255", "name": "大堂区", "code": "820004", "deep": "2", "pid": "3251", "area": [ { "id": "10044", "name": "城区", "code": "10044", "deep": "3", "pid": "3255" } ] }, { "id": "3256", "name": "风顺堂区", "code": "820005", "deep": "2", "pid": "3251", "area": [ { "id": "10045", "name": "城区", "code": "10045", "deep": "3", "pid": "3256" } ] }, { "id": "3257", "name": "嘉模堂区", "code": "820006", "deep": "2", "pid": "3251", "area": [ { "id": "10046", "name": "城区", "code": "10046", "deep": "3", "pid": "3257" } ] }, { "id": "3258", "name": "路凼填海区", "code": "820007", "deep": "2", "pid": "3251", "area": [ { "id": "10047", "name": "城区", "code": "10047", "deep": "3", "pid": "3258" } ] }, { "id": "3259", "name": "圣方济各堂区", "code": "820008", "deep": "2", "pid": "3251", "area": [ { "id": "10048", "name": "城区", "code": "10048", "deep": "3", "pid": "3259" } ] } ] } ] ================================================ FILE: app/src/main/assets/city.txt ================================================ 110000,北京市;110100,市辖区;110101,东城区;110102,西城区;110103,崇文区;110104,宣武区;110105,朝阳区;110106,丰台区;110107,石景山区;110108,海淀区;110109,门头沟区;110111,房山区;110112,通州区;110113,顺义区;110114,昌平区;110115,大兴区;110116,怀柔区;110117,平谷区;110200,县;110228,密云县;110229,延庆县;120000,天津市;120100,市辖区;120101,和平区;120102,河东区;120103,河西区;120104,南开区;120105,河北区;120106,红桥区;120107,塘沽区;120108,汉沽区;120109,大港区;120110,东丽区;120111,西青区;120112,津南区;120113,北辰区;120114,武清区;120115,宝坻区;120200,县;120221,宁河县;120223,静海县;120225,蓟县;130000,河北省;130100,石家庄市;130101,市辖区;130102,长安区;130103,桥东区;130104,桥西区;130105,新华区;130107,井陉矿区;130108,裕华区;130121,井陉县;130123,正定县;130124,栾城县;130125,行唐县;130126,灵寿县;130127,高邑县;130128,深泽县;130129,赞皇县;130130,无极县;130131,平山县;130132,元氏县;130133,赵县;130181,辛集市;130182,藁城市;130183,晋州市;130184,新乐市;130185,鹿泉市;130200,唐山市;130201,市辖区;130202,路南区;130203,路北区;130204,古冶区;130205,开平区;130207,丰南区;130208,丰润区;130223,滦县;130224,滦南县;130225,乐亭县;130227,迁西县;130229,玉田县;130230,唐海县;130281,遵化市;130283,迁安市;130300,秦皇岛市;130301,市辖区;130302,海港区;130303,山海关区;130304,北戴河区;130321,青龙满族自治县;130322,昌黎县;130323,抚宁县;130324,卢龙县;130400,邯郸市;130401,市辖区;130402,邯山区;130403,丛台区;130404,复兴区;130406,峰峰矿区;130421,邯郸县;130423,临漳县;130424,成安县;130425,大名县;130426,涉县;130427,磁县;130428,肥乡县;130429,永年县;130430,邱县;130431,鸡泽县;130432,广平县;130433,馆陶县;130434,魏县;130435,曲周县;130481,武安市;130500,邢台市;130501,市辖区;130502,桥东区;130503,桥西区;130521,邢台县;130522,临城县;130523,内丘县;130524,柏乡县;130525,隆尧县;130526,任县;130527,南和县;130528,宁晋县;130529,巨鹿县;130530,新河县;130531,广宗县;130532,平乡县;130533,威县;130534,清河县;130535,临西县;130581,南宫市;130582,沙河市;130600,保定市;130601,市辖区;130602,新市区;130603,北市区;130604,南市区;130621,满城县;130622,清苑县;130623,涞水县;130624,阜平县;130625,徐水县;130626,定兴县;130627,唐县;130628,高阳县;130629,容城县;130630,涞源县;130631,望都县;130632,安新县;130633,易县;130634,曲阳县;130635,蠡县;130636,顺平县;130637,博野县;130638,雄县;130681,涿州市;130682,定州市;130683,安国市;130684,高碑店市;130700,张家口市;130701,市辖区;130702,桥东区;130703,桥西区;130705,宣化区;130706,下花园区;130721,宣化县;130722,张北县;130723,康保县;130724,沽源县;130725,尚义县;130726,蔚县;130727,阳原县;130728,怀安县;130729,万全县;130730,怀来县;130731,涿鹿县;130732,赤城县;130733,崇礼县;130800,承德市;130801,市辖区;130802,双桥区;130803,双滦区;130804,鹰手营子矿区;130821,承德县;130822,兴隆县;130823,平泉县;130824,滦平县;130825,隆化县;130826,丰宁满族自治县;130827,宽城满族自治县;130828,围场满族蒙古族自治县;130900,沧州市;130901,市辖区;130902,新华区;130903,运河区;130921,沧县;130922,青县;130923,东光县;130924,海兴县;130925,盐山县;130926,肃宁县;130927,南皮县;130928,吴桥县;130929,献县;130930,孟村回族自治县;130981,泊头市;130982,任丘市;130983,黄骅市;130984,河间市;131000,廊坊市;131001,市辖区;131002,安次区;131003,广阳区;131022,固安县;131023,永清县;131024,香河县;131025,大城县;131026,文安县;131028,大厂回族自治县;131081,霸州市;131082,三河市;131100,衡水市;131101,市辖区;131102,桃城区;131121,枣强县;131122,武邑县;131123,武强县;131124,饶阳县;131125,安平县;131126,故城县;131127,景县;131128,阜城县;131181,冀州市;131182,深州市;140000,山西省;140100,太原市;140101,市辖区;140105,小店区;140106,迎泽区;140107,杏花岭区;140108,尖草坪区;140109,万柏林区;140110,晋源区;140121,清徐县;140122,阳曲县;140123,娄烦县;140181,古交市;140200,大同市;140201,市辖区;140202,城区;140203,矿区;140211,南郊区;140212,新荣区;140221,阳高县;140222,天镇县;140223,广灵县;140224,灵丘县;140225,浑源县;140226,左云县;140227,大同县;140300,阳泉市;140301,市辖区;140302,城区;140303,矿区;140311,郊区;140321,平定县;140322,盂县;140400,长治市;140401,市辖区;140402,城区;140411,郊区;140421,长治县;140423,襄垣县;140424,屯留县;140425,平顺县;140426,黎城县;140427,壶关县;140428,长子县;140429,武乡县;140430,沁县;140431,沁源县;140481,潞城市;140500,晋城市;140501,市辖区;140502,城区;140521,沁水县;140522,阳城县;140524,陵川县;140525,泽州县;140581,高平市;140600,朔州市;140601,市辖区;140602,朔城区;140603,平鲁区;140621,山阴县;140622,应县;140623,右玉县;140624,怀仁县;140700,晋中市;140701,市辖区;140702,榆次区;140721,榆社县;140722,左权县;140723,和顺县;140724,昔阳县;140725,寿阳县;140726,太谷县;140727,祁县;140728,平遥县;140729,灵石县;140781,介休市;140800,运城市;140801,市辖区;140802,盐湖区;140821,临猗县;140822,万荣县;140823,闻喜县;140824,稷山县;140825,新绛县;140826,绛县;140827,垣曲县;140828,夏县;140829,平陆县;140830,芮城县;140881,永济市;140882,河津市;140900,忻州市;140901,市辖区;140902,忻府区;140921,定襄县;140922,五台县;140923,代县;140924,繁峙县;140925,宁武县;140926,静乐县;140927,神池县;140928,五寨县;140929,岢岚县;140930,河曲县;140931,保德县;140932,偏关县;140981,原平市;141000,临汾市;141001,市辖区;141002,尧都区;141021,曲沃县;141022,翼城县;141023,襄汾县;141024,洪洞县;141025,古县;141026,安泽县;141027,浮山县;141028,吉县;141029,乡宁县;141030,大宁县;141031,隰县;141032,永和县;141033,蒲县;141034,汾西县;141081,侯马市;141082,霍州市;141100,吕梁市;141101,市辖区;141102,离石区;141121,文水县;141122,交城县;141123,兴县;141124,临县;141125,柳林县;141126,石楼县;141127,岚县;141128,方山县;141129,中阳县;141130,交口县;141181,孝义市;141182,汾阳市;150000,内蒙古自治区;150100,呼和浩特市;150101,市辖区;150102,新城区;150103,回民区;150104,玉泉区;150105,赛罕区;150121,土默特左旗;150122,托克托县;150123,和林格尔县;150124,清水河县;150125,武川县;150200,包头市;150201,市辖区;150202,东河区;150203,昆都仑区;150204,青山区;150205,石拐区;150206,白云矿区;150207,九原区;150221,土默特右旗;150222,固阳县;150223,达尔罕茂明安联合旗;150300,乌海市;150301,市辖区;150302,海勃湾区;150303,海南区;150304,乌达区;150400,赤峰市;150401,市辖区;150402,红山区;150403,元宝山区;150404,松山区;150421,阿鲁科尔沁旗;150422,巴林左旗;150423,巴林右旗;150424,林西县;150425,克什克腾旗;150426,翁牛特旗;150428,喀喇沁旗;150429,宁城县;150430,敖汉旗;150500,通辽市;150501,市辖区;150502,科尔沁区;150521,科尔沁左翼中旗;150522,科尔沁左翼后旗;150523,开鲁县;150524,库伦旗;150525,奈曼旗;150526,扎鲁特旗;150581,霍林郭勒市;150600,鄂尔多斯市;150602,东胜区;150621,达拉特旗;150622,准格尔旗;150623,鄂托克前旗;150624,鄂托克旗;150625,杭锦旗;150626,乌审旗;150627,伊金霍洛旗;150700,呼伦贝尔市;150701,市辖区;150702,海拉尔区;150721,阿荣旗;150722,莫力达瓦达斡尔族自治旗;150723,鄂伦春自治旗;150724,鄂温克族自治旗;150725,陈巴尔虎旗;150726,新巴尔虎左旗;150727,新巴尔虎右旗;150781,满洲里市;150782,牙克石市;150783,扎兰屯市;150784,额尔古纳市;150785,根河市;150800,巴彦淖尔市;150801,市辖区;150802,临河区;150821,五原县;150822,磴口县;150823,乌拉特前旗;150824,乌拉特中旗;150825,乌拉特后旗;150826,杭锦后旗;150900,乌兰察布市;150901,市辖区;150902,集宁区;150921,卓资县;150922,化德县;150923,商都县;150924,兴和县;150925,凉城县;150926,察哈尔右翼前旗;150927,察哈尔右翼中旗;150928,察哈尔右翼后旗;150929,四子王旗;150981,丰镇市;152200,兴安盟;152201,乌兰浩特市;152202,阿尔山市;152221,科尔沁右翼前旗;152222,科尔沁右翼中旗;152223,扎赉特旗;152224,突泉县;152500,锡林郭勒盟;152501,二连浩特市;152502,锡林浩特市;152522,阿巴嘎旗;152523,苏尼特左旗;152524,苏尼特右旗;152525,东乌珠穆沁旗;152526,西乌珠穆沁旗;152527,太仆寺旗;152528,镶黄旗;152529,正镶白旗;152530,正蓝旗;152531,多伦县;152900,阿拉善盟;152921,阿拉善左旗;152922,阿拉善右旗;152923,额济纳旗;210000,辽宁省;210100,沈阳市;210101,市辖区;210102,和平区;210103,沈河区;210104,大东区;210105,皇姑区;210106,铁西区;210111,苏家屯区;210112,东陵区;210113,新城子区;210114,于洪区;210122,辽中县;210123,康平县;210124,法库县;210181,新民市;210200,大连市;210201,市辖区;210202,中山区;210203,西岗区;210204,沙河口区;210211,甘井子区;210212,旅顺口区;210213,金州区;210224,长海县;210281,瓦房店市;210282,普兰店市;210283,庄河市;210300,鞍山市;210301,市辖区;210302,铁东区;210303,铁西区;210304,立山区;210311,千山区;210321,台安县;210323,岫岩满族自治县;210381,海城市;210400,抚顺市;210401,市辖区;210402,新抚区;210403,东洲区;210404,望花区;210411,顺城区;210421,抚顺县;210422,新宾满族自治县;210423,清原满族自治县;210500,本溪市;210501,市辖区;210502,平山区;210503,溪湖区;210504,明山区;210505,南芬区;210521,本溪满族自治县;210522,桓仁满族自治县;210600,丹东市;210601,市辖区;210602,元宝区;210603,振兴区;210604,振安区;210624,宽甸满族自治县;210681,东港市;210682,凤城市;210700,锦州市;210701,市辖区;210702,古塔区;210703,凌河区;210711,太和区;210726,黑山县;210727,义县;210781,凌海市;210782,北宁市;210800,营口市;210801,市辖区;210802,站前区;210803,西市区;210804,鲅鱼圈区;210811,老边区;210881,盖州市;210882,大石桥市;210900,阜新市;210901,市辖区;210902,海州区;210903,新邱区;210904,太平区;210905,清河门区;210911,细河区;210921,阜新蒙古族自治县;210922,彰武县;211000,辽阳市;211001,市辖区;211002,白塔区;211003,文圣区;211004,宏伟区;211005,弓长岭区;211011,太子河区;211021,辽阳县;211081,灯塔市;211100,盘锦市;211101,市辖区;211102,双台子区;211103,兴隆台区;211121,大洼县;211122,盘山县;211200,铁岭市;211201,市辖区;211202,银州区;211204,清河区;211221,铁岭县;211223,西丰县;211224,昌图县;211281,调兵山市;211282,开原市;211300,朝阳市;211301,市辖区;211302,双塔区;211303,龙城区;211321,朝阳县;211322,建平县;211324,喀喇沁左翼蒙古族自治县;211381,北票市;211382,凌源市;211400,葫芦岛市;211401,市辖区;211402,连山区;211403,龙港区;211404,南票区;211421,绥中县;211422,建昌县;211481,兴城市;220000,吉林省;220100,长春市;220101,市辖区;220102,南关区;220103,宽城区;220104,朝阳区;220105,二道区;220106,绿园区;220112,双阳区;220122,农安县;220181,九台市;220182,榆树市;220183,德惠市;220200,吉林市;220201,市辖区;220202,昌邑区;220203,龙潭区;220204,船营区;220211,丰满区;220221,永吉县;220281,蛟河市;220282,桦甸市;220283,舒兰市;220284,磐石市;220300,四平市;220301,市辖区;220302,铁西区;220303,铁东区;220322,梨树县;220323,伊通满族自治县;220381,公主岭市;220382,双辽市;220400,辽源市;220401,市辖区;220402,龙山区;220403,西安区;220421,东丰县;220422,东辽县;220500,通化市;220501,市辖区;220502,东昌区;220503,二道江区;220521,通化县;220523,辉南县;220524,柳河县;220581,梅河口市;220582,集安市;220600,白山市;220601,市辖区;220602,八道江区;220621,抚松县;220622,靖宇县;220623,长白朝鲜族自治县;220625,江源县;220681,临江市;220700,松原市;220701,市辖区;220702,宁江区;220721,前郭尔罗斯蒙古族自治县;220722,长岭县;220723,乾安县;220724,扶余县;220800,白城市;220801,市辖区;220802,洮北区;220821,镇赉县;220822,通榆县;220881,洮南市;220882,大安市;222400,延边朝鲜族自治州;222401,延吉市;222402,图们市;222403,敦化市;222404,珲春市;222405,龙井市;222406,和龙市;222424,汪清县;222426,安图县;230000,黑龙江省;230100,哈尔滨市;230101,市辖区;230102,道里区;230103,南岗区;230104,道外区;230106,香坊区;230107,动力区;230108,平房区;230109,松北区;230111,呼兰区;230123,依兰县;230124,方正县;230125,宾县;230126,巴彦县;230127,木兰县;230128,通河县;230129,延寿县;230181,阿城市;230182,双城市;230183,尚志市;230184,五常市;230200,齐齐哈尔市;230201,市辖区;230202,龙沙区;230203,建华区;230204,铁锋区;230205,昂昂溪区;230206,富拉尔基区;230207,碾子山区;230208,梅里斯达斡尔族区;230221,龙江县;230223,依安县;230224,泰来县;230225,甘南县;230227,富裕县;230229,克山县;230230,克东县;230231,拜泉县;230281,讷河市;230300,鸡西市;230301,市辖区;230302,鸡冠区;230303,恒山区;230304,滴道区;230305,梨树区;230306,城子河区;230307,麻山区;230321,鸡东县;230381,虎林市;230382,密山市;230400,鹤岗市;230401,市辖区;230402,向阳区;230403,工农区;230404,南山区;230405,兴安区;230406,东山区;230407,兴山区;230421,萝北县;230422,绥滨县;230500,双鸭山市;230501,市辖区;230502,尖山区;230503,岭东区;230505,四方台区;230506,宝山区;230521,集贤县;230522,友谊县;230523,宝清县;230524,饶河县;230600,大庆市;230601,市辖区;230602,萨尔图区;230603,龙凤区;230604,让胡路区;230605,红岗区;230606,大同区;230621,肇州县;230622,肇源县;230623,林甸县;230624,杜尔伯特蒙古族自治县;230700,伊春市;230701,市辖区;230702,伊春区;230703,南岔区;230704,友好区;230705,西林区;230706,翠峦区;230707,新青区;230708,美溪区;230709,金山屯区;230710,五营区;230711,乌马河区;230712,汤旺河区;230713,带岭区;230714,乌伊岭区;230715,红星区;230716,上甘岭区;230722,嘉荫县;230781,铁力市;230800,佳木斯市;230801,市辖区;230802,永红区;230803,向阳区;230804,前进区;230805,东风区;230811,郊区;230822,桦南县;230826,桦川县;230828,汤原县;230833,抚远县;230881,同江市;230882,富锦市;230900,七台河市;230901,市辖区;230902,新兴区;230903,桃山区;230904,茄子河区;230921,勃利县;231000,牡丹江市;231001,市辖区;231002,东安区;231003,阳明区;231004,爱民区;231005,西安区;231024,东宁县;231025,林口县;231081,绥芬河市;231083,海林市;231084,宁安市;231085,穆棱市;231100,黑河市;231101,市辖区;231102,爱辉区;231121,嫩江县;231123,逊克县;231124,孙吴县;231181,北安市;231182,五大连池市;231200,绥化市;231201,市辖区;231202,北林区;231221,望奎县;231222,兰西县;231223,青冈县;231224,庆安县;231225,明水县;231226,绥棱县;231281,安达市;231282,肇东市;231283,海伦市;232700,大兴安岭地区;232721,呼玛县;232722,塔河县;232723,漠河县;310000,上海市;310100,市辖区;310101,黄浦区;310103,卢湾区;310104,徐汇区;310105,长宁区;310106,静安区;310107,普陀区;310108,闸北区;310109,虹口区;310110,杨浦区;310112,闵行区;310113,宝山区;310114,嘉定区;310115,浦东新区;310116,金山区;310117,松江区;310118,青浦区;310119,南汇区;310120,奉贤区;310200,县;310230,崇明县;320000,江苏省;320100,南京市;320101,市辖区;320102,玄武区;320103,白下区;320104,秦淮区;320105,建邺区;320106,鼓楼区;320107,下关区;320111,浦口区;320113,栖霞区;320114,雨花台区;320115,江宁区;320116,六合区;320124,溧水县;320125,高淳县;320200,无锡市;320201,市辖区;320202,崇安区;320203,南长区;320204,北塘区;320205,锡山区;320206,惠山区;320211,滨湖区;320281,江阴市;320282,宜兴市;320300,徐州市;320301,市辖区;320302,鼓楼区;320303,云龙区;320304,九里区;320305,贾汪区;320311,泉山区;320321,丰县;320322,沛县;320323,铜山县;320324,睢宁县;320381,新沂市;320382,邳州市;320400,常州市;320401,市辖区;320402,天宁区;320404,钟楼区;320405,戚墅堰区;320411,新北区;320412,武进区;320481,溧阳市;320482,金坛市;320500,苏州市;320501,市辖区;320502,沧浪区;320503,平江区;320504,金阊区;320505,虎丘区;320506,吴中区;320507,相城区;320581,常熟市;320582,张家港市;320583,昆山市;320584,吴江市;320585,太仓市;320600,南通市;320601,市辖区;320602,崇川区;320611,港闸区;320621,海安县;320623,如东县;320681,启东市;320682,如皋市;320683,通州市;320684,海门市;320700,连云港市;320701,市辖区;320703,连云区;320705,新浦区;320706,海州区;320721,赣榆县;320722,东海县;320723,灌云县;320724,灌南县;320800,淮安市;320801,市辖区;320802,清河区;320803,楚州区;320804,淮阴区;320811,清浦区;320826,涟水县;320829,洪泽县;320830,盱眙县;320831,金湖县;320900,盐城市;320901,市辖区;320902,亭湖区;320903,盐都区;320921,响水县;320922,滨海县;320923,阜宁县;320924,射阳县;320925,建湖县;320981,东台市;320982,大丰市;321000,扬州市;321001,市辖区;321002,广陵区;321003,邗江区;321011,维扬区;321023,宝应县;321081,仪征市;321084,高邮市;321088,江都市;321100,镇江市;321101,市辖区;321102,京口区;321111,润州区;321112,丹徒区;321181,丹阳市;321182,扬中市;321183,句容市;321200,泰州市;321201,市辖区;321202,海陵区;321203,高港区;321281,兴化市;321282,靖江市;321283,泰兴市;321284,姜堰市;321300,宿迁市;321301,市辖区;321302,宿城区;321311,宿豫区;321322,沭阳县;321323,泗阳县;321324,泗洪县;330000,浙江省;330100,杭州市;330101,市辖区;330102,上城区;330103,下城区;330104,江干区;330105,拱墅区;330106,西湖区;330108,滨江区;330109,萧山区;330110,余杭区;330122,桐庐县;330127,淳安县;330182,建德市;330183,富阳市;330185,临安市;330200,宁波市;330201,市辖区;330203,海曙区;330204,江东区;330205,江北区;330206,北仑区;330211,镇海区;330212,鄞州区;330225,象山县;330226,宁海县;330281,余姚市;330282,慈溪市;330283,奉化市;330300,温州市;330301,市辖区;330302,鹿城区;330303,龙湾区;330304,瓯海区;330322,洞头县;330324,永嘉县;330326,平阳县;330327,苍南县;330328,文成县;330329,泰顺县;330381,瑞安市;330382,乐清市;330400,嘉兴市;330401,市辖区;330402,秀城区;330411,秀洲区;330421,嘉善县;330424,海盐县;330481,海宁市;330482,平湖市;330483,桐乡市;330500,湖州市;330501,市辖区;330502,吴兴区;330503,南浔区;330521,德清县;330522,长兴县;330523,安吉县;330600,绍兴市;330601,市辖区;330602,越城区;330621,绍兴县;330624,新昌县;330681,诸暨市;330682,上虞市;330683,嵊州市;330700,金华市;330701,市辖区;330702,婺城区;330703,金东区;330723,武义县;330726,浦江县;330727,磐安县;330781,兰溪市;330782,义乌市;330783,东阳市;330784,永康市;330800,衢州市;330801,市辖区;330802,柯城区;330803,衢江区;330822,常山县;330824,开化县;330825,龙游县;330881,江山市;330900,舟山市;330901,市辖区;330902,定海区;330903,普陀区;330921,岱山县;330922,嵊泗县;331000,台州市;331001,市辖区;331002,椒江区;331003,黄岩区;331004,路桥区;331021,玉环县;331022,三门县;331023,天台县;331024,仙居县;331081,温岭市;331082,临海市;331100,丽水市;331101,市辖区;331102,莲都区;331121,青田县;331122,缙云县;331123,遂昌县;331124,松阳县;331125,云和县;331126,庆元县;331127,景宁畲族自治县;331181,龙泉市;340000,安徽省;340100,合肥市;340101,市辖区;340102,瑶海区;340103,庐阳区;340104,蜀山区;340111,包河区;340121,长丰县;340122,肥东县;340123,肥西县;340200,芜湖市;340201,市辖区;340202,镜湖区;340203,弋江区;340207,鸠江区;340208,三山区;340221,芜湖县;340222,繁昌县;340223,南陵县;340300,蚌埠市;340301,市辖区;340302,龙子湖区;340303,蚌山区;340304,禹会区;340311,淮上区;340321,怀远县;340322,五河县;340323,固镇县;340400,淮南市;340401,市辖区;340402,大通区;340403,田家庵区;340404,谢家集区;340405,八公山区;340406,潘集区;340421,凤台县;340500,马鞍山市;340501,市辖区;340502,金家庄区;340503,花山区;340504,雨山区;340521,当涂县;340600,淮北市;340601,市辖区;340602,杜集区;340603,相山区;340604,烈山区;340621,濉溪县;340700,铜陵市;340701,市辖区;340702,铜官山区;340703,狮子山区;340711,郊区;340721,铜陵县;340800,安庆市;340801,市辖区;340802,迎江区;340803,大观区;340811,宜秀区;340822,怀宁县;340823,枞阳县;340824,潜山县;340825,太湖县;340826,宿松县;340827,望江县;340828,岳西县;340881,桐城市;341000,黄山市;341001,市辖区;341002,屯溪区;341003,黄山区;341004,徽州区;341021,歙县;341022,休宁县;341023,黟县;341024,祁门县;341100,滁州市;341101,市辖区;341102,琅琊区;341103,南谯区;341122,来安县;341124,全椒县;341125,定远县;341126,凤阳县;341181,天长市;341182,明光市;341200,阜阳市;341201,市辖区;341202,颍州区;341203,颍东区;341204,颍泉区;341221,临泉县;341222,太和县;341225,阜南县;341226,颍上县;341282,界首市;341300,宿州市;341301,市辖区;341302,埇桥区;341321,砀山县;341322,萧县;341323,灵璧县;341324,泗县;341400,巢湖市;341401,市辖区;341402,居巢区;341421,庐江县;341422,无为县;341423,含山县;341424,和县;341500,六安市;341501,市辖区;341502,金安区;341503,裕安区;341521,寿县;341522,霍邱县;341523,舒城县;341524,金寨县;341525,霍山县;341600,亳州市;341601,市辖区;341602,谯城区;341621,涡阳县;341622,蒙城县;341623,利辛县;341700,池州市;341701,市辖区;341702,贵池区;341721,东至县;341722,石台县;341723,青阳县;341800,宣城市;341801,市辖区;341802,宣州区;341821,郎溪县;341822,广德县;341823,泾县;341824,绩溪县;341825,旌德县;341881,宁国市;350000,福建省;350100,福州市;350101,市辖区;350102,鼓楼区;350103,台江区;350104,仓山区;350105,马尾区;350111,晋安区;350121,闽侯县;350122,连江县;350123,罗源县;350124,闽清县;350125,永泰县;350128,平潭县;350181,福清市;350182,长乐市;350200,厦门市;350201,市辖区;350203,思明区;350205,海沧区;350206,湖里区;350211,集美区;350212,同安区;350213,翔安区;350300,莆田市;350301,市辖区;350302,城厢区;350303,涵江区;350304,荔城区;350305,秀屿区;350322,仙游县;350400,三明市;350401,市辖区;350402,梅列区;350403,三元区;350421,明溪县;350423,清流县;350424,宁化县;350425,大田县;350426,尤溪县;350427,沙县;350428,将乐县;350429,泰宁县;350430,建宁县;350481,永安市;350500,泉州市;350501,市辖区;350502,鲤城区;350503,丰泽区;350504,洛江区;350505,泉港区;350521,惠安县;350524,安溪县;350525,永春县;350526,德化县;350527,金门县;350581,石狮市;350582,晋江市;350583,南安市;350600,漳州市;350601,市辖区;350602,芗城区;350603,龙文区;350622,云霄县;350623,漳浦县;350624,诏安县;350625,长泰县;350626,东山县;350627,南靖县;350628,平和县;350629,华安县;350681,龙海市;350700,南平市;350701,市辖区;350702,延平区;350721,顺昌县;350722,浦城县;350723,光泽县;350724,松溪县;350725,政和县;350781,邵武市;350782,武夷山市;350783,建瓯市;350784,建阳市;350800,龙岩市;350801,市辖区;350802,新罗区;350821,长汀县;350822,永定县;350823,上杭县;350824,武平县;350825,连城县;350881,漳平市;350900,宁德市;350901,市辖区;350902,蕉城区;350921,霞浦县;350922,古田县;350923,屏南县;350924,寿宁县;350925,周宁县;350926,柘荣县;350981,福安市;350982,福鼎市;360000,江西省;360100,南昌市;360101,市辖区;360102,东湖区;360103,西湖区;360104,青云谱区;360105,湾里区;360111,青山湖区;360121,南昌县;360122,新建县;360123,安义县;360124,进贤县;360200,景德镇市;360201,市辖区;360202,昌江区;360203,珠山区;360222,浮梁县;360281,乐平市;360300,萍乡市;360301,市辖区;360302,安源区;360313,湘东区;360321,莲花县;360322,上栗县;360323,芦溪县;360400,九江市;360401,市辖区;360402,庐山区;360403,浔阳区;360421,九江县;360423,武宁县;360424,修水县;360425,永修县;360426,德安县;360427,星子县;360428,都昌县;360429,湖口县;360430,彭泽县;360481,瑞昌市;360500,新余市;360501,市辖区;360502,渝水区;360521,分宜县;360600,鹰潭市;360601,市辖区;360602,月湖区;360622,余江县;360681,贵溪市;360700,赣州市;360701,市辖区;360702,章贡区;360721,赣县;360722,信丰县;360723,大余县;360724,上犹县;360725,崇义县;360726,安远县;360727,龙南县;360728,定南县;360729,全南县;360730,宁都县;360731,于都县;360732,兴国县;360733,会昌县;360734,寻乌县;360735,石城县;360781,瑞金市;360782,南康市;360800,吉安市;360801,市辖区;360802,吉州区;360803,青原区;360821,吉安县;360822,吉水县;360823,峡江县;360824,新干县;360825,永丰县;360826,泰和县;360827,遂川县;360828,万安县;360829,安福县;360830,永新县;360881,井冈山市;360900,宜春市;360901,市辖区;360902,袁州区;360921,奉新县;360922,万载县;360923,上高县;360924,宜丰县;360925,靖安县;360926,铜鼓县;360981,丰城市;360982,樟树市;360983,高安市;361000,抚州市;361001,市辖区;361002,临川区;361021,南城县;361022,黎川县;361023,南丰县;361024,崇仁县;361025,乐安县;361026,宜黄县;361027,金溪县;361028,资溪县;361029,东乡县;361030,广昌县;361100,上饶市;361101,市辖区;361102,信州区;361121,上饶县;361122,广丰县;361123,玉山县;361124,铅山县;361125,横峰县;361126,弋阳县;361127,余干县;361128,鄱阳县;361129,万年县;361130,婺源县;361181,德兴市;370000,山东省;370100,济南市;370101,市辖区;370102,历下区;370103,市中区;370104,槐荫区;370105,天桥区;370112,历城区;370113,长清区;370124,平阴县;370125,济阳县;370126,商河县;370181,章丘市;370200,青岛市;370201,市辖区;370202,市南区;370203,市北区;370205,四方区;370211,黄岛区;370212,崂山区;370213,李沧区;370214,城阳区;370281,胶州市;370282,即墨市;370283,平度市;370284,胶南市;370285,莱西市;370300,淄博市;370301,市辖区;370302,淄川区;370303,张店区;370304,博山区;370305,临淄区;370306,周村区;370321,桓台县;370322,高青县;370323,沂源县;370400,枣庄市;370401,市辖区;370402,市中区;370403,薛城区;370404,峄城区;370405,台儿庄区;370406,山亭区;370481,滕州市;370500,东营市;370501,市辖区;370502,东营区;370503,河口区;370521,垦利县;370522,利津县;370523,广饶县;370600,烟台市;370601,市辖区;370602,芝罘区;370611,福山区;370612,牟平区;370613,莱山区;370634,长岛县;370681,龙口市;370682,莱阳市;370683,莱州市;370684,蓬莱市;370685,招远市;370686,栖霞市;370687,海阳市;370700,潍坊市;370701,市辖区;370702,潍城区;370703,寒亭区;370704,坊子区;370705,奎文区;370724,临朐县;370725,昌乐县;370781,青州市;370782,诸城市;370783,寿光市;370784,安丘市;370785,高密市;370786,昌邑市;370800,济宁市;370801,市辖区;370802,市中区;370811,任城区;370826,微山县;370827,鱼台县;370828,金乡县;370829,嘉祥县;370830,汶上县;370831,泗水县;370832,梁山县;370881,曲阜市;370882,兖州市;370883,邹城市;370900,泰安市;370901,市辖区;370902,泰山区;370903,岱岳区;370921,宁阳县;370923,东平县;370982,新泰市;370983,肥城市;371000,威海市;371001,市辖区;371002,环翠区;371081,文登市;371082,荣成市;371083,乳山市;371100,日照市;371101,市辖区;371102,东港区;371103,岚山区;371121,五莲县;371122,莒县;371200,莱芜市;371201,市辖区;371202,莱城区;371203,钢城区;371300,临沂市;371301,市辖区;371302,兰山区;371311,罗庄区;371312,河东区;371321,沂南县;371322,郯城县;371323,沂水县;371324,苍山县;371325,费县;371326,平邑县;371327,莒南县;371328,蒙阴县;371329,临沭县;371400,德州市;371401,市辖区;371402,德城区;371421,陵县;371422,宁津县;371423,庆云县;371424,临邑县;371425,齐河县;371426,平原县;371427,夏津县;371428,武城县;371481,乐陵市;371482,禹城市;371500,聊城市;371501,市辖区;371502,东昌府区;371521,阳谷县;371522,莘县;371523,茌平县;371524,东阿县;371525,冠县;371526,高唐县;371581,临清市;371600,滨州市;371601,市辖区;371602,滨城区;371621,惠民县;371622,阳信县;371623,无棣县;371624,沾化县;371625,博兴县;371626,邹平县;371700,荷泽市;371701,市辖区;371702,牡丹区;371721,曹县;371722,单县;371723,成武县;371724,巨野县;371725,郓城县;371726,鄄城县;371727,定陶县;371728,东明县;410000,河南省;410100,郑州市;410101,市辖区;410102,中原区;410103,二七区;410104,管城回族区;410105,金水区;410106,上街区;410108,惠济区;410122,中牟县;410181,巩义市;410182,荥阳市;410183,新密市;410184,新郑市;410185,登封市;410200,开封市;410201,市辖区;410202,龙亭区;410203,顺河回族区;410204,鼓楼区;410205,禹王台区;410211,金明区;410221,杞县;410222,通许县;410223,尉氏县;410224,开封县;410225,兰考县;410300,洛阳市;410301,市辖区;410302,老城区;410303,西工区;410304,廛河回族区;410305,涧西区;410306,吉利区;410307,洛龙区;410322,孟津县;410323,新安县;410324,栾川县;410325,嵩县;410326,汝阳县;410327,宜阳县;410328,洛宁县;410329,伊川县;410381,偃师市;410400,平顶山市;410401,市辖区;410402,新华区;410403,卫东区;410404,石龙区;410411,湛河区;410421,宝丰县;410422,叶县;410423,鲁山县;410425,郏县;410481,舞钢市;410482,汝州市;410500,安阳市;410501,市辖区;410502,文峰区;410503,北关区;410505,殷都区;410506,龙安区;410522,安阳县;410523,汤阴县;410526,滑县;410527,内黄县;410581,林州市;410600,鹤壁市;410601,市辖区;410602,鹤山区;410603,山城区;410611,淇滨区;410621,浚县;410622,淇县;410700,新乡市;410701,市辖区;410702,红旗区;410703,卫滨区;410704,凤泉区;410711,牧野区;410721,新乡县;410724,获嘉县;410725,原阳县;410726,延津县;410727,封丘县;410728,长垣县;410781,卫辉市;410782,辉县市;410800,焦作市;410801,市辖区;410802,解放区;410803,中站区;410804,马村区;410811,山阳区;410821,修武县;410822,博爱县;410823,武陟县;410825,温县;410881,济源市;410882,沁阳市;410883,孟州市;410900,濮阳市;410901,市辖区;410902,华龙区;410922,清丰县;410923,南乐县;410926,范县;410927,台前县;410928,濮阳县;411000,许昌市;411001,市辖区;411002,魏都区;411023,许昌县;411024,鄢陵县;411025,襄城县;411081,禹州市;411082,长葛市;411100,漯河市;411101,市辖区;411102,源汇区;411103,郾城区;411104,召陵区;411121,舞阳县;411122,临颍县;411200,三门峡市;411201,市辖区;411202,湖滨区;411221,渑池县;411222,陕县;411224,卢氏县;411281,义马市;411282,灵宝市;411300,南阳市;411301,市辖区;411302,宛城区;411303,卧龙区;411321,南召县;411322,方城县;411323,西峡县;411324,镇平县;411325,内乡县;411326,淅川县;411327,社旗县;411328,唐河县;411329,新野县;411330,桐柏县;411381,邓州市;411400,商丘市;411401,市辖区;411402,梁园区;411403,睢阳区;411421,民权县;411422,睢县;411423,宁陵县;411424,柘城县;411425,虞城县;411426,夏邑县;411481,永城市;411500,信阳市;411501,市辖区;411502,浉河区;411503,平桥区;411521,罗山县;411522,光山县;411523,新县;411524,商城县;411525,固始县;411526,潢川县;411527,淮滨县;411528,息县;411600,周口市;411601,市辖区;411602,川汇区;411621,扶沟县;411622,西华县;411623,商水县;411624,沈丘县;411625,郸城县;411626,淮阳县;411627,太康县;411628,鹿邑县;411681,项城市;411700,驻马店市;411701,市辖区;411702,驿城区;411721,西平县;411722,上蔡县;411723,平舆县;411724,正阳县;411725,确山县;411726,泌阳县;411727,汝南县;411728,遂平县;411729,新蔡县;420000,湖北省;420100,武汉市;420101,市辖区;420102,江岸区;420103,江汉区;420104,硚口区;420105,汉阳区;420106,武昌区;420107,青山区;420111,洪山区;420112,东西湖区;420113,汉南区;420114,蔡甸区;420115,江夏区;420116,黄陂区;420117,新洲区;420200,黄石市;420201,市辖区;420202,黄石港区;420203,西塞山区;420204,下陆区;420205,铁山区;420222,阳新县;420281,大冶市;420300,十堰市;420301,市辖区;420302,茅箭区;420303,张湾区;420321,郧县;420322,郧西县;420323,竹山县;420324,竹溪县;420325,房县;420381,丹江口市;420500,宜昌市;420501,市辖区;420502,西陵区;420503,伍家岗区;420504,点军区;420505,猇亭区;420506,夷陵区;420525,远安县;420526,兴山县;420527,秭归县;420528,长阳土家族自治县;420529,五峰土家族自治县;420581,宜都市;420582,当阳市;420583,枝江市;420600,襄樊市;420601,市辖区;420602,襄城区;420606,樊城区;420607,襄阳区;420624,南漳县;420625,谷城县;420626,保康县;420682,老河口市;420683,枣阳市;420684,宜城市;420700,鄂州市;420701,市辖区;420702,梁子湖区;420703,华容区;420704,鄂城区;420800,荆门市;420801,市辖区;420802,东宝区;420804,掇刀区;420821,京山县;420822,沙洋县;420881,钟祥市;420900,孝感市;420901,市辖区;420902,孝南区;420921,孝昌县;420922,大悟县;420923,云梦县;420981,应城市;420982,安陆市;420984,汉川市;421000,荆州市;421001,市辖区;421002,沙市区;421003,荆州区;421022,公安县;421023,监利县;421024,江陵县;421081,石首市;421083,洪湖市;421087,松滋市;421100,黄冈市;421101,市辖区;421102,黄州区;421121,团风县;421122,红安县;421123,罗田县;421124,英山县;421125,浠水县;421126,蕲春县;421127,黄梅县;421181,麻城市;421182,武穴市;421200,咸宁市;421201,市辖区;421202,咸安区;421221,嘉鱼县;421222,通城县;421223,崇阳县;421224,通山县;421281,赤壁市;421300,随州市;421301,市辖区;421302,曾都区;421381,广水市;422800,恩施土家族苗族自治州;422801,恩施市;422802,利川市;422822,建始县;422823,巴东县;422825,宣恩县;422826,咸丰县;422827,来凤县;422828,鹤峰县;429000,省直辖行政单位;429004,仙桃市;429005,潜江市;429006,天门市;429021,神农架林区;430000,湖南省;430100,长沙市;430101,市辖区;430102,芙蓉区;430103,天心区;430104,岳麓区;430105,开福区;430111,雨花区;430121,长沙县;430122,望城县;430124,宁乡县;430181,浏阳市;430200,株洲市;430201,市辖区;430202,荷塘区;430203,芦淞区;430204,石峰区;430211,天元区;430221,株洲县;430223,攸县;430224,茶陵县;430225,炎陵县;430281,醴陵市;430300,湘潭市;430301,市辖区;430302,雨湖区;430304,岳塘区;430321,湘潭县;430381,湘乡市;430382,韶山市;430400,衡阳市;430401,市辖区;430405,珠晖区;430406,雁峰区;430407,石鼓区;430408,蒸湘区;430412,南岳区;430421,衡阳县;430422,衡南县;430423,衡山县;430424,衡东县;430426,祁东县;430481,耒阳市;430482,常宁市;430500,邵阳市;430501,市辖区;430502,双清区;430503,大祥区;430511,北塔区;430521,邵东县;430522,新邵县;430523,邵阳县;430524,隆回县;430525,洞口县;430527,绥宁县;430528,新宁县;430529,城步苗族自治县;430581,武冈市;430600,岳阳市;430601,市辖区;430602,岳阳楼区;430603,云溪区;430611,君山区;430621,岳阳县;430623,华容县;430624,湘阴县;430626,平江县;430681,汨罗市;430682,临湘市;430700,常德市;430701,市辖区;430702,武陵区;430703,鼎城区;430721,安乡县;430722,汉寿县;430723,澧县;430724,临澧县;430725,桃源县;430726,石门县;430781,津市市;430800,张家界市;430801,市辖区;430802,永定区;430811,武陵源区;430821,慈利县;430822,桑植县;430900,益阳市;430901,市辖区;430902,资阳区;430903,赫山区;430921,南县;430922,桃江县;430923,安化县;430981,沅江市;431000,郴州市;431001,市辖区;431002,北湖区;431003,苏仙区;431021,桂阳县;431022,宜章县;431023,永兴县;431024,嘉禾县;431025,临武县;431026,汝城县;431027,桂东县;431028,安仁县;431081,资兴市;431100,永州市;431101,市辖区;431102,零陵区;431103,冷水滩区;431121,祁阳县;431122,东安县;431123,双牌县;431124,道县;431125,江永县;431126,宁远县;431127,蓝山县;431128,新田县;431129,江华瑶族自治县;431200,怀化市;431201,市辖区;431202,鹤城区;431221,中方县;431222,沅陵县;431223,辰溪县;431224,溆浦县;431225,会同县;431226,麻阳苗族自治县;431227,新晃侗族自治县;431228,芷江侗族自治县;431229,靖州苗族侗族自治县;431230,通道侗族自治县;431281,洪江市;431300,娄底市;431301,市辖区;431302,娄星区;431321,双峰县;431322,新化县;431381,冷水江市;431382,涟源市;433100,湘西土家族苗族自治州;433101,吉首市;433122,泸溪县;433123,凤凰县;433124,花垣县;433125,保靖县;433126,古丈县;433127,永顺县;433130,龙山县;440000,广东省;440100,广州市;440101,市辖区;440103,荔湾区;440104,越秀区;440105,海珠区;440106,天河区;440111,白云区;440112,黄埔区;440113,番禺区;440114,花都区;440115,南沙区;440116,萝岗区;440183,增城市;440184,从化市;440200,韶关市;440201,市辖区;440203,武江区;440204,浈江区;440205,曲江区;440222,始兴县;440224,仁化县;440229,翁源县;440232,乳源瑶族自治县;440233,新丰县;440281,乐昌市;440282,南雄市;440300,深圳市;440301,市辖区;440303,罗湖区;440304,福田区;440305,南山区;440306,宝安区;440307,龙岗区;440308,盐田区;440400,珠海市;440401,市辖区;440402,香洲区;440403,斗门区;440404,金湾区;440500,汕头市;440501,市辖区;440507,龙湖区;440511,金平区;440512,濠江区;440513,潮阳区;440514,潮南区;440515,澄海区;440523,南澳县;440600,佛山市;440601,市辖区;440604,禅城区;440605,南海区;440606,顺德区;440607,三水区;440608,高明区;440700,江门市;440701,市辖区;440703,蓬江区;440704,江海区;440705,新会区;440781,台山市;440783,开平市;440784,鹤山市;440785,恩平市;440800,湛江市;440801,市辖区;440802,赤坎区;440803,霞山区;440804,坡头区;440811,麻章区;440823,遂溪县;440825,徐闻县;440881,廉江市;440882,雷州市;440883,吴川市;440900,茂名市;440901,市辖区;440902,茂南区;440903,茂港区;440923,电白县;440981,高州市;440982,化州市;440983,信宜市;441200,肇庆市;441201,市辖区;441202,端州区;441203,鼎湖区;441223,广宁县;441224,怀集县;441225,封开县;441226,德庆县;441283,高要市;441284,四会市;441300,惠州市;441301,市辖区;441302,惠城区;441303,惠阳区;441322,博罗县;441323,惠东县;441324,龙门县;441400,梅州市;441401,市辖区;441402,梅江区;441421,梅县;441422,大埔县;441423,丰顺县;441424,五华县;441426,平远县;441427,蕉岭县;441481,兴宁市;441500,汕尾市;441501,市辖区;441502,城区;441521,海丰县;441523,陆河县;441581,陆丰市;441600,河源市;441601,市辖区;441602,源城区;441621,紫金县;441622,龙川县;441623,连平县;441624,和平县;441625,东源县;441700,阳江市;441701,市辖区;441702,江城区;441721,阳西县;441723,阳东县;441781,阳春市;441800,清远市;441801,市辖区;441802,清城区;441821,佛冈县;441823,阳山县;441825,连山壮族瑶族自治县;441826,连南瑶族自治县;441827,清新县;441881,英德市;441882,连州市;441900,东莞市;442000,中山市;445100,潮州市;445101,市辖区;445102,湘桥区;445121,潮安县;445122,饶平县;445200,揭阳市;445201,市辖区;445202,榕城区;445221,揭东县;445222,揭西县;445224,惠来县;445281,普宁市;445300,云浮市;445301,市辖区;445302,云城区;445321,新兴县;445322,郁南县;445323,云安县;445381,罗定市;450000,广西壮族自治区;450100,南宁市;450101,市辖区;450102,兴宁区;450103,青秀区;450105,江南区;450107,西乡塘区;450108,良庆区;450109,邕宁区;450122,武鸣县;450123,隆安县;450124,马山县;450125,上林县;450126,宾阳县;450127,横县;450200,柳州市;450201,市辖区;450202,城中区;450203,鱼峰区;450204,柳南区;450205,柳北区;450221,柳江县;450222,柳城县;450223,鹿寨县;450224,融安县;450225,融水苗族自治县;450226,三江侗族自治县;450300,桂林市;450301,市辖区;450302,秀峰区;450303,叠彩区;450304,象山区;450305,七星区;450311,雁山区;450321,阳朔县;450322,临桂县;450323,灵川县;450324,全州县;450325,兴安县;450326,永福县;450327,灌阳县;450328,龙胜各族自治县;450329,资源县;450330,平乐县;450331,荔蒲县;450332,恭城瑶族自治县;450400,梧州市;450401,市辖区;450403,万秀区;450404,蝶山区;450405,长洲区;450421,苍梧县;450422,藤县;450423,蒙山县;450481,岑溪市;450500,北海市;450501,市辖区;450502,海城区;450503,银海区;450512,铁山港区;450521,合浦县;450600,防城港市;450601,市辖区;450602,港口区;450603,防城区;450621,上思县;450681,东兴市;450700,钦州市;450701,市辖区;450702,钦南区;450703,钦北区;450721,灵山县;450722,浦北县;450800,贵港市;450801,市辖区;450802,港北区;450803,港南区;450804,覃塘区;450821,平南县;450881,桂平市;450900,玉林市;450901,市辖区;450902,玉州区;450921,容县;450922,陆川县;450923,博白县;450924,兴业县;450981,北流市;451000,百色市;451001,市辖区;451002,右江区;451021,田阳县;451022,田东县;451023,平果县;451024,德保县;451025,靖西县;451026,那坡县;451027,凌云县;451028,乐业县;451029,田林县;451030,西林县;451031,隆林各族自治县;451100,贺州市;451101,市辖区;451102,八步区;451121,昭平县;451122,钟山县;451123,富川瑶族自治县;451200,河池市;451201,市辖区;451202,金城江区;451221,南丹县;451222,天峨县;451223,凤山县;451224,东兰县;451225,罗城仫佬族自治县;451226,环江毛南族自治县;451227,巴马瑶族自治县;451228,都安瑶族自治县;451229,大化瑶族自治县;451281,宜州市;451300,来宾市;451301,市辖区;451302,兴宾区;451321,忻城县;451322,象州县;451323,武宣县;451324,金秀瑶族自治县;451381,合山市;451400,崇左市;451401,市辖区;451402,江洲区;451421,扶绥县;451422,宁明县;451423,龙州县;451424,大新县;451425,天等县;451481,凭祥市;460000,海南省;460100,海口市;460101,市辖区;460105,秀英区;460106,龙华区;460107,琼山区;460108,美兰区;460200,三亚市;460201,市辖区;469000,省直辖县级行政单位;469001,五指山市;469002,琼海市;469003,儋州市;469005,文昌市;469006,万宁市;469007,东方市;469025,定安县;469026,屯昌县;469027,澄迈县;469028,临高县;469030,白沙黎族自治县;469031,昌江黎族自治县;469033,乐东黎族自治县;469034,陵水黎族自治县;469035,保亭黎族苗族自治县;469036,琼中黎族苗族自治县;469037,西沙群岛;469038,南沙群岛;469039,中沙群岛的岛礁及其海域;500000,重庆市;500100,市辖区;500101,万州区;500102,涪陵区;500103,渝中区;500104,大渡口区;500105,江北区;500106,沙坪坝区;500107,九龙坡区;500108,南岸区;500109,北碚区;500110,万盛区;500111,双桥区;500112,渝北区;500113,巴南区;500114,黔江区;500115,长寿区;500200,县;500222,綦江县;500223,潼南县;500224,铜梁县;500225,大足县;500226,荣昌县;500227,璧山县;500228,梁平县;500229,城口县;500230,丰都县;500231,垫江县;500232,武隆县;500233,忠县;500234,开县;500235,云阳县;500236,奉节县;500237,巫山县;500238,巫溪县;500240,石柱土家族自治县;500241,秀山土家族苗族自治县;500242,酉阳土家族苗族自治县;500243,彭水苗族土家族自治县;500300,市;500381,江津市;500382,合川市;500383,永川市;500384,南川市;510000,四川省;510100,成都市;510101,市辖区;510104,锦江区;510105,青羊区;510106,金牛区;510107,武侯区;510108,成华区;510112,龙泉驿区;510113,青白江区;510114,新都区;510115,温江区;510121,金堂县;510122,双流县;510124,郫县;510129,大邑县;510131,蒲江县;510132,新津县;510181,都江堰市;510182,彭州市;510183,邛崃市;510184,崇州市;510300,自贡市;510301,市辖区;510302,自流井区;510303,贡井区;510304,大安区;510311,沿滩区;510321,荣县;510322,富顺县;510400,攀枝花市;510401,市辖区;510402,东区;510403,西区;510411,仁和区;510421,米易县;510422,盐边县;510500,泸州市;510501,市辖区;510502,江阳区;510503,纳溪区;510504,龙马潭区;510521,泸县;510522,合江县;510524,叙永县;510525,古蔺县;510600,德阳市;510601,市辖区;510603,旌阳区;510623,中江县;510626,罗江县;510681,广汉市;510682,什邡市;510683,绵竹市;510700,绵阳市;510701,市辖区;510703,涪城区;510704,游仙区;510722,三台县;510723,盐亭县;510724,安县;510725,梓潼县;510726,北川羌族自治县;510727,平武县;510781,江油市;510800,广元市;510801,市辖区;510802,市中区;510811,元坝区;510812,朝天区;510821,旺苍县;510822,青川县;510823,剑阁县;510824,苍溪县;510900,遂宁市;510901,市辖区;510903,船山区;510904,安居区;510921,蓬溪县;510922,射洪县;510923,大英县;511000,内江市;511001,市辖区;511002,市中区;511011,东兴区;511024,威远县;511025,资中县;511028,隆昌县;511100,乐山市;511101,市辖区;511102,市中区;511111,沙湾区;511112,五通桥区;511113,金口河区;511123,犍为县;511124,井研县;511126,夹江县;511129,沐川县;511132,峨边彝族自治县;511133,马边彝族自治县;511181,峨眉山市;511300,南充市;511301,市辖区;511302,顺庆区;511303,高坪区;511304,嘉陵区;511321,南部县;511322,营山县;511323,蓬安县;511324,仪陇县;511325,西充县;511381,阆中市;511400,眉山市;511401,市辖区;511402,东坡区;511421,仁寿县;511422,彭山县;511423,洪雅县;511424,丹棱县;511425,青神县;511500,宜宾市;511501,市辖区;511502,翠屏区;511521,宜宾县;511522,南溪县;511523,江安县;511524,长宁县;511525,高县;511526,珙县;511527,筠连县;511528,兴文县;511529,屏山县;511600,广安市;511601,市辖区;511602,广安区;511621,岳池县;511622,武胜县;511623,邻水县;511681,华蓥市;511700,达州市;511701,市辖区;511702,通川区;511721,达县;511722,宣汉县;511723,开江县;511724,大竹县;511725,渠县;511781,万源市;511800,雅安市;511801,市辖区;511802,雨城区;511821,名山县;511822,荥经县;511823,汉源县;511824,石棉县;511825,天全县;511826,芦山县;511827,宝兴县;511900,巴中市;511901,市辖区;511902,巴州区;511921,通江县;511922,南江县;511923,平昌县;512000,资阳市;512001,市辖区;512002,雁江区;512021,安岳县;512022,乐至县;512081,简阳市;513200,阿坝藏族羌族自治州;513221,汶川县;513222,理县;513223,茂县;513224,松潘县;513225,九寨沟县;513226,金川县;513227,小金县;513228,黑水县;513229,马尔康县;513230,壤塘县;513231,阿坝县;513232,若尔盖县;513233,红原县;513300,甘孜藏族自治州;513321,康定县;513322,泸定县;513323,丹巴县;513324,九龙县;513325,雅江县;513326,道孚县;513327,炉霍县;513328,甘孜县;513329,新龙县;513330,德格县;513331,白玉县;513332,石渠县;513333,色达县;513334,理塘县;513335,巴塘县;513336,乡城县;513337,稻城县;513338,得荣县;513400,凉山彝族自治州;513401,西昌市;513422,木里藏族自治县;513423,盐源县;513424,德昌县;513425,会理县;513426,会东县;513427,宁南县;513428,普格县;513429,布拖县;513430,金阳县;513431,昭觉县;513432,喜德县;513433,冕宁县;513434,越西县;513435,甘洛县;513436,美姑县;513437,雷波县;520000,贵州省;520100,贵阳市;520101,市辖区;520102,南明区;520103,云岩区;520111,花溪区;520112,乌当区;520113,白云区;520114,小河区;520121,开阳县;520122,息烽县;520123,修文县;520181,清镇市;520200,六盘水市;520201,钟山区;520203,六枝特区;520221,水城县;520222,盘县;520300,遵义市;520301,市辖区;520302,红花岗区;520303,汇川区;520321,遵义县;520322,桐梓县;520323,绥阳县;520324,正安县;520325,道真仡佬族苗族自治县;520326,务川仡佬族苗族自治县;520327,凤冈县;520328,湄潭县;520329,余庆县;520330,习水县;520381,赤水市;520382,仁怀市;520400,安顺市;520401,市辖区;520402,西秀区;520421,平坝县;520422,普定县;520423,镇宁布依族苗族自治县;520424,关岭布依族苗族自治县;520425,紫云苗族布依族自治县;522200,铜仁地区;522201,铜仁市;522222,江口县;522223,玉屏侗族自治县;522224,石阡县;522225,思南县;522226,印江土家族苗族自治县;522227,德江县;522228,沿河土家族自治县;522229,松桃苗族自治县;522230,万山特区;522300,黔西南布依族苗族自治州;522301,兴义市;522322,兴仁县;522323,普安县;522324,晴隆县;522325,贞丰县;522326,望谟县;522327,册亨县;522328,安龙县;522400,毕节地区;522401,毕节市;522422,大方县;522423,黔西县;522424,金沙县;522425,织金县;522426,纳雍县;522427,威宁彝族回族苗族自治县;522428,赫章县;522600,黔东南苗族侗族自治州;522601,凯里市;522622,黄平县;522623,施秉县;522624,三穗县;522625,镇远县;522626,岑巩县;522627,天柱县;522628,锦屏县;522629,剑河县;522630,台江县;522631,黎平县;522632,榕江县;522633,从江县;522634,雷山县;522635,麻江县;522636,丹寨县;522700,黔南布依族苗族自治州;522701,都匀市;522702,福泉市;522722,荔波县;522723,贵定县;522725,瓮安县;522726,独山县;522727,平塘县;522728,罗甸县;522729,长顺县;522730,龙里县;522731,惠水县;522732,三都水族自治县;530000,云南省;530100,昆明市;530101,市辖区;530102,五华区;530103,盘龙区;530111,官渡区;530112,西山区;530113,东川区;530121,呈贡县;530122,晋宁县;530124,富民县;530125,宜良县;530126,石林彝族自治县;530127,嵩明县;530128,禄劝彝族苗族自治县;530129,寻甸回族彝族自治县;530181,安宁市;530300,曲靖市;530301,市辖区;530302,麒麟区;530321,马龙县;530322,陆良县;530323,师宗县;530324,罗平县;530325,富源县;530326,会泽县;530328,沾益县;530381,宣威市;530400,玉溪市;530401,市辖区;530402,红塔区;530421,江川县;530422,澄江县;530423,通海县;530424,华宁县;530425,易门县;530426,峨山彝族自治县;530427,新平彝族傣族自治县;530428,元江哈尼族彝族傣族自治县;530500,保山市;530501,市辖区;530502,隆阳区;530521,施甸县;530522,腾冲县;530523,龙陵县;530524,昌宁县;530600,昭通市;530601,市辖区;530602,昭阳区;530621,鲁甸县;530622,巧家县;530623,盐津县;530624,大关县;530625,永善县;530626,绥江县;530627,镇雄县;530628,彝良县;530629,威信县;530630,水富县;530700,丽江市;530701,市辖区;530702,古城区;530721,玉龙纳西族自治县;530722,永胜县;530723,华坪县;530724,宁蒗彝族自治县;530800,思茅市;530801,市辖区;530802,翠云区;530821,普洱哈尼族彝族自治县;530822,墨江哈尼族自治县;530823,景东彝族自治县;530824,景谷傣族彝族自治县;530825,镇沅彝族哈尼族拉祜族自治县;530826,江城哈尼族彝族自治县;530827,孟连傣族拉祜族佤族自治县;530828,澜沧拉祜族自治县;530829,西盟佤族自治县;530900,临沧市;530901,市辖区;530902,临翔区;530921,凤庆县;530922,云县;530923,永德县;530924,镇康县;530925,双江拉祜族佤族布朗族傣族自治县;530926,耿马傣族佤族自治县;530927,沧源佤族自治县;532300,楚雄彝族自治州;532301,楚雄市;532322,双柏县;532323,牟定县;532324,南华县;532325,姚安县;532326,大姚县;532327,永仁县;532328,元谋县;532329,武定县;532331,禄丰县;532500,红河哈尼族彝族自治州;532501,个旧市;532502,开远市;532522,蒙自县;532523,屏边苗族自治县;532524,建水县;532525,石屏县;532526,弥勒县;532527,泸西县;532528,元阳县;532529,红河县;532530,金平苗族瑶族傣族自治县;532531,绿春县;532532,河口瑶族自治县;532600,文山壮族苗族自治州;532621,文山县;532622,砚山县;532623,西畴县;532624,麻栗坡县;532625,马关县;532626,丘北县;532627,广南县;532628,富宁县;532800,西双版纳傣族自治州;532801,景洪市;532822,勐海县;532823,勐腊县;532900,大理白族自治州;532901,大理市;532922,漾濞彝族自治县;532923,祥云县;532924,宾川县;532925,弥渡县;532926,南涧彝族自治县;532927,巍山彝族回族自治县;532928,永平县;532929,云龙县;532930,洱源县;532931,剑川县;532932,鹤庆县;533100,德宏傣族景颇族自治州;533102,瑞丽市;533103,潞西市;533122,梁河县;533123,盈江县;533124,陇川县;533300,怒江傈僳族自治州;533321,泸水县;533323,福贡县;533324,贡山独龙族怒族自治县;533325,兰坪白族普米族自治县;533400,迪庆藏族自治州;533421,香格里拉县;533422,德钦县;533423,维西傈僳族自治县;540000,西藏自治区;540100,拉萨市;540101,市辖区;540102,城关区;540121,林周县;540122,当雄县;540123,尼木县;540124,曲水县;540125,堆龙德庆县;540126,达孜县;540127,墨竹工卡县;542100,昌都地区;542121,昌都县;542122,江达县;542123,贡觉县;542124,类乌齐县;542125,丁青县;542126,察雅县;542127,八宿县;542128,左贡县;542129,芒康县;542132,洛隆县;542133,边坝县;542200,山南地区;542221,乃东县;542222,扎囊县;542223,贡嘎县;542224,桑日县;542225,琼结县;542226,曲松县;542227,措美县;542228,洛扎县;542229,加查县;542231,隆子县;542232,错那县;542233,浪卡子县;542300,日喀则地区;542301,日喀则市;542322,南木林县;542323,江孜县;542324,定日县;542325,萨迦县;542326,拉孜县;542327,昂仁县;542328,谢通门县;542329,白朗县;542330,仁布县;542331,康马县;542332,定结县;542333,仲巴县;542334,亚东县;542335,吉隆县;542336,聂拉木县;542337,萨嘎县;542338,岗巴县;542400,那曲地区;542421,那曲县;542422,嘉黎县;542423,比如县;542424,聂荣县;542425,安多县;542426,申扎县;542427,索县;542428,班戈县;542429,巴青县;542430,尼玛县;542500,阿里地区;542521,普兰县;542522,札达县;542523,噶尔县;542524,日土县;542525,革吉县;542526,改则县;542527,措勤县;542600,林芝地区;542621,林芝县;542622,工布江达县;542623,米林县;542624,墨脱县;542625,波密县;542626,察隅县;542627,朗县;610000,陕西省;610100,西安市;610101,市辖区;610102,新城区;610103,碑林区;610104,莲湖区;610111,灞桥区;610112,未央区;610113,雁塔区;610114,阎良区;610115,临潼区;610116,长安区;610122,蓝田县;610124,周至县;610125,户县;610126,高陵县;610200,铜川市;610201,市辖区;610202,王益区;610203,印台区;610204,耀州区;610222,宜君县;610300,宝鸡市;610301,市辖区;610302,渭滨区;610303,金台区;610304,陈仓区;610322,凤翔县;610323,岐山县;610324,扶风县;610326,眉县;610327,陇县;610328,千阳县;610329,麟游县;610330,凤县;610331,太白县;610400,咸阳市;610401,市辖区;610402,秦都区;610403,杨凌区;610404,渭城区;610422,三原县;610423,泾阳县;610424,乾县;610425,礼泉县;610426,永寿县;610427,彬县;610428,长武县;610429,旬邑县;610430,淳化县;610431,武功县;610481,兴平市;610500,渭南市;610501,市辖区;610502,临渭区;610521,华县;610522,潼关县;610523,大荔县;610524,合阳县;610525,澄城县;610526,蒲城县;610527,白水县;610528,富平县;610581,韩城市;610582,华阴市;610600,延安市;610601,市辖区;610602,宝塔区;610621,延长县;610622,延川县;610623,子长县;610624,安塞县;610625,志丹县;610626,吴起县;610627,甘泉县;610628,富县;610629,洛川县;610630,宜川县;610631,黄龙县;610632,黄陵县;610700,汉中市;610701,市辖区;610702,汉台区;610721,南郑县;610722,城固县;610723,洋县;610724,西乡县;610725,勉县;610726,宁强县;610727,略阳县;610728,镇巴县;610729,留坝县;610730,佛坪县;610800,榆林市;610801,市辖区;610802,榆阳区;610821,神木县;610822,府谷县;610823,横山县;610824,靖边县;610825,定边县;610826,绥德县;610827,米脂县;610828,佳县;610829,吴堡县;610830,清涧县;610831,子洲县;610900,安康市;610901,市辖区;610902,汉滨区;610921,汉阴县;610922,石泉县;610923,宁陕县;610924,紫阳县;610925,岚皋县;610926,平利县;610927,镇坪县;610928,旬阳县;610929,白河县;611000,商洛市;611001,市辖区;611002,商州区;611021,洛南县;611022,丹凤县;611023,商南县;611024,山阳县;611025,镇安县;611026,柞水县;620000,甘肃省;620100,兰州市;620101,市辖区;620102,城关区;620103,七里河区;620104,西固区;620105,安宁区;620111,红古区;620121,永登县;620122,皋兰县;620123,榆中县;620200,嘉峪关市;620201,市辖区;620300,金昌市;620301,市辖区;620302,金川区;620321,永昌县;620400,白银市;620401,市辖区;620402,白银区;620403,平川区;620421,靖远县;620422,会宁县;620423,景泰县;620500,天水市;620501,市辖区;620502,秦城区;620503,北道区;620521,清水县;620522,秦安县;620523,甘谷县;620524,武山县;620525,张家川回族自治县;620600,武威市;620601,市辖区;620602,凉州区;620621,民勤县;620622,古浪县;620623,天祝藏族自治县;620700,张掖市;620701,市辖区;620702,甘州区;620721,肃南裕固族自治县;620722,民乐县;620723,临泽县;620724,高台县;620725,山丹县;620800,平凉市;620801,市辖区;620802,崆峒区;620821,泾川县;620822,灵台县;620823,崇信县;620824,华亭县;620825,庄浪县;620826,静宁县;620900,酒泉市;620901,市辖区;620902,肃州区;620921,金塔县;620922,安西县;620923,肃北蒙古族自治县;620924,阿克塞哈萨克族自治县;620981,玉门市;620982,敦煌市;621000,庆阳市;621001,市辖区;621002,西峰区;621021,庆城县;621022,环县;621023,华池县;621024,合水县;621025,正宁县;621026,宁县;621027,镇原县;621100,定西市;621101,市辖区;621102,安定区;621121,通渭县;621122,陇西县;621123,渭源县;621124,临洮县;621125,漳县;621126,岷县;621200,陇南市;621201,市辖区;621202,武都区;621221,成县;621222,文县;621223,宕昌县;621224,康县;621225,西和县;621226,礼县;621227,徽县;621228,两当县;622900,临夏回族自治州;622901,临夏市;622921,临夏县;622922,康乐县;622923,永靖县;622924,广河县;622925,和政县;622926,东乡族自治县;622927,积石山保安族东乡族撒拉族自治县;623000,甘南藏族自治州;623001,合作市;623021,临潭县;623022,卓尼县;623023,舟曲县;623024,迭部县;623025,玛曲县;623026,碌曲县;623027,夏河县;630000,青海省;630100,西宁市;630101,市辖区;630102,城东区;630103,城中区;630104,城西区;630105,城北区;630121,大通回族土族自治县;630122,湟中县;630123,湟源县;632100,海东地区;632121,平安县;632122,民和回族土族自治县;632123,乐都县;632126,互助土族自治县;632127,化隆回族自治县;632128,循化撒拉族自治县;632200,海北藏族自治州;632221,门源回族自治县;632222,祁连县;632223,海晏县;632224,刚察县;632300,黄南藏族自治州;632321,同仁县;632322,尖扎县;632323,泽库县;632324,河南蒙古族自治县;632500,海南藏族自治州;632521,共和县;632522,同德县;632523,贵德县;632524,兴海县;632525,贵南县;632600,果洛藏族自治州;632621,玛沁县;632622,班玛县;632623,甘德县;632624,达日县;632625,久治县;632626,玛多县;632700,玉树藏族自治州;632721,玉树县;632722,杂多县;632723,称多县;632724,治多县;632725,囊谦县;632726,曲麻莱县;632800,海西蒙古族藏族自治州;632801,格尔木市;632802,德令哈市;632821,乌兰县;632822,都兰县;632823,天峻县;;640000,宁夏回族自治区;640100,银川市;640101,市辖区;640104,兴庆区;640105,西夏区;640106,金凤区;640121,永宁县;640122,贺兰县;640181,灵武市;640200,石嘴山市;640201,市辖区;640202,大武口区;640205,惠农区;640221,平罗县;640300,吴忠市;640301,市辖区;640302,利通区;640323,盐池县;640324,同心县;640381,青铜峡市;640400,固原市;640401,市辖区;640402,原州区;640422,西吉县;640423,隆德县;640424,泾源县;640425,彭阳县;640500,中卫市;640501,市辖区;640502,沙坡头区;640521,中宁县;640522,海原县;650000,新疆维吾尔自治区;650100,乌鲁木齐市;650101,市辖区;650102,天山区;650103,沙依巴克区;650104,新市区;650105,水磨沟区;650106,头屯河区;650107,达坂城区;650108,东山区;650121,乌鲁木齐县;650200,克拉玛依市;650201,市辖区;650202,独山子区;650203,克拉玛依区;650204,白碱滩区;650205,乌尔禾区;652100,吐鲁番地区;652101,吐鲁番市;652122,鄯善县;652123,托克逊县;652200,哈密地区;652201,哈密市;652222,巴里坤哈萨克自治县;652223,伊吾县;652300,昌吉回族自治州;652301,昌吉市;652302,阜康市;652303,米泉市;652323,呼图壁县;652324,玛纳斯县;652325,奇台县;652327,吉木萨尔县;652328,木垒哈萨克自治县;652700,博尔塔拉蒙古自治州;652701,博乐市;652722,精河县;652723,温泉县;652800,巴音郭楞蒙古自治州;652801,库尔勒市;652822,轮台县;652823,尉犁县;652824,若羌县;652825,且末县;652826,焉耆回族自治县;652827,和静县;652828,和硕县;652829,博湖县;652900,阿克苏地区;652901,阿克苏市;652922,温宿县;652923,库车县;652924,沙雅县;652925,新和县;652926,拜城县;652927,乌什县;652928,阿瓦提县;652929,柯坪县;653000,克孜勒苏柯尔克孜自治州;653001,阿图什市;653022,阿克陶县;653023,阿合奇县;653024,乌恰县;653100,喀什地区;653101,喀什市;653121,疏附县;653122,疏勒县;653123,英吉沙县;653124,泽普县;653125,莎车县;653126,叶城县;653127,麦盖提县;653128,岳普湖县;653129,伽师县;653130,巴楚县;653131,塔什库尔干塔吉克自治县;653200,和田地区;653201,和田市;653221,和田县;653222,墨玉县;653223,皮山县;653224,洛浦县;653225,策勒县;653226,于田县;653227,民丰县;654000,伊犁哈萨克自治州;654002,伊宁市;654003,奎屯市;654021,伊宁县;654022,察布查尔锡伯自治县;654023,霍城县;654024,巩留县;654025,新源县;654026,昭苏县;654027,特克斯县;654028,尼勒克县;654200,塔城地区;654201,塔城市;654202,乌苏市;654221,额敏县;654223,沙湾县;654224,托里县;654225,裕民县;654226,和布克赛尔蒙古自治县;654300,阿勒泰地区;654301,阿勒泰市;654321,布尔津县;654322,富蕴县;654323,福海县;654324,哈巴河县;654325,青河县;654326,吉木乃县;659000,省直辖行政单位;659001,石河子市;659002,阿拉尔市;659003,图木舒克市;659004,五家渠市;710000,台湾省;810000,香港特别行政区;820000,澳门特别行政区;910000,国外; ================================================ FILE: app/src/main/assets/pca-code.json ================================================ [ { "code": "11", "name": "北京市", "children": [ { "code": "1101", "name": "市辖区", "children": [ { "code": "110101", "name": "东城区" }, { "code": "110102", "name": "西城区" }, { "code": "110105", "name": "朝阳区" }, { "code": "110106", "name": "丰台区" }, { "code": "110107", "name": "石景山区" }, { "code": "110108", "name": "海淀区" }, { "code": "110109", "name": "门头沟区" }, { "code": "110111", "name": "房山区" }, { "code": "110112", "name": "通州区" }, { "code": "110113", "name": "顺义区" }, { "code": "110114", "name": "昌平区" }, { "code": "110115", "name": "大兴区" }, { "code": "110116", "name": "怀柔区" }, { "code": "110117", "name": "平谷区" }, { "code": "110118", "name": "密云区" }, { "code": "110119", "name": "延庆区" } ] } ] }, { "code": "12", "name": "天津市", "children": [ { "code": "1201", "name": "市辖区", "children": [ { "code": "120101", "name": "和平区" }, { "code": "120102", "name": "河东区" }, { "code": "120103", "name": "河西区" }, { "code": "120104", "name": "南开区" }, { "code": "120105", "name": "河北区" }, { "code": "120106", "name": "红桥区" }, { "code": "120110", "name": "东丽区" }, { "code": "120111", "name": "西青区" }, { "code": "120112", "name": "津南区" }, { "code": "120113", "name": "北辰区" }, { "code": "120114", "name": "武清区" }, { "code": "120115", "name": "宝坻区" }, { "code": "120116", "name": "滨海新区" }, { "code": "120117", "name": "宁河区" }, { "code": "120118", "name": "静海区" }, { "code": "120119", "name": "蓟州区" } ] } ] }, { "code": "13", "name": "河北省", "children": [ { "code": "1301", "name": "石家庄市", "children": [ { "code": "130102", "name": "长安区" }, { "code": "130104", "name": "桥西区" }, { "code": "130105", "name": "新华区" }, { "code": "130107", "name": "井陉矿区" }, { "code": "130108", "name": "裕华区" }, { "code": "130109", "name": "藁城区" }, { "code": "130110", "name": "鹿泉区" }, { "code": "130111", "name": "栾城区" }, { "code": "130121", "name": "井陉县" }, { "code": "130123", "name": "正定县" }, { "code": "130125", "name": "行唐县" }, { "code": "130126", "name": "灵寿县" }, { "code": "130127", "name": "高邑县" }, { "code": "130128", "name": "深泽县" }, { "code": "130129", "name": "赞皇县" }, { "code": "130130", "name": "无极县" }, { "code": "130131", "name": "平山县" }, { "code": "130132", "name": "元氏县" }, { "code": "130133", "name": "赵县" }, { "code": "130171", "name": "石家庄高新技术产业开发区" }, { "code": "130172", "name": "石家庄循环化工园区" }, { "code": "130181", "name": "辛集市" }, { "code": "130183", "name": "晋州市" }, { "code": "130184", "name": "新乐市" } ] }, { "code": "1302", "name": "唐山市", "children": [ { "code": "130202", "name": "路南区" }, { "code": "130203", "name": "路北区" }, { "code": "130204", "name": "古冶区" }, { "code": "130205", "name": "开平区" }, { "code": "130207", "name": "丰南区" }, { "code": "130208", "name": "丰润区" }, { "code": "130209", "name": "曹妃甸区" }, { "code": "130224", "name": "滦南县" }, { "code": "130225", "name": "乐亭县" }, { "code": "130227", "name": "迁西县" }, { "code": "130229", "name": "玉田县" }, { "code": "130271", "name": "河北唐山芦台经济开发区" }, { "code": "130272", "name": "唐山市汉沽管理区" }, { "code": "130273", "name": "唐山高新技术产业开发区" }, { "code": "130274", "name": "河北唐山海港经济开发区" }, { "code": "130281", "name": "遵化市" }, { "code": "130283", "name": "迁安市" }, { "code": "130284", "name": "滦州市" } ] }, { "code": "1303", "name": "秦皇岛市", "children": [ { "code": "130302", "name": "海港区" }, { "code": "130303", "name": "山海关区" }, { "code": "130304", "name": "北戴河区" }, { "code": "130306", "name": "抚宁区" }, { "code": "130321", "name": "青龙满族自治县" }, { "code": "130322", "name": "昌黎县" }, { "code": "130324", "name": "卢龙县" }, { "code": "130371", "name": "秦皇岛市经济技术开发区" }, { "code": "130372", "name": "北戴河新区" } ] }, { "code": "1304", "name": "邯郸市", "children": [ { "code": "130402", "name": "邯山区" }, { "code": "130403", "name": "丛台区" }, { "code": "130404", "name": "复兴区" }, { "code": "130406", "name": "峰峰矿区" }, { "code": "130407", "name": "肥乡区" }, { "code": "130408", "name": "永年区" }, { "code": "130423", "name": "临漳县" }, { "code": "130424", "name": "成安县" }, { "code": "130425", "name": "大名县" }, { "code": "130426", "name": "涉县" }, { "code": "130427", "name": "磁县" }, { "code": "130430", "name": "邱县" }, { "code": "130431", "name": "鸡泽县" }, { "code": "130432", "name": "广平县" }, { "code": "130433", "name": "馆陶县" }, { "code": "130434", "name": "魏县" }, { "code": "130435", "name": "曲周县" }, { "code": "130471", "name": "邯郸经济技术开发区" }, { "code": "130473", "name": "邯郸冀南新区" }, { "code": "130481", "name": "武安市" } ] }, { "code": "1305", "name": "邢台市", "children": [ { "code": "130502", "name": "襄都区" }, { "code": "130503", "name": "信都区" }, { "code": "130505", "name": "任泽区" }, { "code": "130506", "name": "南和区" }, { "code": "130522", "name": "临城县" }, { "code": "130523", "name": "内丘县" }, { "code": "130524", "name": "柏乡县" }, { "code": "130525", "name": "隆尧县" }, { "code": "130528", "name": "宁晋县" }, { "code": "130529", "name": "巨鹿县" }, { "code": "130530", "name": "新河县" }, { "code": "130531", "name": "广宗县" }, { "code": "130532", "name": "平乡县" }, { "code": "130533", "name": "威县" }, { "code": "130534", "name": "清河县" }, { "code": "130535", "name": "临西县" }, { "code": "130571", "name": "河北邢台经济开发区" }, { "code": "130581", "name": "南宫市" }, { "code": "130582", "name": "沙河市" } ] }, { "code": "1306", "name": "保定市", "children": [ { "code": "130602", "name": "竞秀区" }, { "code": "130606", "name": "莲池区" }, { "code": "130607", "name": "满城区" }, { "code": "130608", "name": "清苑区" }, { "code": "130609", "name": "徐水区" }, { "code": "130623", "name": "涞水县" }, { "code": "130624", "name": "阜平县" }, { "code": "130626", "name": "定兴县" }, { "code": "130627", "name": "唐县" }, { "code": "130628", "name": "高阳县" }, { "code": "130629", "name": "容城县" }, { "code": "130630", "name": "涞源县" }, { "code": "130631", "name": "望都县" }, { "code": "130632", "name": "安新县" }, { "code": "130633", "name": "易县" }, { "code": "130634", "name": "曲阳县" }, { "code": "130635", "name": "蠡县" }, { "code": "130636", "name": "顺平县" }, { "code": "130637", "name": "博野县" }, { "code": "130638", "name": "雄县" }, { "code": "130671", "name": "保定高新技术产业开发区" }, { "code": "130672", "name": "保定白沟新城" }, { "code": "130681", "name": "涿州市" }, { "code": "130682", "name": "定州市" }, { "code": "130683", "name": "安国市" }, { "code": "130684", "name": "高碑店市" } ] }, { "code": "1307", "name": "张家口市", "children": [ { "code": "130702", "name": "桥东区" }, { "code": "130703", "name": "桥西区" }, { "code": "130705", "name": "宣化区" }, { "code": "130706", "name": "下花园区" }, { "code": "130708", "name": "万全区" }, { "code": "130709", "name": "崇礼区" }, { "code": "130722", "name": "张北县" }, { "code": "130723", "name": "康保县" }, { "code": "130724", "name": "沽源县" }, { "code": "130725", "name": "尚义县" }, { "code": "130726", "name": "蔚县" }, { "code": "130727", "name": "阳原县" }, { "code": "130728", "name": "怀安县" }, { "code": "130730", "name": "怀来县" }, { "code": "130731", "name": "涿鹿县" }, { "code": "130732", "name": "赤城县" }, { "code": "130771", "name": "张家口经济开发区" }, { "code": "130772", "name": "张家口市察北管理区" }, { "code": "130773", "name": "张家口市塞北管理区" } ] }, { "code": "1308", "name": "承德市", "children": [ { "code": "130802", "name": "双桥区" }, { "code": "130803", "name": "双滦区" }, { "code": "130804", "name": "鹰手营子矿区" }, { "code": "130821", "name": "承德县" }, { "code": "130822", "name": "兴隆县" }, { "code": "130824", "name": "滦平县" }, { "code": "130825", "name": "隆化县" }, { "code": "130826", "name": "丰宁满族自治县" }, { "code": "130827", "name": "宽城满族自治县" }, { "code": "130828", "name": "围场满族蒙古族自治县" }, { "code": "130871", "name": "承德高新技术产业开发区" }, { "code": "130881", "name": "平泉市" } ] }, { "code": "1309", "name": "沧州市", "children": [ { "code": "130902", "name": "新华区" }, { "code": "130903", "name": "运河区" }, { "code": "130921", "name": "沧县" }, { "code": "130922", "name": "青县" }, { "code": "130923", "name": "东光县" }, { "code": "130924", "name": "海兴县" }, { "code": "130925", "name": "盐山县" }, { "code": "130926", "name": "肃宁县" }, { "code": "130927", "name": "南皮县" }, { "code": "130928", "name": "吴桥县" }, { "code": "130929", "name": "献县" }, { "code": "130930", "name": "孟村回族自治县" }, { "code": "130971", "name": "河北沧州经济开发区" }, { "code": "130972", "name": "沧州高新技术产业开发区" }, { "code": "130973", "name": "沧州渤海新区" }, { "code": "130981", "name": "泊头市" }, { "code": "130982", "name": "任丘市" }, { "code": "130983", "name": "黄骅市" }, { "code": "130984", "name": "河间市" } ] }, { "code": "1310", "name": "廊坊市", "children": [ { "code": "131002", "name": "安次区" }, { "code": "131003", "name": "广阳区" }, { "code": "131022", "name": "固安县" }, { "code": "131023", "name": "永清县" }, { "code": "131024", "name": "香河县" }, { "code": "131025", "name": "大城县" }, { "code": "131026", "name": "文安县" }, { "code": "131028", "name": "大厂回族自治县" }, { "code": "131071", "name": "廊坊经济技术开发区" }, { "code": "131081", "name": "霸州市" }, { "code": "131082", "name": "三河市" } ] }, { "code": "1311", "name": "衡水市", "children": [ { "code": "131102", "name": "桃城区" }, { "code": "131103", "name": "冀州区" }, { "code": "131121", "name": "枣强县" }, { "code": "131122", "name": "武邑县" }, { "code": "131123", "name": "武强县" }, { "code": "131124", "name": "饶阳县" }, { "code": "131125", "name": "安平县" }, { "code": "131126", "name": "故城县" }, { "code": "131127", "name": "景县" }, { "code": "131128", "name": "阜城县" }, { "code": "131171", "name": "河北衡水高新技术产业开发区" }, { "code": "131172", "name": "衡水滨湖新区" }, { "code": "131182", "name": "深州市" } ] } ] }, { "code": "14", "name": "山西省", "children": [ { "code": "1401", "name": "太原市", "children": [ { "code": "140105", "name": "小店区" }, { "code": "140106", "name": "迎泽区" }, { "code": "140107", "name": "杏花岭区" }, { "code": "140108", "name": "尖草坪区" }, { "code": "140109", "name": "万柏林区" }, { "code": "140110", "name": "晋源区" }, { "code": "140121", "name": "清徐县" }, { "code": "140122", "name": "阳曲县" }, { "code": "140123", "name": "娄烦县" }, { "code": "140171", "name": "山西转型综合改革示范区" }, { "code": "140181", "name": "古交市" } ] }, { "code": "1402", "name": "大同市", "children": [ { "code": "140212", "name": "新荣区" }, { "code": "140213", "name": "平城区" }, { "code": "140214", "name": "云冈区" }, { "code": "140215", "name": "云州区" }, { "code": "140221", "name": "阳高县" }, { "code": "140222", "name": "天镇县" }, { "code": "140223", "name": "广灵县" }, { "code": "140224", "name": "灵丘县" }, { "code": "140225", "name": "浑源县" }, { "code": "140226", "name": "左云县" }, { "code": "140271", "name": "山西大同经济开发区" } ] }, { "code": "1403", "name": "阳泉市", "children": [ { "code": "140302", "name": "城区" }, { "code": "140303", "name": "矿区" }, { "code": "140311", "name": "郊区" }, { "code": "140321", "name": "平定县" }, { "code": "140322", "name": "盂县" } ] }, { "code": "1404", "name": "长治市", "children": [ { "code": "140403", "name": "潞州区" }, { "code": "140404", "name": "上党区" }, { "code": "140405", "name": "屯留区" }, { "code": "140406", "name": "潞城区" }, { "code": "140423", "name": "襄垣县" }, { "code": "140425", "name": "平顺县" }, { "code": "140426", "name": "黎城县" }, { "code": "140427", "name": "壶关县" }, { "code": "140428", "name": "长子县" }, { "code": "140429", "name": "武乡县" }, { "code": "140430", "name": "沁县" }, { "code": "140431", "name": "沁源县" }, { "code": "140471", "name": "山西长治高新技术产业园区" } ] }, { "code": "1405", "name": "晋城市", "children": [ { "code": "140502", "name": "城区" }, { "code": "140521", "name": "沁水县" }, { "code": "140522", "name": "阳城县" }, { "code": "140524", "name": "陵川县" }, { "code": "140525", "name": "泽州县" }, { "code": "140581", "name": "高平市" } ] }, { "code": "1406", "name": "朔州市", "children": [ { "code": "140602", "name": "朔城区" }, { "code": "140603", "name": "平鲁区" }, { "code": "140621", "name": "山阴县" }, { "code": "140622", "name": "应县" }, { "code": "140623", "name": "右玉县" }, { "code": "140671", "name": "山西朔州经济开发区" }, { "code": "140681", "name": "怀仁市" } ] }, { "code": "1407", "name": "晋中市", "children": [ { "code": "140702", "name": "榆次区" }, { "code": "140703", "name": "太谷区" }, { "code": "140721", "name": "榆社县" }, { "code": "140722", "name": "左权县" }, { "code": "140723", "name": "和顺县" }, { "code": "140724", "name": "昔阳县" }, { "code": "140725", "name": "寿阳县" }, { "code": "140727", "name": "祁县" }, { "code": "140728", "name": "平遥县" }, { "code": "140729", "name": "灵石县" }, { "code": "140781", "name": "介休市" } ] }, { "code": "1408", "name": "运城市", "children": [ { "code": "140802", "name": "盐湖区" }, { "code": "140821", "name": "临猗县" }, { "code": "140822", "name": "万荣县" }, { "code": "140823", "name": "闻喜县" }, { "code": "140824", "name": "稷山县" }, { "code": "140825", "name": "新绛县" }, { "code": "140826", "name": "绛县" }, { "code": "140827", "name": "垣曲县" }, { "code": "140828", "name": "夏县" }, { "code": "140829", "name": "平陆县" }, { "code": "140830", "name": "芮城县" }, { "code": "140881", "name": "永济市" }, { "code": "140882", "name": "河津市" } ] }, { "code": "1409", "name": "忻州市", "children": [ { "code": "140902", "name": "忻府区" }, { "code": "140921", "name": "定襄县" }, { "code": "140922", "name": "五台县" }, { "code": "140923", "name": "代县" }, { "code": "140924", "name": "繁峙县" }, { "code": "140925", "name": "宁武县" }, { "code": "140926", "name": "静乐县" }, { "code": "140927", "name": "神池县" }, { "code": "140928", "name": "五寨县" }, { "code": "140929", "name": "岢岚县" }, { "code": "140930", "name": "河曲县" }, { "code": "140931", "name": "保德县" }, { "code": "140932", "name": "偏关县" }, { "code": "140971", "name": "五台山风景名胜区" }, { "code": "140981", "name": "原平市" } ] }, { "code": "1410", "name": "临汾市", "children": [ { "code": "141002", "name": "尧都区" }, { "code": "141021", "name": "曲沃县" }, { "code": "141022", "name": "翼城县" }, { "code": "141023", "name": "襄汾县" }, { "code": "141024", "name": "洪洞县" }, { "code": "141025", "name": "古县" }, { "code": "141026", "name": "安泽县" }, { "code": "141027", "name": "浮山县" }, { "code": "141028", "name": "吉县" }, { "code": "141029", "name": "乡宁县" }, { "code": "141030", "name": "大宁县" }, { "code": "141031", "name": "隰县" }, { "code": "141032", "name": "永和县" }, { "code": "141033", "name": "蒲县" }, { "code": "141034", "name": "汾西县" }, { "code": "141081", "name": "侯马市" }, { "code": "141082", "name": "霍州市" } ] }, { "code": "1411", "name": "吕梁市", "children": [ { "code": "141102", "name": "离石区" }, { "code": "141121", "name": "文水县" }, { "code": "141122", "name": "交城县" }, { "code": "141123", "name": "兴县" }, { "code": "141124", "name": "临县" }, { "code": "141125", "name": "柳林县" }, { "code": "141126", "name": "石楼县" }, { "code": "141127", "name": "岚县" }, { "code": "141128", "name": "方山县" }, { "code": "141129", "name": "中阳县" }, { "code": "141130", "name": "交口县" }, { "code": "141181", "name": "孝义市" }, { "code": "141182", "name": "汾阳市" } ] } ] }, { "code": "15", "name": "内蒙古自治区", "children": [ { "code": "1501", "name": "呼和浩特市", "children": [ { "code": "150102", "name": "新城区" }, { "code": "150103", "name": "回民区" }, { "code": "150104", "name": "玉泉区" }, { "code": "150105", "name": "赛罕区" }, { "code": "150121", "name": "土默特左旗" }, { "code": "150122", "name": "托克托县" }, { "code": "150123", "name": "和林格尔县" }, { "code": "150124", "name": "清水河县" }, { "code": "150125", "name": "武川县" }, { "code": "150172", "name": "呼和浩特经济技术开发区" } ] }, { "code": "1502", "name": "包头市", "children": [ { "code": "150202", "name": "东河区" }, { "code": "150203", "name": "昆都仑区" }, { "code": "150204", "name": "青山区" }, { "code": "150205", "name": "石拐区" }, { "code": "150206", "name": "白云鄂博矿区" }, { "code": "150207", "name": "九原区" }, { "code": "150221", "name": "土默特右旗" }, { "code": "150222", "name": "固阳县" }, { "code": "150223", "name": "达尔罕茂明安联合旗" }, { "code": "150271", "name": "包头稀土高新技术产业开发区" } ] }, { "code": "1503", "name": "乌海市", "children": [ { "code": "150302", "name": "海勃湾区" }, { "code": "150303", "name": "海南区" }, { "code": "150304", "name": "乌达区" } ] }, { "code": "1504", "name": "赤峰市", "children": [ { "code": "150402", "name": "红山区" }, { "code": "150403", "name": "元宝山区" }, { "code": "150404", "name": "松山区" }, { "code": "150421", "name": "阿鲁科尔沁旗" }, { "code": "150422", "name": "巴林左旗" }, { "code": "150423", "name": "巴林右旗" }, { "code": "150424", "name": "林西县" }, { "code": "150425", "name": "克什克腾旗" }, { "code": "150426", "name": "翁牛特旗" }, { "code": "150428", "name": "喀喇沁旗" }, { "code": "150429", "name": "宁城县" }, { "code": "150430", "name": "敖汉旗" } ] }, { "code": "1505", "name": "通辽市", "children": [ { "code": "150502", "name": "科尔沁区" }, { "code": "150521", "name": "科尔沁左翼中旗" }, { "code": "150522", "name": "科尔沁左翼后旗" }, { "code": "150523", "name": "开鲁县" }, { "code": "150524", "name": "库伦旗" }, { "code": "150525", "name": "奈曼旗" }, { "code": "150526", "name": "扎鲁特旗" }, { "code": "150571", "name": "通辽经济技术开发区" }, { "code": "150581", "name": "霍林郭勒市" } ] }, { "code": "1506", "name": "鄂尔多斯市", "children": [ { "code": "150602", "name": "东胜区" }, { "code": "150603", "name": "康巴什区" }, { "code": "150621", "name": "达拉特旗" }, { "code": "150622", "name": "准格尔旗" }, { "code": "150623", "name": "鄂托克前旗" }, { "code": "150624", "name": "鄂托克旗" }, { "code": "150625", "name": "杭锦旗" }, { "code": "150626", "name": "乌审旗" }, { "code": "150627", "name": "伊金霍洛旗" } ] }, { "code": "1507", "name": "呼伦贝尔市", "children": [ { "code": "150702", "name": "海拉尔区" }, { "code": "150703", "name": "扎赉诺尔区" }, { "code": "150721", "name": "阿荣旗" }, { "code": "150722", "name": "莫力达瓦达斡尔族自治旗" }, { "code": "150723", "name": "鄂伦春自治旗" }, { "code": "150724", "name": "鄂温克族自治旗" }, { "code": "150725", "name": "陈巴尔虎旗" }, { "code": "150726", "name": "新巴尔虎左旗" }, { "code": "150727", "name": "新巴尔虎右旗" }, { "code": "150781", "name": "满洲里市" }, { "code": "150782", "name": "牙克石市" }, { "code": "150783", "name": "扎兰屯市" }, { "code": "150784", "name": "额尔古纳市" }, { "code": "150785", "name": "根河市" } ] }, { "code": "1508", "name": "巴彦淖尔市", "children": [ { "code": "150802", "name": "临河区" }, { "code": "150821", "name": "五原县" }, { "code": "150822", "name": "磴口县" }, { "code": "150823", "name": "乌拉特前旗" }, { "code": "150824", "name": "乌拉特中旗" }, { "code": "150825", "name": "乌拉特后旗" }, { "code": "150826", "name": "杭锦后旗" } ] }, { "code": "1509", "name": "乌兰察布市", "children": [ { "code": "150902", "name": "集宁区" }, { "code": "150921", "name": "卓资县" }, { "code": "150922", "name": "化德县" }, { "code": "150923", "name": "商都县" }, { "code": "150924", "name": "兴和县" }, { "code": "150925", "name": "凉城县" }, { "code": "150926", "name": "察哈尔右翼前旗" }, { "code": "150927", "name": "察哈尔右翼中旗" }, { "code": "150928", "name": "察哈尔右翼后旗" }, { "code": "150929", "name": "四子王旗" }, { "code": "150981", "name": "丰镇市" } ] }, { "code": "1522", "name": "兴安盟", "children": [ { "code": "152201", "name": "乌兰浩特市" }, { "code": "152202", "name": "阿尔山市" }, { "code": "152221", "name": "科尔沁右翼前旗" }, { "code": "152222", "name": "科尔沁右翼中旗" }, { "code": "152223", "name": "扎赉特旗" }, { "code": "152224", "name": "突泉县" } ] }, { "code": "1525", "name": "锡林郭勒盟", "children": [ { "code": "152501", "name": "二连浩特市" }, { "code": "152502", "name": "锡林浩特市" }, { "code": "152522", "name": "阿巴嘎旗" }, { "code": "152523", "name": "苏尼特左旗" }, { "code": "152524", "name": "苏尼特右旗" }, { "code": "152525", "name": "东乌珠穆沁旗" }, { "code": "152526", "name": "西乌珠穆沁旗" }, { "code": "152527", "name": "太仆寺旗" }, { "code": "152528", "name": "镶黄旗" }, { "code": "152529", "name": "正镶白旗" }, { "code": "152530", "name": "正蓝旗" }, { "code": "152531", "name": "多伦县" }, { "code": "152571", "name": "乌拉盖管委会" } ] }, { "code": "1529", "name": "阿拉善盟", "children": [ { "code": "152921", "name": "阿拉善左旗" }, { "code": "152922", "name": "阿拉善右旗" }, { "code": "152923", "name": "额济纳旗" }, { "code": "152971", "name": "内蒙古阿拉善经济开发区" } ] } ] }, { "code": "21", "name": "辽宁省", "children": [ { "code": "2101", "name": "沈阳市", "children": [ { "code": "210102", "name": "和平区" }, { "code": "210103", "name": "沈河区" }, { "code": "210104", "name": "大东区" }, { "code": "210105", "name": "皇姑区" }, { "code": "210106", "name": "铁西区" }, { "code": "210111", "name": "苏家屯区" }, { "code": "210112", "name": "浑南区" }, { "code": "210113", "name": "沈北新区" }, { "code": "210114", "name": "于洪区" }, { "code": "210115", "name": "辽中区" }, { "code": "210123", "name": "康平县" }, { "code": "210124", "name": "法库县" }, { "code": "210181", "name": "新民市" } ] }, { "code": "2102", "name": "大连市", "children": [ { "code": "210202", "name": "中山区" }, { "code": "210203", "name": "西岗区" }, { "code": "210204", "name": "沙河口区" }, { "code": "210211", "name": "甘井子区" }, { "code": "210212", "name": "旅顺口区" }, { "code": "210213", "name": "金州区" }, { "code": "210214", "name": "普兰店区" }, { "code": "210224", "name": "长海县" }, { "code": "210281", "name": "瓦房店市" }, { "code": "210283", "name": "庄河市" } ] }, { "code": "2103", "name": "鞍山市", "children": [ { "code": "210302", "name": "铁东区" }, { "code": "210303", "name": "铁西区" }, { "code": "210304", "name": "立山区" }, { "code": "210311", "name": "千山区" }, { "code": "210321", "name": "台安县" }, { "code": "210323", "name": "岫岩满族自治县" }, { "code": "210381", "name": "海城市" } ] }, { "code": "2104", "name": "抚顺市", "children": [ { "code": "210402", "name": "新抚区" }, { "code": "210403", "name": "东洲区" }, { "code": "210404", "name": "望花区" }, { "code": "210411", "name": "顺城区" }, { "code": "210421", "name": "抚顺县" }, { "code": "210422", "name": "新宾满族自治县" }, { "code": "210423", "name": "清原满族自治县" } ] }, { "code": "2105", "name": "本溪市", "children": [ { "code": "210502", "name": "平山区" }, { "code": "210503", "name": "溪湖区" }, { "code": "210504", "name": "明山区" }, { "code": "210505", "name": "南芬区" }, { "code": "210521", "name": "本溪满族自治县" }, { "code": "210522", "name": "桓仁满族自治县" } ] }, { "code": "2106", "name": "丹东市", "children": [ { "code": "210602", "name": "元宝区" }, { "code": "210603", "name": "振兴区" }, { "code": "210604", "name": "振安区" }, { "code": "210624", "name": "宽甸满族自治县" }, { "code": "210681", "name": "东港市" }, { "code": "210682", "name": "凤城市" } ] }, { "code": "2107", "name": "锦州市", "children": [ { "code": "210702", "name": "古塔区" }, { "code": "210703", "name": "凌河区" }, { "code": "210711", "name": "太和区" }, { "code": "210726", "name": "黑山县" }, { "code": "210727", "name": "义县" }, { "code": "210781", "name": "凌海市" }, { "code": "210782", "name": "北镇市" } ] }, { "code": "2108", "name": "营口市", "children": [ { "code": "210802", "name": "站前区" }, { "code": "210803", "name": "西市区" }, { "code": "210804", "name": "鲅鱼圈区" }, { "code": "210811", "name": "老边区" }, { "code": "210881", "name": "盖州市" }, { "code": "210882", "name": "大石桥市" } ] }, { "code": "2109", "name": "阜新市", "children": [ { "code": "210902", "name": "海州区" }, { "code": "210903", "name": "新邱区" }, { "code": "210904", "name": "太平区" }, { "code": "210905", "name": "清河门区" }, { "code": "210911", "name": "细河区" }, { "code": "210921", "name": "阜新蒙古族自治县" }, { "code": "210922", "name": "彰武县" } ] }, { "code": "2110", "name": "辽阳市", "children": [ { "code": "211002", "name": "白塔区" }, { "code": "211003", "name": "文圣区" }, { "code": "211004", "name": "宏伟区" }, { "code": "211005", "name": "弓长岭区" }, { "code": "211011", "name": "太子河区" }, { "code": "211021", "name": "辽阳县" }, { "code": "211081", "name": "灯塔市" } ] }, { "code": "2111", "name": "盘锦市", "children": [ { "code": "211102", "name": "双台子区" }, { "code": "211103", "name": "兴隆台区" }, { "code": "211104", "name": "大洼区" }, { "code": "211122", "name": "盘山县" } ] }, { "code": "2112", "name": "铁岭市", "children": [ { "code": "211202", "name": "银州区" }, { "code": "211204", "name": "清河区" }, { "code": "211221", "name": "铁岭县" }, { "code": "211223", "name": "西丰县" }, { "code": "211224", "name": "昌图县" }, { "code": "211281", "name": "调兵山市" }, { "code": "211282", "name": "开原市" } ] }, { "code": "2113", "name": "朝阳市", "children": [ { "code": "211302", "name": "双塔区" }, { "code": "211303", "name": "龙城区" }, { "code": "211321", "name": "朝阳县" }, { "code": "211322", "name": "建平县" }, { "code": "211324", "name": "喀喇沁左翼蒙古族自治县" }, { "code": "211381", "name": "北票市" }, { "code": "211382", "name": "凌源市" } ] }, { "code": "2114", "name": "葫芦岛市", "children": [ { "code": "211402", "name": "连山区" }, { "code": "211403", "name": "龙港区" }, { "code": "211404", "name": "南票区" }, { "code": "211421", "name": "绥中县" }, { "code": "211422", "name": "建昌县" }, { "code": "211481", "name": "兴城市" } ] } ] }, { "code": "22", "name": "吉林省", "children": [ { "code": "2201", "name": "长春市", "children": [ { "code": "220102", "name": "南关区" }, { "code": "220103", "name": "宽城区" }, { "code": "220104", "name": "朝阳区" }, { "code": "220105", "name": "二道区" }, { "code": "220106", "name": "绿园区" }, { "code": "220112", "name": "双阳区" }, { "code": "220113", "name": "九台区" }, { "code": "220122", "name": "农安县" }, { "code": "220171", "name": "长春经济技术开发区" }, { "code": "220172", "name": "长春净月高新技术产业开发区" }, { "code": "220173", "name": "长春高新技术产业开发区" }, { "code": "220174", "name": "长春汽车经济技术开发区" }, { "code": "220182", "name": "榆树市" }, { "code": "220183", "name": "德惠市" }, { "code": "220184", "name": "公主岭市" } ] }, { "code": "2202", "name": "吉林市", "children": [ { "code": "220202", "name": "昌邑区" }, { "code": "220203", "name": "龙潭区" }, { "code": "220204", "name": "船营区" }, { "code": "220211", "name": "丰满区" }, { "code": "220221", "name": "永吉县" }, { "code": "220271", "name": "吉林经济开发区" }, { "code": "220272", "name": "吉林高新技术产业开发区" }, { "code": "220273", "name": "吉林中国新加坡食品区" }, { "code": "220281", "name": "蛟河市" }, { "code": "220282", "name": "桦甸市" }, { "code": "220283", "name": "舒兰市" }, { "code": "220284", "name": "磐石市" } ] }, { "code": "2203", "name": "四平市", "children": [ { "code": "220302", "name": "铁西区" }, { "code": "220303", "name": "铁东区" }, { "code": "220322", "name": "梨树县" }, { "code": "220323", "name": "伊通满族自治县" }, { "code": "220382", "name": "双辽市" } ] }, { "code": "2204", "name": "辽源市", "children": [ { "code": "220402", "name": "龙山区" }, { "code": "220403", "name": "西安区" }, { "code": "220421", "name": "东丰县" }, { "code": "220422", "name": "东辽县" } ] }, { "code": "2205", "name": "通化市", "children": [ { "code": "220502", "name": "东昌区" }, { "code": "220503", "name": "二道江区" }, { "code": "220521", "name": "通化县" }, { "code": "220523", "name": "辉南县" }, { "code": "220524", "name": "柳河县" }, { "code": "220581", "name": "梅河口市" }, { "code": "220582", "name": "集安市" } ] }, { "code": "2206", "name": "白山市", "children": [ { "code": "220602", "name": "浑江区" }, { "code": "220605", "name": "江源区" }, { "code": "220621", "name": "抚松县" }, { "code": "220622", "name": "靖宇县" }, { "code": "220623", "name": "长白朝鲜族自治县" }, { "code": "220681", "name": "临江市" } ] }, { "code": "2207", "name": "松原市", "children": [ { "code": "220702", "name": "宁江区" }, { "code": "220721", "name": "前郭尔罗斯蒙古族自治县" }, { "code": "220722", "name": "长岭县" }, { "code": "220723", "name": "乾安县" }, { "code": "220771", "name": "吉林松原经济开发区" }, { "code": "220781", "name": "扶余市" } ] }, { "code": "2208", "name": "白城市", "children": [ { "code": "220802", "name": "洮北区" }, { "code": "220821", "name": "镇赉县" }, { "code": "220822", "name": "通榆县" }, { "code": "220871", "name": "吉林白城经济开发区" }, { "code": "220881", "name": "洮南市" }, { "code": "220882", "name": "大安市" } ] }, { "code": "2224", "name": "延边朝鲜族自治州", "children": [ { "code": "222401", "name": "延吉市" }, { "code": "222402", "name": "图们市" }, { "code": "222403", "name": "敦化市" }, { "code": "222404", "name": "珲春市" }, { "code": "222405", "name": "龙井市" }, { "code": "222406", "name": "和龙市" }, { "code": "222424", "name": "汪清县" }, { "code": "222426", "name": "安图县" } ] } ] }, { "code": "23", "name": "黑龙江省", "children": [ { "code": "2301", "name": "哈尔滨市", "children": [ { "code": "230102", "name": "道里区" }, { "code": "230103", "name": "南岗区" }, { "code": "230104", "name": "道外区" }, { "code": "230108", "name": "平房区" }, { "code": "230109", "name": "松北区" }, { "code": "230110", "name": "香坊区" }, { "code": "230111", "name": "呼兰区" }, { "code": "230112", "name": "阿城区" }, { "code": "230113", "name": "双城区" }, { "code": "230123", "name": "依兰县" }, { "code": "230124", "name": "方正县" }, { "code": "230125", "name": "宾县" }, { "code": "230126", "name": "巴彦县" }, { "code": "230127", "name": "木兰县" }, { "code": "230128", "name": "通河县" }, { "code": "230129", "name": "延寿县" }, { "code": "230183", "name": "尚志市" }, { "code": "230184", "name": "五常市" } ] }, { "code": "2302", "name": "齐齐哈尔市", "children": [ { "code": "230202", "name": "龙沙区" }, { "code": "230203", "name": "建华区" }, { "code": "230204", "name": "铁锋区" }, { "code": "230205", "name": "昂昂溪区" }, { "code": "230206", "name": "富拉尔基区" }, { "code": "230207", "name": "碾子山区" }, { "code": "230208", "name": "梅里斯达斡尔族区" }, { "code": "230221", "name": "龙江县" }, { "code": "230223", "name": "依安县" }, { "code": "230224", "name": "泰来县" }, { "code": "230225", "name": "甘南县" }, { "code": "230227", "name": "富裕县" }, { "code": "230229", "name": "克山县" }, { "code": "230230", "name": "克东县" }, { "code": "230231", "name": "拜泉县" }, { "code": "230281", "name": "讷河市" } ] }, { "code": "2303", "name": "鸡西市", "children": [ { "code": "230302", "name": "鸡冠区" }, { "code": "230303", "name": "恒山区" }, { "code": "230304", "name": "滴道区" }, { "code": "230305", "name": "梨树区" }, { "code": "230306", "name": "城子河区" }, { "code": "230307", "name": "麻山区" }, { "code": "230321", "name": "鸡东县" }, { "code": "230381", "name": "虎林市" }, { "code": "230382", "name": "密山市" } ] }, { "code": "2304", "name": "鹤岗市", "children": [ { "code": "230402", "name": "向阳区" }, { "code": "230403", "name": "工农区" }, { "code": "230404", "name": "南山区" }, { "code": "230405", "name": "兴安区" }, { "code": "230406", "name": "东山区" }, { "code": "230407", "name": "兴山区" }, { "code": "230421", "name": "萝北县" }, { "code": "230422", "name": "绥滨县" } ] }, { "code": "2305", "name": "双鸭山市", "children": [ { "code": "230502", "name": "尖山区" }, { "code": "230503", "name": "岭东区" }, { "code": "230505", "name": "四方台区" }, { "code": "230506", "name": "宝山区" }, { "code": "230521", "name": "集贤县" }, { "code": "230522", "name": "友谊县" }, { "code": "230523", "name": "宝清县" }, { "code": "230524", "name": "饶河县" } ] }, { "code": "2306", "name": "大庆市", "children": [ { "code": "230602", "name": "萨尔图区" }, { "code": "230603", "name": "龙凤区" }, { "code": "230604", "name": "让胡路区" }, { "code": "230605", "name": "红岗区" }, { "code": "230606", "name": "大同区" }, { "code": "230621", "name": "肇州县" }, { "code": "230622", "name": "肇源县" }, { "code": "230623", "name": "林甸县" }, { "code": "230624", "name": "杜尔伯特蒙古族自治县" }, { "code": "230671", "name": "大庆高新技术产业开发区" } ] }, { "code": "2307", "name": "伊春市", "children": [ { "code": "230717", "name": "伊美区" }, { "code": "230718", "name": "乌翠区" }, { "code": "230719", "name": "友好区" }, { "code": "230722", "name": "嘉荫县" }, { "code": "230723", "name": "汤旺县" }, { "code": "230724", "name": "丰林县" }, { "code": "230725", "name": "大箐山县" }, { "code": "230726", "name": "南岔县" }, { "code": "230751", "name": "金林区" }, { "code": "230781", "name": "铁力市" } ] }, { "code": "2308", "name": "佳木斯市", "children": [ { "code": "230803", "name": "向阳区" }, { "code": "230804", "name": "前进区" }, { "code": "230805", "name": "东风区" }, { "code": "230811", "name": "郊区" }, { "code": "230822", "name": "桦南县" }, { "code": "230826", "name": "桦川县" }, { "code": "230828", "name": "汤原县" }, { "code": "230881", "name": "同江市" }, { "code": "230882", "name": "富锦市" }, { "code": "230883", "name": "抚远市" } ] }, { "code": "2309", "name": "七台河市", "children": [ { "code": "230902", "name": "新兴区" }, { "code": "230903", "name": "桃山区" }, { "code": "230904", "name": "茄子河区" }, { "code": "230921", "name": "勃利县" } ] }, { "code": "2310", "name": "牡丹江市", "children": [ { "code": "231002", "name": "东安区" }, { "code": "231003", "name": "阳明区" }, { "code": "231004", "name": "爱民区" }, { "code": "231005", "name": "西安区" }, { "code": "231025", "name": "林口县" }, { "code": "231071", "name": "牡丹江经济技术开发区" }, { "code": "231081", "name": "绥芬河市" }, { "code": "231083", "name": "海林市" }, { "code": "231084", "name": "宁安市" }, { "code": "231085", "name": "穆棱市" }, { "code": "231086", "name": "东宁市" } ] }, { "code": "2311", "name": "黑河市", "children": [ { "code": "231102", "name": "爱辉区" }, { "code": "231123", "name": "逊克县" }, { "code": "231124", "name": "孙吴县" }, { "code": "231181", "name": "北安市" }, { "code": "231182", "name": "五大连池市" }, { "code": "231183", "name": "嫩江市" } ] }, { "code": "2312", "name": "绥化市", "children": [ { "code": "231202", "name": "北林区" }, { "code": "231221", "name": "望奎县" }, { "code": "231222", "name": "兰西县" }, { "code": "231223", "name": "青冈县" }, { "code": "231224", "name": "庆安县" }, { "code": "231225", "name": "明水县" }, { "code": "231226", "name": "绥棱县" }, { "code": "231281", "name": "安达市" }, { "code": "231282", "name": "肇东市" }, { "code": "231283", "name": "海伦市" } ] }, { "code": "2327", "name": "大兴安岭地区", "children": [ { "code": "232701", "name": "漠河市" }, { "code": "232721", "name": "呼玛县" }, { "code": "232722", "name": "塔河县" }, { "code": "232761", "name": "加格达奇区" }, { "code": "232762", "name": "松岭区" }, { "code": "232763", "name": "新林区" }, { "code": "232764", "name": "呼中区" } ] } ] }, { "code": "31", "name": "上海市", "children": [ { "code": "3101", "name": "市辖区", "children": [ { "code": "310101", "name": "黄浦区" }, { "code": "310104", "name": "徐汇区" }, { "code": "310105", "name": "长宁区" }, { "code": "310106", "name": "静安区" }, { "code": "310107", "name": "普陀区" }, { "code": "310109", "name": "虹口区" }, { "code": "310110", "name": "杨浦区" }, { "code": "310112", "name": "闵行区" }, { "code": "310113", "name": "宝山区" }, { "code": "310114", "name": "嘉定区" }, { "code": "310115", "name": "浦东新区" }, { "code": "310116", "name": "金山区" }, { "code": "310117", "name": "松江区" }, { "code": "310118", "name": "青浦区" }, { "code": "310120", "name": "奉贤区" }, { "code": "310151", "name": "崇明区" } ] } ] }, { "code": "32", "name": "江苏省", "children": [ { "code": "3201", "name": "南京市", "children": [ { "code": "320102", "name": "玄武区" }, { "code": "320104", "name": "秦淮区" }, { "code": "320105", "name": "建邺区" }, { "code": "320106", "name": "鼓楼区" }, { "code": "320111", "name": "浦口区" }, { "code": "320113", "name": "栖霞区" }, { "code": "320114", "name": "雨花台区" }, { "code": "320115", "name": "江宁区" }, { "code": "320116", "name": "六合区" }, { "code": "320117", "name": "溧水区" }, { "code": "320118", "name": "高淳区" } ] }, { "code": "3202", "name": "无锡市", "children": [ { "code": "320205", "name": "锡山区" }, { "code": "320206", "name": "惠山区" }, { "code": "320211", "name": "滨湖区" }, { "code": "320213", "name": "梁溪区" }, { "code": "320214", "name": "新吴区" }, { "code": "320281", "name": "江阴市" }, { "code": "320282", "name": "宜兴市" } ] }, { "code": "3203", "name": "徐州市", "children": [ { "code": "320302", "name": "鼓楼区" }, { "code": "320303", "name": "云龙区" }, { "code": "320305", "name": "贾汪区" }, { "code": "320311", "name": "泉山区" }, { "code": "320312", "name": "铜山区" }, { "code": "320321", "name": "丰县" }, { "code": "320322", "name": "沛县" }, { "code": "320324", "name": "睢宁县" }, { "code": "320371", "name": "徐州经济技术开发区" }, { "code": "320381", "name": "新沂市" }, { "code": "320382", "name": "邳州市" } ] }, { "code": "3204", "name": "常州市", "children": [ { "code": "320402", "name": "天宁区" }, { "code": "320404", "name": "钟楼区" }, { "code": "320411", "name": "新北区" }, { "code": "320412", "name": "武进区" }, { "code": "320413", "name": "金坛区" }, { "code": "320481", "name": "溧阳市" } ] }, { "code": "3205", "name": "苏州市", "children": [ { "code": "320505", "name": "虎丘区" }, { "code": "320506", "name": "吴中区" }, { "code": "320507", "name": "相城区" }, { "code": "320508", "name": "姑苏区" }, { "code": "320509", "name": "吴江区" }, { "code": "320571", "name": "苏州工业园区" }, { "code": "320581", "name": "常熟市" }, { "code": "320582", "name": "张家港市" }, { "code": "320583", "name": "昆山市" }, { "code": "320585", "name": "太仓市" } ] }, { "code": "3206", "name": "南通市", "children": [ { "code": "320602", "name": "崇川区" }, { "code": "320611", "name": "港闸区" }, { "code": "320612", "name": "通州区" }, { "code": "320623", "name": "如东县" }, { "code": "320671", "name": "南通经济技术开发区" }, { "code": "320681", "name": "启东市" }, { "code": "320682", "name": "如皋市" }, { "code": "320684", "name": "海门市" }, { "code": "320685", "name": "海安市" } ] }, { "code": "3207", "name": "连云港市", "children": [ { "code": "320703", "name": "连云区" }, { "code": "320706", "name": "海州区" }, { "code": "320707", "name": "赣榆区" }, { "code": "320722", "name": "东海县" }, { "code": "320723", "name": "灌云县" }, { "code": "320724", "name": "灌南县" }, { "code": "320771", "name": "连云港经济技术开发区" }, { "code": "320772", "name": "连云港高新技术产业开发区" } ] }, { "code": "3208", "name": "淮安市", "children": [ { "code": "320803", "name": "淮安区" }, { "code": "320804", "name": "淮阴区" }, { "code": "320812", "name": "清江浦区" }, { "code": "320813", "name": "洪泽区" }, { "code": "320826", "name": "涟水县" }, { "code": "320830", "name": "盱眙县" }, { "code": "320831", "name": "金湖县" }, { "code": "320871", "name": "淮安经济技术开发区" } ] }, { "code": "3209", "name": "盐城市", "children": [ { "code": "320902", "name": "亭湖区" }, { "code": "320903", "name": "盐都区" }, { "code": "320904", "name": "大丰区" }, { "code": "320921", "name": "响水县" }, { "code": "320922", "name": "滨海县" }, { "code": "320923", "name": "阜宁县" }, { "code": "320924", "name": "射阳县" }, { "code": "320925", "name": "建湖县" }, { "code": "320971", "name": "盐城经济技术开发区" }, { "code": "320981", "name": "东台市" } ] }, { "code": "3210", "name": "扬州市", "children": [ { "code": "321002", "name": "广陵区" }, { "code": "321003", "name": "邗江区" }, { "code": "321012", "name": "江都区" }, { "code": "321023", "name": "宝应县" }, { "code": "321071", "name": "扬州经济技术开发区" }, { "code": "321081", "name": "仪征市" }, { "code": "321084", "name": "高邮市" } ] }, { "code": "3211", "name": "镇江市", "children": [ { "code": "321102", "name": "京口区" }, { "code": "321111", "name": "润州区" }, { "code": "321112", "name": "丹徒区" }, { "code": "321171", "name": "镇江新区" }, { "code": "321181", "name": "丹阳市" }, { "code": "321182", "name": "扬中市" }, { "code": "321183", "name": "句容市" } ] }, { "code": "3212", "name": "泰州市", "children": [ { "code": "321202", "name": "海陵区" }, { "code": "321203", "name": "高港区" }, { "code": "321204", "name": "姜堰区" }, { "code": "321271", "name": "泰州医药高新技术产业开发区" }, { "code": "321281", "name": "兴化市" }, { "code": "321282", "name": "靖江市" }, { "code": "321283", "name": "泰兴市" } ] }, { "code": "3213", "name": "宿迁市", "children": [ { "code": "321302", "name": "宿城区" }, { "code": "321311", "name": "宿豫区" }, { "code": "321322", "name": "沭阳县" }, { "code": "321323", "name": "泗阳县" }, { "code": "321324", "name": "泗洪县" }, { "code": "321371", "name": "宿迁经济技术开发区" } ] } ] }, { "code": "33", "name": "浙江省", "children": [ { "code": "3301", "name": "杭州市", "children": [ { "code": "330102", "name": "上城区" }, { "code": "330103", "name": "下城区" }, { "code": "330104", "name": "江干区" }, { "code": "330105", "name": "拱墅区" }, { "code": "330106", "name": "西湖区" }, { "code": "330108", "name": "滨江区" }, { "code": "330109", "name": "萧山区" }, { "code": "330110", "name": "余杭区" }, { "code": "330111", "name": "富阳区" }, { "code": "330112", "name": "临安区" }, { "code": "330122", "name": "桐庐县" }, { "code": "330127", "name": "淳安县" }, { "code": "330182", "name": "建德市" } ] }, { "code": "3302", "name": "宁波市", "children": [ { "code": "330203", "name": "海曙区" }, { "code": "330205", "name": "江北区" }, { "code": "330206", "name": "北仑区" }, { "code": "330211", "name": "镇海区" }, { "code": "330212", "name": "鄞州区" }, { "code": "330213", "name": "奉化区" }, { "code": "330225", "name": "象山县" }, { "code": "330226", "name": "宁海县" }, { "code": "330281", "name": "余姚市" }, { "code": "330282", "name": "慈溪市" } ] }, { "code": "3303", "name": "温州市", "children": [ { "code": "330302", "name": "鹿城区" }, { "code": "330303", "name": "龙湾区" }, { "code": "330304", "name": "瓯海区" }, { "code": "330305", "name": "洞头区" }, { "code": "330324", "name": "永嘉县" }, { "code": "330326", "name": "平阳县" }, { "code": "330327", "name": "苍南县" }, { "code": "330328", "name": "文成县" }, { "code": "330329", "name": "泰顺县" }, { "code": "330371", "name": "温州经济技术开发区" }, { "code": "330381", "name": "瑞安市" }, { "code": "330382", "name": "乐清市" }, { "code": "330383", "name": "龙港市" } ] }, { "code": "3304", "name": "嘉兴市", "children": [ { "code": "330402", "name": "南湖区" }, { "code": "330411", "name": "秀洲区" }, { "code": "330421", "name": "嘉善县" }, { "code": "330424", "name": "海盐县" }, { "code": "330481", "name": "海宁市" }, { "code": "330482", "name": "平湖市" }, { "code": "330483", "name": "桐乡市" } ] }, { "code": "3305", "name": "湖州市", "children": [ { "code": "330502", "name": "吴兴区" }, { "code": "330503", "name": "南浔区" }, { "code": "330521", "name": "德清县" }, { "code": "330522", "name": "长兴县" }, { "code": "330523", "name": "安吉县" } ] }, { "code": "3306", "name": "绍兴市", "children": [ { "code": "330602", "name": "越城区" }, { "code": "330603", "name": "柯桥区" }, { "code": "330604", "name": "上虞区" }, { "code": "330624", "name": "新昌县" }, { "code": "330681", "name": "诸暨市" }, { "code": "330683", "name": "嵊州市" } ] }, { "code": "3307", "name": "金华市", "children": [ { "code": "330702", "name": "婺城区" }, { "code": "330703", "name": "金东区" }, { "code": "330723", "name": "武义县" }, { "code": "330726", "name": "浦江县" }, { "code": "330727", "name": "磐安县" }, { "code": "330781", "name": "兰溪市" }, { "code": "330782", "name": "义乌市" }, { "code": "330783", "name": "东阳市" }, { "code": "330784", "name": "永康市" } ] }, { "code": "3308", "name": "衢州市", "children": [ { "code": "330802", "name": "柯城区" }, { "code": "330803", "name": "衢江区" }, { "code": "330822", "name": "常山县" }, { "code": "330824", "name": "开化县" }, { "code": "330825", "name": "龙游县" }, { "code": "330881", "name": "江山市" } ] }, { "code": "3309", "name": "舟山市", "children": [ { "code": "330902", "name": "定海区" }, { "code": "330903", "name": "普陀区" }, { "code": "330921", "name": "岱山县" }, { "code": "330922", "name": "嵊泗县" } ] }, { "code": "3310", "name": "台州市", "children": [ { "code": "331002", "name": "椒江区" }, { "code": "331003", "name": "黄岩区" }, { "code": "331004", "name": "路桥区" }, { "code": "331022", "name": "三门县" }, { "code": "331023", "name": "天台县" }, { "code": "331024", "name": "仙居县" }, { "code": "331081", "name": "温岭市" }, { "code": "331082", "name": "临海市" }, { "code": "331083", "name": "玉环市" } ] }, { "code": "3311", "name": "丽水市", "children": [ { "code": "331102", "name": "莲都区" }, { "code": "331121", "name": "青田县" }, { "code": "331122", "name": "缙云县" }, { "code": "331123", "name": "遂昌县" }, { "code": "331124", "name": "松阳县" }, { "code": "331125", "name": "云和县" }, { "code": "331126", "name": "庆元县" }, { "code": "331127", "name": "景宁畲族自治县" }, { "code": "331181", "name": "龙泉市" } ] } ] }, { "code": "34", "name": "安徽省", "children": [ { "code": "3401", "name": "合肥市", "children": [ { "code": "340102", "name": "瑶海区" }, { "code": "340103", "name": "庐阳区" }, { "code": "340104", "name": "蜀山区" }, { "code": "340111", "name": "包河区" }, { "code": "340121", "name": "长丰县" }, { "code": "340122", "name": "肥东县" }, { "code": "340123", "name": "肥西县" }, { "code": "340124", "name": "庐江县" }, { "code": "340171", "name": "合肥高新技术产业开发区" }, { "code": "340172", "name": "合肥经济技术开发区" }, { "code": "340173", "name": "合肥新站高新技术产业开发区" }, { "code": "340181", "name": "巢湖市" } ] }, { "code": "3402", "name": "芜湖市", "children": [ { "code": "340202", "name": "镜湖区" }, { "code": "340203", "name": "弋江区" }, { "code": "340207", "name": "鸠江区" }, { "code": "340208", "name": "三山区" }, { "code": "340221", "name": "芜湖县" }, { "code": "340222", "name": "繁昌县" }, { "code": "340223", "name": "南陵县" }, { "code": "340271", "name": "芜湖经济技术开发区" }, { "code": "340272", "name": "安徽芜湖长江大桥经济开发区" }, { "code": "340281", "name": "无为市" } ] }, { "code": "3403", "name": "蚌埠市", "children": [ { "code": "340302", "name": "龙子湖区" }, { "code": "340303", "name": "蚌山区" }, { "code": "340304", "name": "禹会区" }, { "code": "340311", "name": "淮上区" }, { "code": "340321", "name": "怀远县" }, { "code": "340322", "name": "五河县" }, { "code": "340323", "name": "固镇县" }, { "code": "340371", "name": "蚌埠市高新技术开发区" }, { "code": "340372", "name": "蚌埠市经济开发区" } ] }, { "code": "3404", "name": "淮南市", "children": [ { "code": "340402", "name": "大通区" }, { "code": "340403", "name": "田家庵区" }, { "code": "340404", "name": "谢家集区" }, { "code": "340405", "name": "八公山区" }, { "code": "340406", "name": "潘集区" }, { "code": "340421", "name": "凤台县" }, { "code": "340422", "name": "寿县" } ] }, { "code": "3405", "name": "马鞍山市", "children": [ { "code": "340503", "name": "花山区" }, { "code": "340504", "name": "雨山区" }, { "code": "340506", "name": "博望区" }, { "code": "340521", "name": "当涂县" }, { "code": "340522", "name": "含山县" }, { "code": "340523", "name": "和县" } ] }, { "code": "3406", "name": "淮北市", "children": [ { "code": "340602", "name": "杜集区" }, { "code": "340603", "name": "相山区" }, { "code": "340604", "name": "烈山区" }, { "code": "340621", "name": "濉溪县" } ] }, { "code": "3407", "name": "铜陵市", "children": [ { "code": "340705", "name": "铜官区" }, { "code": "340706", "name": "义安区" }, { "code": "340711", "name": "郊区" }, { "code": "340722", "name": "枞阳县" } ] }, { "code": "3408", "name": "安庆市", "children": [ { "code": "340802", "name": "迎江区" }, { "code": "340803", "name": "大观区" }, { "code": "340811", "name": "宜秀区" }, { "code": "340822", "name": "怀宁县" }, { "code": "340825", "name": "太湖县" }, { "code": "340826", "name": "宿松县" }, { "code": "340827", "name": "望江县" }, { "code": "340828", "name": "岳西县" }, { "code": "340871", "name": "安徽安庆经济开发区" }, { "code": "340881", "name": "桐城市" }, { "code": "340882", "name": "潜山市" } ] }, { "code": "3410", "name": "黄山市", "children": [ { "code": "341002", "name": "屯溪区" }, { "code": "341003", "name": "黄山区" }, { "code": "341004", "name": "徽州区" }, { "code": "341021", "name": "歙县" }, { "code": "341022", "name": "休宁县" }, { "code": "341023", "name": "黟县" }, { "code": "341024", "name": "祁门县" } ] }, { "code": "3411", "name": "滁州市", "children": [ { "code": "341102", "name": "琅琊区" }, { "code": "341103", "name": "南谯区" }, { "code": "341122", "name": "来安县" }, { "code": "341124", "name": "全椒县" }, { "code": "341125", "name": "定远县" }, { "code": "341126", "name": "凤阳县" }, { "code": "341171", "name": "苏滁现代产业园" }, { "code": "341172", "name": "滁州经济技术开发区" }, { "code": "341181", "name": "天长市" }, { "code": "341182", "name": "明光市" } ] }, { "code": "3412", "name": "阜阳市", "children": [ { "code": "341202", "name": "颍州区" }, { "code": "341203", "name": "颍东区" }, { "code": "341204", "name": "颍泉区" }, { "code": "341221", "name": "临泉县" }, { "code": "341222", "name": "太和县" }, { "code": "341225", "name": "阜南县" }, { "code": "341226", "name": "颍上县" }, { "code": "341271", "name": "阜阳合肥现代产业园区" }, { "code": "341272", "name": "阜阳经济技术开发区" }, { "code": "341282", "name": "界首市" } ] }, { "code": "3413", "name": "宿州市", "children": [ { "code": "341302", "name": "埇桥区" }, { "code": "341321", "name": "砀山县" }, { "code": "341322", "name": "萧县" }, { "code": "341323", "name": "灵璧县" }, { "code": "341324", "name": "泗县" }, { "code": "341371", "name": "宿州马鞍山现代产业园区" }, { "code": "341372", "name": "宿州经济技术开发区" } ] }, { "code": "3415", "name": "六安市", "children": [ { "code": "341502", "name": "金安区" }, { "code": "341503", "name": "裕安区" }, { "code": "341504", "name": "叶集区" }, { "code": "341522", "name": "霍邱县" }, { "code": "341523", "name": "舒城县" }, { "code": "341524", "name": "金寨县" }, { "code": "341525", "name": "霍山县" } ] }, { "code": "3416", "name": "亳州市", "children": [ { "code": "341602", "name": "谯城区" }, { "code": "341621", "name": "涡阳县" }, { "code": "341622", "name": "蒙城县" }, { "code": "341623", "name": "利辛县" } ] }, { "code": "3417", "name": "池州市", "children": [ { "code": "341702", "name": "贵池区" }, { "code": "341721", "name": "东至县" }, { "code": "341722", "name": "石台县" }, { "code": "341723", "name": "青阳县" } ] }, { "code": "3418", "name": "宣城市", "children": [ { "code": "341802", "name": "宣州区" }, { "code": "341821", "name": "郎溪县" }, { "code": "341823", "name": "泾县" }, { "code": "341824", "name": "绩溪县" }, { "code": "341825", "name": "旌德县" }, { "code": "341871", "name": "宣城市经济开发区" }, { "code": "341881", "name": "宁国市" }, { "code": "341882", "name": "广德市" } ] } ] }, { "code": "35", "name": "福建省", "children": [ { "code": "3501", "name": "福州市", "children": [ { "code": "350102", "name": "鼓楼区" }, { "code": "350103", "name": "台江区" }, { "code": "350104", "name": "仓山区" }, { "code": "350105", "name": "马尾区" }, { "code": "350111", "name": "晋安区" }, { "code": "350112", "name": "长乐区" }, { "code": "350121", "name": "闽侯县" }, { "code": "350122", "name": "连江县" }, { "code": "350123", "name": "罗源县" }, { "code": "350124", "name": "闽清县" }, { "code": "350125", "name": "永泰县" }, { "code": "350128", "name": "平潭县" }, { "code": "350181", "name": "福清市" } ] }, { "code": "3502", "name": "厦门市", "children": [ { "code": "350203", "name": "思明区" }, { "code": "350205", "name": "海沧区" }, { "code": "350206", "name": "湖里区" }, { "code": "350211", "name": "集美区" }, { "code": "350212", "name": "同安区" }, { "code": "350213", "name": "翔安区" } ] }, { "code": "3503", "name": "莆田市", "children": [ { "code": "350302", "name": "城厢区" }, { "code": "350303", "name": "涵江区" }, { "code": "350304", "name": "荔城区" }, { "code": "350305", "name": "秀屿区" }, { "code": "350322", "name": "仙游县" } ] }, { "code": "3504", "name": "三明市", "children": [ { "code": "350402", "name": "梅列区" }, { "code": "350403", "name": "三元区" }, { "code": "350421", "name": "明溪县" }, { "code": "350423", "name": "清流县" }, { "code": "350424", "name": "宁化县" }, { "code": "350425", "name": "大田县" }, { "code": "350426", "name": "尤溪县" }, { "code": "350427", "name": "沙县" }, { "code": "350428", "name": "将乐县" }, { "code": "350429", "name": "泰宁县" }, { "code": "350430", "name": "建宁县" }, { "code": "350481", "name": "永安市" } ] }, { "code": "3505", "name": "泉州市", "children": [ { "code": "350502", "name": "鲤城区" }, { "code": "350503", "name": "丰泽区" }, { "code": "350504", "name": "洛江区" }, { "code": "350505", "name": "泉港区" }, { "code": "350521", "name": "惠安县" }, { "code": "350524", "name": "安溪县" }, { "code": "350525", "name": "永春县" }, { "code": "350526", "name": "德化县" }, { "code": "350527", "name": "金门县" }, { "code": "350581", "name": "石狮市" }, { "code": "350582", "name": "晋江市" }, { "code": "350583", "name": "南安市" } ] }, { "code": "3506", "name": "漳州市", "children": [ { "code": "350602", "name": "芗城区" }, { "code": "350603", "name": "龙文区" }, { "code": "350622", "name": "云霄县" }, { "code": "350623", "name": "漳浦县" }, { "code": "350624", "name": "诏安县" }, { "code": "350625", "name": "长泰县" }, { "code": "350626", "name": "东山县" }, { "code": "350627", "name": "南靖县" }, { "code": "350628", "name": "平和县" }, { "code": "350629", "name": "华安县" }, { "code": "350681", "name": "龙海市" } ] }, { "code": "3507", "name": "南平市", "children": [ { "code": "350702", "name": "延平区" }, { "code": "350703", "name": "建阳区" }, { "code": "350721", "name": "顺昌县" }, { "code": "350722", "name": "浦城县" }, { "code": "350723", "name": "光泽县" }, { "code": "350724", "name": "松溪县" }, { "code": "350725", "name": "政和县" }, { "code": "350781", "name": "邵武市" }, { "code": "350782", "name": "武夷山市" }, { "code": "350783", "name": "建瓯市" } ] }, { "code": "3508", "name": "龙岩市", "children": [ { "code": "350802", "name": "新罗区" }, { "code": "350803", "name": "永定区" }, { "code": "350821", "name": "长汀县" }, { "code": "350823", "name": "上杭县" }, { "code": "350824", "name": "武平县" }, { "code": "350825", "name": "连城县" }, { "code": "350881", "name": "漳平市" } ] }, { "code": "3509", "name": "宁德市", "children": [ { "code": "350902", "name": "蕉城区" }, { "code": "350921", "name": "霞浦县" }, { "code": "350922", "name": "古田县" }, { "code": "350923", "name": "屏南县" }, { "code": "350924", "name": "寿宁县" }, { "code": "350925", "name": "周宁县" }, { "code": "350926", "name": "柘荣县" }, { "code": "350981", "name": "福安市" }, { "code": "350982", "name": "福鼎市" } ] } ] }, { "code": "36", "name": "江西省", "children": [ { "code": "3601", "name": "南昌市", "children": [ { "code": "360102", "name": "东湖区" }, { "code": "360103", "name": "西湖区" }, { "code": "360104", "name": "青云谱区" }, { "code": "360111", "name": "青山湖区" }, { "code": "360112", "name": "新建区" }, { "code": "360113", "name": "红谷滩区" }, { "code": "360121", "name": "南昌县" }, { "code": "360123", "name": "安义县" }, { "code": "360124", "name": "进贤县" } ] }, { "code": "3602", "name": "景德镇市", "children": [ { "code": "360202", "name": "昌江区" }, { "code": "360203", "name": "珠山区" }, { "code": "360222", "name": "浮梁县" }, { "code": "360281", "name": "乐平市" } ] }, { "code": "3603", "name": "萍乡市", "children": [ { "code": "360302", "name": "安源区" }, { "code": "360313", "name": "湘东区" }, { "code": "360321", "name": "莲花县" }, { "code": "360322", "name": "上栗县" }, { "code": "360323", "name": "芦溪县" } ] }, { "code": "3604", "name": "九江市", "children": [ { "code": "360402", "name": "濂溪区" }, { "code": "360403", "name": "浔阳区" }, { "code": "360404", "name": "柴桑区" }, { "code": "360423", "name": "武宁县" }, { "code": "360424", "name": "修水县" }, { "code": "360425", "name": "永修县" }, { "code": "360426", "name": "德安县" }, { "code": "360428", "name": "都昌县" }, { "code": "360429", "name": "湖口县" }, { "code": "360430", "name": "彭泽县" }, { "code": "360481", "name": "瑞昌市" }, { "code": "360482", "name": "共青城市" }, { "code": "360483", "name": "庐山市" } ] }, { "code": "3605", "name": "新余市", "children": [ { "code": "360502", "name": "渝水区" }, { "code": "360521", "name": "分宜县" } ] }, { "code": "3606", "name": "鹰潭市", "children": [ { "code": "360602", "name": "月湖区" }, { "code": "360603", "name": "余江区" }, { "code": "360681", "name": "贵溪市" } ] }, { "code": "3607", "name": "赣州市", "children": [ { "code": "360702", "name": "章贡区" }, { "code": "360703", "name": "南康区" }, { "code": "360704", "name": "赣县区" }, { "code": "360722", "name": "信丰县" }, { "code": "360723", "name": "大余县" }, { "code": "360724", "name": "上犹县" }, { "code": "360725", "name": "崇义县" }, { "code": "360726", "name": "安远县" }, { "code": "360728", "name": "定南县" }, { "code": "360729", "name": "全南县" }, { "code": "360730", "name": "宁都县" }, { "code": "360731", "name": "于都县" }, { "code": "360732", "name": "兴国县" }, { "code": "360733", "name": "会昌县" }, { "code": "360734", "name": "寻乌县" }, { "code": "360735", "name": "石城县" }, { "code": "360781", "name": "瑞金市" }, { "code": "360783", "name": "龙南市" } ] }, { "code": "3608", "name": "吉安市", "children": [ { "code": "360802", "name": "吉州区" }, { "code": "360803", "name": "青原区" }, { "code": "360821", "name": "吉安县" }, { "code": "360822", "name": "吉水县" }, { "code": "360823", "name": "峡江县" }, { "code": "360824", "name": "新干县" }, { "code": "360825", "name": "永丰县" }, { "code": "360826", "name": "泰和县" }, { "code": "360827", "name": "遂川县" }, { "code": "360828", "name": "万安县" }, { "code": "360829", "name": "安福县" }, { "code": "360830", "name": "永新县" }, { "code": "360881", "name": "井冈山市" } ] }, { "code": "3609", "name": "宜春市", "children": [ { "code": "360902", "name": "袁州区" }, { "code": "360921", "name": "奉新县" }, { "code": "360922", "name": "万载县" }, { "code": "360923", "name": "上高县" }, { "code": "360924", "name": "宜丰县" }, { "code": "360925", "name": "靖安县" }, { "code": "360926", "name": "铜鼓县" }, { "code": "360981", "name": "丰城市" }, { "code": "360982", "name": "樟树市" }, { "code": "360983", "name": "高安市" } ] }, { "code": "3610", "name": "抚州市", "children": [ { "code": "361002", "name": "临川区" }, { "code": "361003", "name": "东乡区" }, { "code": "361021", "name": "南城县" }, { "code": "361022", "name": "黎川县" }, { "code": "361023", "name": "南丰县" }, { "code": "361024", "name": "崇仁县" }, { "code": "361025", "name": "乐安县" }, { "code": "361026", "name": "宜黄县" }, { "code": "361027", "name": "金溪县" }, { "code": "361028", "name": "资溪县" }, { "code": "361030", "name": "广昌县" } ] }, { "code": "3611", "name": "上饶市", "children": [ { "code": "361102", "name": "信州区" }, { "code": "361103", "name": "广丰区" }, { "code": "361104", "name": "广信区" }, { "code": "361123", "name": "玉山县" }, { "code": "361124", "name": "铅山县" }, { "code": "361125", "name": "横峰县" }, { "code": "361126", "name": "弋阳县" }, { "code": "361127", "name": "余干县" }, { "code": "361128", "name": "鄱阳县" }, { "code": "361129", "name": "万年县" }, { "code": "361130", "name": "婺源县" }, { "code": "361181", "name": "德兴市" } ] } ] }, { "code": "37", "name": "山东省", "children": [ { "code": "3701", "name": "济南市", "children": [ { "code": "370102", "name": "历下区" }, { "code": "370103", "name": "市中区" }, { "code": "370104", "name": "槐荫区" }, { "code": "370105", "name": "天桥区" }, { "code": "370112", "name": "历城区" }, { "code": "370113", "name": "长清区" }, { "code": "370114", "name": "章丘区" }, { "code": "370115", "name": "济阳区" }, { "code": "370116", "name": "莱芜区" }, { "code": "370117", "name": "钢城区" }, { "code": "370124", "name": "平阴县" }, { "code": "370126", "name": "商河县" }, { "code": "370171", "name": "济南高新技术产业开发区" } ] }, { "code": "3702", "name": "青岛市", "children": [ { "code": "370202", "name": "市南区" }, { "code": "370203", "name": "市北区" }, { "code": "370211", "name": "黄岛区" }, { "code": "370212", "name": "崂山区" }, { "code": "370213", "name": "李沧区" }, { "code": "370214", "name": "城阳区" }, { "code": "370215", "name": "即墨区" }, { "code": "370271", "name": "青岛高新技术产业开发区" }, { "code": "370281", "name": "胶州市" }, { "code": "370283", "name": "平度市" }, { "code": "370285", "name": "莱西市" } ] }, { "code": "3703", "name": "淄博市", "children": [ { "code": "370302", "name": "淄川区" }, { "code": "370303", "name": "张店区" }, { "code": "370304", "name": "博山区" }, { "code": "370305", "name": "临淄区" }, { "code": "370306", "name": "周村区" }, { "code": "370321", "name": "桓台县" }, { "code": "370322", "name": "高青县" }, { "code": "370323", "name": "沂源县" } ] }, { "code": "3704", "name": "枣庄市", "children": [ { "code": "370402", "name": "市中区" }, { "code": "370403", "name": "薛城区" }, { "code": "370404", "name": "峄城区" }, { "code": "370405", "name": "台儿庄区" }, { "code": "370406", "name": "山亭区" }, { "code": "370481", "name": "滕州市" } ] }, { "code": "3705", "name": "东营市", "children": [ { "code": "370502", "name": "东营区" }, { "code": "370503", "name": "河口区" }, { "code": "370505", "name": "垦利区" }, { "code": "370522", "name": "利津县" }, { "code": "370523", "name": "广饶县" }, { "code": "370571", "name": "东营经济技术开发区" }, { "code": "370572", "name": "东营港经济开发区" } ] }, { "code": "3706", "name": "烟台市", "children": [ { "code": "370602", "name": "芝罘区" }, { "code": "370611", "name": "福山区" }, { "code": "370612", "name": "牟平区" }, { "code": "370613", "name": "莱山区" }, { "code": "370614", "name": "蓬莱区" }, { "code": "370671", "name": "烟台高新技术产业开发区" }, { "code": "370672", "name": "烟台经济技术开发区" }, { "code": "370681", "name": "龙口市" }, { "code": "370682", "name": "莱阳市" }, { "code": "370683", "name": "莱州市" }, { "code": "370685", "name": "招远市" }, { "code": "370686", "name": "栖霞市" }, { "code": "370687", "name": "海阳市" } ] }, { "code": "3707", "name": "潍坊市", "children": [ { "code": "370702", "name": "潍城区" }, { "code": "370703", "name": "寒亭区" }, { "code": "370704", "name": "坊子区" }, { "code": "370705", "name": "奎文区" }, { "code": "370724", "name": "临朐县" }, { "code": "370725", "name": "昌乐县" }, { "code": "370772", "name": "潍坊滨海经济技术开发区" }, { "code": "370781", "name": "青州市" }, { "code": "370782", "name": "诸城市" }, { "code": "370783", "name": "寿光市" }, { "code": "370784", "name": "安丘市" }, { "code": "370785", "name": "高密市" }, { "code": "370786", "name": "昌邑市" } ] }, { "code": "3708", "name": "济宁市", "children": [ { "code": "370811", "name": "任城区" }, { "code": "370812", "name": "兖州区" }, { "code": "370826", "name": "微山县" }, { "code": "370827", "name": "鱼台县" }, { "code": "370828", "name": "金乡县" }, { "code": "370829", "name": "嘉祥县" }, { "code": "370830", "name": "汶上县" }, { "code": "370831", "name": "泗水县" }, { "code": "370832", "name": "梁山县" }, { "code": "370871", "name": "济宁高新技术产业开发区" }, { "code": "370881", "name": "曲阜市" }, { "code": "370883", "name": "邹城市" } ] }, { "code": "3709", "name": "泰安市", "children": [ { "code": "370902", "name": "泰山区" }, { "code": "370911", "name": "岱岳区" }, { "code": "370921", "name": "宁阳县" }, { "code": "370923", "name": "东平县" }, { "code": "370982", "name": "新泰市" }, { "code": "370983", "name": "肥城市" } ] }, { "code": "3710", "name": "威海市", "children": [ { "code": "371002", "name": "环翠区" }, { "code": "371003", "name": "文登区" }, { "code": "371071", "name": "威海火炬高技术产业开发区" }, { "code": "371072", "name": "威海经济技术开发区" }, { "code": "371073", "name": "威海临港经济技术开发区" }, { "code": "371082", "name": "荣成市" }, { "code": "371083", "name": "乳山市" } ] }, { "code": "3711", "name": "日照市", "children": [ { "code": "371102", "name": "东港区" }, { "code": "371103", "name": "岚山区" }, { "code": "371121", "name": "五莲县" }, { "code": "371122", "name": "莒县" }, { "code": "371171", "name": "日照经济技术开发区" } ] }, { "code": "3713", "name": "临沂市", "children": [ { "code": "371302", "name": "兰山区" }, { "code": "371311", "name": "罗庄区" }, { "code": "371312", "name": "河东区" }, { "code": "371321", "name": "沂南县" }, { "code": "371322", "name": "郯城县" }, { "code": "371323", "name": "沂水县" }, { "code": "371324", "name": "兰陵县" }, { "code": "371325", "name": "费县" }, { "code": "371326", "name": "平邑县" }, { "code": "371327", "name": "莒南县" }, { "code": "371328", "name": "蒙阴县" }, { "code": "371329", "name": "临沭县" }, { "code": "371371", "name": "临沂高新技术产业开发区" } ] }, { "code": "3714", "name": "德州市", "children": [ { "code": "371402", "name": "德城区" }, { "code": "371403", "name": "陵城区" }, { "code": "371422", "name": "宁津县" }, { "code": "371423", "name": "庆云县" }, { "code": "371424", "name": "临邑县" }, { "code": "371425", "name": "齐河县" }, { "code": "371426", "name": "平原县" }, { "code": "371427", "name": "夏津县" }, { "code": "371428", "name": "武城县" }, { "code": "371471", "name": "德州经济技术开发区" }, { "code": "371472", "name": "德州运河经济开发区" }, { "code": "371481", "name": "乐陵市" }, { "code": "371482", "name": "禹城市" } ] }, { "code": "3715", "name": "聊城市", "children": [ { "code": "371502", "name": "东昌府区" }, { "code": "371503", "name": "茌平区" }, { "code": "371521", "name": "阳谷县" }, { "code": "371522", "name": "莘县" }, { "code": "371524", "name": "东阿县" }, { "code": "371525", "name": "冠县" }, { "code": "371526", "name": "高唐县" }, { "code": "371581", "name": "临清市" } ] }, { "code": "3716", "name": "滨州市", "children": [ { "code": "371602", "name": "滨城区" }, { "code": "371603", "name": "沾化区" }, { "code": "371621", "name": "惠民县" }, { "code": "371622", "name": "阳信县" }, { "code": "371623", "name": "无棣县" }, { "code": "371625", "name": "博兴县" }, { "code": "371681", "name": "邹平市" } ] }, { "code": "3717", "name": "菏泽市", "children": [ { "code": "371702", "name": "牡丹区" }, { "code": "371703", "name": "定陶区" }, { "code": "371721", "name": "曹县" }, { "code": "371722", "name": "单县" }, { "code": "371723", "name": "成武县" }, { "code": "371724", "name": "巨野县" }, { "code": "371725", "name": "郓城县" }, { "code": "371726", "name": "鄄城县" }, { "code": "371728", "name": "东明县" }, { "code": "371771", "name": "菏泽经济技术开发区" }, { "code": "371772", "name": "菏泽高新技术开发区" } ] } ] }, { "code": "41", "name": "河南省", "children": [ { "code": "4101", "name": "郑州市", "children": [ { "code": "410102", "name": "中原区" }, { "code": "410103", "name": "二七区" }, { "code": "410104", "name": "管城回族区" }, { "code": "410105", "name": "金水区" }, { "code": "410106", "name": "上街区" }, { "code": "410108", "name": "惠济区" }, { "code": "410122", "name": "中牟县" }, { "code": "410171", "name": "郑州经济技术开发区" }, { "code": "410172", "name": "郑州高新技术产业开发区" }, { "code": "410173", "name": "郑州航空港经济综合实验区" }, { "code": "410181", "name": "巩义市" }, { "code": "410182", "name": "荥阳市" }, { "code": "410183", "name": "新密市" }, { "code": "410184", "name": "新郑市" }, { "code": "410185", "name": "登封市" } ] }, { "code": "4102", "name": "开封市", "children": [ { "code": "410202", "name": "龙亭区" }, { "code": "410203", "name": "顺河回族区" }, { "code": "410204", "name": "鼓楼区" }, { "code": "410205", "name": "禹王台区" }, { "code": "410212", "name": "祥符区" }, { "code": "410221", "name": "杞县" }, { "code": "410222", "name": "通许县" }, { "code": "410223", "name": "尉氏县" }, { "code": "410225", "name": "兰考县" } ] }, { "code": "4103", "name": "洛阳市", "children": [ { "code": "410302", "name": "老城区" }, { "code": "410303", "name": "西工区" }, { "code": "410304", "name": "瀍河回族区" }, { "code": "410305", "name": "涧西区" }, { "code": "410306", "name": "吉利区" }, { "code": "410311", "name": "洛龙区" }, { "code": "410322", "name": "孟津县" }, { "code": "410323", "name": "新安县" }, { "code": "410324", "name": "栾川县" }, { "code": "410325", "name": "嵩县" }, { "code": "410326", "name": "汝阳县" }, { "code": "410327", "name": "宜阳县" }, { "code": "410328", "name": "洛宁县" }, { "code": "410329", "name": "伊川县" }, { "code": "410371", "name": "洛阳高新技术产业开发区" }, { "code": "410381", "name": "偃师市" } ] }, { "code": "4104", "name": "平顶山市", "children": [ { "code": "410402", "name": "新华区" }, { "code": "410403", "name": "卫东区" }, { "code": "410404", "name": "石龙区" }, { "code": "410411", "name": "湛河区" }, { "code": "410421", "name": "宝丰县" }, { "code": "410422", "name": "叶县" }, { "code": "410423", "name": "鲁山县" }, { "code": "410425", "name": "郏县" }, { "code": "410471", "name": "平顶山高新技术产业开发区" }, { "code": "410472", "name": "平顶山市城乡一体化示范区" }, { "code": "410481", "name": "舞钢市" }, { "code": "410482", "name": "汝州市" } ] }, { "code": "4105", "name": "安阳市", "children": [ { "code": "410502", "name": "文峰区" }, { "code": "410503", "name": "北关区" }, { "code": "410505", "name": "殷都区" }, { "code": "410506", "name": "龙安区" }, { "code": "410522", "name": "安阳县" }, { "code": "410523", "name": "汤阴县" }, { "code": "410526", "name": "滑县" }, { "code": "410527", "name": "内黄县" }, { "code": "410571", "name": "安阳高新技术产业开发区" }, { "code": "410581", "name": "林州市" } ] }, { "code": "4106", "name": "鹤壁市", "children": [ { "code": "410602", "name": "鹤山区" }, { "code": "410603", "name": "山城区" }, { "code": "410611", "name": "淇滨区" }, { "code": "410621", "name": "浚县" }, { "code": "410622", "name": "淇县" }, { "code": "410671", "name": "鹤壁经济技术开发区" } ] }, { "code": "4107", "name": "新乡市", "children": [ { "code": "410702", "name": "红旗区" }, { "code": "410703", "name": "卫滨区" }, { "code": "410704", "name": "凤泉区" }, { "code": "410711", "name": "牧野区" }, { "code": "410721", "name": "新乡县" }, { "code": "410724", "name": "获嘉县" }, { "code": "410725", "name": "原阳县" }, { "code": "410726", "name": "延津县" }, { "code": "410727", "name": "封丘县" }, { "code": "410771", "name": "新乡高新技术产业开发区" }, { "code": "410772", "name": "新乡经济技术开发区" }, { "code": "410773", "name": "新乡市平原城乡一体化示范区" }, { "code": "410781", "name": "卫辉市" }, { "code": "410782", "name": "辉县市" }, { "code": "410783", "name": "长垣市" } ] }, { "code": "4108", "name": "焦作市", "children": [ { "code": "410802", "name": "解放区" }, { "code": "410803", "name": "中站区" }, { "code": "410804", "name": "马村区" }, { "code": "410811", "name": "山阳区" }, { "code": "410821", "name": "修武县" }, { "code": "410822", "name": "博爱县" }, { "code": "410823", "name": "武陟县" }, { "code": "410825", "name": "温县" }, { "code": "410871", "name": "焦作城乡一体化示范区" }, { "code": "410882", "name": "沁阳市" }, { "code": "410883", "name": "孟州市" } ] }, { "code": "4109", "name": "濮阳市", "children": [ { "code": "410902", "name": "华龙区" }, { "code": "410922", "name": "清丰县" }, { "code": "410923", "name": "南乐县" }, { "code": "410926", "name": "范县" }, { "code": "410927", "name": "台前县" }, { "code": "410928", "name": "濮阳县" }, { "code": "410971", "name": "河南濮阳工业园区" }, { "code": "410972", "name": "濮阳经济技术开发区" } ] }, { "code": "4110", "name": "许昌市", "children": [ { "code": "411002", "name": "魏都区" }, { "code": "411003", "name": "建安区" }, { "code": "411024", "name": "鄢陵县" }, { "code": "411025", "name": "襄城县" }, { "code": "411071", "name": "许昌经济技术开发区" }, { "code": "411081", "name": "禹州市" }, { "code": "411082", "name": "长葛市" } ] }, { "code": "4111", "name": "漯河市", "children": [ { "code": "411102", "name": "源汇区" }, { "code": "411103", "name": "郾城区" }, { "code": "411104", "name": "召陵区" }, { "code": "411121", "name": "舞阳县" }, { "code": "411122", "name": "临颍县" }, { "code": "411171", "name": "漯河经济技术开发区" } ] }, { "code": "4112", "name": "三门峡市", "children": [ { "code": "411202", "name": "湖滨区" }, { "code": "411203", "name": "陕州区" }, { "code": "411221", "name": "渑池县" }, { "code": "411224", "name": "卢氏县" }, { "code": "411271", "name": "河南三门峡经济开发区" }, { "code": "411281", "name": "义马市" }, { "code": "411282", "name": "灵宝市" } ] }, { "code": "4113", "name": "南阳市", "children": [ { "code": "411302", "name": "宛城区" }, { "code": "411303", "name": "卧龙区" }, { "code": "411321", "name": "南召县" }, { "code": "411322", "name": "方城县" }, { "code": "411323", "name": "西峡县" }, { "code": "411324", "name": "镇平县" }, { "code": "411325", "name": "内乡县" }, { "code": "411326", "name": "淅川县" }, { "code": "411327", "name": "社旗县" }, { "code": "411328", "name": "唐河县" }, { "code": "411329", "name": "新野县" }, { "code": "411330", "name": "桐柏县" }, { "code": "411371", "name": "南阳高新技术产业开发区" }, { "code": "411372", "name": "南阳市城乡一体化示范区" }, { "code": "411381", "name": "邓州市" } ] }, { "code": "4114", "name": "商丘市", "children": [ { "code": "411402", "name": "梁园区" }, { "code": "411403", "name": "睢阳区" }, { "code": "411421", "name": "民权县" }, { "code": "411422", "name": "睢县" }, { "code": "411423", "name": "宁陵县" }, { "code": "411424", "name": "柘城县" }, { "code": "411425", "name": "虞城县" }, { "code": "411426", "name": "夏邑县" }, { "code": "411471", "name": "豫东综合物流产业聚集区" }, { "code": "411472", "name": "河南商丘经济开发区" }, { "code": "411481", "name": "永城市" } ] }, { "code": "4115", "name": "信阳市", "children": [ { "code": "411502", "name": "浉河区" }, { "code": "411503", "name": "平桥区" }, { "code": "411521", "name": "罗山县" }, { "code": "411522", "name": "光山县" }, { "code": "411523", "name": "新县" }, { "code": "411524", "name": "商城县" }, { "code": "411525", "name": "固始县" }, { "code": "411526", "name": "潢川县" }, { "code": "411527", "name": "淮滨县" }, { "code": "411528", "name": "息县" }, { "code": "411571", "name": "信阳高新技术产业开发区" } ] }, { "code": "4116", "name": "周口市", "children": [ { "code": "411602", "name": "川汇区" }, { "code": "411603", "name": "淮阳区" }, { "code": "411621", "name": "扶沟县" }, { "code": "411622", "name": "西华县" }, { "code": "411623", "name": "商水县" }, { "code": "411624", "name": "沈丘县" }, { "code": "411625", "name": "郸城县" }, { "code": "411627", "name": "太康县" }, { "code": "411628", "name": "鹿邑县" }, { "code": "411671", "name": "河南周口经济开发区" }, { "code": "411681", "name": "项城市" } ] }, { "code": "4117", "name": "驻马店市", "children": [ { "code": "411702", "name": "驿城区" }, { "code": "411721", "name": "西平县" }, { "code": "411722", "name": "上蔡县" }, { "code": "411723", "name": "平舆县" }, { "code": "411724", "name": "正阳县" }, { "code": "411725", "name": "确山县" }, { "code": "411726", "name": "泌阳县" }, { "code": "411727", "name": "汝南县" }, { "code": "411728", "name": "遂平县" }, { "code": "411729", "name": "新蔡县" }, { "code": "411771", "name": "河南驻马店经济开发区" } ] }, { "code": "4190", "name": "省直辖县级行政区划", "children": [ { "code": "419001", "name": "济源市" } ] } ] }, { "code": "42", "name": "湖北省", "children": [ { "code": "4201", "name": "武汉市", "children": [ { "code": "420102", "name": "江岸区" }, { "code": "420103", "name": "江汉区" }, { "code": "420104", "name": "硚口区" }, { "code": "420105", "name": "汉阳区" }, { "code": "420106", "name": "武昌区" }, { "code": "420107", "name": "青山区" }, { "code": "420111", "name": "洪山区" }, { "code": "420112", "name": "东西湖区" }, { "code": "420113", "name": "汉南区" }, { "code": "420114", "name": "蔡甸区" }, { "code": "420115", "name": "江夏区" }, { "code": "420116", "name": "黄陂区" }, { "code": "420117", "name": "新洲区" } ] }, { "code": "4202", "name": "黄石市", "children": [ { "code": "420202", "name": "黄石港区" }, { "code": "420203", "name": "西塞山区" }, { "code": "420204", "name": "下陆区" }, { "code": "420205", "name": "铁山区" }, { "code": "420222", "name": "阳新县" }, { "code": "420281", "name": "大冶市" } ] }, { "code": "4203", "name": "十堰市", "children": [ { "code": "420302", "name": "茅箭区" }, { "code": "420303", "name": "张湾区" }, { "code": "420304", "name": "郧阳区" }, { "code": "420322", "name": "郧西县" }, { "code": "420323", "name": "竹山县" }, { "code": "420324", "name": "竹溪县" }, { "code": "420325", "name": "房县" }, { "code": "420381", "name": "丹江口市" } ] }, { "code": "4205", "name": "宜昌市", "children": [ { "code": "420502", "name": "西陵区" }, { "code": "420503", "name": "伍家岗区" }, { "code": "420504", "name": "点军区" }, { "code": "420505", "name": "猇亭区" }, { "code": "420506", "name": "夷陵区" }, { "code": "420525", "name": "远安县" }, { "code": "420526", "name": "兴山县" }, { "code": "420527", "name": "秭归县" }, { "code": "420528", "name": "长阳土家族自治县" }, { "code": "420529", "name": "五峰土家族自治县" }, { "code": "420581", "name": "宜都市" }, { "code": "420582", "name": "当阳市" }, { "code": "420583", "name": "枝江市" } ] }, { "code": "4206", "name": "襄阳市", "children": [ { "code": "420602", "name": "襄城区" }, { "code": "420606", "name": "樊城区" }, { "code": "420607", "name": "襄州区" }, { "code": "420624", "name": "南漳县" }, { "code": "420625", "name": "谷城县" }, { "code": "420626", "name": "保康县" }, { "code": "420682", "name": "老河口市" }, { "code": "420683", "name": "枣阳市" }, { "code": "420684", "name": "宜城市" } ] }, { "code": "4207", "name": "鄂州市", "children": [ { "code": "420702", "name": "梁子湖区" }, { "code": "420703", "name": "华容区" }, { "code": "420704", "name": "鄂城区" } ] }, { "code": "4208", "name": "荆门市", "children": [ { "code": "420802", "name": "东宝区" }, { "code": "420804", "name": "掇刀区" }, { "code": "420822", "name": "沙洋县" }, { "code": "420881", "name": "钟祥市" }, { "code": "420882", "name": "京山市" } ] }, { "code": "4209", "name": "孝感市", "children": [ { "code": "420902", "name": "孝南区" }, { "code": "420921", "name": "孝昌县" }, { "code": "420922", "name": "大悟县" }, { "code": "420923", "name": "云梦县" }, { "code": "420981", "name": "应城市" }, { "code": "420982", "name": "安陆市" }, { "code": "420984", "name": "汉川市" } ] }, { "code": "4210", "name": "荆州市", "children": [ { "code": "421002", "name": "沙市区" }, { "code": "421003", "name": "荆州区" }, { "code": "421022", "name": "公安县" }, { "code": "421023", "name": "监利县" }, { "code": "421024", "name": "江陵县" }, { "code": "421071", "name": "荆州经济技术开发区" }, { "code": "421081", "name": "石首市" }, { "code": "421083", "name": "洪湖市" }, { "code": "421087", "name": "松滋市" } ] }, { "code": "4211", "name": "黄冈市", "children": [ { "code": "421102", "name": "黄州区" }, { "code": "421121", "name": "团风县" }, { "code": "421122", "name": "红安县" }, { "code": "421123", "name": "罗田县" }, { "code": "421124", "name": "英山县" }, { "code": "421125", "name": "浠水县" }, { "code": "421126", "name": "蕲春县" }, { "code": "421127", "name": "黄梅县" }, { "code": "421171", "name": "龙感湖管理区" }, { "code": "421181", "name": "麻城市" }, { "code": "421182", "name": "武穴市" } ] }, { "code": "4212", "name": "咸宁市", "children": [ { "code": "421202", "name": "咸安区" }, { "code": "421221", "name": "嘉鱼县" }, { "code": "421222", "name": "通城县" }, { "code": "421223", "name": "崇阳县" }, { "code": "421224", "name": "通山县" }, { "code": "421281", "name": "赤壁市" } ] }, { "code": "4213", "name": "随州市", "children": [ { "code": "421303", "name": "曾都区" }, { "code": "421321", "name": "随县" }, { "code": "421381", "name": "广水市" } ] }, { "code": "4228", "name": "恩施土家族苗族自治州", "children": [ { "code": "422801", "name": "恩施市" }, { "code": "422802", "name": "利川市" }, { "code": "422822", "name": "建始县" }, { "code": "422823", "name": "巴东县" }, { "code": "422825", "name": "宣恩县" }, { "code": "422826", "name": "咸丰县" }, { "code": "422827", "name": "来凤县" }, { "code": "422828", "name": "鹤峰县" } ] }, { "code": "4290", "name": "省直辖县级行政区划", "children": [ { "code": "429004", "name": "仙桃市" }, { "code": "429005", "name": "潜江市" }, { "code": "429006", "name": "天门市" }, { "code": "429021", "name": "神农架林区" } ] } ] }, { "code": "43", "name": "湖南省", "children": [ { "code": "4301", "name": "长沙市", "children": [ { "code": "430102", "name": "芙蓉区" }, { "code": "430103", "name": "天心区" }, { "code": "430104", "name": "岳麓区" }, { "code": "430105", "name": "开福区" }, { "code": "430111", "name": "雨花区" }, { "code": "430112", "name": "望城区" }, { "code": "430121", "name": "长沙县" }, { "code": "430181", "name": "浏阳市" }, { "code": "430182", "name": "宁乡市" } ] }, { "code": "4302", "name": "株洲市", "children": [ { "code": "430202", "name": "荷塘区" }, { "code": "430203", "name": "芦淞区" }, { "code": "430204", "name": "石峰区" }, { "code": "430211", "name": "天元区" }, { "code": "430212", "name": "渌口区" }, { "code": "430223", "name": "攸县" }, { "code": "430224", "name": "茶陵县" }, { "code": "430225", "name": "炎陵县" }, { "code": "430271", "name": "云龙示范区" }, { "code": "430281", "name": "醴陵市" } ] }, { "code": "4303", "name": "湘潭市", "children": [ { "code": "430302", "name": "雨湖区" }, { "code": "430304", "name": "岳塘区" }, { "code": "430321", "name": "湘潭县" }, { "code": "430371", "name": "湖南湘潭高新技术产业园区" }, { "code": "430372", "name": "湘潭昭山示范区" }, { "code": "430373", "name": "湘潭九华示范区" }, { "code": "430381", "name": "湘乡市" }, { "code": "430382", "name": "韶山市" } ] }, { "code": "4304", "name": "衡阳市", "children": [ { "code": "430405", "name": "珠晖区" }, { "code": "430406", "name": "雁峰区" }, { "code": "430407", "name": "石鼓区" }, { "code": "430408", "name": "蒸湘区" }, { "code": "430412", "name": "南岳区" }, { "code": "430421", "name": "衡阳县" }, { "code": "430422", "name": "衡南县" }, { "code": "430423", "name": "衡山县" }, { "code": "430424", "name": "衡东县" }, { "code": "430426", "name": "祁东县" }, { "code": "430471", "name": "衡阳综合保税区" }, { "code": "430472", "name": "湖南衡阳高新技术产业园区" }, { "code": "430473", "name": "湖南衡阳松木经济开发区" }, { "code": "430481", "name": "耒阳市" }, { "code": "430482", "name": "常宁市" } ] }, { "code": "4305", "name": "邵阳市", "children": [ { "code": "430502", "name": "双清区" }, { "code": "430503", "name": "大祥区" }, { "code": "430511", "name": "北塔区" }, { "code": "430522", "name": "新邵县" }, { "code": "430523", "name": "邵阳县" }, { "code": "430524", "name": "隆回县" }, { "code": "430525", "name": "洞口县" }, { "code": "430527", "name": "绥宁县" }, { "code": "430528", "name": "新宁县" }, { "code": "430529", "name": "城步苗族自治县" }, { "code": "430581", "name": "武冈市" }, { "code": "430582", "name": "邵东市" } ] }, { "code": "4306", "name": "岳阳市", "children": [ { "code": "430602", "name": "岳阳楼区" }, { "code": "430603", "name": "云溪区" }, { "code": "430611", "name": "君山区" }, { "code": "430621", "name": "岳阳县" }, { "code": "430623", "name": "华容县" }, { "code": "430624", "name": "湘阴县" }, { "code": "430626", "name": "平江县" }, { "code": "430671", "name": "岳阳市屈原管理区" }, { "code": "430681", "name": "汨罗市" }, { "code": "430682", "name": "临湘市" } ] }, { "code": "4307", "name": "常德市", "children": [ { "code": "430702", "name": "武陵区" }, { "code": "430703", "name": "鼎城区" }, { "code": "430721", "name": "安乡县" }, { "code": "430722", "name": "汉寿县" }, { "code": "430723", "name": "澧县" }, { "code": "430724", "name": "临澧县" }, { "code": "430725", "name": "桃源县" }, { "code": "430726", "name": "石门县" }, { "code": "430771", "name": "常德市西洞庭管理区" }, { "code": "430781", "name": "津市市" } ] }, { "code": "4308", "name": "张家界市", "children": [ { "code": "430802", "name": "永定区" }, { "code": "430811", "name": "武陵源区" }, { "code": "430821", "name": "慈利县" }, { "code": "430822", "name": "桑植县" } ] }, { "code": "4309", "name": "益阳市", "children": [ { "code": "430902", "name": "资阳区" }, { "code": "430903", "name": "赫山区" }, { "code": "430921", "name": "南县" }, { "code": "430922", "name": "桃江县" }, { "code": "430923", "name": "安化县" }, { "code": "430971", "name": "益阳市大通湖管理区" }, { "code": "430972", "name": "湖南益阳高新技术产业园区" }, { "code": "430981", "name": "沅江市" } ] }, { "code": "4310", "name": "郴州市", "children": [ { "code": "431002", "name": "北湖区" }, { "code": "431003", "name": "苏仙区" }, { "code": "431021", "name": "桂阳县" }, { "code": "431022", "name": "宜章县" }, { "code": "431023", "name": "永兴县" }, { "code": "431024", "name": "嘉禾县" }, { "code": "431025", "name": "临武县" }, { "code": "431026", "name": "汝城县" }, { "code": "431027", "name": "桂东县" }, { "code": "431028", "name": "安仁县" }, { "code": "431081", "name": "资兴市" } ] }, { "code": "4311", "name": "永州市", "children": [ { "code": "431102", "name": "零陵区" }, { "code": "431103", "name": "冷水滩区" }, { "code": "431121", "name": "祁阳县" }, { "code": "431122", "name": "东安县" }, { "code": "431123", "name": "双牌县" }, { "code": "431124", "name": "道县" }, { "code": "431125", "name": "江永县" }, { "code": "431126", "name": "宁远县" }, { "code": "431127", "name": "蓝山县" }, { "code": "431128", "name": "新田县" }, { "code": "431129", "name": "江华瑶族自治县" }, { "code": "431171", "name": "永州经济技术开发区" }, { "code": "431172", "name": "永州市金洞管理区" }, { "code": "431173", "name": "永州市回龙圩管理区" } ] }, { "code": "4312", "name": "怀化市", "children": [ { "code": "431202", "name": "鹤城区" }, { "code": "431221", "name": "中方县" }, { "code": "431222", "name": "沅陵县" }, { "code": "431223", "name": "辰溪县" }, { "code": "431224", "name": "溆浦县" }, { "code": "431225", "name": "会同县" }, { "code": "431226", "name": "麻阳苗族自治县" }, { "code": "431227", "name": "新晃侗族自治县" }, { "code": "431228", "name": "芷江侗族自治县" }, { "code": "431229", "name": "靖州苗族侗族自治县" }, { "code": "431230", "name": "通道侗族自治县" }, { "code": "431271", "name": "怀化市洪江管理区" }, { "code": "431281", "name": "洪江市" } ] }, { "code": "4313", "name": "娄底市", "children": [ { "code": "431302", "name": "娄星区" }, { "code": "431321", "name": "双峰县" }, { "code": "431322", "name": "新化县" }, { "code": "431381", "name": "冷水江市" }, { "code": "431382", "name": "涟源市" } ] }, { "code": "4331", "name": "湘西土家族苗族自治州", "children": [ { "code": "433101", "name": "吉首市" }, { "code": "433122", "name": "泸溪县" }, { "code": "433123", "name": "凤凰县" }, { "code": "433124", "name": "花垣县" }, { "code": "433125", "name": "保靖县" }, { "code": "433126", "name": "古丈县" }, { "code": "433127", "name": "永顺县" }, { "code": "433130", "name": "龙山县" } ] } ] }, { "code": "44", "name": "广东省", "children": [ { "code": "4401", "name": "广州市", "children": [ { "code": "440103", "name": "荔湾区" }, { "code": "440104", "name": "越秀区" }, { "code": "440105", "name": "海珠区" }, { "code": "440106", "name": "天河区" }, { "code": "440111", "name": "白云区" }, { "code": "440112", "name": "黄埔区" }, { "code": "440113", "name": "番禺区" }, { "code": "440114", "name": "花都区" }, { "code": "440115", "name": "南沙区" }, { "code": "440117", "name": "从化区" }, { "code": "440118", "name": "增城区" } ] }, { "code": "4402", "name": "韶关市", "children": [ { "code": "440203", "name": "武江区" }, { "code": "440204", "name": "浈江区" }, { "code": "440205", "name": "曲江区" }, { "code": "440222", "name": "始兴县" }, { "code": "440224", "name": "仁化县" }, { "code": "440229", "name": "翁源县" }, { "code": "440232", "name": "乳源瑶族自治县" }, { "code": "440233", "name": "新丰县" }, { "code": "440281", "name": "乐昌市" }, { "code": "440282", "name": "南雄市" } ] }, { "code": "4403", "name": "深圳市", "children": [ { "code": "440303", "name": "罗湖区" }, { "code": "440304", "name": "福田区" }, { "code": "440305", "name": "南山区" }, { "code": "440306", "name": "宝安区" }, { "code": "440307", "name": "龙岗区" }, { "code": "440308", "name": "盐田区" }, { "code": "440309", "name": "龙华区" }, { "code": "440310", "name": "坪山区" }, { "code": "440311", "name": "光明区" } ] }, { "code": "4404", "name": "珠海市", "children": [ { "code": "440402", "name": "香洲区" }, { "code": "440403", "name": "斗门区" }, { "code": "440404", "name": "金湾区" } ] }, { "code": "4405", "name": "汕头市", "children": [ { "code": "440507", "name": "龙湖区" }, { "code": "440511", "name": "金平区" }, { "code": "440512", "name": "濠江区" }, { "code": "440513", "name": "潮阳区" }, { "code": "440514", "name": "潮南区" }, { "code": "440515", "name": "澄海区" }, { "code": "440523", "name": "南澳县" } ] }, { "code": "4406", "name": "佛山市", "children": [ { "code": "440604", "name": "禅城区" }, { "code": "440605", "name": "南海区" }, { "code": "440606", "name": "顺德区" }, { "code": "440607", "name": "三水区" }, { "code": "440608", "name": "高明区" } ] }, { "code": "4407", "name": "江门市", "children": [ { "code": "440703", "name": "蓬江区" }, { "code": "440704", "name": "江海区" }, { "code": "440705", "name": "新会区" }, { "code": "440781", "name": "台山市" }, { "code": "440783", "name": "开平市" }, { "code": "440784", "name": "鹤山市" }, { "code": "440785", "name": "恩平市" } ] }, { "code": "4408", "name": "湛江市", "children": [ { "code": "440802", "name": "赤坎区" }, { "code": "440803", "name": "霞山区" }, { "code": "440804", "name": "坡头区" }, { "code": "440811", "name": "麻章区" }, { "code": "440823", "name": "遂溪县" }, { "code": "440825", "name": "徐闻县" }, { "code": "440881", "name": "廉江市" }, { "code": "440882", "name": "雷州市" }, { "code": "440883", "name": "吴川市" } ] }, { "code": "4409", "name": "茂名市", "children": [ { "code": "440902", "name": "茂南区" }, { "code": "440904", "name": "电白区" }, { "code": "440981", "name": "高州市" }, { "code": "440982", "name": "化州市" }, { "code": "440983", "name": "信宜市" } ] }, { "code": "4412", "name": "肇庆市", "children": [ { "code": "441202", "name": "端州区" }, { "code": "441203", "name": "鼎湖区" }, { "code": "441204", "name": "高要区" }, { "code": "441223", "name": "广宁县" }, { "code": "441224", "name": "怀集县" }, { "code": "441225", "name": "封开县" }, { "code": "441226", "name": "德庆县" }, { "code": "441284", "name": "四会市" } ] }, { "code": "4413", "name": "惠州市", "children": [ { "code": "441302", "name": "惠城区" }, { "code": "441303", "name": "惠阳区" }, { "code": "441322", "name": "博罗县" }, { "code": "441323", "name": "惠东县" }, { "code": "441324", "name": "龙门县" } ] }, { "code": "4414", "name": "梅州市", "children": [ { "code": "441402", "name": "梅江区" }, { "code": "441403", "name": "梅县区" }, { "code": "441422", "name": "大埔县" }, { "code": "441423", "name": "丰顺县" }, { "code": "441424", "name": "五华县" }, { "code": "441426", "name": "平远县" }, { "code": "441427", "name": "蕉岭县" }, { "code": "441481", "name": "兴宁市" } ] }, { "code": "4415", "name": "汕尾市", "children": [ { "code": "441502", "name": "城区" }, { "code": "441521", "name": "海丰县" }, { "code": "441523", "name": "陆河县" }, { "code": "441581", "name": "陆丰市" } ] }, { "code": "4416", "name": "河源市", "children": [ { "code": "441602", "name": "源城区" }, { "code": "441621", "name": "紫金县" }, { "code": "441622", "name": "龙川县" }, { "code": "441623", "name": "连平县" }, { "code": "441624", "name": "和平县" }, { "code": "441625", "name": "东源县" } ] }, { "code": "4417", "name": "阳江市", "children": [ { "code": "441702", "name": "江城区" }, { "code": "441704", "name": "阳东区" }, { "code": "441721", "name": "阳西县" }, { "code": "441781", "name": "阳春市" } ] }, { "code": "4418", "name": "清远市", "children": [ { "code": "441802", "name": "清城区" }, { "code": "441803", "name": "清新区" }, { "code": "441821", "name": "佛冈县" }, { "code": "441823", "name": "阳山县" }, { "code": "441825", "name": "连山壮族瑶族自治县" }, { "code": "441826", "name": "连南瑶族自治县" }, { "code": "441881", "name": "英德市" }, { "code": "441882", "name": "连州市" } ] }, { "code": "4419", "name": "东莞市", "children": [ { "code": "441900003", "name": "东城街道" }, { "code": "441900004", "name": "南城街道" }, { "code": "441900005", "name": "万江街道" }, { "code": "441900006", "name": "莞城街道" }, { "code": "441900101", "name": "石碣镇" }, { "code": "441900102", "name": "石龙镇" }, { "code": "441900103", "name": "茶山镇" }, { "code": "441900104", "name": "石排镇" }, { "code": "441900105", "name": "企石镇" }, { "code": "441900106", "name": "横沥镇" }, { "code": "441900107", "name": "桥头镇" }, { "code": "441900108", "name": "谢岗镇" }, { "code": "441900109", "name": "东坑镇" }, { "code": "441900110", "name": "常平镇" }, { "code": "441900111", "name": "寮步镇" }, { "code": "441900112", "name": "樟木头镇" }, { "code": "441900113", "name": "大朗镇" }, { "code": "441900114", "name": "黄江镇" }, { "code": "441900115", "name": "清溪镇" }, { "code": "441900116", "name": "塘厦镇" }, { "code": "441900117", "name": "凤岗镇" }, { "code": "441900118", "name": "大岭山镇" }, { "code": "441900119", "name": "长安镇" }, { "code": "441900121", "name": "虎门镇" }, { "code": "441900122", "name": "厚街镇" }, { "code": "441900123", "name": "沙田镇" }, { "code": "441900124", "name": "道滘镇" }, { "code": "441900125", "name": "洪梅镇" }, { "code": "441900126", "name": "麻涌镇" }, { "code": "441900127", "name": "望牛墩镇" }, { "code": "441900128", "name": "中堂镇" }, { "code": "441900129", "name": "高埗镇" }, { "code": "441900401", "name": "松山湖" }, { "code": "441900402", "name": "东莞港" }, { "code": "441900403", "name": "东莞生态园" } ] }, { "code": "4420", "name": "中山市", "children": [ { "code": "442000001", "name": "石岐街道" }, { "code": "442000002", "name": "东区街道" }, { "code": "442000003", "name": "中山港街道" }, { "code": "442000004", "name": "西区街道" }, { "code": "442000005", "name": "南区街道" }, { "code": "442000006", "name": "五桂山街道" }, { "code": "442000100", "name": "小榄镇" }, { "code": "442000101", "name": "黄圃镇" }, { "code": "442000102", "name": "民众镇" }, { "code": "442000103", "name": "东凤镇" }, { "code": "442000104", "name": "东升镇" }, { "code": "442000105", "name": "古镇镇" }, { "code": "442000106", "name": "沙溪镇" }, { "code": "442000107", "name": "坦洲镇" }, { "code": "442000108", "name": "港口镇" }, { "code": "442000109", "name": "三角镇" }, { "code": "442000110", "name": "横栏镇" }, { "code": "442000111", "name": "南头镇" }, { "code": "442000112", "name": "阜沙镇" }, { "code": "442000113", "name": "南朗镇" }, { "code": "442000114", "name": "三乡镇" }, { "code": "442000115", "name": "板芙镇" }, { "code": "442000116", "name": "大涌镇" }, { "code": "442000117", "name": "神湾镇" } ] }, { "code": "4451", "name": "潮州市", "children": [ { "code": "445102", "name": "湘桥区" }, { "code": "445103", "name": "潮安区" }, { "code": "445122", "name": "饶平县" } ] }, { "code": "4452", "name": "揭阳市", "children": [ { "code": "445202", "name": "榕城区" }, { "code": "445203", "name": "揭东区" }, { "code": "445222", "name": "揭西县" }, { "code": "445224", "name": "惠来县" }, { "code": "445281", "name": "普宁市" } ] }, { "code": "4453", "name": "云浮市", "children": [ { "code": "445302", "name": "云城区" }, { "code": "445303", "name": "云安区" }, { "code": "445321", "name": "新兴县" }, { "code": "445322", "name": "郁南县" }, { "code": "445381", "name": "罗定市" } ] } ] }, { "code": "45", "name": "广西壮族自治区", "children": [ { "code": "4501", "name": "南宁市", "children": [ { "code": "450102", "name": "兴宁区" }, { "code": "450103", "name": "青秀区" }, { "code": "450105", "name": "江南区" }, { "code": "450107", "name": "西乡塘区" }, { "code": "450108", "name": "良庆区" }, { "code": "450109", "name": "邕宁区" }, { "code": "450110", "name": "武鸣区" }, { "code": "450123", "name": "隆安县" }, { "code": "450124", "name": "马山县" }, { "code": "450125", "name": "上林县" }, { "code": "450126", "name": "宾阳县" }, { "code": "450127", "name": "横县" } ] }, { "code": "4502", "name": "柳州市", "children": [ { "code": "450202", "name": "城中区" }, { "code": "450203", "name": "鱼峰区" }, { "code": "450204", "name": "柳南区" }, { "code": "450205", "name": "柳北区" }, { "code": "450206", "name": "柳江区" }, { "code": "450222", "name": "柳城县" }, { "code": "450223", "name": "鹿寨县" }, { "code": "450224", "name": "融安县" }, { "code": "450225", "name": "融水苗族自治县" }, { "code": "450226", "name": "三江侗族自治县" } ] }, { "code": "4503", "name": "桂林市", "children": [ { "code": "450302", "name": "秀峰区" }, { "code": "450303", "name": "叠彩区" }, { "code": "450304", "name": "象山区" }, { "code": "450305", "name": "七星区" }, { "code": "450311", "name": "雁山区" }, { "code": "450312", "name": "临桂区" }, { "code": "450321", "name": "阳朔县" }, { "code": "450323", "name": "灵川县" }, { "code": "450324", "name": "全州县" }, { "code": "450325", "name": "兴安县" }, { "code": "450326", "name": "永福县" }, { "code": "450327", "name": "灌阳县" }, { "code": "450328", "name": "龙胜各族自治县" }, { "code": "450329", "name": "资源县" }, { "code": "450330", "name": "平乐县" }, { "code": "450332", "name": "恭城瑶族自治县" }, { "code": "450381", "name": "荔浦市" } ] }, { "code": "4504", "name": "梧州市", "children": [ { "code": "450403", "name": "万秀区" }, { "code": "450405", "name": "长洲区" }, { "code": "450406", "name": "龙圩区" }, { "code": "450421", "name": "苍梧县" }, { "code": "450422", "name": "藤县" }, { "code": "450423", "name": "蒙山县" }, { "code": "450481", "name": "岑溪市" } ] }, { "code": "4505", "name": "北海市", "children": [ { "code": "450502", "name": "海城区" }, { "code": "450503", "name": "银海区" }, { "code": "450512", "name": "铁山港区" }, { "code": "450521", "name": "合浦县" } ] }, { "code": "4506", "name": "防城港市", "children": [ { "code": "450602", "name": "港口区" }, { "code": "450603", "name": "防城区" }, { "code": "450621", "name": "上思县" }, { "code": "450681", "name": "东兴市" } ] }, { "code": "4507", "name": "钦州市", "children": [ { "code": "450702", "name": "钦南区" }, { "code": "450703", "name": "钦北区" }, { "code": "450721", "name": "灵山县" }, { "code": "450722", "name": "浦北县" } ] }, { "code": "4508", "name": "贵港市", "children": [ { "code": "450802", "name": "港北区" }, { "code": "450803", "name": "港南区" }, { "code": "450804", "name": "覃塘区" }, { "code": "450821", "name": "平南县" }, { "code": "450881", "name": "桂平市" } ] }, { "code": "4509", "name": "玉林市", "children": [ { "code": "450902", "name": "玉州区" }, { "code": "450903", "name": "福绵区" }, { "code": "450921", "name": "容县" }, { "code": "450922", "name": "陆川县" }, { "code": "450923", "name": "博白县" }, { "code": "450924", "name": "兴业县" }, { "code": "450981", "name": "北流市" } ] }, { "code": "4510", "name": "百色市", "children": [ { "code": "451002", "name": "右江区" }, { "code": "451003", "name": "田阳区" }, { "code": "451022", "name": "田东县" }, { "code": "451024", "name": "德保县" }, { "code": "451026", "name": "那坡县" }, { "code": "451027", "name": "凌云县" }, { "code": "451028", "name": "乐业县" }, { "code": "451029", "name": "田林县" }, { "code": "451030", "name": "西林县" }, { "code": "451031", "name": "隆林各族自治县" }, { "code": "451081", "name": "靖西市" }, { "code": "451082", "name": "平果市" } ] }, { "code": "4511", "name": "贺州市", "children": [ { "code": "451102", "name": "八步区" }, { "code": "451103", "name": "平桂区" }, { "code": "451121", "name": "昭平县" }, { "code": "451122", "name": "钟山县" }, { "code": "451123", "name": "富川瑶族自治县" } ] }, { "code": "4512", "name": "河池市", "children": [ { "code": "451202", "name": "金城江区" }, { "code": "451203", "name": "宜州区" }, { "code": "451221", "name": "南丹县" }, { "code": "451222", "name": "天峨县" }, { "code": "451223", "name": "凤山县" }, { "code": "451224", "name": "东兰县" }, { "code": "451225", "name": "罗城仫佬族自治县" }, { "code": "451226", "name": "环江毛南族自治县" }, { "code": "451227", "name": "巴马瑶族自治县" }, { "code": "451228", "name": "都安瑶族自治县" }, { "code": "451229", "name": "大化瑶族自治县" } ] }, { "code": "4513", "name": "来宾市", "children": [ { "code": "451302", "name": "兴宾区" }, { "code": "451321", "name": "忻城县" }, { "code": "451322", "name": "象州县" }, { "code": "451323", "name": "武宣县" }, { "code": "451324", "name": "金秀瑶族自治县" }, { "code": "451381", "name": "合山市" } ] }, { "code": "4514", "name": "崇左市", "children": [ { "code": "451402", "name": "江州区" }, { "code": "451421", "name": "扶绥县" }, { "code": "451422", "name": "宁明县" }, { "code": "451423", "name": "龙州县" }, { "code": "451424", "name": "大新县" }, { "code": "451425", "name": "天等县" }, { "code": "451481", "name": "凭祥市" } ] } ] }, { "code": "46", "name": "海南省", "children": [ { "code": "4601", "name": "海口市", "children": [ { "code": "460105", "name": "秀英区" }, { "code": "460106", "name": "龙华区" }, { "code": "460107", "name": "琼山区" }, { "code": "460108", "name": "美兰区" } ] }, { "code": "4602", "name": "三亚市", "children": [ { "code": "460202", "name": "海棠区" }, { "code": "460203", "name": "吉阳区" }, { "code": "460204", "name": "天涯区" }, { "code": "460205", "name": "崖州区" } ] }, { "code": "4603", "name": "三沙市", "children": [ { "code": "460321", "name": "西沙群岛" }, { "code": "460322", "name": "南沙群岛" }, { "code": "460323", "name": "中沙群岛的岛礁及其海域" } ] }, { "code": "4604", "name": "儋州市", "children": [ { "code": "460400100", "name": "那大镇" }, { "code": "460400101", "name": "和庆镇" }, { "code": "460400102", "name": "南丰镇" }, { "code": "460400103", "name": "大成镇" }, { "code": "460400104", "name": "雅星镇" }, { "code": "460400105", "name": "兰洋镇" }, { "code": "460400106", "name": "光村镇" }, { "code": "460400107", "name": "木棠镇" }, { "code": "460400108", "name": "海头镇" }, { "code": "460400109", "name": "峨蔓镇" }, { "code": "460400111", "name": "王五镇" }, { "code": "460400112", "name": "白马井镇" }, { "code": "460400113", "name": "中和镇" }, { "code": "460400114", "name": "排浦镇" }, { "code": "460400115", "name": "东成镇" }, { "code": "460400116", "name": "新州镇" }, { "code": "460400499", "name": "洋浦经济开发区" }, { "code": "460400500", "name": "华南热作学院" } ] }, { "code": "4690", "name": "省直辖县级行政区划", "children": [ { "code": "469001", "name": "五指山市" }, { "code": "469002", "name": "琼海市" }, { "code": "469005", "name": "文昌市" }, { "code": "469006", "name": "万宁市" }, { "code": "469007", "name": "东方市" }, { "code": "469021", "name": "定安县" }, { "code": "469022", "name": "屯昌县" }, { "code": "469023", "name": "澄迈县" }, { "code": "469024", "name": "临高县" }, { "code": "469025", "name": "白沙黎族自治县" }, { "code": "469026", "name": "昌江黎族自治县" }, { "code": "469027", "name": "乐东黎族自治县" }, { "code": "469028", "name": "陵水黎族自治县" }, { "code": "469029", "name": "保亭黎族苗族自治县" }, { "code": "469030", "name": "琼中黎族苗族自治县" } ] } ] }, { "code": "50", "name": "重庆市", "children": [ { "code": "5001", "name": "市辖区", "children": [ { "code": "500101", "name": "万州区" }, { "code": "500102", "name": "涪陵区" }, { "code": "500103", "name": "渝中区" }, { "code": "500104", "name": "大渡口区" }, { "code": "500105", "name": "江北区" }, { "code": "500106", "name": "沙坪坝区" }, { "code": "500107", "name": "九龙坡区" }, { "code": "500108", "name": "南岸区" }, { "code": "500109", "name": "北碚区" }, { "code": "500110", "name": "綦江区" }, { "code": "500111", "name": "大足区" }, { "code": "500112", "name": "渝北区" }, { "code": "500113", "name": "巴南区" }, { "code": "500114", "name": "黔江区" }, { "code": "500115", "name": "长寿区" }, { "code": "500116", "name": "江津区" }, { "code": "500117", "name": "合川区" }, { "code": "500118", "name": "永川区" }, { "code": "500119", "name": "南川区" }, { "code": "500120", "name": "璧山区" }, { "code": "500151", "name": "铜梁区" }, { "code": "500152", "name": "潼南区" }, { "code": "500153", "name": "荣昌区" }, { "code": "500154", "name": "开州区" }, { "code": "500155", "name": "梁平区" }, { "code": "500156", "name": "武隆区" } ] }, { "code": "5002", "name": "县", "children": [ { "code": "500229", "name": "城口县" }, { "code": "500230", "name": "丰都县" }, { "code": "500231", "name": "垫江县" }, { "code": "500233", "name": "忠县" }, { "code": "500235", "name": "云阳县" }, { "code": "500236", "name": "奉节县" }, { "code": "500237", "name": "巫山县" }, { "code": "500238", "name": "巫溪县" }, { "code": "500240", "name": "石柱土家族自治县" }, { "code": "500241", "name": "秀山土家族苗族自治县" }, { "code": "500242", "name": "酉阳土家族苗族自治县" }, { "code": "500243", "name": "彭水苗族土家族自治县" } ] } ] }, { "code": "51", "name": "四川省", "children": [ { "code": "5101", "name": "成都市", "children": [ { "code": "510104", "name": "锦江区" }, { "code": "510105", "name": "青羊区" }, { "code": "510106", "name": "金牛区" }, { "code": "510107", "name": "武侯区" }, { "code": "510108", "name": "成华区" }, { "code": "510112", "name": "龙泉驿区" }, { "code": "510113", "name": "青白江区" }, { "code": "510114", "name": "新都区" }, { "code": "510115", "name": "温江区" }, { "code": "510116", "name": "双流区" }, { "code": "510117", "name": "郫都区" }, { "code": "510118", "name": "新津区" }, { "code": "510121", "name": "金堂县" }, { "code": "510129", "name": "大邑县" }, { "code": "510131", "name": "蒲江县" }, { "code": "510181", "name": "都江堰市" }, { "code": "510182", "name": "彭州市" }, { "code": "510183", "name": "邛崃市" }, { "code": "510184", "name": "崇州市" }, { "code": "510185", "name": "简阳市" } ] }, { "code": "5103", "name": "自贡市", "children": [ { "code": "510302", "name": "自流井区" }, { "code": "510303", "name": "贡井区" }, { "code": "510304", "name": "大安区" }, { "code": "510311", "name": "沿滩区" }, { "code": "510321", "name": "荣县" }, { "code": "510322", "name": "富顺县" } ] }, { "code": "5104", "name": "攀枝花市", "children": [ { "code": "510402", "name": "东区" }, { "code": "510403", "name": "西区" }, { "code": "510411", "name": "仁和区" }, { "code": "510421", "name": "米易县" }, { "code": "510422", "name": "盐边县" } ] }, { "code": "5105", "name": "泸州市", "children": [ { "code": "510502", "name": "江阳区" }, { "code": "510503", "name": "纳溪区" }, { "code": "510504", "name": "龙马潭区" }, { "code": "510521", "name": "泸县" }, { "code": "510522", "name": "合江县" }, { "code": "510524", "name": "叙永县" }, { "code": "510525", "name": "古蔺县" } ] }, { "code": "5106", "name": "德阳市", "children": [ { "code": "510603", "name": "旌阳区" }, { "code": "510604", "name": "罗江区" }, { "code": "510623", "name": "中江县" }, { "code": "510681", "name": "广汉市" }, { "code": "510682", "name": "什邡市" }, { "code": "510683", "name": "绵竹市" } ] }, { "code": "5107", "name": "绵阳市", "children": [ { "code": "510703", "name": "涪城区" }, { "code": "510704", "name": "游仙区" }, { "code": "510705", "name": "安州区" }, { "code": "510722", "name": "三台县" }, { "code": "510723", "name": "盐亭县" }, { "code": "510725", "name": "梓潼县" }, { "code": "510726", "name": "北川羌族自治县" }, { "code": "510727", "name": "平武县" }, { "code": "510781", "name": "江油市" } ] }, { "code": "5108", "name": "广元市", "children": [ { "code": "510802", "name": "利州区" }, { "code": "510811", "name": "昭化区" }, { "code": "510812", "name": "朝天区" }, { "code": "510821", "name": "旺苍县" }, { "code": "510822", "name": "青川县" }, { "code": "510823", "name": "剑阁县" }, { "code": "510824", "name": "苍溪县" } ] }, { "code": "5109", "name": "遂宁市", "children": [ { "code": "510903", "name": "船山区" }, { "code": "510904", "name": "安居区" }, { "code": "510921", "name": "蓬溪县" }, { "code": "510923", "name": "大英县" }, { "code": "510981", "name": "射洪市" } ] }, { "code": "5110", "name": "内江市", "children": [ { "code": "511002", "name": "市中区" }, { "code": "511011", "name": "东兴区" }, { "code": "511024", "name": "威远县" }, { "code": "511025", "name": "资中县" }, { "code": "511071", "name": "内江经济开发区" }, { "code": "511083", "name": "隆昌市" } ] }, { "code": "5111", "name": "乐山市", "children": [ { "code": "511102", "name": "市中区" }, { "code": "511111", "name": "沙湾区" }, { "code": "511112", "name": "五通桥区" }, { "code": "511113", "name": "金口河区" }, { "code": "511123", "name": "犍为县" }, { "code": "511124", "name": "井研县" }, { "code": "511126", "name": "夹江县" }, { "code": "511129", "name": "沐川县" }, { "code": "511132", "name": "峨边彝族自治县" }, { "code": "511133", "name": "马边彝族自治县" }, { "code": "511181", "name": "峨眉山市" } ] }, { "code": "5113", "name": "南充市", "children": [ { "code": "511302", "name": "顺庆区" }, { "code": "511303", "name": "高坪区" }, { "code": "511304", "name": "嘉陵区" }, { "code": "511321", "name": "南部县" }, { "code": "511322", "name": "营山县" }, { "code": "511323", "name": "蓬安县" }, { "code": "511324", "name": "仪陇县" }, { "code": "511325", "name": "西充县" }, { "code": "511381", "name": "阆中市" } ] }, { "code": "5114", "name": "眉山市", "children": [ { "code": "511402", "name": "东坡区" }, { "code": "511403", "name": "彭山区" }, { "code": "511421", "name": "仁寿县" }, { "code": "511423", "name": "洪雅县" }, { "code": "511424", "name": "丹棱县" }, { "code": "511425", "name": "青神县" } ] }, { "code": "5115", "name": "宜宾市", "children": [ { "code": "511502", "name": "翠屏区" }, { "code": "511503", "name": "南溪区" }, { "code": "511504", "name": "叙州区" }, { "code": "511523", "name": "江安县" }, { "code": "511524", "name": "长宁县" }, { "code": "511525", "name": "高县" }, { "code": "511526", "name": "珙县" }, { "code": "511527", "name": "筠连县" }, { "code": "511528", "name": "兴文县" }, { "code": "511529", "name": "屏山县" } ] }, { "code": "5116", "name": "广安市", "children": [ { "code": "511602", "name": "广安区" }, { "code": "511603", "name": "前锋区" }, { "code": "511621", "name": "岳池县" }, { "code": "511622", "name": "武胜县" }, { "code": "511623", "name": "邻水县" }, { "code": "511681", "name": "华蓥市" } ] }, { "code": "5117", "name": "达州市", "children": [ { "code": "511702", "name": "通川区" }, { "code": "511703", "name": "达川区" }, { "code": "511722", "name": "宣汉县" }, { "code": "511723", "name": "开江县" }, { "code": "511724", "name": "大竹县" }, { "code": "511725", "name": "渠县" }, { "code": "511771", "name": "达州经济开发区" }, { "code": "511781", "name": "万源市" } ] }, { "code": "5118", "name": "雅安市", "children": [ { "code": "511802", "name": "雨城区" }, { "code": "511803", "name": "名山区" }, { "code": "511822", "name": "荥经县" }, { "code": "511823", "name": "汉源县" }, { "code": "511824", "name": "石棉县" }, { "code": "511825", "name": "天全县" }, { "code": "511826", "name": "芦山县" }, { "code": "511827", "name": "宝兴县" } ] }, { "code": "5119", "name": "巴中市", "children": [ { "code": "511902", "name": "巴州区" }, { "code": "511903", "name": "恩阳区" }, { "code": "511921", "name": "通江县" }, { "code": "511922", "name": "南江县" }, { "code": "511923", "name": "平昌县" }, { "code": "511971", "name": "巴中经济开发区" } ] }, { "code": "5120", "name": "资阳市", "children": [ { "code": "512002", "name": "雁江区" }, { "code": "512021", "name": "安岳县" }, { "code": "512022", "name": "乐至县" } ] }, { "code": "5132", "name": "阿坝藏族羌族自治州", "children": [ { "code": "513201", "name": "马尔康市" }, { "code": "513221", "name": "汶川县" }, { "code": "513222", "name": "理县" }, { "code": "513223", "name": "茂县" }, { "code": "513224", "name": "松潘县" }, { "code": "513225", "name": "九寨沟县" }, { "code": "513226", "name": "金川县" }, { "code": "513227", "name": "小金县" }, { "code": "513228", "name": "黑水县" }, { "code": "513230", "name": "壤塘县" }, { "code": "513231", "name": "阿坝县" }, { "code": "513232", "name": "若尔盖县" }, { "code": "513233", "name": "红原县" } ] }, { "code": "5133", "name": "甘孜藏族自治州", "children": [ { "code": "513301", "name": "康定市" }, { "code": "513322", "name": "泸定县" }, { "code": "513323", "name": "丹巴县" }, { "code": "513324", "name": "九龙县" }, { "code": "513325", "name": "雅江县" }, { "code": "513326", "name": "道孚县" }, { "code": "513327", "name": "炉霍县" }, { "code": "513328", "name": "甘孜县" }, { "code": "513329", "name": "新龙县" }, { "code": "513330", "name": "德格县" }, { "code": "513331", "name": "白玉县" }, { "code": "513332", "name": "石渠县" }, { "code": "513333", "name": "色达县" }, { "code": "513334", "name": "理塘县" }, { "code": "513335", "name": "巴塘县" }, { "code": "513336", "name": "乡城县" }, { "code": "513337", "name": "稻城县" }, { "code": "513338", "name": "得荣县" } ] }, { "code": "5134", "name": "凉山彝族自治州", "children": [ { "code": "513401", "name": "西昌市" }, { "code": "513422", "name": "木里藏族自治县" }, { "code": "513423", "name": "盐源县" }, { "code": "513424", "name": "德昌县" }, { "code": "513425", "name": "会理县" }, { "code": "513426", "name": "会东县" }, { "code": "513427", "name": "宁南县" }, { "code": "513428", "name": "普格县" }, { "code": "513429", "name": "布拖县" }, { "code": "513430", "name": "金阳县" }, { "code": "513431", "name": "昭觉县" }, { "code": "513432", "name": "喜德县" }, { "code": "513433", "name": "冕宁县" }, { "code": "513434", "name": "越西县" }, { "code": "513435", "name": "甘洛县" }, { "code": "513436", "name": "美姑县" }, { "code": "513437", "name": "雷波县" } ] } ] }, { "code": "52", "name": "贵州省", "children": [ { "code": "5201", "name": "贵阳市", "children": [ { "code": "520102", "name": "南明区" }, { "code": "520103", "name": "云岩区" }, { "code": "520111", "name": "花溪区" }, { "code": "520112", "name": "乌当区" }, { "code": "520113", "name": "白云区" }, { "code": "520115", "name": "观山湖区" }, { "code": "520121", "name": "开阳县" }, { "code": "520122", "name": "息烽县" }, { "code": "520123", "name": "修文县" }, { "code": "520181", "name": "清镇市" } ] }, { "code": "5202", "name": "六盘水市", "children": [ { "code": "520201", "name": "钟山区" }, { "code": "520203", "name": "六枝特区" }, { "code": "520221", "name": "水城县" }, { "code": "520281", "name": "盘州市" } ] }, { "code": "5203", "name": "遵义市", "children": [ { "code": "520302", "name": "红花岗区" }, { "code": "520303", "name": "汇川区" }, { "code": "520304", "name": "播州区" }, { "code": "520322", "name": "桐梓县" }, { "code": "520323", "name": "绥阳县" }, { "code": "520324", "name": "正安县" }, { "code": "520325", "name": "道真仡佬族苗族自治县" }, { "code": "520326", "name": "务川仡佬族苗族自治县" }, { "code": "520327", "name": "凤冈县" }, { "code": "520328", "name": "湄潭县" }, { "code": "520329", "name": "余庆县" }, { "code": "520330", "name": "习水县" }, { "code": "520381", "name": "赤水市" }, { "code": "520382", "name": "仁怀市" } ] }, { "code": "5204", "name": "安顺市", "children": [ { "code": "520402", "name": "西秀区" }, { "code": "520403", "name": "平坝区" }, { "code": "520422", "name": "普定县" }, { "code": "520423", "name": "镇宁布依族苗族自治县" }, { "code": "520424", "name": "关岭布依族苗族自治县" }, { "code": "520425", "name": "紫云苗族布依族自治县" } ] }, { "code": "5205", "name": "毕节市", "children": [ { "code": "520502", "name": "七星关区" }, { "code": "520521", "name": "大方县" }, { "code": "520522", "name": "黔西县" }, { "code": "520523", "name": "金沙县" }, { "code": "520524", "name": "织金县" }, { "code": "520525", "name": "纳雍县" }, { "code": "520526", "name": "威宁彝族回族苗族自治县" }, { "code": "520527", "name": "赫章县" } ] }, { "code": "5206", "name": "铜仁市", "children": [ { "code": "520602", "name": "碧江区" }, { "code": "520603", "name": "万山区" }, { "code": "520621", "name": "江口县" }, { "code": "520622", "name": "玉屏侗族自治县" }, { "code": "520623", "name": "石阡县" }, { "code": "520624", "name": "思南县" }, { "code": "520625", "name": "印江土家族苗族自治县" }, { "code": "520626", "name": "德江县" }, { "code": "520627", "name": "沿河土家族自治县" }, { "code": "520628", "name": "松桃苗族自治县" } ] }, { "code": "5223", "name": "黔西南布依族苗族自治州", "children": [ { "code": "522301", "name": "兴义市" }, { "code": "522302", "name": "兴仁市" }, { "code": "522323", "name": "普安县" }, { "code": "522324", "name": "晴隆县" }, { "code": "522325", "name": "贞丰县" }, { "code": "522326", "name": "望谟县" }, { "code": "522327", "name": "册亨县" }, { "code": "522328", "name": "安龙县" } ] }, { "code": "5226", "name": "黔东南苗族侗族自治州", "children": [ { "code": "522601", "name": "凯里市" }, { "code": "522622", "name": "黄平县" }, { "code": "522623", "name": "施秉县" }, { "code": "522624", "name": "三穗县" }, { "code": "522625", "name": "镇远县" }, { "code": "522626", "name": "岑巩县" }, { "code": "522627", "name": "天柱县" }, { "code": "522628", "name": "锦屏县" }, { "code": "522629", "name": "剑河县" }, { "code": "522630", "name": "台江县" }, { "code": "522631", "name": "黎平县" }, { "code": "522632", "name": "榕江县" }, { "code": "522633", "name": "从江县" }, { "code": "522634", "name": "雷山县" }, { "code": "522635", "name": "麻江县" }, { "code": "522636", "name": "丹寨县" } ] }, { "code": "5227", "name": "黔南布依族苗族自治州", "children": [ { "code": "522701", "name": "都匀市" }, { "code": "522702", "name": "福泉市" }, { "code": "522722", "name": "荔波县" }, { "code": "522723", "name": "贵定县" }, { "code": "522725", "name": "瓮安县" }, { "code": "522726", "name": "独山县" }, { "code": "522727", "name": "平塘县" }, { "code": "522728", "name": "罗甸县" }, { "code": "522729", "name": "长顺县" }, { "code": "522730", "name": "龙里县" }, { "code": "522731", "name": "惠水县" }, { "code": "522732", "name": "三都水族自治县" } ] } ] }, { "code": "53", "name": "云南省", "children": [ { "code": "5301", "name": "昆明市", "children": [ { "code": "530102", "name": "五华区" }, { "code": "530103", "name": "盘龙区" }, { "code": "530111", "name": "官渡区" }, { "code": "530112", "name": "西山区" }, { "code": "530113", "name": "东川区" }, { "code": "530114", "name": "呈贡区" }, { "code": "530115", "name": "晋宁区" }, { "code": "530124", "name": "富民县" }, { "code": "530125", "name": "宜良县" }, { "code": "530126", "name": "石林彝族自治县" }, { "code": "530127", "name": "嵩明县" }, { "code": "530128", "name": "禄劝彝族苗族自治县" }, { "code": "530129", "name": "寻甸回族彝族自治县" }, { "code": "530181", "name": "安宁市" } ] }, { "code": "5303", "name": "曲靖市", "children": [ { "code": "530302", "name": "麒麟区" }, { "code": "530303", "name": "沾益区" }, { "code": "530304", "name": "马龙区" }, { "code": "530322", "name": "陆良县" }, { "code": "530323", "name": "师宗县" }, { "code": "530324", "name": "罗平县" }, { "code": "530325", "name": "富源县" }, { "code": "530326", "name": "会泽县" }, { "code": "530381", "name": "宣威市" } ] }, { "code": "5304", "name": "玉溪市", "children": [ { "code": "530402", "name": "红塔区" }, { "code": "530403", "name": "江川区" }, { "code": "530423", "name": "通海县" }, { "code": "530424", "name": "华宁县" }, { "code": "530425", "name": "易门县" }, { "code": "530426", "name": "峨山彝族自治县" }, { "code": "530427", "name": "新平彝族傣族自治县" }, { "code": "530428", "name": "元江哈尼族彝族傣族自治县" }, { "code": "530481", "name": "澄江市" } ] }, { "code": "5305", "name": "保山市", "children": [ { "code": "530502", "name": "隆阳区" }, { "code": "530521", "name": "施甸县" }, { "code": "530523", "name": "龙陵县" }, { "code": "530524", "name": "昌宁县" }, { "code": "530581", "name": "腾冲市" } ] }, { "code": "5306", "name": "昭通市", "children": [ { "code": "530602", "name": "昭阳区" }, { "code": "530621", "name": "鲁甸县" }, { "code": "530622", "name": "巧家县" }, { "code": "530623", "name": "盐津县" }, { "code": "530624", "name": "大关县" }, { "code": "530625", "name": "永善县" }, { "code": "530626", "name": "绥江县" }, { "code": "530627", "name": "镇雄县" }, { "code": "530628", "name": "彝良县" }, { "code": "530629", "name": "威信县" }, { "code": "530681", "name": "水富市" } ] }, { "code": "5307", "name": "丽江市", "children": [ { "code": "530702", "name": "古城区" }, { "code": "530721", "name": "玉龙纳西族自治县" }, { "code": "530722", "name": "永胜县" }, { "code": "530723", "name": "华坪县" }, { "code": "530724", "name": "宁蒗彝族自治县" } ] }, { "code": "5308", "name": "普洱市", "children": [ { "code": "530802", "name": "思茅区" }, { "code": "530821", "name": "宁洱哈尼族彝族自治县" }, { "code": "530822", "name": "墨江哈尼族自治县" }, { "code": "530823", "name": "景东彝族自治县" }, { "code": "530824", "name": "景谷傣族彝族自治县" }, { "code": "530825", "name": "镇沅彝族哈尼族拉祜族自治县" }, { "code": "530826", "name": "江城哈尼族彝族自治县" }, { "code": "530827", "name": "孟连傣族拉祜族佤族自治县" }, { "code": "530828", "name": "澜沧拉祜族自治县" }, { "code": "530829", "name": "西盟佤族自治县" } ] }, { "code": "5309", "name": "临沧市", "children": [ { "code": "530902", "name": "临翔区" }, { "code": "530921", "name": "凤庆县" }, { "code": "530922", "name": "云县" }, { "code": "530923", "name": "永德县" }, { "code": "530924", "name": "镇康县" }, { "code": "530925", "name": "双江拉祜族佤族布朗族傣族自治县" }, { "code": "530926", "name": "耿马傣族佤族自治县" }, { "code": "530927", "name": "沧源佤族自治县" } ] }, { "code": "5323", "name": "楚雄彝族自治州", "children": [ { "code": "532301", "name": "楚雄市" }, { "code": "532322", "name": "双柏县" }, { "code": "532323", "name": "牟定县" }, { "code": "532324", "name": "南华县" }, { "code": "532325", "name": "姚安县" }, { "code": "532326", "name": "大姚县" }, { "code": "532327", "name": "永仁县" }, { "code": "532328", "name": "元谋县" }, { "code": "532329", "name": "武定县" }, { "code": "532331", "name": "禄丰县" } ] }, { "code": "5325", "name": "红河哈尼族彝族自治州", "children": [ { "code": "532501", "name": "个旧市" }, { "code": "532502", "name": "开远市" }, { "code": "532503", "name": "蒙自市" }, { "code": "532504", "name": "弥勒市" }, { "code": "532523", "name": "屏边苗族自治县" }, { "code": "532524", "name": "建水县" }, { "code": "532525", "name": "石屏县" }, { "code": "532527", "name": "泸西县" }, { "code": "532528", "name": "元阳县" }, { "code": "532529", "name": "红河县" }, { "code": "532530", "name": "金平苗族瑶族傣族自治县" }, { "code": "532531", "name": "绿春县" }, { "code": "532532", "name": "河口瑶族自治县" } ] }, { "code": "5326", "name": "文山壮族苗族自治州", "children": [ { "code": "532601", "name": "文山市" }, { "code": "532622", "name": "砚山县" }, { "code": "532623", "name": "西畴县" }, { "code": "532624", "name": "麻栗坡县" }, { "code": "532625", "name": "马关县" }, { "code": "532626", "name": "丘北县" }, { "code": "532627", "name": "广南县" }, { "code": "532628", "name": "富宁县" } ] }, { "code": "5328", "name": "西双版纳傣族自治州", "children": [ { "code": "532801", "name": "景洪市" }, { "code": "532822", "name": "勐海县" }, { "code": "532823", "name": "勐腊县" } ] }, { "code": "5329", "name": "大理白族自治州", "children": [ { "code": "532901", "name": "大理市" }, { "code": "532922", "name": "漾濞彝族自治县" }, { "code": "532923", "name": "祥云县" }, { "code": "532924", "name": "宾川县" }, { "code": "532925", "name": "弥渡县" }, { "code": "532926", "name": "南涧彝族自治县" }, { "code": "532927", "name": "巍山彝族回族自治县" }, { "code": "532928", "name": "永平县" }, { "code": "532929", "name": "云龙县" }, { "code": "532930", "name": "洱源县" }, { "code": "532931", "name": "剑川县" }, { "code": "532932", "name": "鹤庆县" } ] }, { "code": "5331", "name": "德宏傣族景颇族自治州", "children": [ { "code": "533102", "name": "瑞丽市" }, { "code": "533103", "name": "芒市" }, { "code": "533122", "name": "梁河县" }, { "code": "533123", "name": "盈江县" }, { "code": "533124", "name": "陇川县" } ] }, { "code": "5333", "name": "怒江傈僳族自治州", "children": [ { "code": "533301", "name": "泸水市" }, { "code": "533323", "name": "福贡县" }, { "code": "533324", "name": "贡山独龙族怒族自治县" }, { "code": "533325", "name": "兰坪白族普米族自治县" } ] }, { "code": "5334", "name": "迪庆藏族自治州", "children": [ { "code": "533401", "name": "香格里拉市" }, { "code": "533422", "name": "德钦县" }, { "code": "533423", "name": "维西傈僳族自治县" } ] } ] }, { "code": "54", "name": "西藏自治区", "children": [ { "code": "5401", "name": "拉萨市", "children": [ { "code": "540102", "name": "城关区" }, { "code": "540103", "name": "堆龙德庆区" }, { "code": "540104", "name": "达孜区" }, { "code": "540121", "name": "林周县" }, { "code": "540122", "name": "当雄县" }, { "code": "540123", "name": "尼木县" }, { "code": "540124", "name": "曲水县" }, { "code": "540127", "name": "墨竹工卡县" }, { "code": "540171", "name": "格尔木藏青工业园区" }, { "code": "540172", "name": "拉萨经济技术开发区" }, { "code": "540173", "name": "西藏文化旅游创意园区" }, { "code": "540174", "name": "达孜工业园区" } ] }, { "code": "5402", "name": "日喀则市", "children": [ { "code": "540202", "name": "桑珠孜区" }, { "code": "540221", "name": "南木林县" }, { "code": "540222", "name": "江孜县" }, { "code": "540223", "name": "定日县" }, { "code": "540224", "name": "萨迦县" }, { "code": "540225", "name": "拉孜县" }, { "code": "540226", "name": "昂仁县" }, { "code": "540227", "name": "谢通门县" }, { "code": "540228", "name": "白朗县" }, { "code": "540229", "name": "仁布县" }, { "code": "540230", "name": "康马县" }, { "code": "540231", "name": "定结县" }, { "code": "540232", "name": "仲巴县" }, { "code": "540233", "name": "亚东县" }, { "code": "540234", "name": "吉隆县" }, { "code": "540235", "name": "聂拉木县" }, { "code": "540236", "name": "萨嘎县" }, { "code": "540237", "name": "岗巴县" } ] }, { "code": "5403", "name": "昌都市", "children": [ { "code": "540302", "name": "卡若区" }, { "code": "540321", "name": "江达县" }, { "code": "540322", "name": "贡觉县" }, { "code": "540323", "name": "类乌齐县" }, { "code": "540324", "name": "丁青县" }, { "code": "540325", "name": "察雅县" }, { "code": "540326", "name": "八宿县" }, { "code": "540327", "name": "左贡县" }, { "code": "540328", "name": "芒康县" }, { "code": "540329", "name": "洛隆县" }, { "code": "540330", "name": "边坝县" } ] }, { "code": "5404", "name": "林芝市", "children": [ { "code": "540402", "name": "巴宜区" }, { "code": "540421", "name": "工布江达县" }, { "code": "540422", "name": "米林县" }, { "code": "540423", "name": "墨脱县" }, { "code": "540424", "name": "波密县" }, { "code": "540425", "name": "察隅县" }, { "code": "540426", "name": "朗县" } ] }, { "code": "5405", "name": "山南市", "children": [ { "code": "540502", "name": "乃东区" }, { "code": "540521", "name": "扎囊县" }, { "code": "540522", "name": "贡嘎县" }, { "code": "540523", "name": "桑日县" }, { "code": "540524", "name": "琼结县" }, { "code": "540525", "name": "曲松县" }, { "code": "540526", "name": "措美县" }, { "code": "540527", "name": "洛扎县" }, { "code": "540528", "name": "加查县" }, { "code": "540529", "name": "隆子县" }, { "code": "540530", "name": "错那县" }, { "code": "540531", "name": "浪卡子县" } ] }, { "code": "5406", "name": "那曲市", "children": [ { "code": "540602", "name": "色尼区" }, { "code": "540621", "name": "嘉黎县" }, { "code": "540622", "name": "比如县" }, { "code": "540623", "name": "聂荣县" }, { "code": "540624", "name": "安多县" }, { "code": "540625", "name": "申扎县" }, { "code": "540626", "name": "索县" }, { "code": "540627", "name": "班戈县" }, { "code": "540628", "name": "巴青县" }, { "code": "540629", "name": "尼玛县" }, { "code": "540630", "name": "双湖县" } ] }, { "code": "5425", "name": "阿里地区", "children": [ { "code": "542521", "name": "普兰县" }, { "code": "542522", "name": "札达县" }, { "code": "542523", "name": "噶尔县" }, { "code": "542524", "name": "日土县" }, { "code": "542525", "name": "革吉县" }, { "code": "542526", "name": "改则县" }, { "code": "542527", "name": "措勤县" } ] } ] }, { "code": "61", "name": "陕西省", "children": [ { "code": "6101", "name": "西安市", "children": [ { "code": "610102", "name": "新城区" }, { "code": "610103", "name": "碑林区" }, { "code": "610104", "name": "莲湖区" }, { "code": "610111", "name": "灞桥区" }, { "code": "610112", "name": "未央区" }, { "code": "610113", "name": "雁塔区" }, { "code": "610114", "name": "阎良区" }, { "code": "610115", "name": "临潼区" }, { "code": "610116", "name": "长安区" }, { "code": "610117", "name": "高陵区" }, { "code": "610118", "name": "鄠邑区" }, { "code": "610122", "name": "蓝田县" }, { "code": "610124", "name": "周至县" } ] }, { "code": "6102", "name": "铜川市", "children": [ { "code": "610202", "name": "王益区" }, { "code": "610203", "name": "印台区" }, { "code": "610204", "name": "耀州区" }, { "code": "610222", "name": "宜君县" } ] }, { "code": "6103", "name": "宝鸡市", "children": [ { "code": "610302", "name": "渭滨区" }, { "code": "610303", "name": "金台区" }, { "code": "610304", "name": "陈仓区" }, { "code": "610322", "name": "凤翔县" }, { "code": "610323", "name": "岐山县" }, { "code": "610324", "name": "扶风县" }, { "code": "610326", "name": "眉县" }, { "code": "610327", "name": "陇县" }, { "code": "610328", "name": "千阳县" }, { "code": "610329", "name": "麟游县" }, { "code": "610330", "name": "凤县" }, { "code": "610331", "name": "太白县" } ] }, { "code": "6104", "name": "咸阳市", "children": [ { "code": "610402", "name": "秦都区" }, { "code": "610403", "name": "杨陵区" }, { "code": "610404", "name": "渭城区" }, { "code": "610422", "name": "三原县" }, { "code": "610423", "name": "泾阳县" }, { "code": "610424", "name": "乾县" }, { "code": "610425", "name": "礼泉县" }, { "code": "610426", "name": "永寿县" }, { "code": "610428", "name": "长武县" }, { "code": "610429", "name": "旬邑县" }, { "code": "610430", "name": "淳化县" }, { "code": "610431", "name": "武功县" }, { "code": "610481", "name": "兴平市" }, { "code": "610482", "name": "彬州市" } ] }, { "code": "6105", "name": "渭南市", "children": [ { "code": "610502", "name": "临渭区" }, { "code": "610503", "name": "华州区" }, { "code": "610522", "name": "潼关县" }, { "code": "610523", "name": "大荔县" }, { "code": "610524", "name": "合阳县" }, { "code": "610525", "name": "澄城县" }, { "code": "610526", "name": "蒲城县" }, { "code": "610527", "name": "白水县" }, { "code": "610528", "name": "富平县" }, { "code": "610581", "name": "韩城市" }, { "code": "610582", "name": "华阴市" } ] }, { "code": "6106", "name": "延安市", "children": [ { "code": "610602", "name": "宝塔区" }, { "code": "610603", "name": "安塞区" }, { "code": "610621", "name": "延长县" }, { "code": "610622", "name": "延川县" }, { "code": "610625", "name": "志丹县" }, { "code": "610626", "name": "吴起县" }, { "code": "610627", "name": "甘泉县" }, { "code": "610628", "name": "富县" }, { "code": "610629", "name": "洛川县" }, { "code": "610630", "name": "宜川县" }, { "code": "610631", "name": "黄龙县" }, { "code": "610632", "name": "黄陵县" }, { "code": "610681", "name": "子长市" } ] }, { "code": "6107", "name": "汉中市", "children": [ { "code": "610702", "name": "汉台区" }, { "code": "610703", "name": "南郑区" }, { "code": "610722", "name": "城固县" }, { "code": "610723", "name": "洋县" }, { "code": "610724", "name": "西乡县" }, { "code": "610725", "name": "勉县" }, { "code": "610726", "name": "宁强县" }, { "code": "610727", "name": "略阳县" }, { "code": "610728", "name": "镇巴县" }, { "code": "610729", "name": "留坝县" }, { "code": "610730", "name": "佛坪县" } ] }, { "code": "6108", "name": "榆林市", "children": [ { "code": "610802", "name": "榆阳区" }, { "code": "610803", "name": "横山区" }, { "code": "610822", "name": "府谷县" }, { "code": "610824", "name": "靖边县" }, { "code": "610825", "name": "定边县" }, { "code": "610826", "name": "绥德县" }, { "code": "610827", "name": "米脂县" }, { "code": "610828", "name": "佳县" }, { "code": "610829", "name": "吴堡县" }, { "code": "610830", "name": "清涧县" }, { "code": "610831", "name": "子洲县" }, { "code": "610881", "name": "神木市" } ] }, { "code": "6109", "name": "安康市", "children": [ { "code": "610902", "name": "汉滨区" }, { "code": "610921", "name": "汉阴县" }, { "code": "610922", "name": "石泉县" }, { "code": "610923", "name": "宁陕县" }, { "code": "610924", "name": "紫阳县" }, { "code": "610925", "name": "岚皋县" }, { "code": "610926", "name": "平利县" }, { "code": "610927", "name": "镇坪县" }, { "code": "610928", "name": "旬阳县" }, { "code": "610929", "name": "白河县" } ] }, { "code": "6110", "name": "商洛市", "children": [ { "code": "611002", "name": "商州区" }, { "code": "611021", "name": "洛南县" }, { "code": "611022", "name": "丹凤县" }, { "code": "611023", "name": "商南县" }, { "code": "611024", "name": "山阳县" }, { "code": "611025", "name": "镇安县" }, { "code": "611026", "name": "柞水县" } ] } ] }, { "code": "62", "name": "甘肃省", "children": [ { "code": "6201", "name": "兰州市", "children": [ { "code": "620102", "name": "城关区" }, { "code": "620103", "name": "七里河区" }, { "code": "620104", "name": "西固区" }, { "code": "620105", "name": "安宁区" }, { "code": "620111", "name": "红古区" }, { "code": "620121", "name": "永登县" }, { "code": "620122", "name": "皋兰县" }, { "code": "620123", "name": "榆中县" }, { "code": "620171", "name": "兰州新区" } ] }, { "code": "6202", "name": "嘉峪关市", "children": [ { "code": "620201001", "name": "雄关街道" }, { "code": "620201002", "name": "钢城街道" }, { "code": "620201100", "name": "新城镇" }, { "code": "620201101", "name": "峪泉镇" }, { "code": "620201102", "name": "文殊镇" } ] }, { "code": "6203", "name": "金昌市", "children": [ { "code": "620302", "name": "金川区" }, { "code": "620321", "name": "永昌县" } ] }, { "code": "6204", "name": "白银市", "children": [ { "code": "620402", "name": "白银区" }, { "code": "620403", "name": "平川区" }, { "code": "620421", "name": "靖远县" }, { "code": "620422", "name": "会宁县" }, { "code": "620423", "name": "景泰县" } ] }, { "code": "6205", "name": "天水市", "children": [ { "code": "620502", "name": "秦州区" }, { "code": "620503", "name": "麦积区" }, { "code": "620521", "name": "清水县" }, { "code": "620522", "name": "秦安县" }, { "code": "620523", "name": "甘谷县" }, { "code": "620524", "name": "武山县" }, { "code": "620525", "name": "张家川回族自治县" } ] }, { "code": "6206", "name": "武威市", "children": [ { "code": "620602", "name": "凉州区" }, { "code": "620621", "name": "民勤县" }, { "code": "620622", "name": "古浪县" }, { "code": "620623", "name": "天祝藏族自治县" } ] }, { "code": "6207", "name": "张掖市", "children": [ { "code": "620702", "name": "甘州区" }, { "code": "620721", "name": "肃南裕固族自治县" }, { "code": "620722", "name": "民乐县" }, { "code": "620723", "name": "临泽县" }, { "code": "620724", "name": "高台县" }, { "code": "620725", "name": "山丹县" } ] }, { "code": "6208", "name": "平凉市", "children": [ { "code": "620802", "name": "崆峒区" }, { "code": "620821", "name": "泾川县" }, { "code": "620822", "name": "灵台县" }, { "code": "620823", "name": "崇信县" }, { "code": "620825", "name": "庄浪县" }, { "code": "620826", "name": "静宁县" }, { "code": "620881", "name": "华亭市" } ] }, { "code": "6209", "name": "酒泉市", "children": [ { "code": "620902", "name": "肃州区" }, { "code": "620921", "name": "金塔县" }, { "code": "620922", "name": "瓜州县" }, { "code": "620923", "name": "肃北蒙古族自治县" }, { "code": "620924", "name": "阿克塞哈萨克族自治县" }, { "code": "620981", "name": "玉门市" }, { "code": "620982", "name": "敦煌市" } ] }, { "code": "6210", "name": "庆阳市", "children": [ { "code": "621002", "name": "西峰区" }, { "code": "621021", "name": "庆城县" }, { "code": "621022", "name": "环县" }, { "code": "621023", "name": "华池县" }, { "code": "621024", "name": "合水县" }, { "code": "621025", "name": "正宁县" }, { "code": "621026", "name": "宁县" }, { "code": "621027", "name": "镇原县" } ] }, { "code": "6211", "name": "定西市", "children": [ { "code": "621102", "name": "安定区" }, { "code": "621121", "name": "通渭县" }, { "code": "621122", "name": "陇西县" }, { "code": "621123", "name": "渭源县" }, { "code": "621124", "name": "临洮县" }, { "code": "621125", "name": "漳县" }, { "code": "621126", "name": "岷县" } ] }, { "code": "6212", "name": "陇南市", "children": [ { "code": "621202", "name": "武都区" }, { "code": "621221", "name": "成县" }, { "code": "621222", "name": "文县" }, { "code": "621223", "name": "宕昌县" }, { "code": "621224", "name": "康县" }, { "code": "621225", "name": "西和县" }, { "code": "621226", "name": "礼县" }, { "code": "621227", "name": "徽县" }, { "code": "621228", "name": "两当县" } ] }, { "code": "6229", "name": "临夏回族自治州", "children": [ { "code": "622901", "name": "临夏市" }, { "code": "622921", "name": "临夏县" }, { "code": "622922", "name": "康乐县" }, { "code": "622923", "name": "永靖县" }, { "code": "622924", "name": "广河县" }, { "code": "622925", "name": "和政县" }, { "code": "622926", "name": "东乡族自治县" }, { "code": "622927", "name": "积石山保安族东乡族撒拉族自治县" } ] }, { "code": "6230", "name": "甘南藏族自治州", "children": [ { "code": "623001", "name": "合作市" }, { "code": "623021", "name": "临潭县" }, { "code": "623022", "name": "卓尼县" }, { "code": "623023", "name": "舟曲县" }, { "code": "623024", "name": "迭部县" }, { "code": "623025", "name": "玛曲县" }, { "code": "623026", "name": "碌曲县" }, { "code": "623027", "name": "夏河县" } ] } ] }, { "code": "63", "name": "青海省", "children": [ { "code": "6301", "name": "西宁市", "children": [ { "code": "630102", "name": "城东区" }, { "code": "630103", "name": "城中区" }, { "code": "630104", "name": "城西区" }, { "code": "630105", "name": "城北区" }, { "code": "630106", "name": "湟中区" }, { "code": "630121", "name": "大通回族土族自治县" }, { "code": "630123", "name": "湟源县" } ] }, { "code": "6302", "name": "海东市", "children": [ { "code": "630202", "name": "乐都区" }, { "code": "630203", "name": "平安区" }, { "code": "630222", "name": "民和回族土族自治县" }, { "code": "630223", "name": "互助土族自治县" }, { "code": "630224", "name": "化隆回族自治县" }, { "code": "630225", "name": "循化撒拉族自治县" } ] }, { "code": "6322", "name": "海北藏族自治州", "children": [ { "code": "632221", "name": "门源回族自治县" }, { "code": "632222", "name": "祁连县" }, { "code": "632223", "name": "海晏县" }, { "code": "632224", "name": "刚察县" } ] }, { "code": "6323", "name": "黄南藏族自治州", "children": [ { "code": "632321", "name": "同仁县" }, { "code": "632322", "name": "尖扎县" }, { "code": "632323", "name": "泽库县" }, { "code": "632324", "name": "河南蒙古族自治县" } ] }, { "code": "6325", "name": "海南藏族自治州", "children": [ { "code": "632521", "name": "共和县" }, { "code": "632522", "name": "同德县" }, { "code": "632523", "name": "贵德县" }, { "code": "632524", "name": "兴海县" }, { "code": "632525", "name": "贵南县" } ] }, { "code": "6326", "name": "果洛藏族自治州", "children": [ { "code": "632621", "name": "玛沁县" }, { "code": "632622", "name": "班玛县" }, { "code": "632623", "name": "甘德县" }, { "code": "632624", "name": "达日县" }, { "code": "632625", "name": "久治县" }, { "code": "632626", "name": "玛多县" } ] }, { "code": "6327", "name": "玉树藏族自治州", "children": [ { "code": "632701", "name": "玉树市" }, { "code": "632722", "name": "杂多县" }, { "code": "632723", "name": "称多县" }, { "code": "632724", "name": "治多县" }, { "code": "632725", "name": "囊谦县" }, { "code": "632726", "name": "曲麻莱县" } ] }, { "code": "6328", "name": "海西蒙古族藏族自治州", "children": [ { "code": "632801", "name": "格尔木市" }, { "code": "632802", "name": "德令哈市" }, { "code": "632803", "name": "茫崖市" }, { "code": "632821", "name": "乌兰县" }, { "code": "632822", "name": "都兰县" }, { "code": "632823", "name": "天峻县" }, { "code": "632857", "name": "大柴旦行政委员会" } ] } ] }, { "code": "64", "name": "宁夏回族自治区", "children": [ { "code": "6401", "name": "银川市", "children": [ { "code": "640104", "name": "兴庆区" }, { "code": "640105", "name": "西夏区" }, { "code": "640106", "name": "金凤区" }, { "code": "640121", "name": "永宁县" }, { "code": "640122", "name": "贺兰县" }, { "code": "640181", "name": "灵武市" } ] }, { "code": "6402", "name": "石嘴山市", "children": [ { "code": "640202", "name": "大武口区" }, { "code": "640205", "name": "惠农区" }, { "code": "640221", "name": "平罗县" } ] }, { "code": "6403", "name": "吴忠市", "children": [ { "code": "640302", "name": "利通区" }, { "code": "640303", "name": "红寺堡区" }, { "code": "640323", "name": "盐池县" }, { "code": "640324", "name": "同心县" }, { "code": "640381", "name": "青铜峡市" } ] }, { "code": "6404", "name": "固原市", "children": [ { "code": "640402", "name": "原州区" }, { "code": "640422", "name": "西吉县" }, { "code": "640423", "name": "隆德县" }, { "code": "640424", "name": "泾源县" }, { "code": "640425", "name": "彭阳县" } ] }, { "code": "6405", "name": "中卫市", "children": [ { "code": "640502", "name": "沙坡头区" }, { "code": "640521", "name": "中宁县" }, { "code": "640522", "name": "海原县" } ] } ] }, { "code": "65", "name": "新疆维吾尔自治区", "children": [ { "code": "6501", "name": "乌鲁木齐市", "children": [ { "code": "650102", "name": "天山区" }, { "code": "650103", "name": "沙依巴克区" }, { "code": "650104", "name": "新市区" }, { "code": "650105", "name": "水磨沟区" }, { "code": "650106", "name": "头屯河区" }, { "code": "650107", "name": "达坂城区" }, { "code": "650109", "name": "米东区" }, { "code": "650121", "name": "乌鲁木齐县" } ] }, { "code": "6502", "name": "克拉玛依市", "children": [ { "code": "650202", "name": "独山子区" }, { "code": "650203", "name": "克拉玛依区" }, { "code": "650204", "name": "白碱滩区" }, { "code": "650205", "name": "乌尔禾区" } ] }, { "code": "6504", "name": "吐鲁番市", "children": [ { "code": "650402", "name": "高昌区" }, { "code": "650421", "name": "鄯善县" }, { "code": "650422", "name": "托克逊县" } ] }, { "code": "6505", "name": "哈密市", "children": [ { "code": "650502", "name": "伊州区" }, { "code": "650521", "name": "巴里坤哈萨克自治县" }, { "code": "650522", "name": "伊吾县" } ] }, { "code": "6523", "name": "昌吉回族自治州", "children": [ { "code": "652301", "name": "昌吉市" }, { "code": "652302", "name": "阜康市" }, { "code": "652323", "name": "呼图壁县" }, { "code": "652324", "name": "玛纳斯县" }, { "code": "652325", "name": "奇台县" }, { "code": "652327", "name": "吉木萨尔县" }, { "code": "652328", "name": "木垒哈萨克自治县" } ] }, { "code": "6527", "name": "博尔塔拉蒙古自治州", "children": [ { "code": "652701", "name": "博乐市" }, { "code": "652702", "name": "阿拉山口市" }, { "code": "652722", "name": "精河县" }, { "code": "652723", "name": "温泉县" } ] }, { "code": "6528", "name": "巴音郭楞蒙古自治州", "children": [ { "code": "652801", "name": "库尔勒市" }, { "code": "652822", "name": "轮台县" }, { "code": "652823", "name": "尉犁县" }, { "code": "652824", "name": "若羌县" }, { "code": "652825", "name": "且末县" }, { "code": "652826", "name": "焉耆回族自治县" }, { "code": "652827", "name": "和静县" }, { "code": "652828", "name": "和硕县" }, { "code": "652829", "name": "博湖县" }, { "code": "652871", "name": "库尔勒经济技术开发区" } ] }, { "code": "6529", "name": "阿克苏地区", "children": [ { "code": "652901", "name": "阿克苏市" }, { "code": "652902", "name": "库车市" }, { "code": "652922", "name": "温宿县" }, { "code": "652924", "name": "沙雅县" }, { "code": "652925", "name": "新和县" }, { "code": "652926", "name": "拜城县" }, { "code": "652927", "name": "乌什县" }, { "code": "652928", "name": "阿瓦提县" }, { "code": "652929", "name": "柯坪县" } ] }, { "code": "6530", "name": "克孜勒苏柯尔克孜自治州", "children": [ { "code": "653001", "name": "阿图什市" }, { "code": "653022", "name": "阿克陶县" }, { "code": "653023", "name": "阿合奇县" }, { "code": "653024", "name": "乌恰县" } ] }, { "code": "6531", "name": "喀什地区", "children": [ { "code": "653101", "name": "喀什市" }, { "code": "653121", "name": "疏附县" }, { "code": "653122", "name": "疏勒县" }, { "code": "653123", "name": "英吉沙县" }, { "code": "653124", "name": "泽普县" }, { "code": "653125", "name": "莎车县" }, { "code": "653126", "name": "叶城县" }, { "code": "653127", "name": "麦盖提县" }, { "code": "653128", "name": "岳普湖县" }, { "code": "653129", "name": "伽师县" }, { "code": "653130", "name": "巴楚县" }, { "code": "653131", "name": "塔什库尔干塔吉克自治县" } ] }, { "code": "6532", "name": "和田地区", "children": [ { "code": "653201", "name": "和田市" }, { "code": "653221", "name": "和田县" }, { "code": "653222", "name": "墨玉县" }, { "code": "653223", "name": "皮山县" }, { "code": "653224", "name": "洛浦县" }, { "code": "653225", "name": "策勒县" }, { "code": "653226", "name": "于田县" }, { "code": "653227", "name": "民丰县" } ] }, { "code": "6540", "name": "伊犁哈萨克自治州", "children": [ { "code": "654002", "name": "伊宁市" }, { "code": "654003", "name": "奎屯市" }, { "code": "654004", "name": "霍尔果斯市" }, { "code": "654021", "name": "伊宁县" }, { "code": "654022", "name": "察布查尔锡伯自治县" }, { "code": "654023", "name": "霍城县" }, { "code": "654024", "name": "巩留县" }, { "code": "654025", "name": "新源县" }, { "code": "654026", "name": "昭苏县" }, { "code": "654027", "name": "特克斯县" }, { "code": "654028", "name": "尼勒克县" } ] }, { "code": "6542", "name": "塔城地区", "children": [ { "code": "654201", "name": "塔城市" }, { "code": "654202", "name": "乌苏市" }, { "code": "654221", "name": "额敏县" }, { "code": "654223", "name": "沙湾县" }, { "code": "654224", "name": "托里县" }, { "code": "654225", "name": "裕民县" }, { "code": "654226", "name": "和布克赛尔蒙古自治县" } ] }, { "code": "6543", "name": "阿勒泰地区", "children": [ { "code": "654301", "name": "阿勒泰市" }, { "code": "654321", "name": "布尔津县" }, { "code": "654322", "name": "富蕴县" }, { "code": "654323", "name": "福海县" }, { "code": "654324", "name": "哈巴河县" }, { "code": "654325", "name": "青河县" }, { "code": "654326", "name": "吉木乃县" } ] }, { "code": "6590", "name": "自治区直辖县级行政区划", "children": [ { "code": "659001", "name": "石河子市" }, { "code": "659002", "name": "阿拉尔市" }, { "code": "659003", "name": "图木舒克市" }, { "code": "659004", "name": "五家渠市" }, { "code": "659005", "name": "北屯市" }, { "code": "659006", "name": "铁门关市" }, { "code": "659007", "name": "双河市" }, { "code": "659008", "name": "可克达拉市" }, { "code": "659009", "name": "昆玉市" }, { "code": "659010", "name": "胡杨河市" } ] } ] } ] ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/DemoApp.java ================================================ /* * 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.fallback; import android.app.Application; import android.content.Context; import androidx.multidex.MultiDex; import com.github.gzuliyujiang.dialog.DialogColor; import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.dialog.DialogLog; import com.github.gzuliyujiang.dialog.DialogStyle; import org.json.JSONObject; import java.io.File; import java.io.FileWriter; /** * 应用全局上下文 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2016/7/20 20:28 */ public class DemoApp extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } @Override public void onCreate() { super.onCreate(); DialogLog.enable(); DialogConfig.setDialogStyle(DialogStyle.Default); DialogConfig.setDialogColor(new DialogColor() .cancelTextColor(0xFF999999) .okTextColor(0xFF0099CC)); initXCrash(this); } private static void initXCrash(Application application) { try { // debugRuntimeOnly "com.iqiyi.xcrash:xcrash-android-lib:x.x.x",调试运行才集成xCrash // compileOnly "com.iqiyi.xcrash:xcrash-android-lib:x.x.x",编译模式才集成xCrash Class.forName("xcrash.XCrash"); System.out.println("xCrash SDK dependency was found"); File logDir = application.getExternalFilesDir("xcrash"); if (logDir == null) { logDir = new File(application.getFilesDir(), "xcrash"); //noinspection ResultOfMethodCallIgnored logDir.mkdir(); } System.out.println("xCrash SDK init start: logDir=" + logDir); xcrash.ICrashCallback callback = new xcrash.ICrashCallback() { @Override public void onCrash(String logPath, String emergency) { System.out.println("xCrash SDK: logPath=" + logPath + ", emergency=" + emergency); if (logPath == null || emergency == null) { return; } FileWriter writer = null; try { File file = new File(xcrash.XCrash.getLogDir(), "crash.json"); //noinspection ResultOfMethodCallIgnored file.createNewFile(); writer = new FileWriter(file, false); writer.write(new JSONObject(xcrash.TombstoneParser.parse(logPath, emergency)).toString()); } catch (Exception e) { System.err.println("xCrash SDK failed to export the crash to a JSON file: " + e); } finally { if (writer != null) { try { writer.close(); } catch (Exception ignored) { } } } } }; xcrash.XCrash.init(application, new xcrash.XCrash.InitParameters() .setJavaRethrow(true) .setJavaLogCountMax(10) .setJavaDumpAllThreadsWhiteList(new String[]{"^main$", "^Binder:.*", ".*Finalizer.*"}) .setJavaDumpAllThreadsCountMax(10) .setJavaCallback(callback) .setNativeRethrow(true) .setNativeLogCountMax(10) .setNativeDumpAllThreadsWhiteList(new String[]{"^xcrash\\.sample$", "^Signal Catcher$", "^Jit thread pool$", ".*(R|r)ender.*", ".*Chrome.*"}) .setNativeDumpAllThreadsCountMax(10) .setNativeCallback(callback) .setAnrRethrow(true) .setAnrLogCountMax(10) .setAnrCallback(callback) .setPlaceholderCountMax(3) .setPlaceholderSizeKb(512) .setLogDir(logDir.getAbsolutePath()) .setLogFileMaintainDelayMs(1000)); System.out.println("xCrash SDK init end"); } catch (Exception e) { System.out.println("xCrash SDK dependency not found"); } } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/AddressPickerActivity.java ================================================ /* * 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.fallback.activity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import androidx.annotation.Nullable; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.fallback.custom.CustomAddressPicker; import com.github.gzuliyujiang.fallback.custom.TextAddressLoader; import com.github.gzuliyujiang.fallback.custom.TextAddressParser; import com.github.gzuliyujiang.wheelpicker.AddressPicker; import com.github.gzuliyujiang.wheelpicker.annotation.AddressMode; import com.github.gzuliyujiang.wheelpicker.contract.OnAddressPickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnLinkageSelectedListener; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; 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; /** * 地址滚轮选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/23 */ public class AddressPickerActivity extends BackAbleActivity implements OnAddressPickedListener { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_address); } @Override public void onAddressPicked(ProvinceEntity province, CityEntity city, CountyEntity county) { Toast.makeText(this, province + " " + city + " " + county, Toast.LENGTH_SHORT).show(); } public void onProvinceCityCounty(View view) { AddressPicker picker = new AddressPicker(this); picker.setAddressMode(AddressMode.PROVINCE_CITY_COUNTY); picker.setDefaultValue("贵州省", "贵阳市", "观山湖区"); picker.setOnAddressPickedListener(this); picker.getWheelLayout().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.show(); } public void onProvinceCity(View view) { AddressPicker picker = new AddressPicker(this); picker.setTitle("省市选择"); picker.setAddressMode(AddressMode.PROVINCE_CITY); picker.setDefaultValue("520000", "520100", ""); picker.setOnAddressPickedListener(this); picker.getWheelLayout().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.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.setTextSize(15 * view.getResources().getDisplayMetrics().scaledDensity); wheelLayout.setSelectedTextSize(17 * view.getResources().getDisplayMetrics().scaledDensity); wheelLayout.setSelectedTextBold(true); wheelLayout.setCurtainEnabled(true); wheelLayout.setCurtainColor(0xFF22EEFF); wheelLayout.setCurtainRadius(8 * 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.getProvinceWheelView().formatItem(first), picker.getCityWheelView().formatItem(second), picker.getCountyWheelView().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("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); picker.getWheelLayout().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.show(); } public void onCustomUi(View view) { CustomAddressPicker picker = new CustomAddressPicker(this); picker.setDefaultValue("贵州省", "毕节市", "纳雍县"); picker.setOnAddressPickedListener(this); picker.show(); } public void onCustomDataByJson(View view) { AddressPicker picker = new AddressPicker(this); picker.setAddressMode("city.json", AddressMode.PROVINCE_CITY_COUNTY, new AddressJsonParser.Builder() .provinceCodeField("code") .provinceNameField("name") .provinceChildField("city") .cityCodeField("code") .cityNameField("name") .cityChildField("area") .countyCodeField("code") .countyNameField("name") .build()); picker.setDefaultValue("贵州省", "毕节市", "纳雍县"); picker.setOnAddressPickedListener(this); picker.getWheelLayout().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.show(); } public void onCustomDataByText(View view) { AddressPicker picker = new AddressPicker(this); picker.setAddressLoader(new TextAddressLoader(this), new TextAddressParser()); picker.setDefaultValue("贵州省", "毕节地区", "纳雍县"); picker.setOnAddressPickedListener(this); picker.getWheelLayout().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.show(); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/BackAbleActivity.java ================================================ /* * 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.fallback.activity; import android.view.View; import androidx.fragment.app.FragmentActivity; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/9/18 10:58 */ public class BackAbleActivity extends FragmentActivity { public void goBack(View view) { finish(); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/CalendarPickerActivity.java ================================================ /* * 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.fallback.activity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.calendarpicker.CalendarPicker; import com.github.gzuliyujiang.calendarpicker.OnRangeDatePickListener; import com.github.gzuliyujiang.calendarpicker.OnSingleDatePickListener; 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; /** * 日历日期选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/23 */ public class CalendarPickerActivity extends BackAbleActivity { private long startTimeInMillis, endTimeInMillis, singleTimeInMillis; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_calendar); Date minDate = new Date(System.currentTimeMillis() - 5 * android.text.format.DateUtils.DAY_IN_MILLIS); Calendar calendar = DateUtils.calendar(minDate); calendar.add(Calendar.MONTH, 3); Date maxDate = calendar.getTime(); CalendarView horizontalCalendarView = findViewById(R.id.calendar_picker_body_horizontal); horizontalCalendarView.enablePagerSnap(); horizontalCalendarView.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) .range(minDate, maxDate) .refresh(); CalendarView verticalCalendarView = findViewById(R.id.calendar_picker_body_vertical); verticalCalendarView.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) .range(minDate, maxDate) .refresh(); } public void onCalendarColorScheme(View view) { CalendarPicker picker = new CalendarPicker(this); Date currentDate = new Date(System.currentTimeMillis()); if (startTimeInMillis == 0 && endTimeInMillis == 0) { startTimeInMillis = currentDate.getTime() - 3 * android.text.format.DateUtils.DAY_IN_MILLIS; endTimeInMillis = currentDate.getTime() + 3 * android.text.format.DateUtils.DAY_IN_MILLIS; } picker.setSelectedDate(startTimeInMillis, endTimeInMillis); picker.setColorScheme(new ColorScheme() .daySelectBackgroundColor(0xFF00CC00) .dayStressTextColor(0xFF00AA00)); picker.setOnRangeDatePickListener(new OnRangeDatePickListener() { @Override public void onRangeDatePicked(@NonNull Date startDate, @NonNull Date endDate) { startTimeInMillis = startDate.getTime(); endTimeInMillis = endDate.getTime(); Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(startDate) + "\n" + DateFormat.getDateTimeInstance().format(endDate), Toast.LENGTH_SHORT).show(); } @Override public void onMonthChanged(Date date) { Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show(); } }); picker.show(); } public void onCalendarDateRange(View view) { CalendarPicker picker = new CalendarPicker(this); Date currentDate = new Date(System.currentTimeMillis()); Calendar minCalendar = DateUtils.calendar(currentDate); minCalendar.add(Calendar.MONTH, -12); minCalendar.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(minCalendar.getTime())); Date minDate = minCalendar.getTime(); Calendar maxCalendar = DateUtils.calendar(currentDate); maxCalendar.setTime(currentDate); maxCalendar.add(Calendar.MONTH, 12); maxCalendar.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(maxCalendar.getTime())); Date maxDate = maxCalendar.getTime(); picker.setRangeDate(minDate, maxDate); if (startTimeInMillis == 0 && endTimeInMillis == 0) { startTimeInMillis = currentDate.getTime() - 3 * android.text.format.DateUtils.DAY_IN_MILLIS; endTimeInMillis = currentDate.getTime() + 3 * android.text.format.DateUtils.DAY_IN_MILLIS; } picker.setSelectedDate(startTimeInMillis, endTimeInMillis); picker.setOnRangeDatePickListener(new OnRangeDatePickListener() { @Override public void onRangeDatePicked(@NonNull Date startDate, @NonNull Date endDate) { startTimeInMillis = startDate.getTime(); endTimeInMillis = endDate.getTime(); Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(startDate) + "\n" + DateFormat.getDateTimeInstance().format(endDate), Toast.LENGTH_SHORT).show(); } @Override public void onMonthChanged(Date date) { Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show(); } }); picker.show(); } public void onCalendarDateSingle(View view) { CalendarPicker picker = new CalendarPicker(this); picker.setRangeDateOnFuture(3); if (singleTimeInMillis == 0) { singleTimeInMillis = System.currentTimeMillis(); } picker.setSelectedDate(singleTimeInMillis); picker.setFestivalProvider(new MyFestivalProvider()); picker.setOnSingleDatePickListener(new OnSingleDatePickListener() { @Override public void onSingleDatePicked(@NonNull Date date) { singleTimeInMillis = date.getTime(); Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show(); } @Override public void onMonthChanged(Date date) { Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show(); } }); picker.show(); } public void onHorizontalCalendarPicker(View view) { CalendarPicker picker = new CalendarPicker(this); picker.enablePagerSnap(); picker.setRangeDateOnFuture(3); picker.setFestivalProvider(new MyFestivalProvider()); picker.setOnSingleDatePickListener(new OnSingleDatePickListener() { @Override public void onSingleDatePicked(@NonNull Date date) { singleTimeInMillis = date.getTime(); Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show(); } @Override public void onMonthChanged(Date date) { Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show(); } }); 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 ""; } } } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/ColorPickerActivity.java ================================================ /* * 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.fallback.activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import androidx.annotation.Nullable; import com.github.gzuliyujiang.colorpicker.BrightnessGradientView; import com.github.gzuliyujiang.colorpicker.ColorGradientView; import com.github.gzuliyujiang.colorpicker.ColorPicker; import com.github.gzuliyujiang.colorpicker.OnColorChangedListener; import com.github.gzuliyujiang.colorpicker.OnColorPickedListener; import com.github.gzuliyujiang.fallback.R; /** * 颜色选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 11:49 */ public class ColorPickerActivity extends BackAbleActivity implements View.OnClickListener, OnColorChangedListener { private BrightnessGradientView brightnessGradientView; private Button button; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_color); button = findViewById(R.id.color_picker_button); button.setOnClickListener(this); ColorGradientView colorGradientView = findViewById(R.id.color_picker_panel); colorGradientView.setPointerDrawable(android.R.drawable.ic_menu_compass); colorGradientView.setColor(0xFF7FF7FF); colorGradientView.setOnColorChangedListener(this); brightnessGradientView = findViewById(R.id.color_picker_bright); brightnessGradientView.setColor(0xFF377377); brightnessGradientView.setOnColorChangedListener(this); } @Override public void onClick(View v) { if (v.getId() == R.id.color_picker_button) { ColorPicker picker = new ColorPicker(this); picker.setInitColor(0xFF7FF7FF); picker.setOnColorPickListener(new OnColorPickedListener() { @Override public void onColorPicked(int pickedColor) { button.setTextColor(pickedColor); } }); picker.show(); } } @Override public void onColorChanged(ColorGradientView gradientView, int color) { if (gradientView.getId() == R.id.color_picker_panel) { brightnessGradientView.setColor(color); } button.setTextColor(color); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/DateTimePickerActivity.java ================================================ /* * 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.fallback.activity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import androidx.annotation.Nullable; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.wheelpicker.BirthdayPicker; import com.github.gzuliyujiang.wheelpicker.DatePicker; import com.github.gzuliyujiang.wheelpicker.DatimePicker; import com.github.gzuliyujiang.wheelpicker.TimePicker; import com.github.gzuliyujiang.wheelpicker.annotation.DateMode; import com.github.gzuliyujiang.wheelpicker.annotation.TimeMode; import com.github.gzuliyujiang.wheelpicker.contract.OnDatePickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnDatimePickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnTimeMeridiemPickedListener; import com.github.gzuliyujiang.wheelpicker.contract.OnTimePickedListener; import com.github.gzuliyujiang.wheelpicker.entity.DateEntity; import com.github.gzuliyujiang.wheelpicker.entity.DatimeEntity; import com.github.gzuliyujiang.wheelpicker.entity.TimeEntity; import com.github.gzuliyujiang.wheelpicker.impl.UnitDateFormatter; import com.github.gzuliyujiang.wheelpicker.impl.UnitTimeFormatter; import com.github.gzuliyujiang.wheelpicker.widget.DateWheelLayout; import com.github.gzuliyujiang.wheelpicker.widget.DatimeWheelLayout; import com.github.gzuliyujiang.wheelpicker.widget.TimeWheelLayout; /** * 日期时间滚轮选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/23 */ public class DateTimePickerActivity extends BackAbleActivity implements OnDatePickedListener, OnTimePickedListener { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_date_time); } @Override public void onDatePicked(int year, int month, int day) { Toast.makeText(this, year + "-" + month + "-" + day, Toast.LENGTH_SHORT).show(); } @Override public void onTimePicked(int hour, int minute, int second) { Toast.makeText(this, hour + ":" + minute + ":" + second, Toast.LENGTH_SHORT).show(); } public void onYearMonthDayTime(View view) { DatimePicker picker = new DatimePicker(this); final DatimeWheelLayout wheelLayout = picker.getWheelLayout(); picker.setOnDatimePickedListener(new OnDatimePickedListener() { @Override public void onDatimePicked(int year, int month, int day, int hour, int minute, int second) { String text = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; text += wheelLayout.getTimeWheelLayout().isAnteMeridiem() ? " 上午" : " 下午"; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } }); wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY); wheelLayout.setTimeMode(TimeMode.HOUR_24_NO_SECOND); wheelLayout.setRange(DatimeEntity.now(), DatimeEntity.yearOnFuture(10)); wheelLayout.setDateLabel("年", "月", "日"); wheelLayout.setTimeLabel("时", "分", "秒"); picker.show(); } public void onYearMonthDay(View view) { DatePicker picker = new DatePicker(this); //picker.setBodyWidth(240); DateWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY); //wheelLayout.setDateLabel("年", "月", "日"); wheelLayout.setDateFormatter(new UnitDateFormatter()); //wheelLayout.setRange(DateEntity.target(2021, 1, 1), DateEntity.target(2050, 12, 31), DateEntity.today()); wheelLayout.setRange(DateEntity.today(), DateEntity.monthOnFuture(3)); wheelLayout.setCurtainEnabled(true); wheelLayout.setCurtainColor(0xFFCC0000); wheelLayout.setIndicatorEnabled(true); wheelLayout.setIndicatorColor(0xFFFF0000); wheelLayout.setIndicatorSize(view.getResources().getDisplayMetrics().density * 2); wheelLayout.setTextColor(0xCCCC0000); wheelLayout.setTextSize(14 * getResources().getDisplayMetrics().scaledDensity); //注:建议通过`setStyle`定制样式设置文字加大,若通过`setSelectedTextSize`设置,该解决方案会导致选择器展示时跳动一下 //wheelLayout.setSelectedTextSize(16 * getResources().getDisplayMetrics().scaledDensity); wheelLayout.setSelectedTextColor(0xFFFF0000); //wheelLayout.getYearLabelView().setTextColor(0xFF999999); //wheelLayout.getMonthLabelView().setTextColor(0xFF999999); picker.setOnDatePickedListener(this); picker.getWheelLayout().setResetWhenLinkage(false); picker.show(); } public void onYearMonth(View view) { DatePicker picker = new DatePicker(this); picker.setBodyWidth(240); DateWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setDateMode(DateMode.YEAR_MONTH); wheelLayout.setDateLabel("年", "月", ""); picker.setOnDatePickedListener(this); picker.show(); } public void onMonthDay(View view) { DatePicker picker = new DatePicker(this); picker.setBodyWidth(200); DateWheelLayout wheelLayout = picker.getWheelLayout(); //注:`setStyle`只能在其他设置项之前调用,否则会导致其他项设置失效 wheelLayout.setStyle(R.style.WheelStyleDemo); wheelLayout.setDateMode(DateMode.MONTH_DAY); wheelLayout.setDateFormatter(new UnitDateFormatter()); picker.setOnDatePickedListener(this); picker.show(); } public void onTime12(View view) { TimePicker picker = new TimePicker(this); picker.setBodyWidth(140); TimeWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setRange(TimeEntity.target(0, 0, 0), TimeEntity.target(24, 59, 59)); wheelLayout.setTimeMode(TimeMode.HOUR_12_NO_SECOND); wheelLayout.setTimeLabel(":", " ", ""); wheelLayout.setDefaultValue(TimeEntity.target(24, 0, 0)); wheelLayout.setTimeStep(1, 10, 1); picker.setOnTimeMeridiemPickedListener(new OnTimeMeridiemPickedListener() { @Override public void onTimePicked(int hour, int minute, int second, boolean isAnteMeridiem) { String text = hour + ":" + minute + ":" + second; text += isAnteMeridiem ? " 上午" : " 下午"; Toast.makeText(getApplication(), text, Toast.LENGTH_SHORT).show(); } }); picker.show(); } public void onTime24(View view) { TimePicker picker = new TimePicker(this); TimeWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setTimeMode(TimeMode.HOUR_24_HAS_SECOND); wheelLayout.setTimeFormatter(new UnitTimeFormatter()); wheelLayout.setDefaultValue(TimeEntity.now()); wheelLayout.setResetWhenLinkage(false); picker.setOnTimePickedListener(this); picker.show(); } public void onBirthday(View view) { BirthdayPicker picker = new BirthdayPicker(this); picker.setDefaultValue(1991, 11, 11); picker.setOnDatePickedListener(this); picker.getWheelLayout().setResetWhenLinkage(false); picker.show(); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/FileExplorerFragment.java ================================================ /* * 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.fallback.activity; import android.annotation.SuppressLint; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.filepicker.ExplorerConfig; import com.github.gzuliyujiang.filepicker.FileExplorer; import com.github.gzuliyujiang.filepicker.annotation.ExplorerMode; import java.io.File; import java.util.Objects; /** * @author :Reginer 2022/3/16 16:19. * 联系方式:QQ:282921012 * 功能描述:文件浏览器弹窗 */ public class FileExplorerFragment extends DialogFragment { @Override @SuppressLint("PrivateResource") public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(STYLE_NORMAL, R.style.Theme_Design_Light_BottomSheetDialog); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Objects.requireNonNull(getDialog()).getWindow().getDecorView().setPadding(0, 0, 0, 0); WindowManager.LayoutParams layoutParams = getDialog().getWindow().getAttributes(); layoutParams.gravity = Gravity.BOTTOM; layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; getDialog().getWindow().setAttributes(layoutParams); return inflater.inflate(R.layout.fragment_file_explorer, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); FileExplorer fileExplorer = view.findViewById(R.id.fileExplorer); ExplorerConfig config = new ExplorerConfig(requireContext()); config.setRootDir(new File("sdcard")); config.setLoadAsync(true); config.setExplorerMode(ExplorerMode.FILE); config.setShowHomeDir(false); config.setShowUpDir(false); config.setShowHideDir(false); //config.setAllowExtensions(new String[]{".txt", ".jpg"}); fileExplorer.load(config); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/FilePickerActivity.java ================================================ /* * 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.fallback.activity; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.provider.Settings; import android.view.View; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.filepicker.ExplorerConfig; import com.github.gzuliyujiang.filepicker.FileExplorer; import com.github.gzuliyujiang.filepicker.FilePicker; import com.github.gzuliyujiang.filepicker.annotation.ExplorerMode; import com.github.gzuliyujiang.filepicker.contract.OnFilePickedListener; import java.io.File; /** * 文件/目录选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 19:11 */ public class FilePickerActivity extends BackAbleActivity implements OnFilePickedListener { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_file); FileExplorer fileExplorer = findViewById(R.id.file_picker_explorer); ExplorerConfig config = new ExplorerConfig(this); config.setRootDir(Environment.getExternalStorageDirectory()); config.setLoadAsync(true); config.setExplorerMode(ExplorerMode.FILE); config.setShowHomeDir(true); config.setShowUpDir(true); config.setShowHideDir(true); config.setAllowExtensions(new String[]{".txt", ".jpg"}); fileExplorer.load(config); } @Override public void onFilePicked(@NonNull File file) { Toast.makeText(getApplicationContext(), file.getAbsolutePath(), Toast.LENGTH_SHORT).show(); } public void onPermission(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Environment.isExternalStorageManager()) { Toast.makeText(getApplicationContext(), "isExternalStorageManager==true", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName())); startActivity(intent); } return; } Toast.makeText(getApplicationContext(), "当前系统版本不支持文件管理权限", Toast.LENGTH_SHORT).show(); } public void onFilePick(View view) { ExplorerConfig config = new ExplorerConfig(this); config.setRootDir(getExternalFilesDir(null)); config.setLoadAsync(false); config.setExplorerMode(ExplorerMode.FILE); config.setOnFilePickedListener(this); FilePicker picker = new FilePicker(this); picker.setExplorerConfig(config); picker.show(); } public void onDirPick(View view) { ExplorerConfig config = new ExplorerConfig(this); config.setRootDir(getFilesDir()); config.setLoadAsync(false); config.setExplorerMode(ExplorerMode.DIRECTORY); config.setOnFilePickedListener(this); FilePicker picker = new FilePicker(this); picker.setExplorerConfig(config); picker.show(); } public void onDialogPick(View view) { new FileExplorerFragment().show(getSupportFragmentManager(), getClass().getName()); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/ImagePickerActivity.java ================================================ /* * 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.fallback.activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.imagepicker.ActivityBuilder; import com.github.gzuliyujiang.imagepicker.CropImageView; import com.github.gzuliyujiang.imagepicker.ImagePicker; import com.github.gzuliyujiang.imagepicker.PickCallback; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/7/30 12:44 */ public class ImagePickerActivity extends BackAbleActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_image); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); ImagePicker.getInstance().onActivityResult(this, requestCode, resultCode, data); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); ImagePicker.getInstance().onRequestPermissionsResult(this, requestCode, permissions, grantResults); } public void onCamera(View view) { ImagePicker.getInstance().startCamera(this, true, new PickCallback() { @Override public void onPermissionDenied(String[] permissions, String message) { Toast.makeText(ImagePickerActivity.this, message, Toast.LENGTH_SHORT).show(); } @Override public void cropConfig(ActivityBuilder builder) { builder.setMultiTouchEnabled(true) .setGuidelines(CropImageView.Guidelines.ON_TOUCH) .setCropShape(CropImageView.CropShape.OVAL) .setRequestedSize(400, 400) .setFixAspectRatio(true) .setAspectRatio(1, 1); } @Override public void onCropImage(@Nullable Uri imageUri) { Toast.makeText(ImagePickerActivity.this, String.valueOf(imageUri), Toast.LENGTH_SHORT).show(); } }); } public void onGallery(View view) { ImagePicker.getInstance().startGallery(this, false, new PickCallback() { @Override public void onPermissionDenied(String[] permissions, String message) { Toast.makeText(ImagePickerActivity.this, message, Toast.LENGTH_SHORT).show(); } @Override public void onPickImage(@Nullable Uri imageUri) { Toast.makeText(ImagePickerActivity.this, String.valueOf(imageUri), Toast.LENGTH_SHORT).show(); } }); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/LinkagePickerActivity.java ================================================ /* * 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.fallback.activity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import androidx.annotation.Nullable; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.fallback.custom.AntFortuneLikePicker; 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 OnCarPlatePickedListener, OnLinkagePickedListener { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_linkage); } @Override public void onCarNumberPicked(String province, String letter) { Toast.makeText(getApplication(), province + " " + letter, Toast.LENGTH_SHORT).show(); } @Override public void onLinkagePicked(Object first, Object second, Object third) { Toast.makeText(getApplication(), first + " " + second + " " + third, Toast.LENGTH_SHORT).show(); } public void onCarNumber(View view) { CarPlatePicker picker = new CarPlatePicker(this); picker.setBodyWidth(100); picker.setDefaultValue("贵", "F", ""); picker.setOnCarPlatePickedListener(this); picker.show(); } public void onLikeAntFortune(View view) { AntFortuneLikePicker picker = new AntFortuneLikePicker(this); picker.setOnLinkagePickedListener(this); picker.show(); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/MainActivity.java ================================================ /* * 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.fallback.activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.dialog.DialogStyle; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.fallback.custom.AntFortuneLikeProvider; import com.github.gzuliyujiang.wheelpicker.OptionPicker; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionPickedListener; import com.github.gzuliyujiang.wheelpicker.widget.LinkageWheelLayout; import com.github.gzuliyujiang.wheelpicker.widget.OptionWheelLayout; import com.github.gzuliyujiang.wheelview.widget.WheelView; import java.util.Arrays; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/3 18:18 */ public class MainActivity extends FragmentActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_main); WheelView wheelView = findViewById(R.id.wheel_view); wheelView.setData(Arrays.asList("第1项", "第2项", "第3项", "第4项", "第5项", "第6项", "第7项", "第8项", "第9项", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "第N项")); OptionWheelLayout optionWheelLayout = findViewById(R.id.wheel_option); optionWheelLayout.setData(Arrays.asList("aaa", "bbb", "ccc", "123", "xxx", "yyy", "zzz")); LinkageWheelLayout linkageWheelLayout = findViewById(R.id.wheel_linkage); linkageWheelLayout.setData(new AntFortuneLikeProvider()); } private void startActivity(Class cls) { startActivity(new Intent(this, cls)); } public void onDialogStyle(View view) { OptionPicker picker = new OptionPicker(this); picker.setData("默认-屏幕底部弹窗", "样式1-屏幕底部弹窗", "样式2-屏幕底部弹窗", "样式3-屏幕中间弹窗"); picker.setOnOptionPickedListener(new OnOptionPickedListener() { @Override public void onOptionPicked(int position, Object item) { switch (position) { case 1: DialogConfig.setDialogStyle(DialogStyle.One); break; case 2: DialogConfig.setDialogStyle(DialogStyle.Two); break; case 3: DialogConfig.setDialogStyle(DialogStyle.Three); break; case 0: default: DialogConfig.setDialogStyle(DialogStyle.Default); break; } } }); picker.show(); } public void onDialogFragment(View view) { new OptionPickerFragment().show(getSupportFragmentManager(), OptionPickerFragment.class.getName()); } public void onDateTimePicker(View view) { startActivity(DateTimePickerActivity.class); } public void onSinglePicker(View view) { startActivity(SinglePickerActivity.class); } public void onLinkagePicker(View view) { startActivity(LinkagePickerActivity.class); } public void onAddressPicker(View view) { startActivity(AddressPickerActivity.class); } public void onColorPicker(View view) { startActivity(ColorPickerActivity.class); } public void onFilePicker(View view) { startActivity(FilePickerActivity.class); } public void onCalendarPicker(View view) { startActivity(CalendarPickerActivity.class); } public void onImagePicker(View view) { startActivity(ImagePickerActivity.class); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/OptionPickerFragment.java ================================================ /* * 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.fallback.activity; import android.app.Dialog; import android.os.Bundle; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.wheelpicker.OptionPicker; import com.github.gzuliyujiang.wheelpicker.contract.OnOptionPickedListener; /** * {@link androidx.fragment.app.Fragment}形式的弹窗 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2022/11/04 */ public class OptionPickerFragment extends DialogFragment { @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { OptionPicker picker = new OptionPicker(requireActivity()); picker.setData("土人", "里民子", "羡民", "穿青人", "不在56个民族之内", "未定民族"); picker.setOnOptionPickedListener(new OnOptionPickedListener() { @Override public void onOptionPicked(int position, Object item) { Toast.makeText(requireContext(), item.toString(), Toast.LENGTH_SHORT).show(); } }); picker.getWheelView().setStyle(R.style.WheelStyleDemo); return picker; } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/activity/SinglePickerActivity.java ================================================ /* * 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.fallback.activity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.fallback.bean.GoodsCategoryBean; import com.github.gzuliyujiang.wheelpicker.ConstellationPicker; import com.github.gzuliyujiang.wheelpicker.EthnicPicker; import com.github.gzuliyujiang.wheelpicker.NumberPicker; import com.github.gzuliyujiang.wheelpicker.OptionPicker; import com.github.gzuliyujiang.wheelpicker.PhoneCodePicker; import com.github.gzuliyujiang.wheelpicker.SexPicker; import com.github.gzuliyujiang.wheelpicker.annotation.EthnicSpec; import com.github.gzuliyujiang.wheelpicker.contract.OnNumberPickedListener; 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; /** * 单项滚轮选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/23 */ public class SinglePickerActivity extends BackAbleActivity implements OnNumberPickedListener, OnOptionPickedListener { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picker_single); } @Override public void onNumberPicked(int position, Number item) { Toast.makeText(this, position + "-" + item, Toast.LENGTH_SHORT).show(); } @Override public void onOptionPicked(int position, Object item) { Toast.makeText(this, position + "-" + item, Toast.LENGTH_SHORT).show(); } public void onInteger(View view) { NumberPicker picker = new NumberPicker(this); picker.setOnNumberPickedListener(this); picker.getWheelLayout().setOnNumberSelectedListener(new OnNumberSelectedListener() { @Override public void onNumberSelected(int position, Number item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object item) { return item.toString() + " cm"; } }); picker.setRange(140, 200, 1); picker.setDefaultValue(172); picker.setTitle("身高选择"); picker.show(); } public void onFloat(View view) { NumberPicker picker = new NumberPicker(this); picker.setBodyWidth(120); picker.setOnNumberPickedListener(this); picker.getWheelLayout().setOnNumberSelectedListener(new OnNumberSelectedListener() { @Override public void onNumberSelected(int position, Number item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.setFormatter(new WheelFormatter() { @Override public String formatItem(@NonNull Object item) { DecimalFormat df = new DecimalFormat("0.00"); return df.format(item); } }); picker.setRange(-10f, 10f, 0.1f); picker.setDefaultValue(5f); picker.getTitleView().setText("温度选择"); picker.getLabelView().setText("℃"); picker.show(); } public void onOptionText(View view) { OptionPicker picker = new OptionPicker(this); picker.setData("测试", "很长很长很长很长很长很长很长很长很长很长很长很长很长很长"); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.getWheelView().setStyle(R.style.WheelStyleDemo); picker.show(); } public void onOptionBean(View view) { List data = new ArrayList<>(); data.add(new GoodsCategoryBean(1, "食品生鲜")); data.add(new GoodsCategoryBean(2, "家用电器")); data.add(new GoodsCategoryBean(3, "家居生活")); data.add(new GoodsCategoryBean(4, "医疗保健")); data.add(new GoodsCategoryBean(5, "酒水饮料")); data.add(new GoodsCategoryBean(6, "图书音像")); OptionPicker picker = new OptionPicker(this); picker.setTitle("货物分类"); picker.setBodyWidth(140); picker.setData(data); picker.setDefaultPosition(2); picker.setOnOptionPickedListener(this); OptionWheelLayout wheelLayout = picker.getWheelLayout(); wheelLayout.setIndicatorEnabled(false); wheelLayout.setTextColor(0xFFFF00FF); wheelLayout.setSelectedTextColor(0xFFFF0000); wheelLayout.setTextSize(15 * view.getResources().getDisplayMetrics().scaledDensity); //注:建议通过`setStyle`定制样式设置文字加大,若通过`setSelectedTextSize`设置,该解决方案会导致选择器展示时跳动一下 //wheelLayout.setStyle(R.style.WheelStyleDemo); wheelLayout.setSelectedTextSize(17 * view.getResources().getDisplayMetrics().scaledDensity); wheelLayout.setSelectedTextBold(true); 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.show(); } public void onSex(View view) { SexPicker picker = new SexPicker(this); picker.setBodyWidth(140); picker.setIncludeSecrecy(false); picker.setDefaultValue("女"); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.show(); } public void onEthnic(View view) { EthnicPicker picker = new EthnicPicker(this); picker.setBodyWidth(140); picker.setEthnicSpec(EthnicSpec.SEVENTH_NATIONAL_CENSUS); picker.setDefaultValueByCode("97"); //picker.setDefaultValueByName("未定族称人口"); //picker.setDefaultValueBySpelling("Unrecognized"); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.show(); } public void onConstellation(View view) { ConstellationPicker picker = new ConstellationPicker(this); picker.setBodyWidth(140); 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 public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.show(); } public void onPhoneCode(View view) { PhoneCodePicker picker = new PhoneCodePicker(this); picker.setBodyWidth(140); picker.setOnlyChina(false); picker.setDefaultValueByCode("+86"); picker.setOnOptionPickedListener(this); picker.getWheelLayout().setOnOptionSelectedListener(new OnOptionSelectedListener() { @Override public void onOptionSelected(int position, Object item) { picker.getTitleView().setText(picker.getWheelView().formatItem(position)); } }); picker.show(); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/bean/GoodsCategoryBean.java ================================================ /* * 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.fallback.bean; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelview.contract.TextProvider; import java.io.Serializable; /** * 示例数据实体 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2019/6/23 */ public class GoodsCategoryBean implements Serializable, TextProvider { private int id; private String name; public GoodsCategoryBean(int id, String name) { this.id = id; this.name = name; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String provideText() { return name; } @NonNull @Override public String toString() { return "GoodsCategoryBean{" + "id=" + id + ", name='" + name + '\'' + '}'; } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/custom/AntFortuneLikePicker.java ================================================ /* * 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.fallback.custom; import android.app.Activity; import android.content.DialogInterface; import android.os.Bundle; import android.view.Gravity; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.github.gzuliyujiang.dialog.DialogConfig; import com.github.gzuliyujiang.dialog.DialogStyle; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.wheelpicker.LinkagePicker; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 12:20 */ public class AntFortuneLikePicker extends LinkagePicker { private int lastDialogStyle; public AntFortuneLikePicker(@NonNull Activity activity) { super(activity, R.style.DialogTheme_Sheet); } @Override public void onInit(@Nullable Bundle savedInstanceState) { super.onInit(savedInstanceState); lastDialogStyle = DialogConfig.getDialogStyle(); DialogConfig.setDialogStyle(DialogStyle.Default); setWidth(activity.getResources().getDisplayMetrics().widthPixels); setGravity(Gravity.BOTTOM); } @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); DialogConfig.setDialogStyle(lastDialogStyle); } @Override protected void initData() { super.initData(); setBackgroundColor(0xFFFFFFFF); cancelView.setText("取消"); cancelView.setTextSize(16); cancelView.setTextColor(0xFF0081FF); okView.setTextColor(0xFF0081FF); okView.setText("确定"); okView.setTextSize(16); titleView.setTextColor(0xFF333333); titleView.setText("定投周期"); titleView.setTextSize(16); wheelLayout.setData(new AntFortuneLikeProvider()); wheelLayout.setAtmosphericEnabled(true); wheelLayout.setVisibleItemCount(7); wheelLayout.setCyclicEnabled(false); wheelLayout.setIndicatorEnabled(true); wheelLayout.setIndicatorColor(0xFFDDDDDD); wheelLayout.setIndicatorSize((int) (contentView.getResources().getDisplayMetrics().density * 1)); wheelLayout.setTextColor(0xFF999999); wheelLayout.setSelectedTextColor(0xFF333333); wheelLayout.setCurtainEnabled(false); wheelLayout.setCurvedEnabled(false); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/custom/AntFortuneLikeProvider.java ================================================ /* * 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.fallback.custom; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 12:22 */ public class AntFortuneLikeProvider implements LinkageProvider { @Override public boolean firstLevelVisible() { return true; } @Override public boolean thirdLevelVisible() { return false; } @NonNull @Override public List provideFirstData() { return Arrays.asList("每周", "每两周", "每月", "每日"); } @NonNull @Override public List linkageSecondData(int firstIndex) { switch (firstIndex) { case 0: case 1: return Arrays.asList("周一", "周二", "周三", "周四", "周五"); case 2: List data = new ArrayList<>(); for (int i = 1; i <= 28; i++) { data.add(i + "日"); } return data; } return new ArrayList<>(); } @NonNull @Override public List linkageThirdData(int firstIndex, int secondIndex) { return new ArrayList<>(); } @Override public int findFirstIndex(Object firstValue) { return 0; } @Override public int findSecondIndex(int firstIndex, Object secondValue) { return 0; } @Override public int findThirdIndex(int firstIndex, int secondIndex, Object thirdValue) { return 0; } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/custom/CustomAddressPicker.java ================================================ /* * 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.fallback.custom; import android.app.Activity; import android.view.View; import androidx.annotation.NonNull; import com.github.gzuliyujiang.dialog.BottomDialog; import com.github.gzuliyujiang.fallback.R; import com.github.gzuliyujiang.wheelpicker.annotation.AddressMode; import com.github.gzuliyujiang.wheelpicker.contract.AddressLoader; import com.github.gzuliyujiang.wheelpicker.contract.AddressReceiver; import com.github.gzuliyujiang.wheelpicker.contract.OnAddressPickedListener; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; 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.wheelpicker.widget.LinkageWheelLayout; import java.util.List; /** * 自定义地址选择器 * * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 16:03 */ public class CustomAddressPicker extends BottomDialog implements AddressReceiver, View.OnClickListener { protected LinkageWheelLayout wheelLayout; private OnAddressPickedListener onAddressPickedListener; public CustomAddressPicker(@NonNull Activity activity) { super(activity); } public CustomAddressPicker(@NonNull Activity activity, int themeResId) { super(activity, themeResId); } @NonNull @Override protected View createContentView() { return View.inflate(activity, R.layout.wheel_picker_custom_ui_address, null); } @Override protected void initView() { super.initView(); 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); } @Override protected void initData() { super.initData(); wheelLayout.showLoading(); AddressLoader addressLoader = new AssetAddressLoader(getContext(), "pca-code.json"); addressLoader.loadJson(this, new AddressJsonParser.Builder() .provinceCodeField("code") .provinceNameField("name") .provinceChildField("children") .cityCodeField("code") .cityNameField("name") .cityChildField("children") .countyCodeField("code") .countyNameField("name") .build()); } @Override public void onAddressReceived(@NonNull List data) { wheelLayout.hideLoading(); 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 = wheelLayout.getFirstWheelView().getCurrentItem(); CityEntity city = wheelLayout.getSecondWheelView().getCurrentItem(); CountyEntity county = wheelLayout.getThirdWheelView().getCurrentItem(); onAddressPickedListener.onAddressPicked(province, city, county); } dismiss(); } } public void setDefaultValue(String province, String city, String county) { wheelLayout.setDefaultValue(province, city, county); } public void setOnAddressPickedListener(OnAddressPickedListener onAddressPickedListener) { this.onAddressPickedListener = onAddressPickedListener; } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/custom/TextAddressLoader.java ================================================ /* * 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.fallback.custom; import android.content.Context; import android.content.res.AssetManager; import android.os.Handler; import android.os.Looper; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.contract.AddressLoader; import com.github.gzuliyujiang.wheelpicker.contract.AddressParser; import com.github.gzuliyujiang.wheelpicker.contract.AddressReceiver; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.List; import java.util.concurrent.Executors; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 16:33 */ public class TextAddressLoader implements AddressLoader { private final Context context; public TextAddressLoader(Context context) { this.context = context; } @Override public void loadJson(@NonNull final AddressReceiver receiver, @NonNull final AddressParser parser) { Executors.newSingleThreadExecutor().execute(new Runnable() { @Override public void run() { StringBuilder sb = new StringBuilder(); AssetManager am = context.getAssets(); try (BufferedReader bf = new BufferedReader(new InputStreamReader(am.open("city.txt")))) { String line; while ((line = bf.readLine()) != null) { sb.append(line); } } catch (IOException ignore) { } String json = sb.toString(); try { final List data = parser.parseData(json); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { receiver.onAddressReceived(data); } }); } catch (Exception ignore) { } } }); } } ================================================ FILE: app/src/main/java/com/github/gzuliyujiang/fallback/custom/TextAddressParser.java ================================================ /* * 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.fallback.custom; import androidx.annotation.NonNull; import com.github.gzuliyujiang.wheelpicker.contract.AddressParser; import com.github.gzuliyujiang.wheelpicker.entity.CityEntity; import com.github.gzuliyujiang.wheelpicker.entity.CountyEntity; import com.github.gzuliyujiang.wheelpicker.entity.ProvinceEntity; import java.util.ArrayList; import java.util.List; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/7 16:30 */ public class TextAddressParser implements AddressParser { private final List provinces = new ArrayList<>(); @NonNull @Override public List parseData(@NonNull String text) { provinces.clear(); String[] fullCodeAndNames = text.split(";"); for (String fullCodeAndName : fullCodeAndNames) { String[] codeAndName = fullCodeAndName.split(","); if (codeAndName.length != 2) { continue; } String code = codeAndName[0]; String name = codeAndName[1]; if (code.startsWith("0000", 2)) { //省份 ProvinceEntity province = new ProvinceEntity(); province.setCode(code); province.setName(name); province.setCityList(new ArrayList<>()); provinces.add(province); } else if (code.startsWith("00", 4)) { //地市 ProvinceEntity province = findProvinceByCode(code.substring(0, 2)); if (province != null) { CityEntity city = new CityEntity(); city.setCode(code); city.setName(name); city.setCountyList(new ArrayList<>()); province.getCityList().add(city); } } else { //区县 CityEntity city = findCityByCode(code.substring(0, 2), code.substring(2, 4)); if (city != null) { CountyEntity county = new CountyEntity(); county.setCode(code); county.setName(name); city.getCountyList().add(county); } } } return provinces; } private ProvinceEntity findProvinceByCode(String provinceCode) { for (ProvinceEntity province : provinces) { if (province.getCode().substring(0, 2).equals(provinceCode)) { return province; } } return null; } private CityEntity findCityByCode(String provinceCode, String cityCode) { for (ProvinceEntity province : provinces) { List cities = province.getCityList(); for (CityEntity city : cities) { if (province.getCode().substring(0, 2).equals(provinceCode) && city.getCode().substring(2, 4).equals(cityCode)) { return city; } } } return null; } } ================================================ FILE: app/src/main/res/layout/activity_picker_address.xml ================================================