Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dunwen/JDSelector

仿京东的地址选择做的一个自定义深度的多级选择器
https://github.com/dunwen/JDSelector

Last synced: 3 months ago
JSON representation

仿京东的地址选择做的一个自定义深度的多级选择器

Awesome Lists containing this project

README

        

#Selector

## 简单说明
项目是根据[JDAddressSelector](https://github.com/chihane/JDAddressSelector)修改而来的。

- 支持多级自定义选择
- 去掉原项目依赖的dbflow、gson
- 去掉原项目仅支持地址一类选择,把选择类型放开(原项目写死了只能选择地址)。

## 效果
![](https://github.com/dunwen/JDSelector/blob/master/capture.gif)

## 使用

### 使用原始视图
```
//deep 就是自定义的深度
Selector selector = new Selector(this, deep);

selector.setDataProvider(new DataProvider() {
@Override
public void provideData(int currentDeep, int preId, DataReceiver receiver) {
//根据tab的深度和前一项选择的id,获取下一级菜单项
Log.i(TAG, "provideData: currentDeep >>> "+currentDeep+" preId >>> "+preId);
receiver.send(getDatas());
}
});
selector.setSelectedListener(new SelectedListener() {
@Override
public void onAddressSelected(ArrayList selectAbles) {
String result = "";
for (ISelectAble selectAble : selectAbles) {
result += selectAble.getName()+" ";
}
Toast.makeText(MainActivity.this,result,Toast.LENGTH_SHORT).show();
}
});


// View view = selector.getView();
// frameLayout.addView(view)
// new AlertDialog.Builder(context).setView(view).show()
// ...

```

### BottomDialog

```
BottomDialog dialog = new BottomDialog(this);
dialog.init(this,selector); //selector 按照上面的方法初始化
dialog.show();
```

## 许可证
edit from [JDAddressSelector](https://github.com/chihane/JDAddressSelector)
[MIT License](http://chihane.in/license)