Skip to content

Commit

Permalink
升级版本,规范格式
Browse files Browse the repository at this point in the history
  • Loading branch information
fanhua1994 committed Feb 2, 2018
1 parent f199f3b commit 35a2392
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 23 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

> 城市三级联动选择控件,直接使用。
![](https://github.com/fanhua1994/WheelPicker/blob/master/image/F67C4C652760636CD9CB18C907299964.png?raw=true)

<div>
<img width="200px" src="https://github.com/fanhua1994/WheelPicker/blob/master/image/F67C4C652760636CD9CB18C907299964.png?raw=true" />
</div>

### 如何引用
```
Expand All @@ -15,19 +18,17 @@ allprojects {
```
```
dependencies {
compile 'com.github.fanhua1994:WheelPicker:1.0.1'
compile 'com.github.fanhua1994:WheelPicker:1.0.2'
}
```

### 如何调用
```
WheelPickerPopupWindow wheelPickerPopupWindow = new WheelPickerPopupWindow(MainActivity.this);
wheelPickerPopupWindow.setListener(new WheelPickerPopupWindow.WheelPickerComfirmListener() {
final CityWheelPickerPopupWindow wheelPickerPopupWindow = new CityWheelPickerPopupWindow(MainActivity.this);
wheelPickerPopupWindow.setListener(new OnCityWheelComfirmListener() {
@Override
public void onSelected(String Province, String City, String District, String PostCode) {
Toast.makeText(MainActivity.this,Province + City + District,Toast.LENGTH_LONG).show();
Toast.makeText(MainActivity.this,Province + City + District,Toast.LENGTH_LONG).show();
}
});
wheelPickerPopupWindow.show();
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import android.widget.Toast;

import com.hengyi.wheelpicker.R;
import com.hengyi.wheelpicker.ppw.WheelPickerPopupWindow;
import com.hengyi.wheelpicker.listener.OnCityWheelComfirmListener;
import com.hengyi.wheelpicker.ppw.CityWheelPickerPopupWindow;

public class MainActivity extends AppCompatActivity {
private Button button;
Expand All @@ -16,9 +17,9 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.button);
final WheelPickerPopupWindow wheelPickerPopupWindow = new WheelPickerPopupWindow(MainActivity.this);
wheelPickerPopupWindow.setListener(new WheelPickerPopupWindow.WheelPickerComfirmListener() {

final CityWheelPickerPopupWindow wheelPickerPopupWindow = new CityWheelPickerPopupWindow(MainActivity.this);
wheelPickerPopupWindow.setListener(new OnCityWheelComfirmListener() {
@Override
public void onSelected(String Province, String City, String District, String PostCode) {
Toast.makeText(MainActivity.this,Province + City + District,Toast.LENGTH_LONG).show();
Expand Down
2 changes: 1 addition & 1 deletion wheelpicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0.1"
versionName "1.0.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
6 changes: 6 additions & 0 deletions wheelpicker/src/main/assets/province_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,12 @@
<district name="秀英区" zipcode="570000" />
<district name="其他" zipcode="570000" />
</city>
<city name="三沙市">
<district name="西沙县" zipcode="000000" />
<district name="中沙县" zipcode="000000" />
<district name="南沙县" zipcode="000000" />
<district name="其他" zipcode="000000" />
</city>
</province>
<province name="河北省">
<city name="保定市">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.hengyi.wheelpicker.listener;

/**
* Created by Administrator on 2018/2/2.
*/

public interface OnCityWheelComfirmListener {
public void onSelected(String Province, String City, String District, String PostCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

package com.hengyi.wheelpicker.weight;
package com.hengyi.wheelpicker.listener;

import com.hengyi.wheelpicker.weight.WheelView;

/**
* Wheel changed listener interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

package com.hengyi.wheelpicker.weight;
package com.hengyi.wheelpicker.listener;

import com.hengyi.wheelpicker.weight.WheelView;

/**
* Wheel clicked listener interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

package com.hengyi.wheelpicker.weight;
package com.hengyi.wheelpicker.listener;

import com.hengyi.wheelpicker.weight.WheelView;

/**
* Wheel scrolled listener interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
import android.widget.TextView;

import com.hengyi.wheelpicker.R;
import com.hengyi.wheelpicker.weight.OnWheelChangedListener;
import com.hengyi.wheelpicker.listener.OnCityWheelComfirmListener;
import com.hengyi.wheelpicker.listener.OnWheelChangedListener;
import com.hengyi.wheelpicker.weight.WheelView;
import com.hengyi.wheelpicker.weight.adapters.ArrayWheelAdapter;

/**
* Created by Administrator on 2018/1/3.
*/

public class WheelPickerPopupWindow extends BasePopupWindow implements View.OnClickListener,OnWheelChangedListener {
public class CityWheelPickerPopupWindow extends BasePopupWindow implements View.OnClickListener,OnWheelChangedListener {
private View mView;
private Activity activity;
private TextView btn_cancel,btn_confirm;
private WheelView mViewProvince, mViewCity,mViewDistrict;
private WheelPickerComfirmListener listener = null;
private OnCityWheelComfirmListener listener = null;

public WheelPickerPopupWindow(Activity activity){
public CityWheelPickerPopupWindow(Activity activity){
this.activity = activity;
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = inflater.inflate(R.layout.ppw_wheel_picker_view, null,false);
Expand Down Expand Up @@ -88,7 +89,7 @@ public void backgroundAlpha(float bgAlpha) {
activity.getWindow().setAttributes(lp);
}

public void setListener(WheelPickerComfirmListener wheelPickerComfirmListener){
public void setListener(OnCityWheelComfirmListener wheelPickerComfirmListener){
this.listener = wheelPickerComfirmListener;
}

Expand Down Expand Up @@ -146,8 +147,4 @@ private void updateCities() {
mViewCity.setCurrentItem(0);
updateAreas();
}

public interface WheelPickerComfirmListener{
public void onSelected(String Province, String City, String District, String PostCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import android.widget.LinearLayout;

import com.hengyi.wheelpicker.R;
import com.hengyi.wheelpicker.listener.OnWheelChangedListener;
import com.hengyi.wheelpicker.listener.OnWheelClickedListener;
import com.hengyi.wheelpicker.listener.OnWheelScrollListener;
import com.hengyi.wheelpicker.weight.adapters.WheelViewAdapter;

import java.util.LinkedList;
Expand Down

0 comments on commit 35a2392

Please sign in to comment.