Skip to content

Commit

Permalink
功能完善版本
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuichao committed Sep 30, 2017
1 parent cb33131 commit 53922be
Show file tree
Hide file tree
Showing 25 changed files with 408 additions and 16 deletions.
1 change: 1 addition & 0 deletions addresspickerlibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.CHAOHUILI'
android {
compileSdkVersion 26
Expand Down
1 change: 1 addition & 0 deletions addresspickerlibrary/src/main/assets/address.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
import android.view.ViewGroup.LayoutParams;
import android.view.Window;

import com.vidmt.family.address.address.City;
import com.vidmt.family.address.address.County;
import com.vidmt.family.address.address.Province;
import com.vidmt.family.address.wheel.OnWheelChangedListener;
import com.vidmt.family.address.wheel.OnWheelClickedListener;
import com.vidmt.family.address.wheel.WheelView;
import com.vidmt.family.address.wheel.adapter.AbstractWheelTextAdapter;
import com.addresspicker.huichao.addresspickerlibrary.address.City;
import com.addresspicker.huichao.addresspickerlibrary.address.County;
import com.addresspicker.huichao.addresspickerlibrary.address.Province;
import com.addresspicker.huichao.addresspickerlibrary.wheel.OnWheelChangedListener;
import com.addresspicker.huichao.addresspickerlibrary.wheel.OnWheelClickedListener;
import com.addresspicker.huichao.addresspickerlibrary.wheel.WheelView;
import com.addresspicker.huichao.addresspickerlibrary.wheel.adapter.AbstractWheelTextAdapter;

import java.util.ArrayList;
import java.util.List;


public class CityPickerDialog extends Dialog {

private final static int DEFAULT_ITEMS = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public InitAreaTask(Context context, ArrayList<Province> provinces) {

public void setOnLoadingAddressListener(onLoadingAddressListener onLoadingAddressListener) {
this.onLoadingAddressListener = onLoadingAddressListener;
this.onLoadingAddressListener.onLoading();
}

@Override
Expand Down Expand Up @@ -73,6 +74,7 @@ protected Boolean doInBackground(Integer... params) {

public interface onLoadingAddressListener {
void onLoadFinished();
void onLoading();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.addresspicker.huichao.addresspickerlibrary;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class Util {
/**
* 显示进度加载框
*
* @param context
* @param msg
* @param isAnimation
* @param imageId
* @return
*/
public static Dialog createLoadingDialog(Context context, String msg,
boolean isAnimation, int imageId) {

LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.loading_dialog, null);// 得到加载view
LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 加载布局
// main.xml中的ImageView
ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// 提示文字

if (imageId != 0) {
spaceshipImage.setImageResource(imageId);
}
if (isAnimation) {
// 加载动画
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
context, R.anim.loading_animation);
// 使用ImageView显示动画
spaceshipImage.startAnimation(hyperspaceJumpAnimation);
}

if (TextUtils.isEmpty(msg)) {
tipTextView.setVisibility(View.GONE);
} else {
tipTextView.setVisibility(View.VISIBLE);
tipTextView.setText(msg);// 设置加载信息
}

Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);// 创建自定义样式dialog

loadingDialog.setCancelable(false);// 不可以用“返回键”取消
loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));// 设置布局
return loadingDialog;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.vidmt.family.R;
import com.vidmt.family.address.wheel.adapter.WheelViewAdapter;
import com.addresspicker.huichao.addresspickerlibrary.R;
import com.addresspicker.huichao.addresspickerlibrary.wheel.adapter.WheelViewAdapter;

import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -734,8 +734,8 @@ private void doScroll(int delta) {
/**
* Scroll the wheel
*
* @param itemsToSkip items to scroll
* @param time scrolling duration
// * @param itemsToSkip items to scroll
// * @param time scrolling duration
*/
public void scroll(int itemsToScroll, int time) {
int distance = itemsToScroll * getItemHeight() - scrollingOffset;
Expand Down
13 changes: 13 additions & 0 deletions addresspickerlibrary/src/main/res/anim/loading_animation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<set android:shareInterpolator="false" xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="+360"
android:duration="3000"
android:startOffset="-1"
android:repeatMode="restart"
android:repeatCount="-1"/>
</set>
12 changes: 12 additions & 0 deletions addresspickerlibrary/src/main/res/anim/push_bottom_in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑入式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<translate
android:duration="200"
android:fromYDelta="50%p"
android:toYDelta="0" />



</set>
13 changes: 13 additions & 0 deletions addresspickerlibrary/src/main/res/anim/push_bottom_out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑入式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android" >


<translate
android:duration="200"
android:fromYDelta="0"
android:toYDelta="50%p" />



</set>
5 changes: 5 additions & 0 deletions addresspickerlibrary/src/main/res/color/text_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="#cccccc"/>
<item android:state_enabled="true" android:color="#000000"/>
</selector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#aa000000"/>
<corners android:radius="10dp"/>

</shape>
17 changes: 17 additions & 0 deletions addresspickerlibrary/src/main/res/drawable/wheel_hight_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
<shape android:shape="rectangle" >
<solid android:color="#cccccc" />
</shape>
</item>
<item
android:bottom="1px"
android:top="1px">
<shape android:shape="rectangle" >
<solid android:color="#ffffff" />
</shape>
</item>

</layer-list>
23 changes: 23 additions & 0 deletions addresspickerlibrary/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<Button
android:id="@+id/single_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="单选框" />

<Button
android:id="@+id/select_area_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="@+id/single_picker"
android:text="选择地区" />

</RelativeLayout>
59 changes: 59 additions & 0 deletions addresspickerlibrary/src/main/res/layout/dialog_city_picker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp" >

<TextView
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="取消"
android:textColor="#aa0000"
android:textSize="18sp" />

<TextView
android:id="@+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="完成"
android:textColor="#aa0000"
android:textSize="18sp" />
</RelativeLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<com.addresspicker.huichao.addresspickerlibrary.wheel.WheelView
android:id="@+id/provinceWheel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />

<com.addresspicker.huichao.addresspickerlibrary.wheel.WheelView
android:id="@+id/citiesWheel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />

<com.addresspicker.huichao.addresspickerlibrary.wheel.WheelView
android:id="@+id/countiesWheel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>

</LinearLayout>
34 changes: 34 additions & 0 deletions addresspickerlibrary/src/main/res/layout/loading_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="22dp"
android:minHeight="87dp"
android:minWidth="104dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="26dp" >

<ImageView
android:id="@+id/img"
android:layout_width="38dp"
android:layout_height="38dp"
android:src="@drawable/loading" />

<TextView
android:id="@+id/tipTextView"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:maxWidth="208dp"
android:layout_gravity="center_horizontal"
android:text=""
android:textSize="16sp"
android:includeFontPadding="false"
android:textColor="#ffffff"
android:visibility="visible" />

</LinearLayout>
9 changes: 9 additions & 0 deletions addresspickerlibrary/src/main/res/layout/wheel_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="45dp"
android:textColor="@color/text_color"
android:textSize="17sp"
android:enabled="false"
android:gravity="center"/>

7 changes: 7 additions & 0 deletions addresspickerlibrary/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<resources>

<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

</resources>
7 changes: 6 additions & 1 deletion addresspickerlibrary/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AddressPickerLibrary</string>

<string name="app_name">Picker</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>

</resources>
35 changes: 35 additions & 0 deletions addresspickerlibrary/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="AnimBottom" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_bottom_in</item>
<item name="android:windowExitAnimation">@anim/push_bottom_out</item>
</style>

<style name="loading_dialog" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowBackground">@drawable/progress_dialog_bg</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>

</resources>
Expand Down
Loading

0 comments on commit 53922be

Please sign in to comment.