├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── longsh
│ │ │ └── optionframedemo
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── longsh
│ │ │ └── optionframedemo
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── longsh
│ │ └── optionframedemo
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── OptionFrameLibrary
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── color.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── __picker_bg_dialog.xml
│ │ │ │ ├── bg_button_normal.xml
│ │ │ │ ├── bg_button_pressed.xml
│ │ │ │ ├── material_dialog_window.xml
│ │ │ │ ├── linearlayoutbtn.xml
│ │ │ │ ├── __picker_item_dialog_selector.xml
│ │ │ │ ├── button.xml
│ │ │ │ ├── material_card.xml
│ │ │ │ ├── __picker_item_dialog_selector_bottom.xml
│ │ │ │ └── __picker_item_dialog_selector_top.xml
│ │ │ ├── anim
│ │ │ │ ├── enter_anim.xml
│ │ │ │ └── out_anim.xml
│ │ │ └── layout
│ │ │ │ ├── __picker_dialog_photo_pager.xml
│ │ │ │ ├── __picker_item_dialog.xml
│ │ │ │ ├── item_bottom_popu.xml
│ │ │ │ ├── pupview.xml
│ │ │ │ └── layout_material_dialog.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── longsh
│ │ │ └── optionframelibrary
│ │ │ ├── adapter
│ │ │ ├── BottomPopuAdapter.java
│ │ │ └── CenterDialogAdapter.java
│ │ │ ├── OptionCenterDialog.java
│ │ │ ├── OptionBottomDialog.java
│ │ │ └── OptionMaterialDialog.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── longsh
│ │ │ └── optionframelibrary
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── longsh
│ │ └── optionframelibrary
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── image
├── er.png
├── si.png
├── wu.png
├── yi.gif
└── san.png
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':OptionFrameLibrary'
2 |
--------------------------------------------------------------------------------
/image/er.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/image/er.png
--------------------------------------------------------------------------------
/image/si.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/image/si.png
--------------------------------------------------------------------------------
/image/wu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/image/wu.png
--------------------------------------------------------------------------------
/image/yi.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/image/yi.gif
--------------------------------------------------------------------------------
/image/san.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/image/san.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OptionFrameDemo
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OptionFrameLibrary
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/q805699513/OptionFrame/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/__picker_bg_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/bg_button_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/bg_button_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/material_dialog_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ffffff
4 | #10000000
5 | #ff359ff2
6 | #00000000
7 | #DE000000
8 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/linearlayoutbtn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
5 |
6 |
7 | -
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/__picker_item_dialog_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
5 |
6 |
7 | -
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/anim/enter_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/anim/out_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/button.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/longsh/optionframedemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframedemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/test/java/com/longsh/optionframelibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/layout/__picker_dialog_photo_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/material_card.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 33.5dp
6 | 15sp
7 | 58.5dp
8 | 25dp
9 |
10 | 5dp
11 | 7dp
12 |
13 |
14 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/__picker_item_dialog_selector_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/layout/__picker_item_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/drawable/__picker_item_dialog_selector_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
5 |
6 |
7 |
10 |
11 |
12 | -
13 |
14 |
15 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1024m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/layout/item_bottom_popu.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
21 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/longsh/optionframedemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframedemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.longsh.optionframedemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/androidTest/java/com/longsh/optionframelibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.longsh.optionframelibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.longsh.optionframedemo"
8 | minSdkVersion 14
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.1.1'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':OptionFrameLibrary')
30 | }
31 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/layout/pupview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
17 |
18 |
30 |
31 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
29 |
30 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | lintOptions {
23 | abortOnError false
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | compile 'com.android.support:appcompat-v7:25.1.1'
33 | testCompile 'junit:junit:4.12'
34 | }
35 | publish {
36 | userOrg = 'longsh'//bintray.com用户名
37 | groupId = 'com.longsh'//jcenter上的路径
38 | artifactId = 'OptionFrame'//项目名称
39 | publishVersion = '1.0.0'//版本号
40 | desc = '一款Dialog库'//描述,不重要
41 | website = 'https://github.com/q805699513/OptionFrame'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
42 | }
43 | allprojects {
44 | tasks.withType(Javadoc) {
45 | options {
46 | encoding "UTF-8"
47 | charSet 'UTF-8'
48 | links "http://docs.oracle.com/javase/7/docs/api"
49 | }
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/java/com/longsh/optionframelibrary/adapter/BottomPopuAdapter.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.LinearLayout;
9 | import android.widget.TextView;
10 |
11 |
12 | import com.longsh.optionframelibrary.R;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * Created by Administrator on 2016/8/25.
18 | */
19 | public class BottomPopuAdapter extends BaseAdapter {
20 | private List lstImageItem;
21 | private Context mContext;
22 | public int po = 0;
23 |
24 | public BottomPopuAdapter(Context mContext, List arg0) {
25 | this.lstImageItem = arg0;
26 | this.mContext = mContext;
27 | }
28 |
29 | public int getCount() {
30 | return lstImageItem.size();
31 | }
32 |
33 | public Object getItem(int position) {
34 | return lstImageItem.get(position);
35 | }
36 |
37 | public long getItemId(int position) {
38 | return position;
39 | }
40 |
41 | public View getView(int position, View view, ViewGroup parent) {
42 |
43 |
44 | ViewHolder viewHolder = null;
45 | if (view == null) {
46 | viewHolder = new ViewHolder();
47 | view = LayoutInflater.from(mContext).inflate(R.layout.item_bottom_popu, null);
48 | viewHolder.addtext = (TextView) view.findViewById(R.id.addtext);
49 | viewHolder.addlayout = (LinearLayout) view.findViewById(R.id.addlayout);
50 | view.setTag(viewHolder);
51 | } else {
52 | viewHolder = (ViewHolder) view.getTag();
53 | }
54 | String str = lstImageItem.get(position);
55 | viewHolder.addtext.setText(str);
56 | return view;
57 | }
58 |
59 | class ViewHolder {
60 | TextView addtext;
61 | LinearLayout addlayout;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/java/com/longsh/optionframelibrary/OptionCenterDialog.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.ListView;
10 |
11 | import com.longsh.optionframelibrary.adapter.CenterDialogAdapter;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by q805699513 on 2017/3/1.
17 | */
18 |
19 | public class OptionCenterDialog {
20 | private AlertDialog albumDialog;
21 | private ListView dialog_lv;
22 |
23 | public void show(Context context, ArrayList longData) {
24 | albumDialog = new AlertDialog.Builder(context).create();
25 | albumDialog.setCanceledOnTouchOutside(true);
26 | albumDialog.setCancelable(true);
27 | View v = LayoutInflater.from(context).inflate(
28 | R.layout.__picker_dialog_photo_pager, null);
29 | albumDialog.show();
30 | albumDialog.setContentView(v);
31 | albumDialog.getWindow().setGravity(Gravity.CENTER);
32 | albumDialog.getWindow().setBackgroundDrawableResource(R.drawable.__picker_bg_dialog);
33 | dialog_lv = (ListView) v.findViewById(R.id.dialog_lv);
34 |
35 | CenterDialogAdapter photoDialogAdapter = new CenterDialogAdapter(context, longData);
36 | dialog_lv.setAdapter(photoDialogAdapter);
37 | // dialog_lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
38 | // @Override
39 | // public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
40 | //
41 | // albumDialog.dismiss();
42 | // }
43 | // });
44 | }
45 |
46 | public void setItemClickListener(AdapterView.OnItemClickListener listener) {
47 | dialog_lv.setOnItemClickListener(listener);
48 | }
49 |
50 | public void dismiss(){
51 | albumDialog.dismiss();
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/java/com/longsh/optionframelibrary/adapter/CenterDialogAdapter.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.TextView;
9 |
10 | import com.longsh.optionframelibrary.R;
11 |
12 | import java.util.ArrayList;
13 |
14 |
15 | /**
16 | * Created by Administrator on 2016/4/7.
17 | */
18 | public class CenterDialogAdapter extends BaseAdapter {
19 | private ArrayList lstImageItem;
20 | private Context mContext;
21 |
22 | public CenterDialogAdapter(Context mContext, ArrayList arg0) {
23 | this.lstImageItem = arg0;
24 | this.mContext = mContext;
25 | }
26 |
27 | public int getCount() {
28 | return lstImageItem.size();
29 | }
30 |
31 | public Object getItem(int position) {
32 | return lstImageItem.get(position);
33 | }
34 |
35 | public long getItemId(int position) {
36 | return position;
37 | }
38 |
39 | public View getView(int position, View view, ViewGroup parent) {
40 |
41 | ViewHolder viewHolder = null;
42 | if (view == null) {
43 | viewHolder = new ViewHolder();
44 | view = LayoutInflater.from(mContext).inflate(R.layout.__picker_item_dialog, null);
45 | viewHolder.tv_dialog = (TextView) view.findViewById(R.id.tv_dialog);
46 |
47 | view.setTag(viewHolder);
48 | } else {
49 | viewHolder = (ViewHolder) view.getTag();
50 | }
51 | if (position == 0) {
52 | viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector_top);
53 | } else if (position == getCount() - 1) {
54 | viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector_bottom);
55 | } else {
56 | viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector);
57 | }
58 |
59 | viewHolder.tv_dialog.setText(lstImageItem.get(position));
60 | return view;
61 | }
62 |
63 | class ViewHolder {
64 | TextView tv_dialog;
65 | }
66 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/java/com/longsh/optionframelibrary/OptionBottomDialog.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.drawable.BitmapDrawable;
6 | import android.os.Handler;
7 | import android.view.Gravity;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.WindowManager;
11 | import android.widget.AdapterView;
12 | import android.widget.LinearLayout;
13 | import android.widget.ListView;
14 | import android.widget.PopupWindow;
15 | import android.widget.RelativeLayout;
16 | import android.widget.TextView;
17 |
18 | import com.longsh.optionframelibrary.adapter.BottomPopuAdapter;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * Created by q805699513 on 2016/12/14.
24 | */
25 |
26 | public class OptionBottomDialog extends PopupWindow {
27 |
28 | private final ListView listView;
29 |
30 | public OptionBottomDialog(Context context, List listData) {
31 | super(context);
32 | final Activity activity = (Activity) context;
33 | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
34 | View view = inflater.inflate(R.layout.pupview, null);
35 | this.setContentView(view);
36 | this.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
37 | this.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
38 | RelativeLayout review = (RelativeLayout) view.findViewById(R.id.review);
39 | review.setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 | dismiss();
43 | }
44 | });
45 | TextView quxiao = (TextView) view.findViewById(R.id.quxiao);
46 | quxiao.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View v) {
49 | dismiss();
50 | }
51 | });
52 |
53 | listView = (ListView) view.findViewById(R.id.list);
54 | final BottomPopuAdapter popuSFAdapter = new BottomPopuAdapter(context, listData);
55 | listView.setAdapter(popuSFAdapter);
56 |
57 |
58 | // 设置外部可点击
59 | this.setFocusable(true);
60 | this.setOutsideTouchable(true);
61 | // ColorDrawable dw = new ColorDrawable(Color.parseColor("#90000000"));
62 | this.setBackgroundDrawable(new BitmapDrawable());
63 |
64 | this.setAnimationStyle(R.style.Animation);
65 |
66 | this.showAtLocation(activity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
67 | backgroundAlpha(0.65f,activity);
68 | this.setOnDismissListener(new PopupWindow.OnDismissListener() {
69 | @Override
70 | public void onDismiss() {
71 | new Handler().postDelayed(new Runnable() {
72 | @Override
73 | public void run() {
74 | backgroundAlpha(1.0f,activity);
75 | }
76 | },290);
77 | }
78 | });
79 | }
80 |
81 | public void setItemClickListener(AdapterView.OnItemClickListener listener) {
82 | listView.setOnItemClickListener(listener);
83 | }
84 |
85 | public void backgroundAlpha(float bgAlpha,Activity activity) {
86 | WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
87 | lp.alpha = bgAlpha; //0.0-1.0
88 | activity.getWindow().setAttributes(lp);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/longsh/optionframedemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframedemo;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.LinearLayout;
10 | import android.widget.Toast;
11 |
12 | import com.longsh.optionframelibrary.OptionBottomDialog;
13 | import com.longsh.optionframelibrary.OptionCenterDialog;
14 | import com.longsh.optionframelibrary.OptionMaterialDialog;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class MainActivity extends AppCompatActivity {
20 |
21 | private LinearLayout activity_main;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | activity_main = (LinearLayout) findViewById(R.id.activity_main);
28 | }
29 |
30 |
31 | public void QQDialog(View view) {
32 | List stringList = new ArrayList();
33 | stringList.add("拍照");
34 | stringList.add("从相册选择");
35 | final OptionBottomDialog optionBottomDialog = new OptionBottomDialog(MainActivity.this, stringList);
36 | optionBottomDialog.setItemClickListener(new AdapterView.OnItemClickListener() {
37 | @Override
38 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
39 | optionBottomDialog.dismiss();
40 | }
41 | });
42 | }
43 |
44 | public void WXCenterDialog(View view) {
45 | final ArrayList list = new ArrayList<>();
46 | list.add("标为已读");
47 | list.add("置顶聊天");
48 | list.add("删除该聊天");
49 | final OptionCenterDialog optionCenterDialog = new OptionCenterDialog();
50 | optionCenterDialog.show(MainActivity.this, list);
51 | optionCenterDialog.setItemClickListener(new AdapterView.OnItemClickListener() {
52 | @Override
53 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
54 | optionCenterDialog.dismiss();
55 | }
56 | });
57 | }
58 |
59 |
60 | public void WXDialog(View view) {
61 | final OptionMaterialDialog mMaterialDialog = new OptionMaterialDialog(MainActivity.this);
62 | mMaterialDialog
63 | // .setTitle("这是标题")
64 | // .setTitleTextColor(R.color.colorPrimary)
65 | // .setTitleTextSize((float) 22.5)
66 | .setMessage("支持所有布局文字大小颜色等设置。")
67 | // .setMessageTextColor(R.color.colorPrimary)
68 | // .setMessageTextSize((float) 16.5)
69 | .setPositiveButtonTextColor(R.color.colorAccent)
70 | // .setNegativeButtonTextColor(R.color.colorPrimary)
71 | // .setPositiveButtonTextSize(15)
72 | // .setNegativeButtonTextSize(15)
73 | .setPositiveButton("确定", new View.OnClickListener() {
74 | @Override
75 | public void onClick(View v) {
76 | mMaterialDialog.dismiss();
77 | }
78 | })
79 | .setNegativeButton("取消",
80 | new View.OnClickListener() {
81 | @Override
82 | public void onClick(View v) {
83 | mMaterialDialog.dismiss();
84 | }
85 | })
86 | .setCanceledOnTouchOutside(true)
87 | .setOnDismissListener(
88 | new DialogInterface.OnDismissListener() {
89 | @Override
90 | public void onDismiss(DialogInterface dialog) {
91 | // Toast.makeText(MainActivity.this, "onDismiss 取消", Toast.LENGTH_SHORT).show();
92 | }
93 | })
94 | .show();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/res/layout/layout_material_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
18 |
19 |
25 |
26 |
37 |
38 |
45 |
46 |
52 |
53 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
77 |
78 |
86 |
87 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OptionFrame
2 |
3 | 一款Android弹出框、对话框、Dialog、popuwindow
4 | ---
5 |
6 | # Example
7 |
8 |
9 |
10 |
11 |
12 |
13 | ---
14 |
15 | # Usage
16 |
17 | ### Gradle
18 |
19 | ```groovy
20 | dependencies {
21 |
22 | compile 'com.longsh:OptionFrame:1.0.0'
23 |
24 | }
25 | //由于内部使用的25的api,所以直接使用可能会跟你的版本的不同,造成导入问题。建议下载源码把gradle修改成你对应的api
26 | //后续有空可能会修改下
27 | ```
28 |
29 |
30 |
31 | ### 仿QQ底部弹出窗口
32 | ```java
33 | List stringList = new ArrayList();
34 | stringList.add("拍照");
35 | stringList.add("从相册选择");
36 |
37 | final OptionBottomDialog optionBottomDialog = new OptionBottomDialog(MainActivity.this, stringList);
38 | optionBottomDialog.setItemClickListener(new AdapterView.OnItemClickListener() {
39 | @Override
40 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
41 | optionBottomDialog.dismiss();
42 | }
43 | });
44 |
45 | ```
46 |
47 | ### 仿微信中间弹出框
48 | ```java
49 | final ArrayList list = new ArrayList<>();
50 | list.add("标为已读");
51 | list.add("置顶聊天");
52 | list.add("删除该聊天");
53 | final OptionCenterDialog optionCenterDialog = new OptionCenterDialog();
54 | optionCenterDialog.show(MainActivity.this, list);
55 | optionCenterDialog.setItemClickListener(new AdapterView.OnItemClickListener() {
56 | @Override
57 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
58 | optionCenterDialog.dismiss();
59 | }
60 | });
61 | ```
62 |
63 | ### Material Design风格对话框
64 | ```java
65 | final OptionMaterialDialog mMaterialDialog = new OptionMaterialDialog(MainActivity.this);
66 | mMaterialDialog.setTitle("这是标题")
67 | // .setTitleTextColor(R.color.colorPrimary)
68 | // .setTitleTextSize((float) 22.5)
69 | .setMessage("支持所有布局文字大小颜色等设置。")
70 | // .setMessageTextColor(R.color.colorPrimary)
71 | // .setMessageTextSize((float) 16.5)
72 | // .setPositiveButtonTextColor(R.color.colorAccent)
73 | // .setNegativeButtonTextColor(R.color.colorPrimary)
74 | // .setPositiveButtonTextSize(15)
75 | // .setNegativeButtonTextSize(15)
76 | .setPositiveButton("确定", new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | mMaterialDialog.dismiss();
80 | }
81 | })
82 | .setNegativeButton("取消",
83 | new View.OnClickListener() {
84 | @Override
85 | public void onClick(View v) {
86 | mMaterialDialog.dismiss();
87 | }
88 | })
89 | .setCanceledOnTouchOutside(true)
90 | .setOnDismissListener(
91 | new DialogInterface.OnDismissListener() {
92 | @Override
93 | public void onDismiss(DialogInterface dialog) {
94 | //对话框消失后回调
95 | }
96 | })
97 | .show();
98 | ```
99 |
100 |
101 | ### Version: 1.0.0
102 |
103 | 有其他弹出窗的需求可以给我提Issues,本文主要提供实现代码。其他弹窗布局可以自行下载源码修改
104 |
105 | ## License
106 | ```text
107 |
108 | Licensed under the Apache License, Version 2.0 (the "License");
109 | you may not use this file except in compliance with the License.
110 | You may obtain a copy of the License at
111 |
112 | http://www.apache.org/licenses/LICENSE-2.0
113 |
114 | Unless required by applicable law or agreed to in writing, software
115 | distributed under the License is distributed on an "AS IS" BASIS,
116 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
117 | See the License for the specific language governing permissions and
118 | limitations under the License.
119 | ```
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/OptionFrameLibrary/src/main/java/com/longsh/optionframelibrary/OptionMaterialDialog.java:
--------------------------------------------------------------------------------
1 | package com.longsh.optionframelibrary;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.graphics.Color;
7 | import android.graphics.drawable.ColorDrawable;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.Build;
10 | import android.support.annotation.ColorRes;
11 | import android.support.v4.content.ContextCompat;
12 | import android.view.Gravity;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.view.Window;
17 | import android.view.WindowManager;
18 | import android.view.inputmethod.InputMethodManager;
19 | import android.widget.AutoCompleteTextView;
20 | import android.widget.Button;
21 | import android.widget.EditText;
22 | import android.widget.LinearLayout;
23 | import android.widget.ListAdapter;
24 | import android.widget.ListView;
25 | import android.widget.TextView;
26 |
27 |
28 | public class OptionMaterialDialog {
29 |
30 | private final static int BUTTON_BOTTOM = 9;
31 | private final static int BUTTON_TOP = 9;
32 |
33 | private boolean mCancel;
34 | private Context mContext;
35 | private AlertDialog mAlertDialog;
36 | private Builder mBuilder;
37 | private View mView;
38 | private int mTitleResId;
39 | private CharSequence mTitle;
40 | private int mMessageResId;
41 | private CharSequence mMessage;
42 | private Button mPositiveButton;
43 | private LinearLayout.LayoutParams mLayoutParams;
44 | private Button mNegativeButton;
45 | private boolean mHasShow = false;
46 | private int mBackgroundResId = -1;
47 | private Drawable mBackgroundDrawable;
48 | private View mMessageContentView;
49 | private int mMessageContentViewResId;
50 | private DialogInterface.OnDismissListener mOnDismissListener;
51 | private int pId = -1, nId = -1;
52 | private String pText, nText;
53 | View.OnClickListener pListener, nListener;
54 | private int pTextColor = 0;
55 | private int nTextColor = 0;
56 | private int mTextColor = 0;
57 | private int tTextColor = 0;
58 | private float tTextSize = -1;
59 | private float mTextSize = -1;
60 | private float pTextSize = -1;
61 | private float nTextSize = -1;
62 |
63 |
64 | public OptionMaterialDialog(Context context) {
65 | this.mContext = context;
66 | }
67 |
68 |
69 | public void show() {
70 | if (!mHasShow) {
71 | mBuilder = new Builder();
72 | } else {
73 | mAlertDialog.show();
74 | }
75 | mHasShow = true;
76 | }
77 |
78 |
79 | public OptionMaterialDialog setView(View view) {
80 | mView = view;
81 | if (mBuilder != null) {
82 | mBuilder.setView(view);
83 | }
84 | return this;
85 | }
86 |
87 |
88 | public OptionMaterialDialog setContentView(View view) {
89 | mMessageContentView = view;
90 | mMessageContentViewResId = 0;
91 | if (mBuilder != null) {
92 | mBuilder.setContentView(mMessageContentView);
93 | }
94 | return this;
95 | }
96 |
97 |
98 | /**
99 | * Set a custom view resource to be the contents of the dialog.
100 | *
101 | * @param layoutResId resource ID to be inflated
102 | */
103 | public OptionMaterialDialog setContentView(int layoutResId) {
104 | mMessageContentViewResId = layoutResId;
105 | mMessageContentView = null;
106 | if (mBuilder != null) {
107 | mBuilder.setContentView(layoutResId);
108 | }
109 | return this;
110 | }
111 |
112 |
113 | public OptionMaterialDialog setBackground(Drawable drawable) {
114 | mBackgroundDrawable = drawable;
115 | if (mBuilder != null) {
116 | mBuilder.setBackground(mBackgroundDrawable);
117 | }
118 | return this;
119 | }
120 |
121 |
122 | public OptionMaterialDialog setBackgroundResource(int resId) {
123 | mBackgroundResId = resId;
124 | if (mBuilder != null) {
125 | mBuilder.setBackgroundResource(mBackgroundResId);
126 | }
127 | return this;
128 | }
129 |
130 |
131 | public void dismiss() {
132 | mAlertDialog.dismiss();
133 | }
134 |
135 |
136 | private int dip2px(float dpValue) {
137 | final float scale = mContext.getResources().getDisplayMetrics().density;
138 | return (int) (dpValue * scale + 0.5f);
139 | }
140 |
141 |
142 | private static boolean isLollipop() {
143 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
144 | }
145 |
146 |
147 | public OptionMaterialDialog setTitle(int resId) {
148 | mTitleResId = resId;
149 | if (mBuilder != null) {
150 | mBuilder.setTitle(resId);
151 | }
152 | return this;
153 | }
154 |
155 |
156 | public OptionMaterialDialog setTitle(CharSequence title) {
157 | mTitle = title;
158 | if (mBuilder != null) {
159 | mBuilder.setTitle(title);
160 | }
161 | return this;
162 | }
163 |
164 | public OptionMaterialDialog setTitleTextColor(@ColorRes int tTextColor) {
165 | this.tTextColor = tTextColor;
166 | if (mBuilder != null) {
167 | mBuilder.setTitleColor(tTextColor);
168 | }
169 | return this;
170 | }
171 |
172 | public OptionMaterialDialog setTitleTextSize(float tTextSize) {
173 | this.tTextSize = tTextSize;
174 | if (mBuilder != null) {
175 | mBuilder.setTitleSize(tTextSize);
176 | }
177 | return this;
178 | }
179 |
180 |
181 | public OptionMaterialDialog setMessage(int resId) {
182 | mMessageResId = resId;
183 | if (mBuilder != null) {
184 | mBuilder.setMessage(resId);
185 | }
186 | return this;
187 | }
188 |
189 |
190 | public OptionMaterialDialog setMessage(CharSequence message) {
191 | mMessage = message;
192 | if (mBuilder != null) {
193 | mBuilder.setMessage(message);
194 | }
195 | return this;
196 | }
197 |
198 |
199 | public OptionMaterialDialog setMessageTextColor(@ColorRes int mTextColor) {
200 | this.mTextColor = mTextColor;
201 | if (mBuilder != null) {
202 | mBuilder.setMessageColor(mTextColor);
203 | }
204 | return this;
205 | }
206 |
207 | public OptionMaterialDialog setMessageTextSize(float mTextSize) {
208 |
209 | this.mTextSize = mTextSize;
210 | if (mBuilder != null) {
211 | mBuilder.setMessageSize(mTextSize);
212 | }
213 | return this;
214 | }
215 |
216 | public OptionMaterialDialog setPositiveButtonTextColor(@ColorRes int pTextColor) {
217 | this.pTextColor = pTextColor;
218 | if (mBuilder != null && mPositiveButton != null) {
219 | mPositiveButton.setTextColor(ContextCompat.getColor(mContext, pTextColor));
220 | }
221 | return this;
222 | }
223 |
224 | public OptionMaterialDialog setPositiveButtonTextSize(float pTextSize) {
225 | this.pTextSize = pTextSize;
226 | if (mBuilder != null && mPositiveButton != null) {
227 | mPositiveButton.setTextSize(pTextSize);
228 | }
229 | return this;
230 | }
231 |
232 | public OptionMaterialDialog setNegativeButtonTextColor(@ColorRes int nTextColor) {
233 | this.nTextColor = nTextColor;
234 | if (mBuilder != null && mNegativeButton != null) {
235 | mNegativeButton.setTextColor(ContextCompat.getColor(mContext, nTextColor));
236 | }
237 | return this;
238 | }
239 |
240 | public OptionMaterialDialog setNegativeButtonTextSize(float nTextSize) {
241 | this.nTextSize = nTextSize;
242 | if (mBuilder != null && mNegativeButton != null) {
243 | mNegativeButton.setTextSize(nTextSize);
244 | }
245 | return this;
246 | }
247 |
248 | public OptionMaterialDialog setPositiveButton(int resId, final View.OnClickListener listener) {
249 | this.pId = resId;
250 | this.pListener = listener;
251 | return this;
252 | }
253 |
254 |
255 | public Button getPositiveButton() {
256 | return mPositiveButton;
257 | }
258 |
259 |
260 | public Button getNegativeButton() {
261 | return mNegativeButton;
262 | }
263 |
264 |
265 | public OptionMaterialDialog setPositiveButton(String text, final View.OnClickListener listener) {
266 | this.pText = text;
267 | this.pListener = listener;
268 | return this;
269 | }
270 |
271 |
272 | public OptionMaterialDialog setNegativeButton(int resId, final View.OnClickListener listener) {
273 | this.nId = resId;
274 | this.nListener = listener;
275 | return this;
276 | }
277 |
278 |
279 | public OptionMaterialDialog setNegativeButton(String text, final View.OnClickListener listener) {
280 | this.nText = text;
281 | this.nListener = listener;
282 | return this;
283 | }
284 |
285 |
286 | /**
287 | * Sets whether this dialog is canceled when touched outside the window's
288 | * bounds OR pressed the back key. If setting to true, the dialog is
289 | * set to be cancelable if not
290 | * already set.
291 | *
292 | * @param cancel Whether the dialog should be canceled when touched outside
293 | * the window OR pressed the back key.
294 | */
295 | public OptionMaterialDialog setCanceledOnTouchOutside(boolean cancel) {
296 | this.mCancel = cancel;
297 | if (mBuilder != null) {
298 | mBuilder.setCanceledOnTouchOutside(mCancel);
299 | }
300 | return this;
301 | }
302 |
303 |
304 | public OptionMaterialDialog setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
305 | this.mOnDismissListener = onDismissListener;
306 | return this;
307 | }
308 |
309 |
310 | private class Builder {
311 |
312 | private TextView mTitleView;
313 | private ViewGroup mMessageContentRoot;
314 | private TextView mMessageView;
315 | private Window mAlertDialogWindow;
316 | private LinearLayout mButtonLayout;
317 |
318 |
319 | private Builder() {
320 | mAlertDialog = new AlertDialog.Builder(mContext).create();
321 | mAlertDialog.show();
322 |
323 | mAlertDialog.getWindow()
324 | .clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
325 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
326 | mAlertDialog.getWindow()
327 | .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE);
328 |
329 | mAlertDialogWindow = mAlertDialog.getWindow();
330 | mAlertDialogWindow.setBackgroundDrawable(
331 | new ColorDrawable(Color.TRANSPARENT));
332 |
333 | View contentView = LayoutInflater.from(mContext)
334 | .inflate(R.layout.layout_material_dialog, null);
335 | contentView.setFocusable(true);
336 | contentView.setFocusableInTouchMode(true);
337 |
338 | mAlertDialogWindow.setBackgroundDrawableResource(R.drawable.material_dialog_window);
339 |
340 | mAlertDialogWindow.setContentView(contentView);
341 |
342 | mTitleView = (TextView) mAlertDialogWindow.findViewById(R.id.title);
343 | mMessageView = (TextView) mAlertDialogWindow.findViewById(R.id.message);
344 | mButtonLayout = (LinearLayout) mAlertDialogWindow.findViewById(R.id.buttonLayout);
345 | mPositiveButton = (Button) mButtonLayout.findViewById(R.id.btn_p);
346 | mNegativeButton = (Button) mButtonLayout.findViewById(R.id.btn_n);
347 | mMessageContentRoot = (ViewGroup) mAlertDialogWindow.findViewById(
348 | R.id.message_content_root);
349 | if (mView != null) {
350 | LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
351 | R.id.contentView);
352 | linearLayout.removeAllViews();
353 | linearLayout.addView(mView);
354 | }
355 | if (mTitleResId != 0) {
356 | setTitle(mTitleResId);
357 | }
358 | if (mTitle != null) {
359 | setTitle(mTitle);
360 | }
361 | if (tTextSize != -1) {
362 | setTitleSize(tTextSize);
363 | }
364 | if (tTextColor != 0) {
365 | setTitleColor(tTextColor);
366 | }
367 |
368 | if (mTitle == null && mTitleResId == 0) {
369 | mTitleView.setVisibility(View.GONE);
370 | }
371 | if (mMessageResId != 0) {
372 | setMessage(mMessageResId);
373 | }
374 | if (mTextColor != 0) {
375 | setMessageColor(mTextColor);
376 | }
377 | if (mMessage != null) {
378 | setMessage(mMessage);
379 | }
380 |
381 | if (mTextSize != -1) {
382 | setMessageSize(mTextSize);
383 | }
384 |
385 | if (pTextColor != 0) {
386 | mPositiveButton.setTextColor(ContextCompat.getColor(mContext, pTextColor));
387 | }
388 |
389 | if (nTextColor != 0) {
390 | mNegativeButton.setTextColor(ContextCompat.getColor(mContext, nTextColor));
391 | }
392 |
393 | if (pTextSize != 0) {
394 | mPositiveButton.setTextSize(pTextSize);
395 | }
396 |
397 | if (nTextSize != 0) {
398 | mNegativeButton.setTextSize(nTextSize);
399 | }
400 |
401 |
402 | if (pId != -1) {
403 | mPositiveButton.setVisibility(View.VISIBLE);
404 | mPositiveButton.setText(pId);
405 | mPositiveButton.setOnClickListener(pListener);
406 | if (isLollipop()) {
407 | mPositiveButton.setElevation(0);
408 | }
409 | }
410 | if (nId != -1) {
411 | mNegativeButton.setVisibility(View.VISIBLE);
412 | mNegativeButton.setText(nId);
413 | mNegativeButton.setOnClickListener(nListener);
414 | if (isLollipop()) {
415 | mNegativeButton.setElevation(0);
416 | }
417 | }
418 | if (!isNullOrEmpty(pText)) {
419 | mPositiveButton.setVisibility(View.VISIBLE);
420 | mPositiveButton.setText(pText);
421 | mPositiveButton.setOnClickListener(pListener);
422 | if (isLollipop()) {
423 | mPositiveButton.setElevation(0);
424 | }
425 | }
426 |
427 | if (!isNullOrEmpty(nText)) {
428 | mNegativeButton.setVisibility(View.VISIBLE);
429 | mNegativeButton.setText(nText);
430 | mNegativeButton.setOnClickListener(nListener);
431 | if (isLollipop()) {
432 | mNegativeButton.setElevation(0);
433 | }
434 | }
435 | if (isNullOrEmpty(pText) && pId == -1) {
436 | mPositiveButton.setVisibility(View.GONE);
437 | }
438 | if (isNullOrEmpty(nText) && nId == -1) {
439 | mNegativeButton.setVisibility(View.GONE);
440 | }
441 | if (mBackgroundResId != -1) {
442 | LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
443 | R.id.material_background);
444 | linearLayout.setBackgroundResource(mBackgroundResId);
445 | }
446 | if (mBackgroundDrawable != null) {
447 | LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
448 | R.id.material_background);
449 | linearLayout.setBackground(mBackgroundDrawable);
450 | }
451 |
452 | if (mMessageContentView != null) {
453 | this.setContentView(mMessageContentView);
454 | } else if (mMessageContentViewResId != 0) {
455 | this.setContentView(mMessageContentViewResId);
456 | }
457 | mAlertDialog.setCanceledOnTouchOutside(mCancel);
458 | mAlertDialog.setCancelable(mCancel);
459 | if (mOnDismissListener != null) {
460 | mAlertDialog.setOnDismissListener(mOnDismissListener);
461 | }
462 | }
463 |
464 |
465 | public void setTitle(int resId) {
466 | mTitleView.setText(resId);
467 | }
468 |
469 |
470 | public void setTitle(CharSequence title) {
471 | mTitleView.setText(title);
472 | }
473 |
474 |
475 | public void setMessage(int resId) {
476 | if (mMessageView != null) {
477 | mMessageView.setText(resId);
478 | }
479 | }
480 |
481 |
482 | public void setMessage(CharSequence message) {
483 | if (mMessageView != null) {
484 | mMessageView.setText(message);
485 | }
486 | }
487 |
488 | public void setMessageColor(int mTextColor) {
489 | if (mMessageView != null) {
490 | mMessageView.setTextColor(ContextCompat.getColor(mContext, mTextColor));
491 | }
492 | }
493 |
494 | public void setMessageSize(float mTextSize) {
495 | if (mMessageView != null) {
496 | mMessageView.setTextSize(mTextSize);
497 | }
498 | }
499 |
500 | public void setTitleColor(int tTextColor) {
501 | if (mTitleView != null) {
502 | mTitleView.setTextColor(ContextCompat.getColor(mContext, tTextColor));
503 | }
504 | }
505 |
506 | public void setTitleSize(float mTextsSize) {
507 | if (mTitleView != null) {
508 | mTitleView.setTextSize(mTextsSize);
509 | }
510 | }
511 |
512 | /**
513 | * dp转px
514 | *
515 | * @param dpValue dp值
516 | * @return px值
517 | */
518 | public int dp2px(float dpValue) {
519 | final float scale = mContext.getResources().getDisplayMetrics().density;
520 | return (int) (dpValue * scale + 0.5f);
521 | }
522 |
523 | /**
524 | * set positive button
525 | *
526 | * @param text the name of button
527 | */
528 | public void setPositiveButton(String text, final View.OnClickListener listener) {
529 | Button button = new Button(mContext);
530 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
531 | LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
532 | button.setLayoutParams(params);
533 | button.setBackgroundResource(R.drawable.material_card);
534 | button.setTextColor(Color.argb(255, 35, 159, 242));
535 | button.setText(text);
536 | button.setGravity(Gravity.CENTER);
537 | button.setTextSize(14);
538 | button.setPadding(dip2px(12), 0, dip2px(32), dip2px(BUTTON_BOTTOM));
539 | button.setOnClickListener(listener);
540 | mButtonLayout.addView(button);
541 | }
542 |
543 |
544 | /**
545 | * set negative button
546 | *
547 | * @param text the name of button
548 | */
549 | public void setNegativeButton(String text, final View.OnClickListener listener) {
550 | Button button = new Button(mContext);
551 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
552 | LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
553 | button.setLayoutParams(params);
554 | button.setBackgroundResource(R.drawable.material_card);
555 | button.setText(text);
556 | button.setTextColor(Color.argb(222, 0, 0, 0));
557 | button.setTextSize(14);
558 | button.setGravity(Gravity.CENTER);
559 | button.setPadding(0, 0, 0, dip2px(8));
560 | button.setOnClickListener(listener);
561 | if (mButtonLayout.getChildCount() > 0) {
562 | params.setMargins(20, 0, 10, dip2px(BUTTON_BOTTOM));
563 | button.setLayoutParams(params);
564 | mButtonLayout.addView(button, 1);
565 | } else {
566 | button.setLayoutParams(params);
567 | mButtonLayout.addView(button);
568 | }
569 | }
570 |
571 |
572 | public void setView(View view) {
573 | LinearLayout l = (LinearLayout) mAlertDialogWindow.findViewById(R.id.contentView);
574 | l.removeAllViews();
575 | ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
576 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
577 | view.setLayoutParams(layoutParams);
578 |
579 | view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
580 | @Override
581 | public void onFocusChange(View v, boolean hasFocus) {
582 | mAlertDialogWindow.setSoftInputMode(
583 | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
584 | // show imm
585 | InputMethodManager imm = (InputMethodManager) mContext.getSystemService(
586 | Context.INPUT_METHOD_SERVICE);
587 | imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
588 | InputMethodManager.HIDE_IMPLICIT_ONLY);
589 | }
590 | });
591 |
592 | l.addView(view);
593 |
594 | if (view instanceof ViewGroup) {
595 |
596 | ViewGroup viewGroup = (ViewGroup) view;
597 |
598 | for (int i = 0; i < viewGroup.getChildCount(); i++) {
599 | if (viewGroup.getChildAt(i) instanceof EditText) {
600 | EditText editText = (EditText) viewGroup.getChildAt(i);
601 | editText.setFocusable(true);
602 | editText.requestFocus();
603 | editText.setFocusableInTouchMode(true);
604 | }
605 | }
606 | for (int i = 0; i < viewGroup.getChildCount(); i++) {
607 | if (viewGroup.getChildAt(i) instanceof AutoCompleteTextView) {
608 | AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) viewGroup
609 | .getChildAt(i);
610 | autoCompleteTextView.setFocusable(true);
611 | autoCompleteTextView.requestFocus();
612 | autoCompleteTextView.setFocusableInTouchMode(true);
613 | }
614 | }
615 | }
616 | }
617 |
618 |
619 | public void setContentView(View contentView) {
620 | ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
621 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
622 | contentView.setLayoutParams(layoutParams);
623 | if (contentView instanceof ListView) {
624 | setListViewHeightBasedOnChildren((ListView) contentView);
625 | }
626 | LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
627 | R.id.message_content_view);
628 | if (linearLayout != null) {
629 | linearLayout.removeAllViews();
630 | linearLayout.addView(contentView);
631 | }
632 | for (int i = 0; i < (linearLayout != null ? linearLayout.getChildCount() : 0); i++) {
633 | if (linearLayout.getChildAt(i) instanceof AutoCompleteTextView) {
634 | AutoCompleteTextView autoCompleteTextView
635 | = (AutoCompleteTextView) linearLayout.getChildAt(i);
636 | autoCompleteTextView.setFocusable(true);
637 | autoCompleteTextView.requestFocus();
638 | autoCompleteTextView.setFocusableInTouchMode(true);
639 | }
640 | }
641 | }
642 |
643 |
644 | /**
645 | * Set a custom view resource to be the contents of the dialog. The
646 | * resource will be inflated into a ScrollView.
647 | *
648 | * @param layoutResId resource ID to be inflated
649 | */
650 | public void setContentView(int layoutResId) {
651 | mMessageContentRoot.removeAllViews();
652 | // Not setting this to the other content view because user has defined their own
653 | // layout params, and we don't want to overwrite those.
654 | LayoutInflater.from(mMessageContentRoot.getContext())
655 | .inflate(layoutResId, mMessageContentRoot);
656 | }
657 |
658 |
659 | public void setBackground(Drawable drawable) {
660 | LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
661 | R.id.material_background);
662 | linearLayout.setBackground(drawable);
663 | }
664 |
665 |
666 | public void setBackgroundResource(int resId) {
667 | LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
668 | R.id.material_background);
669 | linearLayout.setBackgroundResource(resId);
670 | }
671 |
672 |
673 | public void setCanceledOnTouchOutside(boolean canceledOnTouchOutside) {
674 | mAlertDialog.setCanceledOnTouchOutside(canceledOnTouchOutside);
675 | mAlertDialog.setCancelable(canceledOnTouchOutside);
676 | }
677 | }
678 |
679 |
680 | private boolean isNullOrEmpty(String nText) {
681 | return nText == null || nText.isEmpty();
682 | }
683 |
684 |
685 | private void setListViewHeightBasedOnChildren(ListView listView) {
686 | ListAdapter listAdapter = listView.getAdapter();
687 | if (listAdapter == null) {
688 | // pre-condition
689 | return;
690 | }
691 |
692 | int totalHeight = 0;
693 | for (int i = 0; i < listAdapter.getCount(); i++) {
694 | View listItem = listAdapter.getView(i, null, listView);
695 | listItem.measure(0, 0);
696 | totalHeight += listItem.getMeasuredHeight();
697 | }
698 |
699 | ViewGroup.LayoutParams params = listView.getLayoutParams();
700 | params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
701 | listView.setLayoutParams(params);
702 | }
703 | }
704 |
705 |
--------------------------------------------------------------------------------