diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..39fb081
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..e100a7d
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..5d19981
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..b9dac15
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..af3c3e9
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "26.0.0"
+ defaultConfig {
+ applicationId "com.gac.widget.gacdialog"
+ minSdkVersion 15
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ testCompile 'junit:junit:4.12'
+ compile project(':gacdialog')
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..41afecb
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\Android\sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/app/src/androidTest/java/com/gac/widget/gacdialog/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/gac/widget/gacdialog/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..a7eed38
--- /dev/null
+++ b/app/src/androidTest/java/com/gac/widget/gacdialog/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.gac.widget.gacdialog;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.gac.widget.gacdialog", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a884556
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/gac/widget/gacdialog/MainActivity.java b/app/src/main/java/com/gac/widget/gacdialog/MainActivity.java
new file mode 100644
index 0000000..9e569cb
--- /dev/null
+++ b/app/src/main/java/com/gac/widget/gacdialog/MainActivity.java
@@ -0,0 +1,124 @@
+package com.gac.widget.gacdialog;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
+
+import com.widget.dialog.IosAlertDialog;
+import com.widget.dialog.ListDialog;
+import com.widget.dialog.PhotoPickDialog;
+import com.widget.dialog.PickerSelect;
+import com.widget.dialog.ProgressDialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MainActivity extends AppCompatActivity {
+ Button bt_ios;
+ Button bt_progress;
+ Button bt_photo;
+ Button bt_list;
+ Button bt_select;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ bt_ios = (Button)findViewById(R.id.bt_ios);
+ bt_progress = (Button)findViewById(R.id.bt_progress);
+ bt_photo = (Button)findViewById(R.id.bt_photo);
+ bt_list = (Button)findViewById(R.id.bt_list);
+ bt_select= (Button)findViewById(R.id.bt_select);
+ setListener();
+ }
+
+ private void setListener(){
+ bt_ios.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+// new IosAlertDialog(MainActivity.this).builder().setCancelable(true).setMsg("ios alert dialog").setTitle("alert title")
+// .show();
+ new IosAlertDialog(MainActivity.this).builder().setCancelable(true).setMsg("ios alert dialog").setPositiveButton("确定", new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ }
+ }).setNegativeButton("取消", new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ }
+ }).setTitle("alert title")
+ .show();
+ }
+ });
+
+
+
+ bt_progress.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new ProgressDialog(MainActivity.this).builder().setCancelable(true).setMsg("加载对话框")
+ .setProgressColor(getResources().getColor(R.color.colorPrimary)).show();
+
+ }
+ });
+
+ bt_photo.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new PhotoPickDialog(MainActivity.this).builder().setCancelable(true).setTakePhotoListener(new PhotoPickDialog.TakePhotoListener() {
+ @Override
+ public void takePhoto() {
+
+ }
+
+ @Override
+ public void pickPhoto() {
+
+ }
+ }).show();
+ }
+ });
+
+ bt_list.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ List list = new ArrayList();
+ for(int i = 0; i < 10; i++){
+ list.add("第"+i+"条项目");
+ }
+ new ListDialog(MainActivity.this).builder().setCancelable(true).setContent(list).setListSelectListener(new ListDialog.ListSelectListener() {
+ @Override
+ public void select(String content, int pos) {
+ Toast.makeText(MainActivity.this,"content:"+content+" pos:"+pos,Toast.LENGTH_SHORT).show();
+ }
+ }).show();
+ }
+ });
+
+ bt_select.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ List list = new ArrayList();
+ for(int i = 0; i < 10; i++){
+ list.add("第"+i+"条项目");
+ }
+ PickerSelect pickerSelect = new PickerSelect(MainActivity.this,list,"title");
+ pickerSelect.setSelected(list.get(5));
+ pickerSelect.setSelectListener(new PickerSelect.SelectListener() {
+ @Override
+ public void onSelect(String str) {
+ Toast.makeText(MainActivity.this,"content:"+str,Toast.LENGTH_SHORT).show();
+ }
+
+ });
+ pickerSelect.show();
+ }
+ });
+
+ }
+
+
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..30a4236
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+
+
+ 64dp
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 16dp
+ 16dp
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..5fba6ff
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ GacDialog
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..5885930
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/app/src/test/java/com/gac/widget/gacdialog/ExampleUnitTest.java b/app/src/test/java/com/gac/widget/gacdialog/ExampleUnitTest.java
new file mode 100644
index 0000000..0336422
--- /dev/null
+++ b/app/src/test/java/com/gac/widget/gacdialog/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.gac.widget.gacdialog;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..74b2ab0
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,23 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.2.3'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/gacdialog/.gitignore b/gacdialog/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/gacdialog/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/gacdialog/build.gradle b/gacdialog/build.gradle
new file mode 100644
index 0000000..214c5b6
--- /dev/null
+++ b/gacdialog/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "26.0.0"
+
+ defaultConfig {
+ minSdkVersion 15
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ testCompile 'junit:junit:4.12'
+}
diff --git a/gacdialog/proguard-rules.pro b/gacdialog/proguard-rules.pro
new file mode 100644
index 0000000..41afecb
--- /dev/null
+++ b/gacdialog/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\Android\sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/gacdialog/src/main/AndroidManifest.xml b/gacdialog/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..4e68200
--- /dev/null
+++ b/gacdialog/src/main/AndroidManifest.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/gacdialog/src/main/java/com/widget/dialog/IosAlertDialog.java b/gacdialog/src/main/java/com/widget/dialog/IosAlertDialog.java
new file mode 100644
index 0000000..409b9f7
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/IosAlertDialog.java
@@ -0,0 +1,196 @@
+package com.widget.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.Display;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+
+
+public class IosAlertDialog {
+ private Context context;
+ private Dialog dialog;
+ private LinearLayout lLayout_bg;
+ private TextView txt_title;
+ private TextView txt_msg;
+ private Button btn_neg;
+ private Button btn_pos;
+ private ImageView img_line;
+ private Display display;
+ private boolean showTitle = false;
+ private boolean showMsg = false;
+ private boolean showPosBtn = false;
+ private boolean showNegBtn = false;
+
+ public IosAlertDialog(Context context) {
+ this.context = context;
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context
+ .WINDOW_SERVICE);
+ display = windowManager.getDefaultDisplay();
+ }
+
+ public IosAlertDialog builder() {
+ // 获取Dialog布局
+ View view = LayoutInflater.from(context).inflate(R.layout.dialog_ios, null);
+
+ // 获取自定义Dialog布局中的控件
+ lLayout_bg = (LinearLayout) view.findViewById(R.id.lLayout_bg);
+ txt_title = (TextView) view.findViewById(R.id.txt_title);
+ txt_title.setVisibility(View.GONE);
+ txt_msg = (TextView) view.findViewById(R.id.txt_msg);
+ txt_msg.setVisibility(View.GONE);
+ btn_neg = (Button) view.findViewById(R.id.btn_neg);
+ btn_neg.setVisibility(View.GONE);
+ btn_pos = (Button) view.findViewById(R.id.btn_pos);
+ btn_pos.setVisibility(View.GONE);
+ img_line = (ImageView) view.findViewById(R.id.img_line);
+ img_line.setVisibility(View.GONE);
+
+ // 定义Dialog布局和参数
+ dialog = new Dialog(context, R.style.AlertDialogStyle);
+ dialog.setContentView(view);
+
+ // 调整dialog背景大小
+ /* lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display.getWidth() * 0.8)
+ , LayoutParams.WRAP_CONTENT));*/
+ Window dialogWindow = dialog.getWindow();
+ WindowManager.LayoutParams lp = dialogWindow.getAttributes();
+ lp.width = (int) (display.getWidth() * 0.8);
+
+ return this;
+ }
+
+ public IosAlertDialog setTitle(String title) {
+ showTitle = true;
+ if ("".equals(title)) {
+ txt_title.setText("标题");
+ } else {
+ txt_title.setText(title);
+ }
+ return this;
+ }
+
+ public IosAlertDialog setMsg(String msg) {
+ showMsg = true;
+ if ("".equals(msg)) {
+ txt_msg.setText("内容");
+ } else {
+ txt_msg.setText(msg);
+ }
+ return this;
+ }
+
+ public IosAlertDialog setCancelable(boolean cancel) {
+ dialog.setCancelable(cancel);
+ return this;
+ }
+
+ public IosAlertDialog setPositiveButton(String text, final OnClickListener listener) {
+ showPosBtn = true;
+ if ("".equals(text)) {
+ btn_pos.setText("确定");
+ } else {
+ btn_pos.setText(text);
+ }
+ btn_pos.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(v);
+ }
+ dialog.dismiss();
+ }
+ });
+ return this;
+ }
+
+ public IosAlertDialog setNegativeButton(String text, final OnClickListener listener) {
+ showNegBtn = true;
+ if ("".equals(text)) {
+ btn_neg.setText("取消");
+ } else {
+ btn_neg.setText(text);
+ }
+ btn_neg.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(v);
+ }
+ dialog.dismiss();
+ }
+ });
+ return this;
+ }
+
+ public void setOnDismissListener(DialogInterface.OnDismissListener dismissListener) {
+ dialog.setOnDismissListener(dismissListener);
+ }
+
+ public void setOnKeyListener(DialogInterface.OnKeyListener onKeyListener) {
+ dialog.setOnKeyListener(onKeyListener);
+ }
+
+ public void setCanceledOnTouchOutside(boolean b) {
+ dialog.setCanceledOnTouchOutside(b);
+ }
+
+ private void setLayout() {
+ if (!showTitle && !showMsg) {
+ txt_title.setText("提示");
+ txt_title.setVisibility(View.VISIBLE);
+ }
+
+ if (showTitle) {
+ txt_title.setVisibility(View.VISIBLE);
+ }
+
+ if (showMsg) {
+ txt_msg.setVisibility(View.VISIBLE);
+ }
+
+ if (!showPosBtn && !showNegBtn) {
+ btn_pos.setText("确定");
+ btn_pos.setVisibility(View.VISIBLE);
+ btn_pos.setBackgroundResource(R.drawable.iosdialog_single_selector);
+ btn_pos.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.dismiss();
+ }
+ });
+ }
+
+ if (showPosBtn && showNegBtn) {
+ btn_pos.setVisibility(View.VISIBLE);
+ btn_pos.setBackgroundResource(R.drawable.iosdialog_right_selector);
+ btn_neg.setVisibility(View.VISIBLE);
+ btn_neg.setBackgroundResource(R.drawable.iosdialog_left_selector);
+ img_line.setVisibility(View.VISIBLE);
+ }
+
+ if (showPosBtn && !showNegBtn) {
+ btn_pos.setVisibility(View.VISIBLE);
+ btn_pos.setBackgroundResource(R.drawable.iosdialog_single_selector);
+ }
+
+ if (!showPosBtn && showNegBtn) {
+ btn_neg.setVisibility(View.VISIBLE);
+ btn_neg.setBackgroundResource(R.drawable.iosdialog_single_selector);
+ }
+ }
+
+ public void show() {
+ setLayout();
+ dialog.show();
+ }
+}
diff --git a/gacdialog/src/main/java/com/widget/dialog/ListDialog.java b/gacdialog/src/main/java/com/widget/dialog/ListDialog.java
new file mode 100644
index 0000000..b46221d
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/ListDialog.java
@@ -0,0 +1,109 @@
+package com.widget.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.Display;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class ListDialog {
+ private Context context;
+ private Dialog dialog;
+ View mView;
+ List mList;
+ ListView lv;
+ ArrayAdapter mAdapter;
+ ListSelectListener mListener;
+
+ private Display display;
+
+
+ public ListDialog(Context context) {
+ this.context = context;
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context
+ .WINDOW_SERVICE);
+ display = windowManager.getDefaultDisplay();
+ }
+
+ public ListDialog builder() {
+ mView = LayoutInflater.from(context).inflate(R.layout.dialog_gac_list,null);
+ dialog = new Dialog(context, R.style.photo_dialog);
+ dialog.setCancelable(true);
+ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ dialog.setContentView(mView);
+ Window window = dialog.getWindow();
+ window.setGravity(Gravity.BOTTOM);
+ WindowManager.LayoutParams lp = window.getAttributes();
+ int width = display.getWidth();
+ lp.width = width;
+ window.setAttributes(lp);
+ initView();
+
+ return this;
+ }
+ private void initView() {
+ lv = (ListView) mView.findViewById(R.id.lv);
+ mList = new ArrayList<>();
+ mAdapter = new ArrayAdapter<>(context,R.layout.item_gac_textview,mList);
+ lv.setAdapter(mAdapter);
+ lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ if(mListener != null){
+ mListener.select(mList.get(position),position);
+ }
+
+ dialog.dismiss();
+ }
+ });
+ }
+
+
+ public ListDialog setContent(List list) {
+ mList.clear();
+ mList.addAll(list);
+ mAdapter.notifyDataSetChanged();
+ return this;
+ }
+
+ public ListDialog setCancelable(boolean cancel) {
+ dialog.setCancelable(cancel);
+ return this;
+ }
+
+
+
+
+
+
+
+ public void show() {
+
+ dialog.show();
+ }
+
+
+ public ListDialog setListSelectListener(ListSelectListener listener){
+ mListener = listener;
+ return this;
+ }
+ public interface ListSelectListener{
+ public void select(String content,int pos);
+ }
+}
diff --git a/gacdialog/src/main/java/com/widget/dialog/PhotoPickDialog.java b/gacdialog/src/main/java/com/widget/dialog/PhotoPickDialog.java
new file mode 100644
index 0000000..5e358b8
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/PhotoPickDialog.java
@@ -0,0 +1,109 @@
+package com.widget.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+
+import android.util.DisplayMetrics;
+
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import android.view.Window;
+import android.view.WindowManager;
+
+import android.widget.TextView;
+
+
+public class PhotoPickDialog {
+ private Context context;
+
+
+ private TextView tv_takephoto;
+ TextView tv_photo;
+
+ TextView tv_cancle;
+ TakePhotoListener mListener;
+ View mView;
+ private Dialog dialog;
+
+ //private Display display;
+
+
+ public PhotoPickDialog(Context context) {
+ this.context = context;
+// WindowManager windowManager = (WindowManager) context.getSystemService(Context
+// .WINDOW_SERVICE);
+ //display = windowManager.getDefaultDisplay();
+ }
+
+ public PhotoPickDialog builder() {
+ if (dialog == null) {
+ mView = LayoutInflater.from(context).inflate(R.layout.dialog_photo_picker,null);
+ dialog = new Dialog(context, R.style.photo_dialog);
+ dialog.setCancelable(true);
+ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ dialog.setContentView(mView);
+ Window window = dialog.getWindow();
+ window.setGravity(Gravity.BOTTOM);
+ WindowManager.LayoutParams lp = window.getAttributes();
+ WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ DisplayMetrics dm = new DisplayMetrics();
+ manager.getDefaultDisplay().getMetrics(dm);
+ int width = dm.widthPixels;
+ lp.width = width;
+ window.setAttributes(lp);
+ }
+ initView();
+ return this;
+ }
+ private void initView() {
+ tv_takephoto = (TextView) mView.findViewById(R.id.tv_takephoto);
+ tv_cancle = (TextView) mView.findViewById(R.id.tv_cancel);
+ tv_photo = (TextView) mView.findViewById(R.id.tv_photo);
+ tv_cancle.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.dismiss();
+ }
+ });
+ tv_takephoto.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(mListener != null){
+ mListener.takePhoto();
+ }
+
+ dialog.dismiss();
+ }
+ });
+ tv_photo.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(mListener != null){
+ mListener.pickPhoto();
+ }
+ dialog.dismiss();
+ }
+ });
+ }
+
+
+ public PhotoPickDialog setCancelable(boolean cancel) {
+ dialog.setCancelable(cancel);
+ return this;
+ }
+
+ public void show() {
+ dialog.show();
+ }
+
+ public PhotoPickDialog setTakePhotoListener(TakePhotoListener listener){
+ mListener = listener;
+ return this;
+ }
+ public interface TakePhotoListener{
+ public void takePhoto();
+ public void pickPhoto();
+ }
+}
diff --git a/gacdialog/src/main/java/com/widget/dialog/PickerSelect.java b/gacdialog/src/main/java/com/widget/dialog/PickerSelect.java
new file mode 100644
index 0000000..a629366
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/PickerSelect.java
@@ -0,0 +1,99 @@
+package com.widget.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.view.Gravity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+
+import java.util.List;
+
+/**
+ * Created by gacmy on 2017/4/18.
+ */
+
+public class PickerSelect {
+ private Dialog seletorDialog;
+ private PickerView pickerView;
+ Context context;
+ List mList;
+ TextView tv_cancle;
+ TextView tv_select;
+ TextView tv_title;
+ SelectListener listener;
+ String title;
+ String selected="";
+ public PickerSelect(Context context, List list, String title) {
+ this.context = context;
+ mList = list;
+ this.title = title;
+ initDialog();
+ initView();
+ pickerView.setData(list);
+ }
+ public interface SelectListener{
+ void onSelect(String str);
+ }
+
+ public void setSelectListener(SelectListener listener){
+ this.listener = listener;
+ }
+ private void initView() {
+ pickerView = (PickerView) seletorDialog.findViewById(R.id.pickerView);
+ tv_cancle = (TextView) seletorDialog.findViewById(R.id.tv_cancle);
+ tv_select = (TextView) seletorDialog.findViewById(R.id.tv_select);
+ tv_title = (TextView) seletorDialog.findViewById(R.id.tv_title);
+ tv_title.setText(title);
+
+ tv_cancle.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ seletorDialog.dismiss();
+ }
+ });
+ tv_select.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ listener.onSelect(selected);
+ seletorDialog.dismiss();
+ }
+ });
+
+ }
+ private void initDialog() {
+ if (seletorDialog == null) {
+ seletorDialog = new Dialog(context, R.style.photo_dialog);
+ seletorDialog.setCancelable(false);
+ seletorDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ seletorDialog.setContentView(R.layout.dialog_gac_picker);
+ Window window = seletorDialog.getWindow();
+ window.setGravity(Gravity.BOTTOM);
+ WindowManager.LayoutParams lp = window.getAttributes();
+ int width = ScreenUtil.getInstance(context).getScreenWidth();
+ lp.width = width;
+ window.setAttributes(lp);
+ }
+ }
+ public void show() {
+ addListener();
+ seletorDialog.show();
+ }
+ public void setSelected(String name){
+ pickerView.setSelected(mList.indexOf(name));
+ selected = name;
+ }
+ private void addListener() {
+
+ pickerView.setOnSelectListener(new PickerView.onSelectListener() {
+ @Override
+ public void onSelect(String text, int pos) {
+ selected = text;
+ // Log.d("PickerSelect","text:"+text+" pos:"+pos);
+ }
+ });
+ }
+
+}
diff --git a/gacdialog/src/main/java/com/widget/dialog/PickerView.java b/gacdialog/src/main/java/com/widget/dialog/PickerView.java
new file mode 100644
index 0000000..1fa4b4a
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/PickerView.java
@@ -0,0 +1,382 @@
+package com.widget.dialog;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Paint.Align;
+import android.graphics.Paint.FontMetricsInt;
+import android.graphics.Paint.Style;
+import android.os.Handler;
+import android.os.Message;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+
+public class PickerView extends View {
+ /**
+ * 新增字段 控制是否首尾相接循环显示 默认为循环显示
+ */
+ private boolean loop = true;
+
+
+ /**
+ * text之间间距和minTextSize之比
+ */
+ public static final float MARGIN_ALPHA = 2.8f;
+ /**
+ * 自动回滚到中间的速度
+ */
+ public static final float SPEED = 10;
+
+ private List mDataList;
+ /**
+ * 选中的位置,这个位置是mDataList的中心位置,一直不变
+ */
+ private int mCurrentSelected;
+ private Paint mPaint, nPaint;
+
+ private float mMaxTextSize = 80;
+ private float mMinTextSize = 40;
+
+ private float mMaxTextAlpha = 255;
+ private float mMinTextAlpha = 120;
+
+ private int mColorText = 0x333333;
+ private int nColorText = 0x666666;
+
+ private int mViewHeight;
+ private int mViewWidth;
+
+ private float mLastDownY;
+ /**
+ * 滑动的距离
+ */
+ private float mMoveLen = 0;
+ private boolean isInit = false;
+ private onSelectListener mSelectListener;
+ private Timer timer;
+ private MyTimerTask mTask;
+
+ Handler updateHandler = new Handler() {
+
+ @Override
+ public void handleMessage(Message msg) {
+ if (Math.abs(mMoveLen) < SPEED) {
+ mMoveLen = 0;
+ if (mTask != null) {
+ mTask.cancel();
+ mTask = null;
+ performSelect();
+ }
+ } else
+ // 这里mMoveLen / Math.abs(mMoveLen)是为了保有mMoveLen的正负号,以实现上滚或下滚
+ mMoveLen = mMoveLen - mMoveLen / Math.abs(mMoveLen) * SPEED;
+ invalidate();
+ }
+
+ };
+ private boolean canScroll = true;
+
+ public PickerView(Context context) {
+ super(context);
+ init();
+ }
+
+ public PickerView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PickerView);
+ loop = typedArray.getBoolean(R.styleable.PickerView_isLoop, loop);
+ init();
+ }
+
+ public void setOnSelectListener(onSelectListener listener) {
+ mSelectListener = listener;
+ }
+
+ private void performSelect() {
+ if (mSelectListener != null){
+ Log.d("PickView","mCurrentSelected:"+mCurrentSelected);
+ mSelectListener.onSelect(mDataList.get(mCurrentSelected),mCurrentSelected);
+ }
+
+ }
+
+ public void setData(List datas) {
+ mDataList = datas;
+ mCurrentSelected = datas.size() / 4;
+ invalidate();
+ }
+
+ /**
+ * 选择选中的item的index
+ *
+ * @param selected
+ */
+ public void setSelected(int selected) {
+ mCurrentSelected = selected;
+ if (loop) {
+ int distance = mDataList.size() / 2 - mCurrentSelected;
+ if (distance < 0)
+ for (int i = 0; i < -distance; i++) {
+ moveHeadToTail();
+ mCurrentSelected--;
+ }
+ else if (distance > 0)
+ for (int i = 0; i < distance; i++) {
+ moveTailToHead();
+ mCurrentSelected++;
+ }
+ }
+ invalidate();
+ }
+
+ /**
+ * 选择选中的内容
+ *
+ * @param mSelectItem
+ */
+ public void setSelected(String mSelectItem) {
+ for (int i = 0; i < mDataList.size(); i++)
+ if (mDataList.get(i).equals(mSelectItem)) {
+ setSelected(i);
+ break;
+ }
+ }
+
+
+ private void moveHeadToTail() {
+ if (loop) {
+ String head = mDataList.get(0);
+ mDataList.remove(0);
+ mDataList.add(head);
+ }
+ }
+
+ private void moveTailToHead() {
+ if (loop) {
+ String tail = mDataList.get(mDataList.size() - 1);
+ mDataList.remove(mDataList.size() - 1);
+ mDataList.add(0, tail);
+ }
+
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ mViewHeight = getMeasuredHeight();
+ mViewWidth = getMeasuredWidth();
+ // 按照View的高度计算字体大小
+ mMaxTextSize = mViewHeight / 7f;
+ mMinTextSize = mMaxTextSize / 2.2f;
+ isInit = true;
+ invalidate();
+ }
+
+ private void init() {
+ timer = new Timer();
+ mDataList = new ArrayList();
+ //第一个paint
+ mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mPaint.setStyle(Style.FILL);
+ mPaint.setTextAlign(Align.CENTER);
+ mPaint.setColor(getResources().getColor(R.color.textcolor35));
+ //第二个paint
+ nPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ nPaint.setStyle(Style.FILL);
+ nPaint.setTextAlign(Align.CENTER);
+ nPaint.setColor(mColorText);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ // 根据index绘制view
+ if (isInit)
+ drawData(canvas);
+ }
+
+ private void drawData(Canvas canvas) {
+ // 先绘制选中的text再往上往下绘制其余的text
+ float scale = parabola(mViewHeight / 4.0f, mMoveLen);
+ float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
+ mPaint.setTextSize(size);
+ mPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
+ // text居中绘制,注意baseline的计算才能达到居中,y值是text中心坐标
+ float x = (float) (mViewWidth / 2.0);
+ float y = (float) (mViewHeight / 2.0 + mMoveLen);
+ FontMetricsInt fmi = mPaint.getFontMetricsInt();
+ float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));
+
+ canvas.drawText(mDataList.get(mCurrentSelected), x, baseline, mPaint);
+ // 绘制上方data
+ for (int i = 1; (mCurrentSelected - i) >= 0; i++) {
+ drawOtherText(canvas, i, -1);
+ }
+ // 绘制下方data
+ for (int i = 1; (mCurrentSelected + i) < mDataList.size(); i++) {
+ drawOtherText(canvas, i, 1);
+ }
+
+ }
+
+ /**
+ * @param canvas
+ * @param position 距离mCurrentSelected的差值
+ * @param type 1表示向下绘制,-1表示向上绘制
+ */
+ private void drawOtherText(Canvas canvas, int position, int type) {
+ float d = (float) (MARGIN_ALPHA * mMinTextSize * position + type
+ * mMoveLen);
+ float scale = parabola(mViewHeight / 4.0f, d);
+ float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
+ nPaint.setTextSize(size);
+ nPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
+ float y = (float) (mViewHeight / 2.0 + type * d);
+ FontMetricsInt fmi = nPaint.getFontMetricsInt();
+ float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));
+ canvas.drawText(mDataList.get(mCurrentSelected + type * position),
+ (float) (mViewWidth / 2.0), baseline, nPaint);
+ }
+
+ /**
+ * 抛物线
+ *
+ * @param zero 零点坐标
+ * @param x 偏移量
+ * @return scale
+ */
+ private float parabola(float zero, float x) {
+ float f = (float) (1 - Math.pow(x / zero, 2));
+ return f < 0 ? 0 : f;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ doDown(event);
+ break;
+ case MotionEvent.ACTION_MOVE:
+ mMoveLen += (event.getY() - mLastDownY);
+
+ if (mMoveLen > MARGIN_ALPHA * mMinTextSize / 2) {
+ if (!loop && mCurrentSelected == 0) {
+ mLastDownY = event.getY();
+ invalidate();
+ return true;
+ }
+ if (!loop) mCurrentSelected--;
+ // 往下滑超过离开距离
+ moveTailToHead();
+ mMoveLen = mMoveLen - MARGIN_ALPHA * mMinTextSize;
+ } else if (mMoveLen < -MARGIN_ALPHA * mMinTextSize / 2) {
+ if (mCurrentSelected == mDataList.size() - 1) {
+ mLastDownY = event.getY();
+ invalidate();
+ return true;
+ }
+ if (!loop) mCurrentSelected++;
+ // 往上滑超过离开距离
+ moveHeadToTail();
+ mMoveLen = mMoveLen + MARGIN_ALPHA * mMinTextSize;
+ }
+
+ mLastDownY = event.getY();
+ invalidate();
+ break;
+ case MotionEvent.ACTION_UP:
+ doUp(event);
+ break;
+ }
+ return true;
+ }
+
+ private void doDown(MotionEvent event) {
+ if (mTask != null) {
+ mTask.cancel();
+ mTask = null;
+ }
+ mLastDownY = event.getY();
+ }
+
+// private void doMove(MotionEvent event) {
+//
+// mMoveLen += (event.getY() - mLastDownY);
+//
+// if (mMoveLen > MARGIN_ALPHA * mMinTextSize / 2) {
+// // 往下滑超过离开距离
+// moveTailToHead();
+// mMoveLen = mMoveLen - MARGIN_ALPHA * mMinTextSize;
+// } else if (mMoveLen < -MARGIN_ALPHA * mMinTextSize / 2) {
+// // 往上滑超过离开距离
+// moveHeadToTail();
+// mMoveLen = mMoveLen + MARGIN_ALPHA * mMinTextSize;
+// }
+//
+// mLastDownY = event.getY();
+// invalidate();
+// }
+
+ private void doUp(MotionEvent event) {
+ // 抬起手后mCurrentSelected的位置由当前位置move到中间选中位置
+ if (Math.abs(mMoveLen) < 0.0001) {
+ mMoveLen = 0;
+ return;
+ }
+ if (mTask != null) {
+ mTask.cancel();
+ mTask = null;
+ }
+ mTask = new MyTimerTask(updateHandler);
+ timer.schedule(mTask, 0, 10);
+ }
+
+ class MyTimerTask extends TimerTask {
+ Handler handler;
+
+ public MyTimerTask(Handler handler) {
+ this.handler = handler;
+ }
+
+ @Override
+ public void run() {
+ handler.sendMessage(handler.obtainMessage());
+ }
+
+ }
+
+ public interface onSelectListener {
+ void onSelect(String text, int pos);
+ }
+
+ public void setCanScroll(boolean canScroll) {
+ this.canScroll = canScroll;
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ if (canScroll)
+ return super.dispatchTouchEvent(event);
+ else
+ return false;
+ }
+
+ /**
+ * 新增字段 控制内容是否首尾相连
+ * by liuli
+ *
+ * @param isLoop
+ */
+ public void setIsLoop(boolean isLoop) {
+ loop = isLoop;
+ }
+}
\ No newline at end of file
diff --git a/gacdialog/src/main/java/com/widget/dialog/ProgressDialog.java b/gacdialog/src/main/java/com/widget/dialog/ProgressDialog.java
new file mode 100644
index 0000000..51b1014
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/ProgressDialog.java
@@ -0,0 +1,101 @@
+package com.widget.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.Display;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+
+public class ProgressDialog {
+ private Context context;
+ private Dialog dialog;
+ private LinearLayout lLayout_bg;
+ private TextView tv_msg;
+
+ private Display display;
+ ProgressWheel wheel;
+
+ public ProgressDialog(Context context) {
+ this.context = context;
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context
+ .WINDOW_SERVICE);
+ display = windowManager.getDefaultDisplay();
+ }
+
+ public ProgressDialog builder() {
+ // 获取Dialog布局
+ View view = LayoutInflater.from(context).inflate(R.layout.dialog_gac_progress, null);
+ wheel = (ProgressWheel)view.findViewById(R.id.progress);
+ wheel.setBarColor(context.getResources().getColor(R.color.colorAccent));
+ // 获取自定义Dialog布局中的控件
+ lLayout_bg = (LinearLayout) view.findViewById(R.id.lLayout_bg);
+ tv_msg = (TextView)view.findViewById(R.id.tv_msg);
+ // 定义Dialog布局和参数
+ dialog = new Dialog(context, R.style.AlertDialogStyle);
+ dialog.setContentView(view);
+
+ // 调整dialog背景大小
+ /* lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display.getWidth() * 0.8)
+ , LayoutParams.WRAP_CONTENT));*/
+ Window dialogWindow = dialog.getWindow();
+ WindowManager.LayoutParams lp = dialogWindow.getAttributes();
+ lp.width = (int) (display.getWidth() * 0.8);
+ setListener();
+ return this;
+ }
+
+ public ProgressDialog setProgressColor(int color){
+ if(wheel != null){
+ wheel.setBarColor(color);
+ }
+ return this;
+ }
+ private void startSpin(){
+ if(wheel != null){
+ wheel.spin();
+ }
+ }
+ private void stopSpin(){
+ if(wheel != null){
+ wheel.stopSpinning();
+ }
+ }
+ public ProgressDialog setMsg(String msg) {
+
+ if ("".equals(msg)) {
+ tv_msg.setText("正在加载...");
+ } else {
+ tv_msg.setText(msg);
+ }
+ return this;
+ }
+
+
+ private void setListener(){
+ dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ stopSpin();
+ }
+ });
+ }
+ public ProgressDialog setCancelable(boolean cancel) {
+ dialog.setCancelable(cancel);
+ return this;
+ }
+
+ public void show() {
+ // setLayout();
+ if(dialog != null){
+ dialog.show();
+ startSpin();
+ }
+
+ }
+}
diff --git a/gacdialog/src/main/java/com/widget/dialog/ProgressWheel.java b/gacdialog/src/main/java/com/widget/dialog/ProgressWheel.java
new file mode 100644
index 0000000..5feedbd
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/ProgressWheel.java
@@ -0,0 +1,765 @@
+package com.widget.dialog;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Paint.Style;
+import android.graphics.RectF;
+import android.os.Build;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.view.View;
+
+
+
+/**
+ * A Material style progress wheel, compatible up to 2.2.
+ * Todd Davies' Progress Wheel https://github.com/Todd-Davies/ProgressWheel
+ *
+ * @author Nico Hormazábal
+ *
+ * Licensed under the Apache License 2.0 license see:
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+public class ProgressWheel extends View {
+ private static final String TAG = ProgressWheel.class.getSimpleName();
+ private final int barLength = 16;
+ private final int barMaxLength = 270;
+ private final long pauseGrowingTime = 200;
+ /**
+ * *********
+ * DEFAULTS *
+ * **********
+ */
+ //Sizes (with defaults in DP)
+ private int circleRadius = 28;
+ private int barWidth = 4;
+ private int rimWidth = 4;
+ private boolean fillRadius = false;
+ private double timeStartGrowing = 0;
+ private double barSpinCycleTime = 460;
+ private float barExtraLength = 0;
+ private boolean barGrowingFromFront = true;
+ private long pausedTimeWithoutGrowing = 0;
+ //Colors (with defaults)
+ private int barColor = 0xAA000000;
+ private int rimColor = 0x00FFFFFF;
+
+ //Paints
+ private Paint barPaint = new Paint();
+ private Paint rimPaint = new Paint();
+
+ //Rectangles
+ private RectF circleBounds = new RectF();
+
+ //Animation
+ //The amount of degrees per second
+ private float spinSpeed = 230.0f;
+ //private float spinSpeed = 120.0f;
+ // The last time the spinner was animated
+ private long lastTimeAnimated = 0;
+
+ private boolean linearProgress;
+
+ private float mProgress = 0.0f;
+ private float mTargetProgress = 0.0f;
+ private boolean isSpinning = false;
+
+ private ProgressCallback callback;
+
+ private boolean shouldAnimate;
+
+ /**
+ * The constructor for the ProgressWheel
+ */
+ public ProgressWheel(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ parseAttributes(context.obtainStyledAttributes(attrs, R.styleable.ProgressWheel));
+
+ setAnimationEnabled();
+ }
+
+ /**
+ * The constructor for the ProgressWheel
+ */
+ public ProgressWheel(Context context) {
+ super(context);
+ setAnimationEnabled();
+ }
+
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void setAnimationEnabled() {
+ int currentApiVersion = Build.VERSION.SDK_INT;
+
+ float animationValue;
+ if (currentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ animationValue = Settings.Global.getFloat(getContext().getContentResolver(),
+ Settings.Global.ANIMATOR_DURATION_SCALE, 1);
+ } else {
+ animationValue = Settings.System.getFloat(getContext().getContentResolver(),
+ Settings.System.ANIMATOR_DURATION_SCALE, 1);
+ }
+
+ shouldAnimate = animationValue != 0;
+ }
+
+ //----------------------------------
+ //Setting up stuff
+ //----------------------------------
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ int viewWidth = circleRadius + this.getPaddingLeft() + this.getPaddingRight();
+ int viewHeight = circleRadius + this.getPaddingTop() + this.getPaddingBottom();
+
+ 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(viewWidth, widthSize);
+ } else {
+ //Be whatever you want
+ width = viewWidth;
+ }
+
+ //Measure Height
+ if (heightMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.EXACTLY) {
+ //Must be this size
+ height = heightSize;
+ } else if (heightMode == MeasureSpec.AT_MOST) {
+ //Can't be bigger than...
+ height = Math.min(viewHeight, heightSize);
+ } else {
+ //Be whatever you want
+ height = viewHeight;
+ }
+
+ setMeasuredDimension(width, height);
+ }
+
+ /**
+ * Use onSizeChanged instead of onAttachedToWindow to get the dimensions of the view,
+ * because this method is called after measuring the dimensions of MATCH_PARENT & WRAP_CONTENT.
+ * Use this dimensions to setup the bounds and paints.
+ */
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ setupBounds(w, h);
+ setupPaints();
+ invalidate();
+ }
+
+ /**
+ * Set the properties of the paints we're using to
+ * draw the progress wheel
+ */
+ private void setupPaints() {
+ barPaint.setColor(barColor);
+ barPaint.setAntiAlias(true);
+ barPaint.setStyle(Style.STROKE);
+ barPaint.setStrokeWidth(barWidth);
+
+ rimPaint.setColor(rimColor);
+ rimPaint.setAntiAlias(true);
+ rimPaint.setStyle(Style.STROKE);
+ rimPaint.setStrokeWidth(rimWidth);
+ }
+
+ /**
+ * Set the bounds of the component
+ */
+ private void setupBounds(int layout_width, int layout_height) {
+ int paddingTop = getPaddingTop();
+ int paddingBottom = getPaddingBottom();
+ int paddingLeft = getPaddingLeft();
+ int paddingRight = getPaddingRight();
+
+ if (!fillRadius) {
+ // Width should equal to Height, find the min value to setup the circle
+ int minValue = Math.min(layout_width - paddingLeft - paddingRight,
+ layout_height - paddingBottom - paddingTop);
+
+ int circleDiameter = Math.min(minValue, circleRadius * 2 - barWidth * 2);
+
+ // Calc the Offset if needed for centering the wheel in the available space
+ int xOffset = (layout_width - paddingLeft - paddingRight - circleDiameter) / 2 + paddingLeft;
+ int yOffset = (layout_height - paddingTop - paddingBottom - circleDiameter) / 2 + paddingTop;
+
+ circleBounds =
+ new RectF(xOffset + barWidth, yOffset + barWidth, xOffset + circleDiameter - barWidth,
+ yOffset + circleDiameter - barWidth);
+ } else {
+ circleBounds = new RectF(paddingLeft + barWidth, paddingTop + barWidth,
+ layout_width - paddingRight - barWidth, layout_height - paddingBottom - barWidth);
+ }
+ }
+
+ /**
+ * Parse the attributes passed to the view from the XML
+ *
+ * @param a the attributes to parse
+ */
+ private void parseAttributes(TypedArray a) {
+ // We transform the default values from DIP to pixels
+ DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
+ barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
+ rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
+ circleRadius =
+ (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);
+
+ circleRadius =
+ (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);
+
+ fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);
+
+ barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);
+
+ rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);
+
+ float baseSpinSpeed =
+ a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
+ spinSpeed = baseSpinSpeed * 360;
+
+ barSpinCycleTime =
+ a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);
+
+ barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);
+
+ rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);
+
+ linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);
+
+ if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
+ spin();
+ }
+
+ // Recycle
+ a.recycle();
+ }
+
+ public void setCallback(ProgressCallback progressCallback) {
+ callback = progressCallback;
+
+ if (!isSpinning) {
+ runCallback();
+ }
+ }
+
+ //----------------------------------
+ //Animation stuff
+ //----------------------------------
+
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ canvas.drawArc(circleBounds, 360, 360, false, rimPaint);
+
+ boolean mustInvalidate = false;
+
+ if (!shouldAnimate) {
+ return;
+ }
+
+ if (isSpinning) {
+ //Draw the spinning bar
+ mustInvalidate = true;
+
+ long deltaTime = (SystemClock.uptimeMillis() - lastTimeAnimated);
+ float deltaNormalized = deltaTime * spinSpeed / 1000.0f;
+
+ updateBarLength(deltaTime);
+
+ mProgress += deltaNormalized;
+ if (mProgress > 360) {
+ mProgress -= 360f;
+
+ // A full turn has been completed
+ // we run the callback with -1 in case we want to
+ // do something, like changing the color
+ runCallback(-1.0f);
+ }
+ lastTimeAnimated = SystemClock.uptimeMillis();
+
+ float from = mProgress - 90;
+ float length = barLength + barExtraLength;
+
+ if (isInEditMode()) {
+ from = 0;
+ length = 135;
+ }
+
+ canvas.drawArc(circleBounds, from, length, false, barPaint);
+ } else {
+ float oldProgress = mProgress;
+
+ if (mProgress != mTargetProgress) {
+ //We smoothly increase the progress bar
+ mustInvalidate = true;
+
+ float deltaTime = (float) (SystemClock.uptimeMillis() - lastTimeAnimated) / 1000;
+ float deltaNormalized = deltaTime * spinSpeed;
+
+ mProgress = Math.min(mProgress + deltaNormalized, mTargetProgress);
+ lastTimeAnimated = SystemClock.uptimeMillis();
+ }
+
+ if (oldProgress != mProgress) {
+ runCallback();
+ }
+
+ float offset = 0.0f;
+ float progress = mProgress;
+ if (!linearProgress) {
+ float factor = 2.0f;
+ offset = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, 2.0f * factor)) * 360.0f;
+ progress = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, factor)) * 360.0f;
+ }
+
+ if (isInEditMode()) {
+ progress = 360;
+ }
+
+ canvas.drawArc(circleBounds, offset - 90, progress, false, barPaint);
+ }
+
+ if (mustInvalidate) {
+ invalidate();
+ }
+ }
+
+ @Override
+ protected void onVisibilityChanged(View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+
+ if (visibility == VISIBLE) {
+ lastTimeAnimated = SystemClock.uptimeMillis();
+ }
+ }
+
+ private void updateBarLength(long deltaTimeInMilliSeconds) {
+ if (pausedTimeWithoutGrowing >= pauseGrowingTime) {
+ timeStartGrowing += deltaTimeInMilliSeconds;
+
+ if (timeStartGrowing > barSpinCycleTime) {
+ // We completed a size change cycle
+ // (growing or shrinking)
+ timeStartGrowing -= barSpinCycleTime;
+ //if(barGrowingFromFront) {
+ pausedTimeWithoutGrowing = 0;
+ //}
+ barGrowingFromFront = !barGrowingFromFront;
+ }
+
+ float distance =
+ (float) Math.cos((timeStartGrowing / barSpinCycleTime + 1) * Math.PI) / 2 + 0.5f;
+ float destLength = (barMaxLength - barLength);
+
+ if (barGrowingFromFront) {
+ barExtraLength = distance * destLength;
+ } else {
+ float newLength = destLength * (1 - distance);
+ mProgress += (barExtraLength - newLength);
+ barExtraLength = newLength;
+ }
+ } else {
+ pausedTimeWithoutGrowing += deltaTimeInMilliSeconds;
+ }
+ }
+
+ /**
+ * Check if the wheel is currently spinning
+ */
+
+ public boolean isSpinning() {
+ return isSpinning;
+ }
+
+ /**
+ * Reset the count (in increment mode)
+ */
+ public void resetCount() {
+ mProgress = 0.0f;
+ mTargetProgress = 0.0f;
+ invalidate();
+ }
+
+ /**
+ * Turn off spin mode
+ */
+ public void stopSpinning() {
+ isSpinning = false;
+ mProgress = 0.0f;
+ mTargetProgress = 0.0f;
+ invalidate();
+ }
+
+ /**
+ * Puts the view on spin mode
+ */
+ public void spin() {
+ lastTimeAnimated = SystemClock.uptimeMillis();
+ isSpinning = true;
+ invalidate();
+ }
+
+ private void runCallback(float value) {
+ if (callback != null) {
+ callback.onProgressUpdate(value);
+ }
+ }
+
+ private void runCallback() {
+ if (callback != null) {
+ float normalizedProgress = (float) Math.round(mProgress * 100 / 360.0f) / 100;
+ callback.onProgressUpdate(normalizedProgress);
+ }
+ }
+
+ /**
+ * Set the progress to a specific value,
+ * the bar will be set instantly to that value
+ *
+ * @param progress the progress between 0 and 1
+ */
+ public void setInstantProgress(float progress) {
+ if (isSpinning) {
+ mProgress = 0.0f;
+ isSpinning = false;
+ }
+
+ if (progress > 1.0f) {
+ progress -= 1.0f;
+ } else if (progress < 0) {
+ progress = 0;
+ }
+
+ if (progress == mTargetProgress) {
+ return;
+ }
+
+ mTargetProgress = Math.min(progress * 360.0f, 360.0f);
+ mProgress = mTargetProgress;
+ lastTimeAnimated = SystemClock.uptimeMillis();
+ invalidate();
+ }
+
+ // Great way to save a view's state http://stackoverflow.com/a/7089687/1991053
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+
+ WheelSavedState ss = new WheelSavedState(superState);
+
+ // We save everything that can be changed at runtime
+ ss.mProgress = this.mProgress;
+ ss.mTargetProgress = this.mTargetProgress;
+ ss.isSpinning = this.isSpinning;
+ ss.spinSpeed = this.spinSpeed;
+ ss.barWidth = this.barWidth;
+ ss.barColor = this.barColor;
+ ss.rimWidth = this.rimWidth;
+ ss.rimColor = this.rimColor;
+ ss.circleRadius = this.circleRadius;
+ ss.linearProgress = this.linearProgress;
+ ss.fillRadius = this.fillRadius;
+
+ return ss;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ if (!(state instanceof WheelSavedState)) {
+ super.onRestoreInstanceState(state);
+ return;
+ }
+
+ WheelSavedState ss = (WheelSavedState) state;
+ super.onRestoreInstanceState(ss.getSuperState());
+
+ this.mProgress = ss.mProgress;
+ this.mTargetProgress = ss.mTargetProgress;
+ this.isSpinning = ss.isSpinning;
+ this.spinSpeed = ss.spinSpeed;
+ this.barWidth = ss.barWidth;
+ this.barColor = ss.barColor;
+ this.rimWidth = ss.rimWidth;
+ this.rimColor = ss.rimColor;
+ this.circleRadius = ss.circleRadius;
+ this.linearProgress = ss.linearProgress;
+ this.fillRadius = ss.fillRadius;
+
+ this.lastTimeAnimated = SystemClock.uptimeMillis();
+ }
+
+ /**
+ * @return the current progress between 0.0 and 1.0,
+ * if the wheel is indeterminate, then the result is -1
+ */
+ public float getProgress() {
+ return isSpinning ? -1 : mProgress / 360.0f;
+ }
+
+ //----------------------------------
+ //Getters + setters
+ //----------------------------------
+
+ /**
+ * Set the progress to a specific value,
+ * the bar will smoothly animate until that value
+ *
+ * @param progress the progress between 0 and 1
+ */
+ public void setProgress(float progress) {
+ if (isSpinning) {
+ mProgress = 0.0f;
+ isSpinning = false;
+
+ runCallback();
+ }
+
+ if (progress > 1.0f) {
+ progress -= 1.0f;
+ } else if (progress < 0) {
+ progress = 0;
+ }
+
+ if (progress == mTargetProgress) {
+ return;
+ }
+
+ // If we are currently in the right position
+ // we set again the last time animated so the
+ // animation starts smooth from here
+ if (mProgress == mTargetProgress) {
+ lastTimeAnimated = SystemClock.uptimeMillis();
+ }
+
+ mTargetProgress = Math.min(progress * 360.0f, 360.0f);
+
+ invalidate();
+ }
+
+ /**
+ * Sets the determinate progress mode
+ *
+ * @param isLinear if the progress should increase linearly
+ */
+ public void setLinearProgress(boolean isLinear) {
+ linearProgress = isLinear;
+ if (!isSpinning) {
+ invalidate();
+ }
+ }
+
+ /**
+ * @return the radius of the wheel in pixels
+ */
+ public int getCircleRadius() {
+ return circleRadius;
+ }
+
+ /**
+ * Sets the radius of the wheel
+ *
+ * @param circleRadius the expected radius, in pixels
+ */
+ public void setCircleRadius(int circleRadius) {
+ this.circleRadius = circleRadius;
+ if (!isSpinning) {
+ invalidate();
+ }
+ }
+
+ /**
+ * @return the width of the spinning bar
+ */
+ public int getBarWidth() {
+ return barWidth;
+ }
+
+ /**
+ * Sets the width of the spinning bar
+ *
+ * @param barWidth the spinning bar width in pixels
+ */
+ public void setBarWidth(int barWidth) {
+ this.barWidth = barWidth;
+ if (!isSpinning) {
+ invalidate();
+ }
+ }
+
+ /**
+ * @return the color of the spinning bar
+ */
+ public int getBarColor() {
+ return barColor;
+ }
+
+ /**
+ * Sets the color of the spinning bar
+ *
+ * @param barColor The spinning bar color
+ */
+ public void setBarColor(int barColor) {
+ this.barColor = barColor;
+ setupPaints();
+ if (!isSpinning) {
+ invalidate();
+ }
+ }
+
+ /**
+ * @return the color of the wheel's contour
+ */
+ public int getRimColor() {
+ return rimColor;
+ }
+
+ /**
+ * Sets the color of the wheel's contour
+ *
+ * @param rimColor the color for the wheel
+ */
+ public void setRimColor(int rimColor) {
+ this.rimColor = rimColor;
+ setupPaints();
+ if (!isSpinning) {
+ invalidate();
+ }
+ }
+
+ /**
+ * @return the base spinning speed, in full circle turns per second
+ * (1.0 equals on full turn in one second), this value also is applied for
+ * the smoothness when setting a progress
+ */
+ public float getSpinSpeed() {
+ return spinSpeed / 360.0f;
+ }
+
+ /**
+ * Sets the base spinning speed, in full circle turns per second
+ * (1.0 equals on full turn in one second), this value also is applied for
+ * the smoothness when setting a progress
+ *
+ * @param spinSpeed the desired base speed in full turns per second
+ */
+ public void setSpinSpeed(float spinSpeed) {
+ this.spinSpeed = spinSpeed * 360.0f;
+ }
+
+ /**
+ * @return the width of the wheel's contour in pixels
+ */
+ public int getRimWidth() {
+ return rimWidth;
+ }
+
+ /**
+ * Sets the width of the wheel's contour
+ *
+ * @param rimWidth the width in pixels
+ */
+ public void setRimWidth(int rimWidth) {
+ this.rimWidth = rimWidth;
+ if (!isSpinning) {
+ invalidate();
+ }
+ }
+
+ public interface ProgressCallback {
+ /**
+ * Method to call when the progress reaches a value
+ * in order to avoid float precision issues, the progress
+ * is rounded to a float with two decimals.
+ *
+ * In indeterminate mode, the callback is called each time
+ * the wheel completes an animation cycle, with, the progress value is -1.0f
+ *
+ * @param progress a double value between 0.00 and 1.00 both included
+ */
+ public void onProgressUpdate(float progress);
+ }
+
+ static class WheelSavedState extends BaseSavedState {
+ //required field that makes Parcelables from a Parcel
+ public static final Creator CREATOR =
+ new Creator() {
+ public WheelSavedState createFromParcel(Parcel in) {
+ return new WheelSavedState(in);
+ }
+
+ public WheelSavedState[] newArray(int size) {
+ return new WheelSavedState[size];
+ }
+ };
+ float mProgress;
+ float mTargetProgress;
+ boolean isSpinning;
+ float spinSpeed;
+ int barWidth;
+ int barColor;
+ int rimWidth;
+ int rimColor;
+ int circleRadius;
+ boolean linearProgress;
+ boolean fillRadius;
+
+ WheelSavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ private WheelSavedState(Parcel in) {
+ super(in);
+ this.mProgress = in.readFloat();
+ this.mTargetProgress = in.readFloat();
+ this.isSpinning = in.readByte() != 0;
+ this.spinSpeed = in.readFloat();
+ this.barWidth = in.readInt();
+ this.barColor = in.readInt();
+ this.rimWidth = in.readInt();
+ this.rimColor = in.readInt();
+ this.circleRadius = in.readInt();
+ this.linearProgress = in.readByte() != 0;
+ this.fillRadius = in.readByte() != 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeFloat(this.mProgress);
+ out.writeFloat(this.mTargetProgress);
+ out.writeByte((byte) (isSpinning ? 1 : 0));
+ out.writeFloat(this.spinSpeed);
+ out.writeInt(this.barWidth);
+ out.writeInt(this.barColor);
+ out.writeInt(this.rimWidth);
+ out.writeInt(this.rimColor);
+ out.writeInt(this.circleRadius);
+ out.writeByte((byte) (linearProgress ? 1 : 0));
+ out.writeByte((byte) (fillRadius ? 1 : 0));
+ }
+ }
+}
diff --git a/gacdialog/src/main/java/com/widget/dialog/ScreenUtil.java b/gacdialog/src/main/java/com/widget/dialog/ScreenUtil.java
new file mode 100644
index 0000000..cfd595b
--- /dev/null
+++ b/gacdialog/src/main/java/com/widget/dialog/ScreenUtil.java
@@ -0,0 +1,49 @@
+package com.widget.dialog;
+
+import android.content.Context;
+import android.util.DisplayMetrics;
+import android.view.WindowManager;
+
+public class ScreenUtil {
+
+ public static int height;
+ public static int width;
+ private Context context;
+
+ private static ScreenUtil instance;
+
+ private ScreenUtil(Context context) {
+ this.context = context;
+ WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ DisplayMetrics dm = new DisplayMetrics();
+ manager.getDefaultDisplay().getMetrics(dm);
+ width = dm.widthPixels;
+ height = dm.heightPixels;
+ }
+
+ public static ScreenUtil getInstance(Context context) {
+ if (instance == null) {
+ instance = new ScreenUtil(context);
+ }
+ return instance;
+ }
+
+
+
+
+
+ /**
+ * 得到手机屏幕的宽度, pix单位
+ */
+ public int getScreenWidth() {
+ return width;
+ }
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/gacdialog/src/main/res/drawable/iosdialog_btn_left_pressed.9.png b/gacdialog/src/main/res/drawable/iosdialog_btn_left_pressed.9.png
new file mode 100644
index 0000000..57b4abd
Binary files /dev/null and b/gacdialog/src/main/res/drawable/iosdialog_btn_left_pressed.9.png differ
diff --git a/gacdialog/src/main/res/drawable/iosdialog_btn_right_pressed.9.png b/gacdialog/src/main/res/drawable/iosdialog_btn_right_pressed.9.png
new file mode 100644
index 0000000..31a7b1c
Binary files /dev/null and b/gacdialog/src/main/res/drawable/iosdialog_btn_right_pressed.9.png differ
diff --git a/gacdialog/src/main/res/drawable/iosdialog_btn_single_pressed.9.png b/gacdialog/src/main/res/drawable/iosdialog_btn_single_pressed.9.png
new file mode 100644
index 0000000..8719e1a
Binary files /dev/null and b/gacdialog/src/main/res/drawable/iosdialog_btn_single_pressed.9.png differ
diff --git a/gacdialog/src/main/res/drawable/iosdialog_btn_trans_bg.png b/gacdialog/src/main/res/drawable/iosdialog_btn_trans_bg.png
new file mode 100644
index 0000000..0a4c3cd
Binary files /dev/null and b/gacdialog/src/main/res/drawable/iosdialog_btn_trans_bg.png differ
diff --git a/gacdialog/src/main/res/drawable/iosdialog_left_selector.xml b/gacdialog/src/main/res/drawable/iosdialog_left_selector.xml
new file mode 100644
index 0000000..70262c1
--- /dev/null
+++ b/gacdialog/src/main/res/drawable/iosdialog_left_selector.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/drawable/iosdialog_right_selector.xml b/gacdialog/src/main/res/drawable/iosdialog_right_selector.xml
new file mode 100644
index 0000000..bacd8c0
--- /dev/null
+++ b/gacdialog/src/main/res/drawable/iosdialog_right_selector.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/drawable/iosdialog_single_selector.xml b/gacdialog/src/main/res/drawable/iosdialog_single_selector.xml
new file mode 100644
index 0000000..0d97bfe
--- /dev/null
+++ b/gacdialog/src/main/res/drawable/iosdialog_single_selector.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/drawable/shape_iosdialog_bg.xml b/gacdialog/src/main/res/drawable/shape_iosdialog_bg.xml
new file mode 100644
index 0000000..b18e9b5
--- /dev/null
+++ b/gacdialog/src/main/res/drawable/shape_iosdialog_bg.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/layout/dialog_gac_list.xml b/gacdialog/src/main/res/layout/dialog_gac_list.xml
new file mode 100644
index 0000000..bc9099e
--- /dev/null
+++ b/gacdialog/src/main/res/layout/dialog_gac_list.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/layout/dialog_gac_picker.xml b/gacdialog/src/main/res/layout/dialog_gac_picker.xml
new file mode 100644
index 0000000..65d2bc5
--- /dev/null
+++ b/gacdialog/src/main/res/layout/dialog_gac_picker.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/layout/dialog_gac_progress.xml b/gacdialog/src/main/res/layout/dialog_gac_progress.xml
new file mode 100644
index 0000000..6078bc6
--- /dev/null
+++ b/gacdialog/src/main/res/layout/dialog_gac_progress.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/layout/dialog_ios.xml b/gacdialog/src/main/res/layout/dialog_ios.xml
new file mode 100644
index 0000000..c0010aa
--- /dev/null
+++ b/gacdialog/src/main/res/layout/dialog_ios.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/layout/dialog_photo_picker.xml b/gacdialog/src/main/res/layout/dialog_photo_picker.xml
new file mode 100644
index 0000000..6672757
--- /dev/null
+++ b/gacdialog/src/main/res/layout/dialog_photo_picker.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/layout/item_gac_textview.xml b/gacdialog/src/main/res/layout/item_gac_textview.xml
new file mode 100644
index 0000000..b6ecd78
--- /dev/null
+++ b/gacdialog/src/main/res/layout/item_gac_textview.xml
@@ -0,0 +1,14 @@
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/values/attrs.xml b/gacdialog/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..c1a5f69
--- /dev/null
+++ b/gacdialog/src/main/res/values/attrs.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gacdialog/src/main/res/values/colors.xml b/gacdialog/src/main/res/values/colors.xml
new file mode 100644
index 0000000..ebc9d8c
--- /dev/null
+++ b/gacdialog/src/main/res/values/colors.xml
@@ -0,0 +1,13 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
+ #e4e4e4
+ #535353
+ #ffffff
+
+ #353535
+ #177F5E
+
diff --git a/gacdialog/src/main/res/values/strings.xml b/gacdialog/src/main/res/values/strings.xml
new file mode 100644
index 0000000..5fba6ff
--- /dev/null
+++ b/gacdialog/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ GacDialog
+
diff --git a/gacdialog/src/test/java/com/gac/widget/gacdialog/ExampleUnitTest.java b/gacdialog/src/test/java/com/gac/widget/gacdialog/ExampleUnitTest.java
new file mode 100644
index 0000000..0336422
--- /dev/null
+++ b/gacdialog/src/test/java/com/gac/widget/gacdialog/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.gac.widget.gacdialog;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..aac7c9b
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..04e285f
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..451f7f5
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app', ':gacdialog'