All Projects → zaaach → Citypicker

zaaach / Citypicker

🔥🔥🔥城市选择、定位、搜索及右侧字母导航,类似美团 百度糯米 饿了么等APP选择城市功能

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Citypicker

City Geo
🌄 中国城市经纬度数据。
Stars: ✭ 196 (-93.41%)
Mutual labels:  location, city
google streetview
A command line tool and module for Google Street View Image API
Stars: ✭ 77 (-97.41%)
Mutual labels:  location, city
GeoLite2-City
GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 170 (-94.28%)
Mutual labels:  location, city
arboles
Mapa de Arbolado Urbano
Stars: ✭ 13 (-99.56%)
Mutual labels:  location, city
pikaz-location
定位插件(限中国)
Stars: ✭ 78 (-97.38%)
Mutual labels:  location, city
jqIpLocation
jqIpLocation – jQuery Plugin that returns the location of an IP address in JSON format
Stars: ✭ 18 (-99.39%)
Mutual labels:  location, city
WheelPickerByRecyclerView
用RecyclerView实现的滚轮选择器
Stars: ✭ 14 (-99.53%)
Mutual labels:  recyclerview
iOS-MapKit-Tutorial
iOS MapKit Getting Started
Stars: ✭ 24 (-99.19%)
Mutual labels:  location
CarouselGifViewer
Efficiently display a list of GIFs in a carousel (RecyclerView).
Stars: ✭ 33 (-98.89%)
Mutual labels:  recyclerview
FancyAdapters
A collection of customizable RecyclerView Adapters for Android, that provide various functionality like item selection, contextual action mode controls, drag&drop and swiping, among other.
Stars: ✭ 49 (-98.35%)
Mutual labels:  recyclerview
Fccurrentlocationgeocoder
iOS Geocoder for forward geocode and reverse geocode user's current location using a block-based syntax. 📍🌍
Stars: ✭ 268 (-90.99%)
Mutual labels:  location
Tableview
TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
Stars: ✭ 2,928 (-1.51%)
Mutual labels:  recyclerview
Polet
A solution to compose RecyclerView Decoration
Stars: ✭ 23 (-99.23%)
Mutual labels:  recyclerview
AccordionRecycler
Android RecyclerView Adapter with nested items & expand/contract functionality
Stars: ✭ 17 (-99.43%)
Mutual labels:  recyclerview
Jetpack-compose-sample
Forget about bunch of XML files for maintaining UIs. Jetpack Compose is Android’s modern toolkit for building native UI. Here is a small example to get started.
Stars: ✭ 29 (-99.02%)
Mutual labels:  recyclerview
react-recycled-scrolling
Simulate normal scrolling by using only fixed number of DOM elements for large lists of items with React Hooks
Stars: ✭ 26 (-99.13%)
Mutual labels:  recyclerview
Transformerslayout
🔥 App金刚区导航菜单,类似淘宝、QQ音乐等APP导航,方格布局横向多行滑动翻页带滚动条
Stars: ✭ 258 (-91.32%)
Mutual labels:  recyclerview
city-tour
A procedurally generated city built with WebGL and three.js
Stars: ✭ 57 (-98.08%)
Mutual labels:  city
FlexItemDecoration
FlexItemDecoration, can customize the head, bottom, leftmost, rightmost dividing line, but also customize any one of the dividing lines and batch custom multiple dividing lines
Stars: ✭ 52 (-98.25%)
Mutual labels:  recyclerview
SpannedGridLayoutManager
Android RecyclerView.LayoutManager that resizes and reorders views based on SpanSize
Stars: ✭ 522 (-82.44%)
Mutual labels:  recyclerview

CityPicker

Platform API

现在使用较多的类似美团、外卖等APP的城市选择界面,一行代码搞定,就是这么简单粗暴!!!

Tips:(旧版本1.x)会报高德定位jar包冲突,推荐使用2.x版本。

主要功能:

  • 字母悬浮栏
  • 指定热门城市
  • 自定义动画效果
  • 自定义主题
  • 名称或拼音搜索
  • 返回城市名、code等数据
  • 提供定位接口,解耦定位SDK

Preview

image image image

APK

下载demo.apk体验.

Download

1: 项目根目录的build.gradle添加如下配置:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

2: app添加依赖:

dependencies {
	 implementation 'com.github.zaaach:CityPicker:x.y.z'
}

记得把x.y.z替换为jitpack中的数字

Usage

CityPicker 基于DialogFragment 实现,已提供定位接口,需要APP自身实现定位。

基本使用:

Step1:

manifest.xml中给使用CityPickeractivity添加主题android:theme="@style/DefaultCityPickerTheme"

<activity android:name=".MainActivity" android:theme="@style/DefaultCityPickerTheme">
  ......
</activity>

Step2:

注意:热门城市使用HotCity ,定位城市使用LocatedCity

List<HotCity> hotCities = new ArrayList<>();
hotCities.add(new HotCity("北京", "北京", "101010100")); //code为城市代码
hotCities.add(new HotCity("上海", "上海", "101020100"));
hotCities.add(new HotCity("广州", "广东", "101280101"));
hotCities.add(new HotCity("深圳", "广东", "101280601"));
hotCities.add(new HotCity("杭州", "浙江", "101210101"));
......

CityPicker.from(activity) //activity或者fragment
  .enableAnimation(true)	//启用动画效果,默认无
  .setAnimationStyle(anim)	//自定义动画
  .setLocatedCity(new LocatedCity("杭州", "浙江", "101210101")))  //APP自身已定位的城市,传null会自动定位(默认)
  .setHotCities(hotCities)	//指定热门城市
  .setOnPickListener(new OnPickListener() {
    @Override
    public void onPick(int position, City data) {
      Toast.makeText(getApplicationContext(), data.getName(), Toast.LENGTH_SHORT).show();
    }
      
    @Override
    public void onCancel(){
      Toast.makeText(getApplicationContext(), "取消选择", Toast.LENGTH_SHORT).show();     
    }
      
    @Override
    public void onLocate() {
      //定位接口,需要APP自身实现,这里模拟一下定位
      new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
          //定位完成之后更新数据
          CityPicker.getInstance()
            .locateComplete(new LocatedCity("深圳", "广东", "101280601"), LocateState.SUCCESS);
        }
      }, 3000);
    }
  })
  .show();

关于自定义主题:

style.xml 中自定义主题并且继承DefaultCityPickerTheme ,别忘了在manifest.xml 设置给activity

<style name="CustomTheme" parent="DefaultCityPickerTheme">
        <item name="cpCancelTextColor">@color/color_green</item>
        <item name="cpSearchCursorDrawable">@color/color_green</item>
        <item name="cpIndexBarNormalTextColor">@color/color_green</item>
        <item name="cpIndexBarSelectedTextColor">@color/color_green</item>
        <item name="cpSectionHeight">@dimen/custom_section_height</item>
        <item name="cpOverlayBackground">@color/color_green</item>
  		......
</style>

CityPicker 中自定义的所有属性如下,有些属性值必须是引用类型refrence,使用时注意。

<resources>
    <attr name="cpCancelTextSize" format="dimension|reference" />
    <attr name="cpCancelTextColor" format="color|reference" />

    <attr name="cpClearTextIcon" format="reference" />
    <attr name="cpSearchTextSize" format="dimension|reference" />
    <attr name="cpSearchTextColor" format="color|reference" />
    <attr name="cpSearchHintText" format="string|reference" />
    <attr name="cpSearchHintTextColor" format="color|reference" />
    <attr name="cpSearchCursorDrawable" format="reference" />

    <attr name="cpListItemTextSize" format="dimension|reference" />
    <attr name="cpListItemTextColor" format="color|reference" />
    <attr name="cpListItemHeight" format="dimension|reference"/>

    <attr name="cpEmptyIcon" format="reference"/>
    <attr name="cpEmptyIconWidth" format="dimension|reference"/>
    <attr name="cpEmptyIconHeight" format="dimension|reference"/>
    <attr name="cpEmptyText" format="string|reference"/>
    <attr name="cpEmptyTextSize" format="dimension|reference"/>
    <attr name="cpEmptyTextColor" format="color|reference"/>

    <attr name="cpGridItemBackground" format="color|reference"/>
    <attr name="cpGridItemSpace" format="reference"/>
	<!--悬浮栏-->
    <attr name="cpSectionHeight" format="reference"/>
    <attr name="cpSectionTextSize" format="reference" />
    <attr name="cpSectionTextColor" format="reference" />
    <attr name="cpSectionBackground" format="reference" />

    <attr name="cpIndexBarTextSize" format="reference" />
    <attr name="cpIndexBarNormalTextColor" format="reference" />
    <attr name="cpIndexBarSelectedTextColor" format="reference" />
	<!--特写布局-->
    <attr name="cpOverlayWidth" format="dimension|reference"/>
    <attr name="cpOverlayHeight" format="dimension|reference"/>
    <attr name="cpOverlayTextSize" format="dimension|reference"/>
    <attr name="cpOverlayTextColor" format="color|reference"/>
    <attr name="cpOverlayBackground" format="color|reference"/>
</resources>

OK,enjoy it~

Changelog

v2.1.0

  • 迁移至AndroidX

v2.0.3

  • 修复状态栏变黑问题
  • 修复字母索引栏被软遮挡的问题
  • 新增取消选择监听
  • 方法调用方式稍微改变

v2.0.2

  • 修复定位城市偶尔不刷新的bug

v2.0.1

  • 新增定位接口
  • 修改返回类型为City ,可获取城市名、code等数据

v2.0.0

  • 项目重构优化,结构更清晰
  • 使用RecyclerView

感谢

ImmersionBar

About me

掘金: https://juejin.im/user/56f3dfe8efa6310055ac719f

简书: https://www.jianshu.com/u/913a8bb93d12

淘宝店: LEON家居生活馆 (动漫摆件)

LEON

😉淘宝店求个关注😉

QQ群

有兴趣可以加入QQ群一起交流: 扫码入群601783167

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].