Commit c55b3db1a78da9815fa4b6b644930c6d109a2c76

Authored by xiongwei
1 parent b4a2140e72
Exists in master

自定义对话框,选择教材页,电子保卡弹出,16-开始学习体验,填写保卡-手机验证。等等界面的编写。

Showing 72 changed files with 3994 additions and 18 deletions   Show diff stats
PersonalCenter/.idea/gradle.xml
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="GradleSettings"> 3 <component name="GradleSettings">
4 <option name="linkedExternalProjectsSettings"> 4 <option name="linkedExternalProjectsSettings">
5 <GradleProjectSettings> 5 <GradleProjectSettings>
6 <option name="distributionType" value="DEFAULT_WRAPPED" /> 6 <option name="distributionType" value="DEFAULT_WRAPPED" />
7 <option name="externalProjectPath" value="$PROJECT_DIR$" /> 7 <option name="externalProjectPath" value="$PROJECT_DIR$" />
8 <option name="modules"> 8 <option name="modules">
9 <set> 9 <set>
10 <option value="$PROJECT_DIR$" /> 10 <option value="$PROJECT_DIR$" />
11 <option value="$PROJECT_DIR$/app" /> 11 <option value="$PROJECT_DIR$/app" />
12 <option value="$PROJECT_DIR$/circledialog" />
12 </set> 13 </set>
13 </option> 14 </option>
14 <option name="resolveModulePerSourceSet" value="false" /> 15 <option name="resolveModulePerSourceSet" value="false" />
15 </GradleProjectSettings> 16 </GradleProjectSettings>
16 </option> 17 </option>
17 </component> 18 </component>
18 </project> 19 </project>
PersonalCenter/.idea/misc.xml
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="EntryPointsManager"> 3 <component name="EntryPointsManager">
4 <entry_points version="2.0" /> 4 <entry_points version="2.0" />
5 </component> 5 </component>
6 <component name="NullableNotNullManager"> 6 <component name="NullableNotNullManager">
7 <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> 7 <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
8 <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> 8 <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
9 <option name="myNullables"> 9 <option name="myNullables">
10 <value> 10 <value>
11 <list size="4"> 11 <list size="4">
12 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> 12 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
13 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> 13 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
14 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> 14 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
15 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> 15 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
16 </list> 16 </list>
17 </value> 17 </value>
18 </option> 18 </option>
19 <option name="myNotNulls"> 19 <option name="myNotNulls">
20 <value> 20 <value>
21 <list size="4"> 21 <list size="4">
22 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> 22 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
23 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> 23 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
24 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> 24 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
25 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> 25 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
26 </list> 26 </list>
27 </value> 27 </value>
28 </option> 28 </option>
29 </component> 29 </component>
30 <component name="ProjectLevelVcsManager" settingsEditedManually="false"> 30 <component name="ProjectLevelVcsManager" settingsEditedManually="false">
31 <OptionsSetting value="true" id="Add" /> 31 <OptionsSetting value="true" id="Add" />
32 <OptionsSetting value="true" id="Remove" /> 32 <OptionsSetting value="true" id="Remove" />
33 <OptionsSetting value="true" id="Checkout" /> 33 <OptionsSetting value="true" id="Checkout" />
34 <OptionsSetting value="true" id="Update" /> 34 <OptionsSetting value="true" id="Update" />
35 <OptionsSetting value="true" id="Status" /> 35 <OptionsSetting value="true" id="Status" />
36 <OptionsSetting value="true" id="Edit" /> 36 <OptionsSetting value="true" id="Edit" />
37 <ConfirmationsSetting value="0" id="Add" /> 37 <ConfirmationsSetting value="0" id="Add" />
38 <ConfirmationsSetting value="0" id="Remove" /> 38 <ConfirmationsSetting value="0" id="Remove" />
39 </component> 39 </component>
40 <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> 40 <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
41 <output url="file://$PROJECT_DIR$/build/classes" /> 41 <output url="file://$PROJECT_DIR$/build/classes" />
42 </component> 42 </component>
43 <component name="ProjectType"> 43 <component name="ProjectType">
44 <option name="id" value="Android" /> 44 <option name="id" value="Android" />
45 </component> 45 </component>
46 <component name="masterDetails"> 46 <component name="masterDetails">
47 <states> 47 <states>
48 <state key="ProjectJDKs.UI"> 48 <state key="ProjectJDKs.UI">
49 <settings> 49 <settings>
50 <last-edited>1.8</last-edited> 50 <last-edited>1.8</last-edited>
51 <splitter-proportions> 51 <splitter-proportions>
52 <option name="proportions"> 52 <option name="proportions">
53 <list> 53 <list>
54 <option value="0.2" /> 54 <option value="0.2" />
55 </list> 55 </list>
56 </option> 56 </option>
57 </splitter-proportions> 57 </splitter-proportions>
58 </settings> 58 </settings>
59 </state> 59 </state>
60 </states> 60 </states>
61 </component> 61 </component>
62 </project> 62 </project>
PersonalCenter/.idea/modules.xml
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="ProjectModuleManager"> 3 <component name="ProjectModuleManager">
4 <modules> 4 <modules>
5 <module fileurl="file://$PROJECT_DIR$/PersonalCenter.iml" filepath="$PROJECT_DIR$/PersonalCenter.iml" /> 5 <module fileurl="file://$PROJECT_DIR$/PersonalCenter.iml" filepath="$PROJECT_DIR$/PersonalCenter.iml" />
6 <module fileurl="file://$PROJECT_DIR$/PersonalCenter.iml" filepath="$PROJECT_DIR$/PersonalCenter.iml" />
7 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
6 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> 8 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
9 <module fileurl="file://$PROJECT_DIR$/circledialog/circledialog.iml" filepath="$PROJECT_DIR$/circledialog/circledialog.iml" />
7 </modules> 10 </modules>
8 </component> 11 </component>
9 </project> 12 </project>
PersonalCenter/app/build.gradle
1 apply plugin: 'com.android.application' 1 apply plugin: 'com.android.application'
2 2
3 android { 3 android {
4 compileSdkVersion 25 4 compileSdkVersion 25
5 buildToolsVersion "25.0.3" 5 buildToolsVersion "25.0.3"
6 defaultConfig { 6 defaultConfig {
7 applicationId "com.hjx.personalcenter" 7 applicationId "com.hjx.personalcenter"
8 minSdkVersion 9 8 minSdkVersion 15
9 targetSdkVersion 25 9 targetSdkVersion 25
10 versionCode 1 10 versionCode 1
11 versionName "1.0" 11 versionName "1.0"
12 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 } 13 }
14 buildTypes { 14 buildTypes {
15 release { 15 release {
16 minifyEnabled false 16 minifyEnabled false
17 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 } 18 }
19 } 19 }
20 } 20 }
21 21
22 dependencies { 22 dependencies {
23 compile fileTree(dir: 'libs', include: ['*.jar']) 23 compile fileTree(include: ['*.jar'], dir: 'libs')
24 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 24 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 exclude group: 'com.android.support', module: 'support-annotations' 25 exclude group: 'com.android.support', module: 'support-annotations'
26 }) 26 })
27 compile 'com.android.support:appcompat-v7:25.3.1' 27 compile 'com.android.support:appcompat-v7:25.3.1'
28 testCompile 'junit:junit:4.12' 28 testCompile 'junit:junit:4.12'
29 compile project(':circledialog')
29 } 30 }
30 31
PersonalCenter/app/src/main/AndroidManifest.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.hjx.personalcenter"> 3 package="com.hjx.personalcenter">
4 4
5 <application 5 <application
6 android:allowBackup="true" 6 android:allowBackup="true"
7 android:icon="@mipmap/ic_launcher" 7 android:icon="@mipmap/ic_launcher"
8 android:label="@string/app_name" 8 android:label="@string/app_name"
9 android:supportsRtl="true" 9 android:supportsRtl="true"
10 android:theme="@style/Theme.AppCompat.NoActionBar"> 10 android:theme="@style/Theme.AppCompat.NoActionBar">
11 <activity 11 <activity
12 android:name=".activity.MainActivity" 12 android:name=".activity.MainActivity"
13 android:launchMode="singleTask" 13 android:launchMode="singleTask"
14 android:screenOrientation="landscape"> 14 android:screenOrientation="landscape">
15 <intent-filter> 15 <intent-filter>
16 <action android:name="android.intent.action.MAIN" /> 16 <action android:name="android.intent.action.MAIN" />
17 17
18 <category android:name="android.intent.category.LAUNCHER" /> 18 <category android:name="android.intent.category.LAUNCHER" />
19 </intent-filter> 19 </intent-filter>
20 </activity> 20 </activity>
21 <activity 21 <activity
22 android:name=".activity.LoginAndRegisterActivity" 22 android:name=".activity.LoginAndRegisterActivity"
23 android:launchMode="singleTask" 23 android:launchMode="singleTask"
24 android:screenOrientation="landscape"> 24 android:screenOrientation="landscape">
25 25
26 </activity> 26 </activity>
27 <activity 27 <activity
28 android:name=".activity.ForgotPasswordActivity" 28 android:name=".activity.ForgotPasswordActivity"
29 android:launchMode="singleTask" 29 android:launchMode="singleTask"
30 android:screenOrientation="landscape"> 30 android:screenOrientation="landscape">
31 31
32 </activity> 32 </activity>
33 <activity 33 <activity
34 android:name=".activity.ChangePasswordActivity" 34 android:name=".activity.ChangePasswordActivity"
35 android:launchMode="singleTask" 35 android:launchMode="singleTask"
36 android:screenOrientation="landscape"> 36 android:screenOrientation="landscape">
37 37
38 </activity> 38 </activity>
39 <activity 39 <activity
40 android:name=".activity.RegisterInfoActivity" 40 android:name=".activity.RegisterInfoActivity"
41 android:launchMode="singleTask" 41 android:launchMode="singleTask"
42 android:screenOrientation="landscape"> 42 android:screenOrientation="landscape">
43 43
44 </activity> 44 </activity>
45 <activity 45 <activity
46 android:name=".activity.ElectronicCardValidationActivity" 46 android:name=".activity.ElectronicCardValidationActivity"
47 android:launchMode="singleTask" 47 android:launchMode="singleTask"
48 android:screenOrientation="landscape"> 48 android:screenOrientation="landscape">
49 49
50 </activity> 50 </activity>
51 <activity 51 <activity
52 android:name=".activity.ChangeBangDingActivity" 52 android:name=".activity.ChangeBangDingActivity"
53 android:launchMode="singleTask" 53 android:launchMode="singleTask"
54 android:screenOrientation="landscape"> 54 android:screenOrientation="landscape">
55 55
56 </activity> 56 </activity>
57 <activity 57 <activity
58 android:name=".activity.ChangeElectronicCardInfoActivity" 58 android:name=".activity.ChangeElectronicCardInfoActivity"
59 android:launchMode="singleTask" 59 android:launchMode="singleTask"
60 android:screenOrientation="landscape"> 60 android:screenOrientation="landscape">
61 61
62 </activity> 62 </activity>
63 <activity 63 <activity
64 android:name=".activity.ChangeEletronicCardPhone" 64 android:name=".activity.ChangeEletronicCardPhone"
65 android:launchMode="singleTask" 65 android:launchMode="singleTask"
66 android:screenOrientation="landscape"> 66 android:screenOrientation="landscape">
67 67
68 </activity> 68 </activity>
69 <activity
70 android:name=".activity.ChoiseTextBookActivity"
71 android:launchMode="singleTask"
72 android:screenOrientation="landscape">
73
74 </activity>
75 <activity
76 android:name=".activity.TheStartPageActivity"
77 android:launchMode="singleTask"
78 android:screenOrientation="landscape">
79
80 </activity>
69 </application> 81 </application>
70 82
71 </manifest> 83 </manifest>
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChoiseTextBookActivity.java
File was created 1 package com.hjx.personalcenter.activity;
2
3 import android.os.Bundle;
4 import android.support.v7.app.AppCompatActivity;
5 import android.view.View;
6 import android.widget.Button;
7 import android.widget.GridView;
8 import android.widget.SimpleAdapter;
9
10 import com.hjx.personalcenter.R;
11 import com.hjx.personalcenter.customdialog.ElectronicCardDialog;
12
13 import java.util.ArrayList;
14 import java.util.HashMap;
15 import java.util.List;
16 import java.util.Map;
17
18 /**选择教材
19 * Created by h on 2017/8/10.
20 */
21
22 public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener {
23 private GridView gridView;
24 private Button btn_ok;
25 private List<Map<String, Object>> data_list;
26 private SimpleAdapter sim_adapter;
27 // 图片封装为一个数组
28 private int[] icon = { R.mipmap.ic_launcher, R.mipmap.ic_launcher,
29 R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher,
30 R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher,
31 R.mipmap.ic_launcher};
32 private String[] subject = { "语文", "数学", "英语", "物理", "化学", "生物", "政治",
33 "历史", "地理" };
34 private String[] publish = { "人民教育出版社", "人民教育出版社", "人民教育出版社",
35 "人民教育出版社", "人民教育出版社", "人民教育出版社", "人民教育出版社",
36 "人民教育出版社", "人民教育出版社" };
37 @Override
38 protected void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState);
40 setContentView(R.layout.activity_choisetextbook);
41 initView();
42 initData();
43 initLister();
44 }
45
46 private void initView() {
47 gridView = (GridView) findViewById(R.id.grideview);
48 btn_ok = (Button) findViewById(R.id.btn_ok);
49 }
50
51 private void initData() {
52 data_list = new ArrayList<Map<String, Object>>();
53 getData();
54 String [] from ={"image","text","text1"};
55 int [] to = {R.id.image,R.id.text};
56 sim_adapter = new SimpleAdapter(this, data_list, R.layout.activity_choisetextbook_items, from, to);
57 //配置适配器
58 gridView.setAdapter(sim_adapter);
59
60 }
61
62 private void initLister() {
63 btn_ok.setOnClickListener(this);
64
65 }
66 public List<Map<String, Object>> getData(){
67 //cion和iconName的长度是相同的,这里任选其一都可以
68 for(int i=0;i<icon.length;i++){
69 Map<String, Object> map = new HashMap<String, Object>();
70 map.put("image", icon[i]);
71 map.put("text", subject[i]);
72 map.put("text1", publish[i]);
73 data_list.add(map);
74 }
75
76 return data_list;
77 }
78
79 @Override
80 public void onClick(View v) {
81 switch (v.getId()){
82 case R.id.btn_ok:
83 ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog");
84 break;
85 }
86
87 }
88 }
89
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.app.Activity; 3 import android.content.Intent;
4 import android.app.AlertDialog;
5 import android.content.DialogInterface;
6 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity;
7 import android.view.View; 6 import android.view.View;
8 import android.widget.Button; 7 import android.widget.Button;
9 import android.widget.EditText; 8 import android.widget.EditText;
10 import android.widget.TextView; 9 import android.widget.TextView;
11 import android.widget.Toast;
12 10
13 import com.hjx.personalcenter.R; 11 import com.hjx.personalcenter.R;
12 import com.hjx.personalcenter.customdialog.ListDialog;
14 13
15 /**填写注册信息 熊巍 14 /**填写注册信息 熊巍
16 * Created by h on 2017/8/9. 15 * Created by h on 2017/8/9.
17 */ 16 */
18 17
19 public class RegisterInfoActivity extends Activity implements View.OnClickListener { 18 public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener {
20 private EditText et_username; 19 private EditText et_username;
21 private TextView et_region,et_grade,et_school; 20 private TextView et_region,et_grade,et_school;
22 private Button btn_ok; 21 private Button btn_ok;
23 String[] items; 22 String[] items;
24 23
25 @Override 24 @Override
26 protected void onCreate(Bundle savedInstanceState) { 25 protected void onCreate(Bundle savedInstanceState) {
27 super.onCreate(savedInstanceState); 26 super.onCreate(savedInstanceState);
28 setContentView(R.layout.activity_registerinfo); 27 setContentView(R.layout.activity_registerinfo);
29 initView(); 28 initView();
30 initData(); 29 initData();
31 initLister(); 30 initLister();
32 } 31 }
33 32
34 private void initView() { 33 private void initView() {
35 et_username = (EditText) findViewById(R.id.et_username); 34 et_username = (EditText) findViewById(R.id.et_username);
36 et_region = (TextView) findViewById(R.id.et_region); 35 et_region = (TextView) findViewById(R.id.et_region);
37 et_grade = (TextView) findViewById(R.id.et_grade); 36 et_grade = (TextView) findViewById(R.id.et_grade);
38 et_school = (TextView) findViewById(R.id.et_school); 37 et_school = (TextView) findViewById(R.id.et_school);
39 btn_ok = (Button) findViewById(R.id.btn_ok); 38 btn_ok = (Button) findViewById(R.id.btn_ok);
40 39
41 40
42 } 41 }
43 42
44 private void initData() { 43 private void initData() {
45 items = new String[] { "魏", "蜀", "吴" }; 44 items = new String[] { "魏", "蜀", "吴" };
46 45
47 } 46 }
48 47
49 private void initLister() { 48 private void initLister() {
50 et_region.setOnClickListener(this); 49 et_region.setOnClickListener(this);
51 et_grade.setOnClickListener(this); 50 et_grade.setOnClickListener(this);
52 et_school.setOnClickListener(this); 51 et_school.setOnClickListener(this);
52 btn_ok.setOnClickListener(this);
53 53
54 54
55 } 55 }
56 56
57 @Override 57 @Override
58 public void onClick(View v) { 58 public void onClick(View v) {
59 switch (v.getId()){ 59 switch (v.getId()){
60 case R.id.et_region: 60 case R.id.et_region:
61 break; 61 break;
62 case R.id.et_grade: 62 case R.id.et_grade:
63 choisegrade(); 63 choisegrade();
64 break; 64 break;
65 case R.id.et_school: 65 case R.id.et_school:
66 break; 66 break;
67 case R.id.btn_ok: 67 case R.id.btn_ok:
68 Intent intent = new Intent();
69 intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class);
70 startActivity(intent);
71 overridePendingTransition(R.anim.rightin, R.anim.rightout);
68 break; 72 break;
69 } 73 }
70 74
71 } 75 }
72 76
73 private void choisegrade() { 77 private void choisegrade() {
74 AlertDialog dialog = new AlertDialog.Builder(this) 78 ListDialog.getInstance().show(getSupportFragmentManager(), "ListDialog");
75 .setTitle("选择年级") 79
76 .setItems(items, new DialogInterface.OnClickListener() {
77 @Override
78 public void onClick(DialogInterface dialog, int which) {
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/TheStartPageActivity.java
File was created 1 package com.hjx.personalcenter.activity;
2
3 import android.app.Activity;
4 import android.os.Bundle;
5
6 import com.hjx.personalcenter.R;
7
8 /**
9 * Created by h on 2017/8/10.
10 */
11
12 public class TheStartPageActivity extends Activity{
13 @Override
14 protected void onCreate(Bundle savedInstanceState) {
15 super.onCreate(savedInstanceState);
16 setContentView(R.layout.activity_start_page);
17 }
18 }
19
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ElectronicCardDialog.java
File was created 1 package com.hjx.personalcenter.customdialog;
2
3 import android.content.Context;
4 import android.content.Intent;
5 import android.os.Bundle;
6 import android.view.LayoutInflater;
7 import android.view.View;
8 import android.view.ViewGroup;
9
10 import com.hjx.personalcenter.R;
11 import com.hjx.personalcenter.activity.TheStartPageActivity;
12 import com.mylhyl.circledialog.BaseCircleDialog;
13 import com.mylhyl.circledialog.res.values.CircleDimen;
14
15 /**
16 * Created by h on 2017/8/10.
17 */
18
19 public class ElectronicCardDialog extends BaseCircleDialog {
20 public static ElectronicCardDialog getInstance() {
21 ElectronicCardDialog dialogFragment = new ElectronicCardDialog();
22 dialogFragment.setCanceledBack(true);
23 dialogFragment.setCanceledOnTouchOutside(true);
24 dialogFragment.setRadius(CircleDimen.RADIUS);
25 dialogFragment.setWidth(0.8f);
26 return dialogFragment;
27 }
28 @Override
29 public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
30 return inflater.inflate(R.layout.custom_adilog_electroniccard, container, false);
31 }
32 @Override
33 public void onActivityCreated(Bundle savedInstanceState) {
34 super.onActivityCreated(savedInstanceState);
35 getView().findViewById(R.id.fill_card).setOnClickListener(new View.OnClickListener() {
36 @Override
37 public void onClick(View v) {
38 Intent intent = new Intent();
39 intent.setClass(getActivity(),TheStartPageActivity.class);
40 startActivity(intent);
41 getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout);
42
43 }
44 });
45
46 }
47
48 }
49
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ListDialog.java
File was created 1 package com.hjx.personalcenter.customdialog;
2
3 import android.content.Context;
4 import android.os.Bundle;
5 import android.view.LayoutInflater;
6 import android.view.View;
7 import android.view.ViewGroup;
8 import android.widget.AdapterView;
9 import android.widget.ArrayAdapter;
10 import android.widget.ListView;
11 import android.widget.Toast;
12
13 import com.hjx.personalcenter.R;
14 import com.mylhyl.circledialog.BaseCircleDialog;
15 import com.mylhyl.circledialog.res.values.CircleDimen;
16
17 import java.util.ArrayList;
18
19 /**自定义列表对话框
20 * Created by h on 2017/8/10.
21 */
22
23 public class ListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener {
24 ArrayAdapter listadapter;
25 ListView listView;
26 ArrayList<String> data = new ArrayList<>();
27 public static ListDialog getInstance() {
28 ListDialog dialogFragment = new ListDialog();
29 dialogFragment.setCanceledBack(true);
30 dialogFragment.setCanceledOnTouchOutside(true);
31 dialogFragment.setRadius(CircleDimen.RADIUS);
32 dialogFragment.setWidth(0.5f);
33 return dialogFragment;
34 }
35 @Override
36 public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
37
38 return inflater.inflate(R.layout.custom_adilog_list, container, false);
39 }
40 @Override
41 public void onActivityCreated(Bundle savedInstanceState) {
42 super.onActivityCreated(savedInstanceState);
43 listView = (ListView) getView().findViewById(R.id.listadapter);
44 for (int i=0;i<=50;i++){
45 data.add("sss"+i);
46 }
47
48 listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data);
49 listView.setAdapter(listadapter);
50 listView.setOnItemClickListener(this);
51
52 }
53
54 @Override
55 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
56 Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show();
57
58 dismiss();
59
60 }
61 }
62
PersonalCenter/app/src/main/res/drawable/corcle_white_bg.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android"
3 android:shape="rectangle">
4 <solid
5 android:color="@color/white"/>
6 <corners
7 android:bottomLeftRadius="100dp"
8 android:topLeftRadius="100dp"
9 android:bottomRightRadius="100dp"
10 android:topRightRadius="100dp"/>
11 <stroke android:width="1dp"
12 android:color="@color/cutoff_line"/>
13 </shape>
PersonalCenter/app/src/main/res/layout/activity_choisetextbook.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:background="@color/white">
6 <RelativeLayout
7 android:id="@+id/title"
8 android:layout_width="match_parent"
9 android:layout_height="wrap_content"
10 android:background="@color/login_text_blue"
11 android:minHeight="50dp" >
12
13 <ImageView
14 android:id="@+id/cancel"
15 android:layout_width="wrap_content"
16 android:layout_height="wrap_content"
17 android:layout_centerVertical="true"
18 android:paddingLeft="20dp"
19 android:paddingRight="20dp"
20 android:src="@mipmap/title_back" />
21
22 <TextView
23 android:id="@+id/menu_title"
24 android:layout_width="wrap_content"
25 android:layout_height="wrap_content"
26 android:layout_centerInParent="true"
27 android:text="@string/string_textbook_info"
28 android:textColor="@android:color/white"
29 android:textSize="22sp" />
30 </RelativeLayout>
31 <GridView
32 android:id="@+id/grideview"
33 android:layout_marginTop="10dp"
34 android:layout_width="match_parent"
35 android:layout_height="wrap_content"
36 android:layout_below="@+id/title"
37 android:numColumns="5">
38
39 </GridView>
40 <LinearLayout
41 android:layout_width="match_parent"
42 android:layout_height="match_parent"
43
44 android:background="#ffffffff"
45 android:layout_below="@+id/grideview"
46 android:orientation="vertical"
47 android:paddingLeft="250dp"
48 android:paddingRight="250dp">
49 <Button
50 android:id="@+id/btn_ok"
51 style="@style/button_login_register_style"
52 android:layout_marginTop="30dp"
53 android:text="@string/string_regist_next" />
54 </LinearLayout>
55
56
57 </RelativeLayout>
PersonalCenter/app/src/main/res/layout/activity_choisetextbook_items.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 android:gravity="center"
7 android:padding="20dp">
8 <ImageView
9 android:src="@mipmap/ic_launcher"
10 android:id="@+id/image"
11 android:layout_width="80dp"
12 android:layout_height="120dp"
13
14 />
15 <TextView
16 android:id="@+id/text"
17 android:layout_marginTop="5dp"
18 android:textSize="17sp"
19 android:layout_width="wrap_content"
20 android:layout_height="wrap_content"
21 android:textColor="@color/login_text_black"
22 android:text="语文"
23 />
24 <TextView
25 android:id="@+id/tv_publish"
26 android:layout_marginTop="5dp"
27 android:textSize="14sp"
28 android:layout_width="wrap_content"
29 android:layout_height="wrap_content"
30 android:textColor="@color/login_text_black"
31 android:text="人民教育出版社"
32 />
33
34 </LinearLayout>
PersonalCenter/app/src/main/res/layout/activity_start_page.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 android:background="@mipmap/startpage">
7 <RelativeLayout
8 android:layout_width="wrap_content"
9 android:layout_height="wrap_content"
10 android:layout_alignParentBottom="true"
11 android:paddingLeft="250dp"
12 android:paddingRight="250dp">
13 <Button
14 android:id="@+id/btn_ok"
15 style="@style/button_login_register_style"
16 android:layout_marginBottom="50dp"
17 android:text="@string/string_start_page" />
18 </RelativeLayout>
19
20
21 </RelativeLayout>
PersonalCenter/app/src/main/res/layout/custom_adilog_electroniccard.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:background="@android:color/white">
6 <RelativeLayout
7 android:id="@+id/title"
8 android:layout_width="match_parent"
9 android:layout_height="wrap_content"
10 android:background="@android:color/white"
11 android:minHeight="70dp" >
12
13 <ImageView
14 android:id="@+id/cancel"
15 android:layout_width="wrap_content"
16 android:layout_height="wrap_content"
17 android:layout_centerVertical="true"
18 android:layout_alignParentRight="true"
19 android:padding="20dp"
20 android:src="@mipmap/cancel_fork" />
21
22 </RelativeLayout>
23 <RelativeLayout
24 android:gravity="center"
25 android:layout_gravity="clip_horizontal"
26 android:layout_width="match_parent"
27 android:background="@android:color/white"
28 android:layout_height="wrap_content">
29 <ImageView
30 android:layout_width="wrap_content"
31 android:src="@mipmap/electroniccard"
32 android:layout_height="wrap_content" />
33 </RelativeLayout>
34 <LinearLayout
35 android:orientation="vertical"
36 android:background="@android:color/white"
37 android:layout_width="match_parent"
38 android:layout_height="wrap_content">
39 <TextView
40 android:layout_gravity="center"
41 android:layout_marginTop="30dp"
42 android:textSize="15sp"
43 android:layout_width="wrap_content"
44 android:layout_height="wrap_content"
45 android:textColor="@color/electronic_card"
46 android:text="@string/electronic_card1"/>
47 <TextView
48 android:layout_gravity="center"
49 android:layout_width="wrap_content"
50 android:layout_height="wrap_content"
51 android:textSize="15sp"
52 android:textColor="@color/electronic_card"
53 android:text="@string/electronic_card2"/>
54 <View
55 android:layout_marginTop="20dp"
56 android:layout_width="match_parent"
57 android:background="@color/login_edittext_hint"
58 android:layout_height="0.7dp">
59
60 </View>
61
62 <TextView
63 android:id="@+id/fill_card"
64 android:layout_gravity="center"
65 android:layout_marginTop="20dp"
66 android:layout_width="wrap_content"
67 android:layout_height="wrap_content"
68 android:textSize="15sp"
69 android:textColor="@color/login_text_black"
70 android:text="@string/string_electroniccard_info_fill"/>
71
72 </LinearLayout>
73 <LinearLayout
74 android:orientation="vertical"
75 android:background="@android:color/white"
76 android:layout_width="match_parent"
77 android:layout_height="30dp">
78 </LinearLayout>
79
80
81 </LinearLayout>
PersonalCenter/app/src/main/res/layout/custom_adilog_list.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:orientation="vertical">
6
7 <RelativeLayout
8 android:id="@+id/title"
9 android:layout_width="match_parent"
10 android:layout_height="wrap_content"
11 android:background="@android:color/white"
12 android:minHeight="70dp" >
13
14 <ImageView
15 android:id="@+id/cancel"
16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content"
18 android:layout_centerVertical="true"
19 android:layout_alignParentRight="true"
20 android:padding="20dp"
21 android:src="@mipmap/cancel_fork" />
22
23 <TextView
24 android:id="@+id/menu_title"
25 android:layout_width="wrap_content"
26 android:layout_height="wrap_content"
27 android:layout_centerInParent="true"
28 android:padding="20dp"
29 android:text="选年级"
30 android:textColor="@android:color/black"
31 android:textSize="22sp" />
32 </RelativeLayout>
33 <ListView
34 android:id="@+id/listadapter"
35 android:background="@android:color/white"
36 android:layout_width="match_parent"
37 android:layout_height="match_parent">
38
39 </ListView>
40 </LinearLayout>
41
PersonalCenter/app/src/main/res/layout/custom_adilog_list_item.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" android:layout_width="match_parent"
4 android:layout_height="match_parent">
5 <TextView
6 android:id="@+id/list_items"
7 android:textSize="18sp"
8 android:layout_width="match_parent"
9 android:layout_height="50dp"
10 android:gravity="center"
11 android:textColor="@color/btn_text_color"/>
12
13 </LinearLayout>
PersonalCenter/app/src/main/res/mipmap-xhdpi/cancel_fork.png

596 Bytes

PersonalCenter/app/src/main/res/mipmap-xhdpi/electroniccard.png

46.2 KB

PersonalCenter/app/src/main/res/mipmap-xhdpi/startpage.jpg

137 KB

PersonalCenter/app/src/main/res/values/colors.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <resources> 2 <resources>
3 <color name="colorPrimary">#3F51B5</color> 3 <color name="colorPrimary">#3F51B5</color>
4 <color name="colorPrimaryDark">#303F9F</color> 4 <color name="colorPrimaryDark">#303F9F</color>
5 <color name="colorAccent">#FF4081</color> 5 <color name="colorAccent">#FF4081</color>
6 <color name="white">#ffffffff</color> 6 <color name="white">#ffffffff</color>
7 <color name="login_edittext_hint">#afafaf</color> 7 <color name="login_edittext_hint">#afafaf</color>
8 <color name="login_text_blue">#1cb8ff</color> 8 <color name="login_text_blue">#1cb8ff</color>
9 <color name="login_text_black">#313131</color> 9 <color name="login_text_black">#313131</color>
10 <color name="login_edittext_normal">#d4d4d4</color> 10 <color name="login_edittext_normal">#d4d4d4</color>
11 <color name="error_hint">#ED1c24</color> 11 <color name="error_hint">#ED1c24</color>
12 <color name="login_edittext_pressed">#1cb8ff</color> 12 <color name="login_edittext_pressed">#1cb8ff</color>
13 <color name="cutoff_line">#CCCCCC</color>
14 <color name="electronic_card">#ff480f</color>
15
13 </resources> 16 </resources>
14 17
PersonalCenter/app/src/main/res/values/strings.xml
1 <resources> 1 <resources>
2 <string name="app_name">PersonalCenter</string> 2 <string name="app_name">PersonalCenter</string>
3 3
4 4
5 5
6 //登录注册 6 //登录注册
7 <string name="cancel">取 消</string> 7 <string name="cancel">取 消</string>
8 <string name="ok">确 定</string> 8 <string name="ok">确 定</string>
9 <string name="forget_pwd">忘记密码</string> 9 <string name="forget_pwd">忘记密码</string>
10 <string name="string_menu_title">修改密码</string> 10 <string name="string_menu_title">修改密码</string>
11 <string name="string_regist_info">填写注册信息</string> 11 <string name="string_regist_info">填写注册信息</string>
12 <string name="string_textbook_info">选择教材版本</string>
12 <string name="string_regist_username">用户名</string> 13 <string name="string_regist_username">用户名</string>
13 <string name="string_regist_region">地区</string> 14 <string name="string_regist_region">地区</string>
14 <string name="string_regist_grade">年级</string> 15 <string name="string_regist_grade">年级</string>
15 <string name="string_regist_school">学校</string> 16 <string name="string_regist_school">学校</string>
16 <string name="string_regist_next">下一步</string> 17 <string name="string_regist_next">下一步</string>
18 <string name="string_start_page">开始学习体验</string>
19
17 //电子保卡 20 //电子保卡
18 <string name="string_electroniccard_info_title">填写保卡信息</string> 21 <string name="string_electroniccard_info_title">填写保卡信息</string>
22 <string name="string_electroniccard_info_fill">填写电子保卡</string>
19 <string name="string_electroniccard_info_change">修改保卡信息</string> 23 <string name="string_electroniccard_info_change">修改保卡信息</string>
20 <string name="string_electroniccard_change_bangding">更换绑定</string> 24 <string name="string_electroniccard_change_bangding">更换绑定</string>
25 <string name="electronic_card1">请先填写《好记星-电子保卡》信息</string>
26 <string name="electronic_card2">该信息是本产品的三包证明,为维护您的合法权益,请认真填写</string>
21 27
22 28
23 </resources> 29 </resources>
24 30
PersonalCenter/build.gradle
1 // Top-level build file where you can add configuration options common to all sub-projects/modules. 1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 2
3 buildscript { 3 buildscript {
4 repositories { 4 repositories {
5 jcenter() 5 jcenter()
6 } 6 }
7 dependencies { 7 dependencies {
8 classpath 'com.android.tools.build:gradle:2.2.2' 8 classpath 'com.android.tools.build:gradle:2.2.2'
9 9
10 // NOTE: Do not place your application dependencies here; they belong 10 // NOTE: Do not place your application dependencies here; they belong
11 // in the individual module build.gradle files 11 // in the individual module build.gradle files
12 classpath 'com.novoda:bintray-release:0.3.4'
12 } 13 }
13 } 14 }
14 15
15 allprojects { 16 allprojects {
16 repositories { 17 repositories {
17 jcenter() 18 jcenter()
18 } 19 }
19 } 20 }
20 21
21 task clean(type: Delete) { 22 task clean(type: Delete) {
22 delete rootProject.buildDir 23 delete rootProject.buildDir
23 } 24 }
24 25
PersonalCenter/circledialog/.gitignore
File was created 1 /build
2
PersonalCenter/circledialog/build.gradle
File was created 1 apply plugin: 'com.android.library'
2 apply plugin: 'maven'
3 apply plugin: 'com.novoda.bintray-release'
4
5 android {
6 compileSdkVersion 23
7 buildToolsVersion "23.0.3"
8 defaultConfig {
9 minSdkVersion 15
10 targetSdkVersion 23
11 versionCode 1
12 versionName "2017.5.8"
13 }
14 buildTypes {
15 release {
16 minifyEnabled false
17 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 }
19 }
20 productFlavors {
21 }
22 lintOptions {
23 abortOnError false
24 checkReleaseBuilds false
25 }
26 }
27
28 dependencies {
29 compile 'com.android.support:appcompat-v7:23.4.0'
30 }
31
32 publish {
33 userOrg = 'mylhyl'
34 groupId = 'com.mylhyl'
35 artifactId = 'circleDialog'
36 version = '2.1.6'
37 description = 'circleDialog ios style'
38 website = "https://github.com/mylhyl/Android-CircleDialog"
39 }
PersonalCenter/circledialog/proguard-rules.pro
File was created 1 # Add project specific ProGuard rules here.
2 # By default, the flags in this file are appended to flags specified
3 # in E:\android\android-sdk-windows/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
PersonalCenter/circledialog/src/main/AndroidManifest.xml
File was created 1 <manifest package="com.mylhyl.circledialog">
2
3 <application/>
4
5 </manifest>
6
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/AbsCircleDialog.java
File was created 1 package com.mylhyl.circledialog;
2
3 import android.content.Context;
4 import android.content.DialogInterface;
5 import android.os.Bundle;
6 import android.support.annotation.Nullable;
7 import android.view.LayoutInflater;
8 import android.view.View;
9 import android.view.ViewGroup;
10
11 import com.mylhyl.circledialog.params.CircleParams;
12 import com.mylhyl.circledialog.params.DialogParams;
13
14 /**
15 * Created by hupei on 2017/3/29.
16 */
17
18 public final class AbsCircleDialog extends BaseCircleDialog {
19 private static final String SAVED_PARAMS = "circle:params";
20 private CircleParams mParams;
21 private Controller mController;
22
23 public static AbsCircleDialog newAbsCircleDialog(CircleParams params) {
24 AbsCircleDialog circleDialog = new AbsCircleDialog();
25 circleDialog.mParams = params;
26 Bundle bundle = new Bundle();
27 bundle.putParcelable(SAVED_PARAMS, params);
28 circleDialog.setArguments(bundle);
29 return circleDialog;
30 }
31
32 @Override
33 public void onDismiss(DialogInterface dialog) {
34 super.onDismiss(dialog);
35 mParams = null;
36 }
37
38 @Override
39 public void onCreate(@Nullable Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
41 if (savedInstanceState != null) {
42 mParams = savedInstanceState.getParcelable(SAVED_PARAMS);
43 }
44 DialogParams dialogParams = mParams.dialogParams;
45 setGravity(dialogParams.gravity);
46 setCanceledOnTouchOutside(dialogParams.canceledOnTouchOutside);
47 setCanceledBack(dialogParams.cancelable);
48 setWidth(dialogParams.width);
49 int[] mPadding = dialogParams.mPadding;
50 if (mPadding != null)
51 setPadding(mPadding[0], mPadding[1], mPadding[2], mPadding[3]);
52 setAnimations(dialogParams.animStyle);
53 setDimEnabled(dialogParams.isDimEnabled);
54 setBackgroundColor(dialogParams.backgroundColor);
55 setRadius(dialogParams.radius);
56 setAlpha(dialogParams.alpha);
57 setX(dialogParams.xOff);
58 setY(dialogParams.yOff);
59 }
60
61 @Override
62 public void onSaveInstanceState(Bundle outState) {
63 super.onSaveInstanceState(outState);
64 outState.putParcelable(SAVED_PARAMS, mParams);
65 }
66
67 @Override
68 public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
69 mController = new Controller(getContext(), mParams);
70 mParams.dialogFragment = this;
71 return mController.createView();
72 }
73
74 public void refreshView() {
75 mController.refreshView();
76 }
77 }
78
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/BaseCircleDialog.java
File was created 1 package com.mylhyl.circledialog;
2
3 import android.app.Dialog;
4 import android.content.Context;
5 import android.graphics.Color;
6 import android.os.Build;
7 import android.os.Bundle;
8 import android.support.annotation.ColorInt;
9 import android.support.annotation.FloatRange;
10 import android.support.annotation.Nullable;
11 import android.support.v4.app.DialogFragment;
12 import android.support.v4.app.FragmentManager;
13 import android.support.v4.app.FragmentTransaction;
14 import android.util.DisplayMetrics;
15 import android.view.Gravity;
16 import android.view.LayoutInflater;
17 import android.view.View;
18 import android.view.ViewGroup;
19 import android.view.Window;
20 import android.view.WindowManager;
21
22 import com.mylhyl.circledialog.res.drawable.CircleDrawable;
23 import com.mylhyl.circledialog.res.values.CircleDimen;
24 import com.mylhyl.circledialog.scale.ScaleUtils;
25
26 /**
27 * Created by hupei on 2017/3/29.
28 */
29
30 public abstract class BaseCircleDialog extends DialogFragment {
31
32 public abstract View createView(Context context, LayoutInflater inflater, ViewGroup container);
33
34 private static final String SAVED_GRAVITY = "circle:baseGravity";
35 private static final String SAVED_TOUCH_OUT = "circle:baseTouchOut";
36 private static final String SAVED_CANCELED_BACK = "circle:baseCanceledBack";
37 private static final String SAVED_WIDTH = "circle:baseWidth";
38 private static final String SAVED_PADDING = "circle:basePadding";
39 private static final String SAVED_ANIM_STYLE = "circle:baseAnimStyle";
40 private static final String SAVED_DIM_ENABLED = "circle:baseDimEnabled";
41 private static final String SAVED_BACKGROUND_COLOR = "circle:baseBackgroundColor";
42 private static final String SAVED_RADIUS = "circle:baseRadius";
43 private static final String SAVED_ALPHA = "circle:baseAlpha";
44 private static final String SAVED_X = "circle:baseX";
45 private static final String SAVED_Y = "circle:baseY";
46
47 private int mGravity = Gravity.CENTER;//对话框的位置
48 private boolean mCanceledOnTouchOutside = true;//是否触摸外部关闭
49 private boolean mCanceledBack = true;//是否返回键关闭
50 private float mWidth = 0.9f;//对话框宽度,范围:0-1;1整屏宽
51 private int[] mPadding;//对话框与屏幕边缘距离
52 private int mAnimStyle;//显示动画
53 private boolean isDimEnabled = true;
54 private int mBackgroundColor = Color.TRANSPARENT;//对话框的背景色
55 private int mRadius = CircleDimen.RADIUS;//对话框的圆角半径
56 private float mAlpha = 1f;//对话框透明度,范围:0-1;1不透明
57 private int mX, mY;
58
59 @Override
60 public void onCreate(@Nullable Bundle savedInstanceState) {
61 super.onCreate(savedInstanceState);
62 //设置 无标题 无边框
63 setStyle(DialogFragment.STYLE_NO_TITLE, 0);
64 if (savedInstanceState != null) {
65 mGravity = savedInstanceState.getInt(SAVED_GRAVITY);
66 mCanceledOnTouchOutside = savedInstanceState.getBoolean(SAVED_TOUCH_OUT);
67 mCanceledBack = savedInstanceState.getBoolean(SAVED_CANCELED_BACK);
68 mWidth = savedInstanceState.getFloat(SAVED_WIDTH);
69 mPadding = savedInstanceState.getIntArray(SAVED_PADDING);
70 mAnimStyle = savedInstanceState.getInt(SAVED_ANIM_STYLE);
71 isDimEnabled = savedInstanceState.getBoolean(SAVED_DIM_ENABLED);
72 mBackgroundColor = savedInstanceState.getInt(SAVED_BACKGROUND_COLOR);
73 mRadius = savedInstanceState.getInt(SAVED_RADIUS);
74 mAlpha = savedInstanceState.getFloat(SAVED_ALPHA);
75 mX = savedInstanceState.getInt(SAVED_X);
76 mY = savedInstanceState.getInt(SAVED_Y);
77 }
78 }
79
80 @Override
81 public void onSaveInstanceState(Bundle outState) {
82 super.onSaveInstanceState(outState);
83 outState.putInt(SAVED_GRAVITY, mGravity);
84 outState.putBoolean(SAVED_TOUCH_OUT, mCanceledOnTouchOutside);
85 outState.putBoolean(SAVED_CANCELED_BACK, mCanceledBack);
86 outState.putFloat(SAVED_WIDTH, mWidth);
87 if (mPadding != null) outState.putIntArray(SAVED_PADDING, mPadding);
88 outState.putInt(SAVED_ANIM_STYLE, mAnimStyle);
89 outState.putBoolean(SAVED_DIM_ENABLED, isDimEnabled);
90 outState.putInt(SAVED_BACKGROUND_COLOR, mBackgroundColor);
91 outState.putInt(SAVED_RADIUS, mRadius);
92 outState.putFloat(SAVED_ALPHA, mAlpha);
93 outState.putInt(SAVED_X, mX);
94 outState.putInt(SAVED_Y, mY);
95 }
96
97 @Override
98 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
99 savedInstanceState) {
100 View view = createView(getContext(), inflater, container);
101 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
102 view.setBackground(new CircleDrawable(mBackgroundColor, mRadius));
103 } else {
104 view.setBackgroundDrawable(new CircleDrawable(mBackgroundColor, mRadius));
105 }
106 view.setAlpha(mAlpha);
107 return view;
108 }
109
110
111 @Override
112 public void onStart() {
113 Dialog dialog = getDialog();
114 if (dialog != null) {
115 dialog.setCanceledOnTouchOutside(mCanceledOnTouchOutside);
116 dialog.setCancelable(mCanceledBack);
117 setDialogGravity(dialog);//设置对话框布局
118 }
119 super.onStart();
120 }
121
122 /**
123 * 设置对话框底部显示
124 *
125 * @param dialog
126 */
127 private void setDialogGravity(Dialog dialog) {
128 // 设置宽度为屏宽、靠近屏幕底部。
129 Window window = dialog.getWindow();
130 window.setBackgroundDrawableResource(android.R.color.transparent);
131 WindowManager.LayoutParams wlp = window.getAttributes();
132 DisplayMetrics dm = new DisplayMetrics();
133 getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);//获取屏幕宽
134 wlp.width = (int) (dm.widthPixels * mWidth);//宽度按屏幕大小的百分比设置
135 wlp.gravity = mGravity;
136 wlp.x = mX;
137 wlp.y = mY;
138 //边距
139 if (mPadding != null) {
140 int[] padding = mPadding;
141 wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
142 window.getDecorView().setPadding(ScaleUtils.scaleValue(padding[0]), ScaleUtils
143 .scaleValue(padding[1]), ScaleUtils.scaleValue(padding[2]), ScaleUtils
144 .scaleValue(padding[3]));
145 }
146 //动画
147 if (mAnimStyle != 0) window.setWindowAnimations(mAnimStyle);
148
149 if (isDimEnabled) window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
150 else window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
151 window.setAttributes(wlp);
152 }
153
154 @Override
155 public void show(FragmentManager manager, String tag) {
156 if (!isAdded()) {
157 FragmentTransaction transaction = manager.beginTransaction();
158 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
159 transaction.add(this, tag);
160 transaction.commitAllowingStateLoss();
161 }
162 }
163
164 public void remove() {
165 FragmentTransaction ft = getFragmentManager().beginTransaction();
166 ft.remove(this);
167 ft.addToBackStack(null);
168 }
169
170 /**
171 * 设置对话框位置
172 * {@link Gravity#CENTER 默认}
173 *
174 * @param gravity 位置
175 */
176 protected void setGravity(int gravity) {
177 mGravity = gravity;
178 }
179
180 /**
181 * 设置对话框点击外部关闭
182 *
183 * @param cancel true允许
184 */
185 protected void setCanceledOnTouchOutside(boolean cancel) {
186 mCanceledOnTouchOutside = cancel;
187 }
188
189 /**
190 * 设置对话框返回键关闭关闭
191 *
192 * @param cancel true允许
193 */
194 protected void setCanceledBack(boolean cancel) {
195 mCanceledBack = cancel;
196 }
197
198 /**
199 * 设置对话框宽度
200 *
201 * @param width 0.0 - 1.0
202 */
203 protected void setWidth(@FloatRange(from = 0.0, to = 1.0) float width) {
204 mWidth = width;
205 }
206
207 /**
208 * 设置边距
209 *
210 * @param left px
211 * @param top px
212 * @param right px
213 * @param bottom px
214 */
215 protected void setPadding(int left, int top, int right, int bottom) {
216 mPadding = new int[]{left, top, right, bottom};
217 }
218
219 /**
220 * 弹出对话框的动画
221 *
222 * @param animStyle StyleRes
223 */
224 protected void setAnimations(int animStyle) {
225 mAnimStyle = animStyle;
226 }
227
228
229 /**
230 * 设置背景是否昏暗,默认true
231 *
232 * @param dimEnabled true昏暗
233 */
234 protected void setDimEnabled(boolean dimEnabled) {
235 isDimEnabled = dimEnabled;
236 }
237
238 /**
239 * 设置对话框背景色
240 *
241 * @param color 颜色值
242 */
243 protected void setBackgroundColor(@ColorInt int color) {
244 mBackgroundColor = color;
245 }
246
247 /**
248 * 设置对话框圆角
249 *
250 * @param radius 半径
251 */
252 protected void setRadius(int radius) {
253 mRadius = radius;
254 }
255
256 /**
257 * 设置对话框透明度
258 *
259 * @param alpha 0.0 - 1.0
260 */
261 protected void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) {
262 mAlpha = alpha;
263 }
264
265 protected void setX(int x) {
266 mX = x;
267 }
268
269 protected void setY(int y) {
270 mY = y;
271 }
272 }
273
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/BuildView.java
File was created 1 package com.mylhyl.circledialog;
2
3 import android.view.View;
4
5 /**
6 * Created by hupei on 2017/3/29.
7 */
8
9 public interface BuildView {
10 /**
11 * 生成根布局
12 */
13 void buildRoot();
14
15 /**
16 * 生成标题布局
17 */
18 void buildTitle();
19
20 /**
21 * 生成文本布局
22 */
23 void buildText();
24
25 /**
26 * 刷新文本内容
27 */
28 void refreshText();
29
30 /**
31 * 生成列表布局
32 */
33 void buildItems();
34
35 /**
36 * 生成列表按钮
37 */
38 void buildItemsButton();
39
40 /**
41 * 刷新列表内容
42 */
43 void refreshItems();
44
45 /**
46 * 生成进度条布局
47 */
48 void buildProgress();
49
50 /**
51 * 刷新进度条
52 */
53 void refreshProgress();
54
55 /**
56 * 生成输入布局
57 */
58 void buildInput();
59
60 /**
61 * 生成多按钮布局
62 */
63 void buildMultipleButton();
64
65 /**
66 * 生成单个按钮布局
67 */
68 void buildSingleButton();
69
70 /**
71 * 注册输入框确定事件
72 */
73 void regInputListener();
74
75 /**
76 * 取出根布局
77 *
78 * @return 对话框视图
79 */
80 View getView();
81 }
82
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/CircleDialog.java
File was created 1 package com.mylhyl.circledialog;
2
3 import android.support.annotation.ColorInt;
4 import android.support.annotation.DrawableRes;
5 import android.support.annotation.FloatRange;
6 import android.support.annotation.NonNull;
7 import android.support.v4.app.DialogFragment;
8 import android.support.v4.app.FragmentActivity;
9 import android.view.Gravity;
10 import android.view.View;
11 import android.widget.AdapterView;
12
13 import com.mylhyl.circledialog.callback.ConfigButton;
14 import com.mylhyl.circledialog.callback.ConfigDialog;
15 import com.mylhyl.circledialog.callback.ConfigInput;
16 import com.mylhyl.circledialog.callback.ConfigItems;
17 import com.mylhyl.circledialog.callback.ConfigProgress;
18 import com.mylhyl.circledialog.callback.ConfigText;
19 import com.mylhyl.circledialog.callback.ConfigTitle;
20 import com.mylhyl.circledialog.params.ButtonParams;
21 import com.mylhyl.circledialog.params.CircleParams;
22 import com.mylhyl.circledialog.params.DialogParams;
23 import com.mylhyl.circledialog.params.InputParams;
24 import com.mylhyl.circledialog.params.ItemsParams;
25 import com.mylhyl.circledialog.params.ProgressParams;
26 import com.mylhyl.circledialog.params.TextParams;
27 import com.mylhyl.circledialog.params.TitleParams;
28 import com.mylhyl.circledialog.view.listener.OnInputClickListener;
29
30 /**
31 * Created by hupei on 2017/3/29.
32 */
33
34 public final class CircleDialog {
35 private AbsCircleDialog mDialog;
36
37 private CircleDialog() {
38 }
39
40 public DialogFragment create(CircleParams params) {
41 if (mDialog == null)
42 mDialog = AbsCircleDialog.newAbsCircleDialog(params);
43 else {
44 if (mDialog != null && mDialog.getDialog() != null && mDialog.getDialog().isShowing()) {
45 mDialog.refreshView();
46 }
47 }
48 return mDialog;
49 }
50
51 public void show(FragmentActivity activity) {
52 mDialog.show(activity.getSupportFragmentManager(), "circleDialog");
53 }
54
55 public static class Builder {
56 private FragmentActivity mActivity;
57 private CircleDialog mCircleDialog;
58 private CircleParams mCircleParams;
59
60
61 public Builder(@NonNull FragmentActivity activity) {
62 this.mActivity = activity;
63 mCircleParams = new CircleParams();
64 mCircleParams.dialogParams = new DialogParams();
65 }
66
67 /**
68 * 设置对话框位置
69 *
70 * @param gravity 位置
71 * @return builder
72 */
73 public Builder setGravity(int gravity) {
74 mCircleParams.dialogParams.gravity = gravity;
75 return this;
76 }
77
78 /**
79 * 设置对话框点击外部关闭
80 *
81 * @param cancel true允许
82 * @return Builder
83 */
84 public Builder setCanceledOnTouchOutside(boolean cancel) {
85 mCircleParams.dialogParams.canceledOnTouchOutside = cancel;
86 return this;
87 }
88
89 /**
90 * 设置对话框返回键关闭
91 *
92 * @param cancel true允许
93 * @return Builder
94 */
95 public Builder setCancelable(boolean cancel) {
96 mCircleParams.dialogParams.cancelable = cancel;
97 return this;
98 }
99
100 /**
101 * 设置对话框宽度
102 *
103 * @param width 0.0 - 1.0
104 * @return Builder
105 */
106 public Builder setWidth(@FloatRange(from = 0.0, to = 1.0) float width) {
107 mCircleParams.dialogParams.width = width;
108 return this;
109 }
110
111 /**
112 * 设置对话框圆角
113 *
114 * @param radius 半径
115 * @return Builder
116 */
117 public Builder setRadius(int radius) {
118 mCircleParams.dialogParams.radius = radius;
119 return this;
120 }
121
122 public Builder configDialog(@NonNull ConfigDialog configDialog) {
123 configDialog.onConfig(mCircleParams.dialogParams);
124 return this;
125 }
126
127 public Builder setTitle(@NonNull String text) {
128 newTitleParams();
129 mCircleParams.titleParams.text = text;
130 return this;
131 }
132
133 public Builder setTitleColor(@ColorInt int color) {
134 newTitleParams();
135 mCircleParams.titleParams.textColor = color;
136 return this;
137 }
138
139 public Builder configTitle(@NonNull ConfigTitle configTitle) {
140 newTitleParams();
141 configTitle.onConfig(mCircleParams.titleParams);
142 return this;
143 }
144
145 private void newTitleParams() {
146 if (mCircleParams.titleParams == null)
147 mCircleParams.titleParams = new TitleParams();
148 }
149
150 public Builder setText(@NonNull String text) {
151 newTextParams();
152 mCircleParams.textParams.text = text;
153 return this;
154 }
155
156 public Builder setTextColor(@ColorInt int color) {
157 newTextParams();
158 mCircleParams.textParams.textColor = color;
159 return this;
160 }
161
162 public Builder configText(@NonNull ConfigText configText) {
163 newTextParams();
164 configText.onConfig(mCircleParams.textParams);
165 return this;
166 }
167
168 private void newTextParams() {
169 //判断是否已经设置过
170 if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY)
171 mCircleParams.dialogParams.gravity = Gravity.CENTER;
172 if (mCircleParams.textParams == null)
173 mCircleParams.textParams = new TextParams();
174 }
175
176 public Builder setItems(@NonNull Object items, AdapterView.OnItemClickListener listener) {
177 newItemsParams();
178 ItemsParams params = mCircleParams.itemsParams;
179 params.items = items;
180 params.listener = listener;
181 return this;
182 }
183
184
185 public Builder configItems(@NonNull ConfigItems configItems) {
186 newItemsParams();
187 configItems.onConfig(mCircleParams.itemsParams);
188 return this;
189 }
190
191 private void newItemsParams() {
192 //设置列表特殊的参数
193 DialogParams dialogParams = mCircleParams.dialogParams;
194 //判断是否已经设置过
195 if (dialogParams.gravity == Gravity.NO_GRAVITY)
196 dialogParams.gravity = Gravity.BOTTOM;//默认底部显示
197 //判断是否已经设置过
198 if (dialogParams.yOff == 0)
199 dialogParams.yOff = 20;//底部与屏幕的距离
200
201 if (mCircleParams.itemsParams == null)
202 mCircleParams.itemsParams = new ItemsParams() {
203 @Override
204 public void dismiss() {
205 onDismiss();
206 }
207 };
208 }
209
210 /**
211 * 设置进度条文本
212 *
213 * @param text 进度条文本,style = 水平样式时,支持String.format() 例如:已经下载%s
214 * @return
215 */
216 public Builder setProgressText(@NonNull String text) {
217 newProgressParams();
218 mCircleParams.progressParams.text = text;
219 return this;
220 }
221
222 /**
223 * 设置进度条样式
224 *
225 * @param style {@link ProgressParams#STYLE_HORIZONTAL 水平样式} or
226 * {@link ProgressParams#STYLE_SPINNER}
227 * @return
228 */
229 public Builder setProgressStyle(int style) {
230 newProgressParams();
231 mCircleParams.progressParams.style = style;
232 return this;
233 }
234
235 public Builder setProgress(int max, int progress) {
236 newProgressParams();
237 ProgressParams progressParams = mCircleParams.progressParams;
238 progressParams.max = max;
239 progressParams.progress = progress;
240 return this;
241 }
242
243 public Builder setProgressDrawable(@DrawableRes int progressDrawableId) {
244 newProgressParams();
245 mCircleParams.progressParams.progressDrawableId = progressDrawableId;
246 return this;
247 }
248
249 public Builder setProgressHeight(int height) {
250 newProgressParams();
251 mCircleParams.progressParams.progressHeight = height;
252 return this;
253 }
254
255 public Builder configProgress(@NonNull ConfigProgress configProgress) {
256 newProgressParams();
257 configProgress.onConfig(mCircleParams.progressParams);
258 return this;
259 }
260
261 private void newProgressParams() {
262 //判断是否已经设置过
263 if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY)
264 mCircleParams.dialogParams.gravity = Gravity.CENTER;
265 if (mCircleParams.progressParams == null)
266 mCircleParams.progressParams = new ProgressParams();
267 }
268
269 public Builder setInputHint(@NonNull String text) {
270 newInputParams();
271 mCircleParams.inputParams.hintText = text;
272 return this;
273 }
274
275 public Builder setInputHeight(int height) {
276 newInputParams();
277 mCircleParams.inputParams.inputHeight = height;
278 return this;
279 }
280
281 public Builder configInput(@NonNull ConfigInput configInput) {
282 newInputParams();
283 configInput.onConfig(mCircleParams.inputParams);
284 return this;
285 }
286
287 private void newInputParams() {
288 //判断是否已经设置过
289 if (mCircleParams.dialogParams.gravity == Gravity.NO_GRAVITY)
290 mCircleParams.dialogParams.gravity = Gravity.CENTER;
291 if (mCircleParams.inputParams == null)
292 mCircleParams.inputParams = new InputParams();
293 }
294
295 public Builder setPositive(@NonNull String text, View.OnClickListener listener) {
296 newPositiveParams();
297 ButtonParams params = mCircleParams.positiveParams;
298 params.text = text;
299 params.listener = listener;
300 return this;
301 }
302
303 public Builder setPositiveInput(@NonNull String text, OnInputClickListener listener) {
304 newPositiveParams();
305 ButtonParams params = mCircleParams.positiveParams;
306 params.text = text;
307 params.inputListener = listener;
308 return this;
309 }
310
311 public Builder configPositive(@NonNull ConfigButton configButton) {
312 newPositiveParams();
313 configButton.onConfig(mCircleParams.positiveParams);
314 return this;
315 }
316
317 private void newPositiveParams() {
318 if (mCircleParams.positiveParams == null)
319 mCircleParams.positiveParams = new ButtonParams() {
320 @Override
321 public void dismiss() {
322 onDismiss();
323 }
324 };
325 }
326
327 public Builder setNegative(@NonNull String text, View.OnClickListener listener) {
328 newNegativeParams();
329 ButtonParams params = mCircleParams.negativeParams;
330 params.text = text;
331 params.listener = listener;
332 return this;
333 }
334
335
336 public Builder configNegative(@NonNull ConfigButton configButton) {
337 newNegativeParams();
338 configButton.onConfig(mCircleParams.negativeParams);
339 return this;
340 }
341
342 private void newNegativeParams() {
343 if (mCircleParams.negativeParams == null)
344 mCircleParams.negativeParams = new ButtonParams() {
345 @Override
346 public void dismiss() {
347 onDismiss();
348 }
349 };
350 }
351
352 private void onDismiss() {
353 if (mCircleParams.dialogFragment != null) {
354 mCircleParams.dialogFragment.dismiss();
355 mActivity = null;
356 mCircleParams.dialogFragment = null;
357 }
358 }
359
360 public DialogFragment create() {
361 if (mCircleDialog == null)
362 mCircleDialog = new CircleDialog();
363 return mCircleDialog.create(mCircleParams);
364 }
365
366 public DialogFragment show() {
367 DialogFragment dialogFragment = create();
368 mCircleDialog.show(mActivity);
369 return dialogFragment;
370 }
371 }
372 }
373
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/Controller.java
File was created 1 package com.mylhyl.circledialog;
2
3 import android.content.Context;
4 import android.view.View;
5 import android.view.animation.Animation;
6 import android.view.animation.AnimationUtils;
7
8 import com.mylhyl.circledialog.params.CircleParams;
9 import com.mylhyl.circledialog.view.BuildViewImpl;
10
11 /**
12 * Created by hupei on 2017/3/29.
13 */
14
15 public class Controller {
16 private Context mContext;
17 private CircleParams mParams;
18 private BuildView mCreateView;
19
20 public Controller(Context context, CircleParams params) {
21 this.mContext = context;
22 this.mParams = params;
23 mCreateView = new BuildViewImpl(mContext, mParams);
24 }
25
26 public View createView() {
27 applyRoot();
28 applyHeader();
29 applyBody();
30 return getView();
31 }
32
33 public void refreshView() {
34 mCreateView.refreshText();
35 mCreateView.refreshItems();
36 mCreateView.refreshProgress();
37 //刷新时带动画
38 if (mParams.dialogParams.refreshAnimation != 0 && getView() != null)
39 getView().post(new Runnable() {
40 @Override
41 public void run() {
42 Animation animation = AnimationUtils.loadAnimation(mContext, mParams
43 .dialogParams
44 .refreshAnimation);
45 if (animation != null) getView().startAnimation(animation);
46 }
47 });
48 }
49
50 private void applyRoot() {
51 mCreateView.buildRoot();
52 }
53
54 private void applyHeader() {
55 if (mParams.titleParams != null)
56 mCreateView.buildTitle();
57 }
58
59 private void applyBody() {
60 //文本
61 if (mParams.textParams != null) {
62 mCreateView.buildText();
63 applyButton();
64 }
65 //列表
66 else if (mParams.itemsParams != null) {
67 mCreateView.buildItems();
68 //有确定或者有取消按钮
69 if (mParams.positiveParams != null || mParams.negativeParams != null)
70 mCreateView.buildItemsButton();
71 }
72 //进度条
73 else if (mParams.progressParams != null) {
74 mCreateView.buildProgress();
75 applyButton();
76 }
77 //输入框
78 else if (mParams.inputParams != null) {
79 mCreateView.buildInput();
80 applyButton();
81 mCreateView.regInputListener();
82 }
83 }
84
85 private void applyButton() {
86 //有确定并且有取消按钮
87 if (mParams.positiveParams != null && mParams.negativeParams != null)
88 mCreateView.buildMultipleButton();
89 //有确定或者有取消按钮
90 else if (mParams.positiveParams != null || mParams.negativeParams != null)
91 mCreateView.buildSingleButton();
92 }
93
94 private View getView() {
95 return mCreateView.getView();
96 }
97 }
98
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigButton.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.ButtonParams;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8
9 public abstract class ConfigButton {
10 public abstract void onConfig(ButtonParams params);
11 }
12
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigDialog.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.DialogParams;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8 public abstract class ConfigDialog {
9 public abstract void onConfig(DialogParams params);
10 }
11
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigInput.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.InputParams;
4
5 /**
6 * Created by hupei on 2017/3/31.
7 */
8
9 public abstract class ConfigInput {
10 public abstract void onConfig(InputParams params);
11 }
12
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigItems.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.ItemsParams;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8
9 public abstract class ConfigItems {
10 public abstract void onConfig(ItemsParams params);
11 }
12
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigProgress.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.ProgressParams;
4
5 /**
6 * Created by hupei on 2017/3/31.
7 */
8
9 public abstract class ConfigProgress {
10 public abstract void onConfig(ProgressParams params);
11 }
12
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigText.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.TextParams;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8
9 public abstract class ConfigText {
10 public abstract void onConfig(TextParams params);
11 }
12
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/callback/ConfigTitle.java
File was created 1 package com.mylhyl.circledialog.callback;
2
3 import com.mylhyl.circledialog.params.TitleParams;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8
9 public abstract class ConfigTitle {
10 public abstract void onConfig(TitleParams params);
11 }
12
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/ButtonParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 import android.view.View;
6
7 import com.mylhyl.circledialog.res.values.CircleColor;
8 import com.mylhyl.circledialog.res.values.CircleDimen;
9 import com.mylhyl.circledialog.view.listener.OnInputClickListener;
10
11 import java.io.Serializable;
12
13 /**
14 * 按钮参数
15 * Created by hupei on 2017/3/30.
16 */
17 public class ButtonParams implements Parcelable {
18 public void dismiss() {
19
20 }
21
22 /**
23 * 按钮点击事件
24 */
25 public View.OnClickListener listener;
26 /**
27 * 输入框确定事件
28 */
29 public OnInputClickListener inputListener;
30 /**
31 * 按钮框与顶部距离
32 */
33 public int topMargin;
34 /**
35 * 按钮文本颜色
36 */
37 public int textColor = CircleColor.button;
38 /**
39 * 按钮文本大小
40 */
41 public int textSize = CircleDimen.FOOTER_TEXT_SIZE;
42 /**
43 * 按钮高度
44 */
45 public int height = CircleDimen.FOOTER_HEIGHT;
46 /**
47 * 按钮背景颜色
48 */
49 public int backgroundColor;
50 /**
51 * 按钮文本
52 */
53 public String text;
54
55
56 @Override
57 public int describeContents() {
58 return 0;
59 }
60
61 @Override
62 public void writeToParcel(Parcel dest, int flags) {
63 dest.writeInt(this.topMargin);
64 dest.writeInt(this.textColor);
65 dest.writeInt(this.textSize);
66 dest.writeInt(this.height);
67 dest.writeInt(this.backgroundColor);
68 dest.writeString(this.text);
69 }
70
71 public ButtonParams() {
72 }
73
74 protected ButtonParams(Parcel in) {
75 this.topMargin = in.readInt();
76 this.textColor = in.readInt();
77 this.textSize = in.readInt();
78 this.height = in.readInt();
79 this.backgroundColor = in.readInt();
80 this.text = in.readString();
81 }
82
83 public static final Parcelable.Creator<ButtonParams> CREATOR = new Parcelable.Creator<ButtonParams>() {
84 @Override
85 public ButtonParams createFromParcel(Parcel source) {
86 return new ButtonParams(source);
87 }
88
89 @Override
90 public ButtonParams[] newArray(int size) {
91 return new ButtonParams[size];
92 }
93 };
94 }
95
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/CircleParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 import android.support.v4.app.DialogFragment;
6
7 import com.mylhyl.circledialog.AbsCircleDialog;
8
9 import java.io.Serializable;
10
11 /**
12 * Created by hupei on 2017/3/30.
13 */
14
15 public final class CircleParams implements Parcelable {
16 public DialogFragment dialogFragment;
17 public DialogParams dialogParams;
18 public TitleParams titleParams;
19 public TextParams textParams;
20 public ButtonParams negativeParams;
21 public ButtonParams positiveParams;
22 public ItemsParams itemsParams;
23 public ProgressParams progressParams;
24 public InputParams inputParams;
25
26 @Override
27 public int describeContents() {
28 return 0;
29 }
30
31 @Override
32 public void writeToParcel(Parcel dest, int flags) {
33 dest.writeParcelable(this.dialogParams, flags);
34 dest.writeParcelable(this.titleParams, flags);
35 dest.writeParcelable(this.textParams, flags);
36 dest.writeParcelable(this.negativeParams, flags);
37 dest.writeParcelable(this.positiveParams, flags);
38 dest.writeParcelable(this.itemsParams, flags);
39 dest.writeParcelable(this.progressParams, flags);
40 dest.writeParcelable(this.inputParams, flags);
41 }
42
43 public CircleParams() {
44 }
45
46 protected CircleParams(Parcel in) {
47 this.dialogParams = in.readParcelable(DialogParams.class.getClassLoader());
48 this.titleParams = in.readParcelable(TitleParams.class.getClassLoader());
49 this.textParams = in.readParcelable(TextParams.class.getClassLoader());
50 this.negativeParams = in.readParcelable(ButtonParams.class.getClassLoader());
51 this.positiveParams = in.readParcelable(ButtonParams.class.getClassLoader());
52 this.itemsParams = in.readParcelable(ItemsParams.class.getClassLoader());
53 this.progressParams = in.readParcelable(ProgressParams.class.getClassLoader());
54 this.inputParams = in.readParcelable(InputParams.class.getClassLoader());
55 }
56
57 public static final Parcelable.Creator<CircleParams> CREATOR = new Parcelable.Creator<CircleParams>() {
58 @Override
59 public CircleParams createFromParcel(Parcel source) {
60 return new CircleParams(source);
61 }
62
63 @Override
64 public CircleParams[] newArray(int size) {
65 return new CircleParams[size];
66 }
67 };
68 }
69
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/DialogParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.graphics.Color;
4 import android.os.Parcel;
5 import android.os.Parcelable;
6 import android.view.Gravity;
7
8 import com.mylhyl.circledialog.res.values.CircleDimen;
9
10 import java.io.Serializable;
11
12 /**
13 * 对话框参数
14 * Created by hupei on 2017/3/30.
15 */
16 public class DialogParams implements Parcelable {
17 /**
18 * 对话框的位置
19 */
20 public int gravity = Gravity.NO_GRAVITY;
21 /**
22 * 是否触摸外部关闭
23 */
24 public boolean canceledOnTouchOutside = true;
25 /**
26 * 返回键是否关闭
27 */
28 public boolean cancelable = true;
29 /**
30 * 对话框透明度,范围:0-1;1不透明
31 */
32 public float alpha = 1f;
33 /**
34 * 对话框宽度,范围:0-1;1整屏宽
35 */
36 public float width = 0.9f;
37 /**
38 * 对话框与屏幕边距
39 */
40 public int[] mPadding;
41 /**
42 * 对话框弹出动画,StyleRes
43 */
44 public int animStyle;
45 /**
46 * 对话框刷新动画,AnimRes
47 */
48 public int refreshAnimation;
49 /**
50 * 对话框背景是否昏暗,默认true
51 */
52 public boolean isDimEnabled = true;
53 /**
54 * 对话框的背景色透明,因为列表模式情况,内容与按钮中间有距离
55 */
56 public int backgroundColor = Color.TRANSPARENT;
57 /**
58 * 对话框的圆角半径
59 */
60 public int radius = CircleDimen.RADIUS;
61 /**
62 * 对话框 x 坐标偏移
63 */
64 public int xOff;
65 /**
66 * 对话框 y 坐标偏移
67 */
68 public int yOff;
69
70 @Override
71 public int describeContents() {
72 return 0;
73 }
74
75 @Override
76 public void writeToParcel(Parcel dest, int flags) {
77 dest.writeInt(this.gravity);
78 dest.writeByte(this.canceledOnTouchOutside ? (byte) 1 : (byte) 0);
79 dest.writeByte(this.cancelable ? (byte) 1 : (byte) 0);
80 dest.writeFloat(this.alpha);
81 dest.writeFloat(this.width);
82 dest.writeIntArray(this.mPadding);
83 dest.writeInt(this.animStyle);
84 dest.writeInt(this.refreshAnimation);
85 dest.writeByte(this.isDimEnabled ? (byte) 1 : (byte) 0);
86 dest.writeInt(this.backgroundColor);
87 dest.writeInt(this.radius);
88 dest.writeInt(this.xOff);
89 dest.writeInt(this.yOff);
90 }
91
92 public DialogParams() {
93 }
94
95 protected DialogParams(Parcel in) {
96 this.gravity = in.readInt();
97 this.canceledOnTouchOutside = in.readByte() != 0;
98 this.cancelable = in.readByte() != 0;
99 this.alpha = in.readFloat();
100 this.width = in.readFloat();
101 this.mPadding = in.createIntArray();
102 this.animStyle = in.readInt();
103 this.refreshAnimation = in.readInt();
104 this.isDimEnabled = in.readByte() != 0;
105 this.backgroundColor = in.readInt();
106 this.radius = in.readInt();
107 this.xOff = in.readInt();
108 this.yOff = in.readInt();
109 }
110
111 public static final Parcelable.Creator<DialogParams> CREATOR = new Parcelable.Creator<DialogParams>() {
112 @Override
113 public DialogParams createFromParcel(Parcel source) {
114 return new DialogParams(source);
115 }
116
117 @Override
118 public DialogParams[] newArray(int size) {
119 return new DialogParams[size];
120 }
121 };
122 }
123
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/InputParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.graphics.Color;
4 import android.os.Parcel;
5 import android.os.Parcelable;
6
7 import com.mylhyl.circledialog.res.values.CircleColor;
8 import com.mylhyl.circledialog.res.values.CircleDimen;
9
10 import java.io.Serializable;
11
12 /**
13 * 输入框参数
14 * Created by hupei on 2017/3/31.
15 */
16 public class InputParams implements Parcelable {
17 private static final int[] MARGINS = {50, 20, 50, 40};
18
19 /**
20 * 输入框与body视图的距离
21 */
22 public int[] margins = MARGINS;
23 /**
24 * 输入框的高度
25 */
26 public int inputHeight = CircleDimen.INPUT_HEIGHT;
27 /**
28 * 输入框提示语
29 */
30 public String hintText;
31 /**
32 * 输入框提示语颜色
33 */
34 public int hintTextColor = CircleColor.content;
35 /**
36 * 输入框背景资源文件
37 */
38 public int inputBackgroundResourceId;
39 /**
40 * 输入框边框线条粗细
41 */
42 public int strokeWidth = 1;
43 /**
44 * 输入框边框线条颜色
45 */
46 public int strokeColor = CircleColor.inputStroke;
47 /**
48 * 输入框的背景
49 */
50 public int inputBackgroundColor = Color.TRANSPARENT;
51 /**
52 * body视图的背景色
53 */
54 public int backgroundColor;
55 /**
56 * 输入框字体大小
57 */
58 public int textSize = CircleDimen.CONTENT_TEXT_SIZE;
59 /**
60 * 输入框字体颜色
61 */
62 public int textColor = CircleColor.title;
63
64 @Override
65 public int describeContents() {
66 return 0;
67 }
68
69 @Override
70 public void writeToParcel(Parcel dest, int flags) {
71 dest.writeIntArray(this.margins);
72 dest.writeInt(this.inputHeight);
73 dest.writeString(this.hintText);
74 dest.writeInt(this.hintTextColor);
75 dest.writeInt(this.inputBackgroundResourceId);
76 dest.writeInt(this.strokeWidth);
77 dest.writeInt(this.strokeColor);
78 dest.writeInt(this.inputBackgroundColor);
79 dest.writeInt(this.backgroundColor);
80 dest.writeInt(this.textSize);
81 dest.writeInt(this.textColor);
82 }
83
84 public InputParams() {
85 }
86
87 protected InputParams(Parcel in) {
88 this.margins = in.createIntArray();
89 this.inputHeight = in.readInt();
90 this.hintText = in.readString();
91 this.hintTextColor = in.readInt();
92 this.inputBackgroundResourceId = in.readInt();
93 this.strokeWidth = in.readInt();
94 this.strokeColor = in.readInt();
95 this.inputBackgroundColor = in.readInt();
96 this.backgroundColor = in.readInt();
97 this.textSize = in.readInt();
98 this.textColor = in.readInt();
99 }
100
101 public static final Parcelable.Creator<InputParams> CREATOR = new Parcelable
102 .Creator<InputParams>() {
103 @Override
104 public InputParams createFromParcel(Parcel source) {
105 return new InputParams(source);
106 }
107
108 @Override
109 public InputParams[] newArray(int size) {
110 return new InputParams[size];
111 }
112 };
113 }
114
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/ItemsParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 import android.widget.AdapterView;
6
7 import com.mylhyl.circledialog.res.values.CircleColor;
8 import com.mylhyl.circledialog.res.values.CircleDimen;
9
10 import java.io.Serializable;
11
12 /**
13 * items 内容参数
14 * Created by hupei on 2017/3/30.
15 */
16 public class ItemsParams implements Parcelable {
17 public void dismiss() {
18 }
19
20 /**
21 * item点击事件
22 */
23 public AdapterView.OnItemClickListener listener;
24 /**
25 * item高度
26 */
27 public int itemHeight = CircleDimen.ITEM_HEIGHT;
28 /**
29 * item内间距
30 */
31 public int[] padding;
32 /**
33 * 数据源:array or list
34 */
35 public Object items;
36 /**
37 * item背景色
38 */
39 public int backgroundColor;
40 /**
41 * item字体色
42 */
43 public int textColor = CircleColor.content;
44 /**
45 * item字体大小
46 */
47 public int textSize = CircleDimen.CONTENT_TEXT_SIZE;
48
49 @Override
50 public int describeContents() {
51 return 0;
52 }
53
54 @Override
55 public void writeToParcel(Parcel dest, int flags) {
56 dest.writeInt(this.itemHeight);
57 dest.writeIntArray(this.padding);
58 dest.writeInt(this.backgroundColor);
59 dest.writeInt(this.textColor);
60 dest.writeInt(this.textSize);
61 }
62
63 public ItemsParams() {
64 }
65
66 protected ItemsParams(Parcel in) {
67 this.itemHeight = in.readInt();
68 this.padding = in.createIntArray();
69 this.backgroundColor = in.readInt();
70 this.textColor = in.readInt();
71 this.textSize = in.readInt();
72 }
73
74 public static final Parcelable.Creator<ItemsParams> CREATOR = new Parcelable.Creator<ItemsParams>() {
75 @Override
76 public ItemsParams createFromParcel(Parcel source) {
77 return new ItemsParams(source);
78 }
79
80 @Override
81 public ItemsParams[] newArray(int size) {
82 return new ItemsParams[size];
83 }
84 };
85 }
86
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/ProgressParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.os.Parcel;
4 import android.os.Parcelable;
5
6 import com.mylhyl.circledialog.res.values.CircleColor;
7 import com.mylhyl.circledialog.res.values.CircleDimen;
8
9 /**
10 * 进度条参数
11 * Created by hupei on 2017/3/31.
12 */
13 public class ProgressParams implements Parcelable {
14
15 private static final int[] MARGINS = {20, 45, 20, 45};
16 private static final int[] TEXT_PADDING = {0, 0, 0, 45};
17
18 /**
19 * 水平进度条
20 */
21 public static final int STYLE_HORIZONTAL = 0;
22 /**
23 * 旋转进度条
24 */
25 public static final int STYLE_SPINNER = 1;
26
27 /**
28 * 进度条样式,默认水平样式
29 */
30 public int style = STYLE_HORIZONTAL;
31 /**
32 * 进度条与body的边距
33 */
34 public int[] margins = MARGINS;
35 /**
36 * 底部文字内边距
37 */
38 public int[] padding = TEXT_PADDING;
39 /**
40 * 进度条资源背景
41 */
42 public int progressDrawableId;
43 /**
44 * 进度条高度
45 */
46 public int progressHeight;
47 /**
48 * 最大刻度
49 */
50 public int max;
51 /**
52 * 刻度
53 */
54 public int progress;
55 /**
56 * 进度条显示的文字,支持String.format() 例如:已经下载%s
57 */
58 public String text = "";
59
60 /**
61 * body背景颜色
62 */
63 public int backgroundColor;
64 /**
65 * 文本字体颜色
66 */
67 public int textColor = CircleColor.content;
68 /**
69 * 文本字体大小
70 */
71 public int textSize = CircleDimen.CONTENT_TEXT_SIZE;
72
73 @Override
74 public int describeContents() {
75 return 0;
76 }
77
78 @Override
79 public void writeToParcel(Parcel dest, int flags) {
80 dest.writeInt(this.style);
81 dest.writeIntArray(this.margins);
82 dest.writeIntArray(this.padding);
83 dest.writeInt(this.progressDrawableId);
84 dest.writeInt(this.progressHeight);
85 dest.writeInt(this.max);
86 dest.writeInt(this.progress);
87 dest.writeString(this.text);
88 dest.writeInt(this.backgroundColor);
89 dest.writeInt(this.textColor);
90 dest.writeInt(this.textSize);
91 }
92
93 public ProgressParams() {
94 }
95
96 protected ProgressParams(Parcel in) {
97 this.style = in.readInt();
98 this.margins = in.createIntArray();
99 this.padding = in.createIntArray();
100 this.progressDrawableId = in.readInt();
101 this.progressHeight = in.readInt();
102 this.max = in.readInt();
103 this.progress = in.readInt();
104 this.text = in.readString();
105 this.backgroundColor = in.readInt();
106 this.textColor = in.readInt();
107 this.textSize = in.readInt();
108 }
109
110 public static final Parcelable.Creator<ProgressParams> CREATOR = new Parcelable
111 .Creator<ProgressParams>() {
112 @Override
113 public ProgressParams createFromParcel(Parcel source) {
114 return new ProgressParams(source);
115 }
116
117 @Override
118 public ProgressParams[] newArray(int size) {
119 return new ProgressParams[size];
120 }
121 };
122 }
123
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/TextParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 import android.view.Gravity;
6
7 import com.mylhyl.circledialog.res.values.CircleColor;
8 import com.mylhyl.circledialog.res.values.CircleDimen;
9
10 /**
11 * 文本内容参数
12 * Created by hupei on 2017/3/30.
13 */
14 public class TextParams implements Parcelable {
15 /**
16 * body文本内间距
17 */
18 public int[] padding;
19 /**
20 * 文本
21 */
22 public String text;
23 /**
24 * 文本高度
25 */
26 public int height = CircleDimen.TITLE_HEIGHT;
27 /**
28 * 文本背景颜色
29 */
30 public int backgroundColor;
31 /**
32 * 文本字体颜色
33 */
34 public int textColor = CircleColor.content;
35 /**
36 * 文本字体大小
37 */
38 public int textSize = CircleDimen.CONTENT_TEXT_SIZE;
39
40 public int gravity = Gravity.CENTER;
41
42 @Override
43 public int describeContents() {
44 return 0;
45 }
46
47 @Override
48 public void writeToParcel(Parcel dest, int flags) {
49 dest.writeIntArray(this.padding);
50 dest.writeString(this.text);
51 dest.writeInt(this.height);
52 dest.writeInt(this.backgroundColor);
53 dest.writeInt(this.textColor);
54 dest.writeInt(this.textSize);
55 dest.writeInt(this.gravity);
56 }
57
58 public TextParams() {
59 }
60
61 protected TextParams(Parcel in) {
62 this.padding = in.createIntArray();
63 this.text = in.readString();
64 this.height = in.readInt();
65 this.backgroundColor = in.readInt();
66 this.textColor = in.readInt();
67 this.textSize = in.readInt();
68 this.gravity = in.readInt();
69 }
70
71 public static final Parcelable.Creator<TextParams> CREATOR = new Parcelable
72 .Creator<TextParams>() {
73 @Override
74 public TextParams createFromParcel(Parcel source) {
75 return new TextParams(source);
76 }
77
78 @Override
79 public TextParams[] newArray(int size) {
80 return new TextParams[size];
81 }
82 };
83 }
84
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/params/TitleParams.java
File was created 1 package com.mylhyl.circledialog.params;
2
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 import android.view.Gravity;
6
7 import com.mylhyl.circledialog.res.values.CircleColor;
8 import com.mylhyl.circledialog.res.values.CircleDimen;
9
10 /**
11 * 标题参数
12 * Created by hupei on 2017/3/30.
13 */
14 public class TitleParams implements Parcelable {
15 /**
16 * 标题
17 */
18 public String text;
19 /**
20 * 标题高度
21 */
22 public int height = CircleDimen.TITLE_HEIGHT;
23 /**
24 * 标题字体大小
25 */
26 public int textSize = CircleDimen.TITLE_TEXT_SIZE;
27 /**
28 * 标题字体颜色
29 */
30 public int textColor = CircleColor.title;
31 /**
32 * 标题背景颜色
33 */
34 public int backgroundColor;
35
36 public int gravity = Gravity.CENTER;
37
38 @Override
39 public int describeContents() {
40 return 0;
41 }
42
43 @Override
44 public void writeToParcel(Parcel dest, int flags) {
45 dest.writeString(this.text);
46 dest.writeInt(this.height);
47 dest.writeInt(this.textSize);
48 dest.writeInt(this.textColor);
49 dest.writeInt(this.backgroundColor);
50 dest.writeInt(this.gravity);
51 }
52
53 public TitleParams() {
54 }
55
56 protected TitleParams(Parcel in) {
57 this.text = in.readString();
58 this.height = in.readInt();
59 this.textSize = in.readInt();
60 this.textColor = in.readInt();
61 this.backgroundColor = in.readInt();
62 this.gravity = in.readInt();
63 }
64
65 public static final Parcelable.Creator<TitleParams> CREATOR = new Parcelable
66 .Creator<TitleParams>() {
67 @Override
68 public TitleParams createFromParcel(Parcel source) {
69 return new TitleParams(source);
70 }
71
72 @Override
73 public TitleParams[] newArray(int size) {
74 return new TitleParams[size];
75 }
76 };
77 }
78
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/drawable/CircleDrawable.java
File was created 1 package com.mylhyl.circledialog.res.drawable;
2
3 import android.graphics.drawable.ShapeDrawable;
4 import android.graphics.drawable.shapes.RoundRectShape;
5
6 /**
7 * 圆角
8 * Created by hupei on 2017/3/29.
9 */
10 public class CircleDrawable extends ShapeDrawable {
11
12 public CircleDrawable(int backgroundColor, int radius) {
13 this(backgroundColor, radius, radius, radius, radius);
14 }
15
16 public CircleDrawable(int backgroundColor, int leftTopRadius, int rightTopRadius
17 , int rightBottomRadius, int leftBottomRadius) {
18 getPaint().setColor(backgroundColor);//内部填充颜色
19 //圆角半径
20 setShape(DrawableHelper.getRoundRectShape(leftTopRadius, rightTopRadius, rightBottomRadius, leftBottomRadius));
21 }
22
23 }
24
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/drawable/DrawableHelper.java
File was created 1 package com.mylhyl.circledialog.res.drawable;
2
3 import android.graphics.drawable.shapes.RoundRectShape;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8
9 class DrawableHelper {
10
11 public static RoundRectShape getRoundRectShape(int leftTop, int rightTop, int rightBottom, int leftBottom) {
12 float outerRadii[] = new float[8];
13 if (leftTop > 0) {
14 outerRadii[0] = leftTop;
15 outerRadii[1] = leftTop;
16 }
17 if (rightTop > 0) {
18 outerRadii[2] = rightTop;
19 outerRadii[3] = rightTop;
20 }
21 if (rightBottom > 0) {
22 outerRadii[4] = rightBottom;
23 outerRadii[5] = rightBottom;
24 }
25 if (leftBottom > 0) {
26 outerRadii[6] = leftBottom;
27 outerRadii[7] = leftBottom;
28 }
29 return new RoundRectShape(outerRadii, null, null);
30 }
31 }
32
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/drawable/InputDrawable.java
File was created 1 package com.mylhyl.circledialog.res.drawable;
2
3 import android.graphics.drawable.GradientDrawable;
4
5 /**
6 * 输入框背景
7 * Created by hupei on 2017/3/31.
8 */
9
10 public class InputDrawable extends GradientDrawable {
11 public InputDrawable(int strokeWidth, int strokeColor, int backgroundColor) {
12 setColor(backgroundColor);//内部填充颜色
13 setStroke(strokeWidth, strokeColor);//边框宽度,边框颜色
14 }
15 }
16
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/drawable/ProgressDrawable.java
File was created 1 package com.mylhyl.circledialog.res.drawable;
2
3 import android.graphics.drawable.ClipDrawable;
4 import android.graphics.drawable.Drawable;
5 import android.graphics.drawable.GradientDrawable;
6 import android.graphics.drawable.LayerDrawable;
7 import android.view.Gravity;
8
9 /**
10 * 进度条背景,不提供内置水平样式
11 * Created by hupei on 2017/3/29.
12 */
13 @Deprecated
14 public final class ProgressDrawable {
15 private static final int colorsBg[] = {0xffBEBEBE, 0xffF5F5F5};
16 private static final int colorsSecondaryProgress[] = {0xff85B0E9, 0xff165CBC};
17 private static final int colorsProgress[] = {0xff85B0E9, 0xff165CBC};
18 private LayerDrawable mLayerDrawable;
19
20 public ProgressDrawable() {
21 GradientDrawable background = createBackground();
22 ClipDrawable secondaryProgress = createSecondaryProgress();
23 ClipDrawable progress = createProgress();
24 Drawable[] layers = {background, secondaryProgress, progress};
25 mLayerDrawable = new LayerDrawable(layers);
26 mLayerDrawable.setId(0, android.R.id.background);
27 mLayerDrawable.setId(1, android.R.id.secondaryProgress);
28 mLayerDrawable.setId(2, android.R.id.progress);
29 }
30
31 private GradientDrawable createBackground() {
32 /* <item android:id="@android:id/background">
33 <shape>
34 <corners android:radius="5dip" />
35
36 <gradient
37 android:angle="270"
38 android:centerY="0.75"
39 android:endColor="#F5F5F5"
40 android:startColor="#BEBEBE" />
41 </shape>
42 </item>*/
43
44 GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colorsBg);
45 drawable.setCornerRadius(5);
46 drawable.setGradientCenter(0.5f, 0.75f);
47 return drawable;
48 }
49
50 private ClipDrawable createSecondaryProgress() {
51 /* <item android:id="@android:id/secondaryProgress">
52 <clip>
53 <shape>
54 <corners android:radius="0dip" />
55
56 <gradient
57 android:angle="270"
58 android:centerY="0.75"
59 android:endColor="#165CBC"
60 android:startColor="#85B0E9" />
61 </shape>
62 </clip>
63 </item>*/
64 GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
65 colorsSecondaryProgress);
66 drawable.setGradientCenter(0.5f, 0.75f);
67 ClipDrawable clipDrawable = new ClipDrawable(drawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
68 return clipDrawable;
69 }
70
71 private ClipDrawable createProgress() {
72 /* <item android:id="@android:id/progress">
73 <clip>
74 <shape>
75 <corners android:radius="5dip" />
76
77 <gradient
78 android:angle="270"
79 android:centerY="0.75"
80 android:endColor="#165CBC"
81 android:startColor="#85B0E9" />
82 </shape>
83 </clip>
84 </item>*/
85
86 //android:angle 默认是Orientation.TOP_BOTTOM,见源码 GradientDrawableGradient_angle 处
87 //见源码 updateGradientDrawableGradient
88 GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colorsProgress);
89 drawable.setCornerRadius(5);//android:radius
90 drawable.setGradientCenter(0.5f, 0.75f);//x默认是0.5,android:centerY
91 ClipDrawable clipDrawable = new ClipDrawable(drawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
92 return clipDrawable;
93 }
94
95 public LayerDrawable getLayerDrawable() {
96 return mLayerDrawable;
97 }
98 }
99
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/drawable/SelectorBtn.java
File was created 1 package com.mylhyl.circledialog.res.drawable;
2
3 import android.graphics.drawable.ShapeDrawable;
4 import android.graphics.drawable.StateListDrawable;
5
6 import com.mylhyl.circledialog.res.values.CircleColor;
7
8 /**
9 * 按钮的背景,有点击效果
10 * Created by hupei on 2017/3/30.
11 */
12
13 public class SelectorBtn extends StateListDrawable {
14
15 public SelectorBtn(int backgroundColor, int leftTopRadius, int rightTopRadius, int rightBottomRadius, int
16 leftBottomRadius) {
17 //按下
18 ShapeDrawable drawablePress = new ShapeDrawable(DrawableHelper.getRoundRectShape(leftTopRadius, rightTopRadius,
19 rightBottomRadius, leftBottomRadius));
20 drawablePress.getPaint().setColor(CircleColor.buttonPress);
21 //默认
22 ShapeDrawable defaultDrawable = new ShapeDrawable(DrawableHelper.getRoundRectShape(leftTopRadius,
23 rightTopRadius,
24 rightBottomRadius, leftBottomRadius));
25 defaultDrawable.getPaint().setColor(backgroundColor);
26
27 addState(new int[]{android.R.attr.state_pressed}, drawablePress);
28 addState(new int[]{-android.R.attr.state_pressed}, defaultDrawable);
29 }
30 }
31
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/values/CircleColor.java
File was created 1 package com.mylhyl.circledialog.res.values;
2
3 /**
4 * Created by hupei on 2017/3/29.
5 */
6 public class CircleColor {
7
8 /**
9 * 对话框背景色
10 */
11 public static final int bgDialog = 0xFFf8f8f8;
12
13 /**
14 * 标题颜色
15 */
16 public static final int title = 0xFF000000;
17 /**
18 * 消息内容颜色
19 */
20 public static final int content = 0xFF8F8F8F;
21 /**
22 * 按钮颜色
23 */
24 public static final int button = 0xFF007AFF;
25 /**
26 * 线条颜色
27 */
28 public static final int divider = 0xFFD7D7DB;
29 /**
30 * 按钮点击颜色
31 */
32 public static final int buttonPress = 0xFFEAEAEA;
33 /**
34 * 输入框边框颜色
35 */
36 public static final int inputStroke = 0xFF808080;
37 }
38
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/values/CircleDimen.java
File was created 1 package com.mylhyl.circledialog.res.values;
2
3 /**
4 * Created by hupei on 2017/3/29.
5 */
6 public class CircleDimen {
7 /**
8 * 所有的圆角
9 */
10 public static final int RADIUS = 30;
11 /**
12 * 标题高
13 */
14 public static final int TITLE_HEIGHT = 170;
15 /**
16 * 标题字体大小
17 */
18 public static final int TITLE_TEXT_SIZE = 60;
19 /**
20 * 文字消息字体大小
21 */
22 public static final int CONTENT_TEXT_SIZE = 50;
23
24 /**
25 * 列表每行高度
26 */
27 public static final int ITEM_HEIGHT = 170;
28 /**
29 * 底部按钮高度
30 */
31 public static final int FOOTER_HEIGHT = 150;
32 /**
33 * 底部按钮字体大小
34 */
35 public static final int FOOTER_TEXT_SIZE = 40;
36
37 /**
38 * 列表模式底部按钮与列表的距离
39 */
40 public static final int BUTTON_ITEMS_MARGIN = 15;
41
42 /**
43 * 输入框的高
44 */
45 public static final int INPUT_HEIGHT = 340;
46 /**
47 * 水平进度条高度
48 */
49 public static final int PROGRESS_HEIGHT_HORIZONTAL = 10;
50 /**
51 * 转换进度条高度
52 */
53 public static final int PROGRESS_HEIGHT_SPINNER = 80;
54 }
55
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/scale/ScaleAdapter.java
File was created 1 package com.mylhyl.circledialog.scale;
2
3 import android.content.Context;
4
5 /**
6 * Created by hupei on 2016/3/8 17:33.
7 */
8 class ScaleAdapter {
9
10 private Context mContext;
11
12 public ScaleAdapter(Context context) {
13 mContext = context;
14 }
15
16 public float adapt(float scale, int screenWidth, int screenHeight) {
17 if (screenWidth < 720 || screenHeight < 720) {//针对小屏(小分辨率)设备做调整
18 if (screenWidth <= 480 || screenHeight <= 480) {//普通480设备
19 scale *= 1.2f;
20 } else {
21 if (ScaleUtils.getDevicePhysicalSize(mContext) < 4.0) {//小屏手机,较高分辨率(如 mx)
22 scale *= 1.3f;
23 } else {//华为U9200
24 scale *= 1.05f;
25 }
26 }
27 }
28 return scale;
29 }
30 }
31
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/scale/ScaleLayoutConfig.java
File was created 1 package com.mylhyl.circledialog.scale;
2
3 import android.content.Context;
4 import android.content.pm.ApplicationInfo;
5 import android.content.pm.PackageManager;
6
7 /**
8 * Created by hupei on 2016/3/8 17:32.
9 */
10 public class ScaleLayoutConfig {
11 private static ScaleLayoutConfig sInstance;
12
13 private static final String KEY_DESIGN_WIDTH = "design_width";
14 private static final String KEY_DESIGN_HEIGHT = "design_height";
15
16 private int mScreenWidth;
17 private int mScreenHeight;
18
19 private int mDesignWidth = 1080;
20 private int mDesignHeight = 1920;
21
22 private float mScale;
23
24 private ScaleLayoutConfig() {
25 }
26
27 public static void init(Context context) {
28 if (sInstance == null) {
29 sInstance = new ScaleLayoutConfig();
30 sInstance.initInternal(context, new ScaleAdapter(context));
31 }
32 }
33
34 public static ScaleLayoutConfig getInstance() {
35 if (sInstance == null) {
36 throw new IllegalStateException("Must init before using.");
37 }
38 return sInstance;
39 }
40
41 private void initInternal(Context context, ScaleAdapter scaleAdapter) {
42 getMetaData(context);
43 checkParams();
44 int[] size = ScaleUtils.getRealScreenSize(context);
45 mScreenWidth = size[0];
46 mScreenHeight = size[1];
47
48 if (mScreenWidth > mScreenHeight) {//横屏状态下,宽高互换,按竖屏模式计算scale
49 mScreenWidth = mScreenWidth + mScreenHeight;
50 mScreenHeight = mScreenWidth - mScreenHeight;
51 mScreenWidth = mScreenWidth - mScreenHeight;
52 }
53
54 float deviceScale = (float) mScreenHeight / mScreenWidth;
55 float designScale = (float) mDesignHeight / mDesignWidth;
56 if (deviceScale <= designScale) {//高宽比小于等于标准比(较标准屏宽一些),以高为基准计算scale(以短边计算),否则以宽为基准计算scale
57 mScale = (float) mScreenHeight / mDesignHeight;
58 } else {
59 mScale = (float) mScreenWidth / mDesignWidth;
60 }
61
62 if (scaleAdapter != null) {
63 mScale = scaleAdapter.adapt(mScale, mScreenWidth, mScreenHeight);
64 }
65 }
66
67 private void getMetaData(Context context) {
68 PackageManager packageManager = context.getPackageManager();
69 ApplicationInfo applicationInfo;
70 try {
71 applicationInfo = packageManager.getApplicationInfo(context
72 .getPackageName(), PackageManager.GET_META_DATA);
73 if (applicationInfo != null && applicationInfo.metaData != null
74 && applicationInfo.metaData.containsKey(KEY_DESIGN_WIDTH)
75 && applicationInfo.metaData.containsKey(KEY_DESIGN_HEIGHT)) {
76 mDesignWidth = (int) applicationInfo.metaData.get(KEY_DESIGN_WIDTH);
77 mDesignHeight = (int) applicationInfo.metaData.get(KEY_DESIGN_HEIGHT);
78 }
79 } catch (PackageManager.NameNotFoundException e) {
80
81 }
82 }
83
84 private void checkParams() {
85 if (mDesignHeight <= 0 || mDesignWidth <= 0) {
86 throw new RuntimeException(
87 "you must set " + KEY_DESIGN_WIDTH + " and " + KEY_DESIGN_HEIGHT + " > 0");
88 }
89 }
90
91 public float getScale() {
92 return mScale;
93 }
94 }
95
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/scale/ScaleUtils.java
File was created 1 package com.mylhyl.circledialog.scale;
2
3 import android.content.Context;
4 import android.graphics.Point;
5 import android.os.Build;
6 import android.util.DisplayMetrics;
7 import android.view.Display;
8 import android.view.WindowManager;
9
10 /**
11 * Created by hupei on 2016/3/8 17:19.
12 */
13 public class ScaleUtils {
14 public static int scaleValue(int val) {
15 return (int) (val * ScaleLayoutConfig.getInstance().getScale());
16 }
17
18 public static int[] getRealScreenSize(Context context) {
19
20 int[] size = new int[2];
21
22 WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
23 Display d = w.getDefaultDisplay();
24 DisplayMetrics metrics = new DisplayMetrics();
25 d.getMetrics(metrics);
26
27 // since SDK_INT = 1;
28 int widthPixels = metrics.widthPixels;
29 int heightPixels = metrics.heightPixels;
30 // includes window decorations (statusbar bar/menu bar)
31 if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17) {
32 try {
33 widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d);
34 heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d);
35 } catch (Exception ignored) {
36 }
37 } else if (Build.VERSION.SDK_INT >= 17) {// includes window decorations (statusbar bar/menu bar)
38 Point realSize = new Point();
39 d.getRealSize(realSize);
40 widthPixels = realSize.x;
41 heightPixels = realSize.y;
42 }
43
44 size[0] = widthPixels;
45 size[1] = heightPixels;
46 return size;
47 }
48
49
50 public static double getDevicePhysicalSize(Context context) {
51 int[] size = getRealScreenSize(context);
52 DisplayMetrics dm = context.getResources().getDisplayMetrics();
53 double x = Math.pow(size[0] / dm.xdpi, 2);
54 double y = Math.pow(size[1] / dm.ydpi, 2);
55
56 return Math.sqrt(x + y);
57 }
58 }
59
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/BodyInputView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5 import android.widget.EditText;
6 import android.widget.LinearLayout;
7
8 import com.mylhyl.circledialog.params.ButtonParams;
9 import com.mylhyl.circledialog.params.CircleParams;
10 import com.mylhyl.circledialog.params.DialogParams;
11 import com.mylhyl.circledialog.params.InputParams;
12 import com.mylhyl.circledialog.params.TitleParams;
13 import com.mylhyl.circledialog.res.drawable.CircleDrawable;
14 import com.mylhyl.circledialog.res.drawable.InputDrawable;
15 import com.mylhyl.circledialog.res.values.CircleColor;
16
17 /**
18 * Created by hupei on 2017/3/31.
19 */
20
21 class BodyInputView extends ScaleLinearLayout {
22 private ScaleEditText mEditText;
23
24 public BodyInputView(Context context, CircleParams params) {
25 super(context);
26 init(context, params);
27 }
28
29 private void init(Context context, CircleParams params) {
30 DialogParams dialogParams = params.dialogParams;
31 TitleParams titleParams = params.titleParams;
32 InputParams inputParams = params.inputParams;
33 ButtonParams negativeParams = params.negativeParams;
34 ButtonParams positiveParams = params.positiveParams;
35
36 //如果标题没有背景色,则使用默认色
37 int backgroundColor = inputParams.backgroundColor != 0 ? inputParams.backgroundColor :
38 CircleColor.bgDialog;
39
40 //有标题没按钮则底部圆角
41 if (titleParams != null && negativeParams == null && positiveParams == null) {
42 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
43 setBackground(new CircleDrawable(backgroundColor, 0, 0, dialogParams.radius,
44 dialogParams.radius));
45 } else {
46 setBackgroundDrawable(new CircleDrawable(backgroundColor, 0, 0, dialogParams
47 .radius, dialogParams.radius));
48 }
49 }
50 //没标题有按钮则顶部圆角
51 else if (titleParams == null && (negativeParams != null || positiveParams != null)) {
52 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
53 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius, dialogParams
54 .radius, 0, 0));
55 } else {
56 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius,
57 dialogParams.radius, 0, 0));
58 }
59 }
60 //没标题没按钮则全部圆角
61 else if (titleParams == null && negativeParams == null && positiveParams == null) {
62 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
63 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius));
64 } else {
65 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius));
66 }
67 }
68 //有标题有按钮则不用考虑圆角
69 else setBackgroundColor(backgroundColor);
70
71 mEditText = new ScaleEditText(context);
72 mEditText.setHint(inputParams.hintText);
73 mEditText.setHintTextColor(inputParams.hintTextColor);
74 mEditText.setTextSize(inputParams.textSize);
75 mEditText.setTextColor(inputParams.textColor);
76 mEditText.setHeight(inputParams.inputHeight);
77
78 int backgroundResourceId = inputParams.inputBackgroundResourceId;
79 if (backgroundResourceId == 0) {
80 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
81 mEditText.setBackground(new InputDrawable(inputParams.strokeWidth, inputParams
82 .strokeColor, inputParams.inputBackgroundColor));
83 } else {
84 mEditText.setBackgroundDrawable(new InputDrawable(inputParams.strokeWidth,
85 inputParams.strokeColor, inputParams.inputBackgroundColor));
86 }
87 } else mEditText.setBackgroundResource(backgroundResourceId);
88
89 LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
90 LayoutParams.WRAP_CONTENT);
91 int[] margins = inputParams.margins;
92 if (margins != null) {
93 layoutParams.setMargins(margins[0], margins[1], margins[2], margins[3]);
94 }
95 addView(mEditText, layoutParams);
96 }
97
98 public EditText getInput() {
99 return mEditText;
100 }
101 }
102
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/BodyItemsView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.graphics.Color;
5 import android.graphics.drawable.ColorDrawable;
6 import android.os.Build;
7 import android.view.View;
8 import android.view.ViewGroup;
9 import android.widget.AdapterView;
10 import android.widget.BaseAdapter;
11 import android.widget.LinearLayout;
12 import android.widget.ListView;
13 import android.widget.TextView;
14
15 import com.mylhyl.circledialog.params.CircleParams;
16 import com.mylhyl.circledialog.params.ItemsParams;
17 import com.mylhyl.circledialog.params.TitleParams;
18 import com.mylhyl.circledialog.res.drawable.SelectorBtn;
19 import com.mylhyl.circledialog.res.values.CircleColor;
20
21 import java.util.Arrays;
22 import java.util.List;
23
24 /**
25 * Created by hupei on 2017/3/30.
26 */
27
28 class BodyItemsView extends ListView {
29 private BaseAdapter mAdapter;
30
31 public BodyItemsView(Context context, CircleParams params) {
32 super(context);
33 init(context, params);
34 }
35
36 private void init(Context context, CircleParams params) {
37 final ItemsParams itemsParams = params.itemsParams;
38
39 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams
40 .MATCH_PARENT, LayoutParams
41 .MATCH_PARENT);
42 setLayoutParams(layoutParams);
43
44 setSelector(new ColorDrawable(Color.TRANSPARENT));
45 setDivider(new ColorDrawable(CircleColor.divider));
46 setDividerHeight(1);
47
48 setOnItemClickListener(new OnItemClickListener() {
49 @Override
50 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
51 itemsParams.dismiss();
52 if (itemsParams.listener != null)
53 itemsParams.listener.onItemClick(parent, view, position, id);
54 }
55 });
56
57 mAdapter = new ItemsAdapter(context, params);
58 setAdapter(mAdapter);
59 }
60
61 public void refreshItems() {
62 post(new Runnable() {
63 @Override
64 public void run() {
65 mAdapter.notifyDataSetChanged();
66 }
67 });
68 }
69
70 static class ItemsAdapter<T> extends BaseAdapter {
71 class ViewHolder {
72 TextView item;
73 }
74
75 private Context mContext;
76 private List<T> mItems;
77 private int mRadius;
78 private int mBackgroundColor;
79 private ItemsParams mItemsParams;
80 private TitleParams mTitleParams;
81
82 public ItemsAdapter(Context context, CircleParams params) {
83 this.mContext = context;
84 this.mTitleParams = params.titleParams;
85 this.mItemsParams = params.itemsParams;
86 this.mRadius = params.dialogParams.radius;
87 //如果没有背景色,则使用默认色
88 this.mBackgroundColor = mItemsParams.backgroundColor != 0 ? mItemsParams
89 .backgroundColor : CircleColor
90 .bgDialog;
91 Object entity = this.mItemsParams.items;
92 if (entity != null && entity instanceof Iterable) {
93 this.mItems = (List<T>) entity;
94 } else if (entity != null && entity.getClass().isArray()) {
95 this.mItems = Arrays.asList((T[]) entity);
96 } else {
97 throw new IllegalArgumentException("entity must be an Array or an Iterable.");
98 }
99 }
100
101 @Override
102 public int getCount() {
103 if (mItems != null)
104 return mItems.size();
105 return 0;
106 }
107
108 @Override
109 public T getItem(int position) {
110 if (mItems != null)
111 return mItems.get(position);
112 return null;
113 }
114
115 @Override
116 public long getItemId(int position) {
117 return 0;
118 }
119
120 @Override
121 public View getView(int position, View convertView, ViewGroup parent) {
122 ViewHolder viewHolder;
123 if (convertView == null) {
124 viewHolder = new ViewHolder();
125 ScaleTextView textView = new ScaleTextView(mContext);
126 textView.setTextSize(mItemsParams.textSize);
127 textView.setTextColor(mItemsParams.textColor);
128 textView.setHeight(mItemsParams.itemHeight);
129 viewHolder.item = textView;
130 convertView = textView;
131 convertView.setTag(viewHolder);
132 } else {
133 viewHolder = (ViewHolder) convertView.getTag();
134 }
135
136 //top
137 if (position == 0 && mTitleParams == null) {
138 if (getCount() == 1) {
139 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
140 viewHolder.item.setBackground(new SelectorBtn(mBackgroundColor, mRadius,
141 mRadius, mRadius, mRadius));
142 } else {
143 viewHolder.item.setBackgroundDrawable(new SelectorBtn(mBackgroundColor,
144 mRadius, mRadius, mRadius, mRadius));
145 }
146 } else {
147 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
148 viewHolder.item.setBackground(new SelectorBtn(mBackgroundColor,
149 mRadius, mRadius, 0, 0));
150 } else {
151 viewHolder.item.setBackgroundDrawable(new SelectorBtn(mBackgroundColor,
152 mRadius, mRadius, 0, 0));
153 }
154 }
155 }
156 //bottom
157 else if (position == getCount() - 1) {
158 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
159 viewHolder.item.setBackground(new SelectorBtn(mBackgroundColor, 0, 0,
160 mRadius, mRadius));
161 } else {
162 viewHolder.item.setBackgroundDrawable(new SelectorBtn(mBackgroundColor, 0, 0,
163 mRadius, mRadius));
164 }
165 }
166 //middle
167 else {
168 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
169 viewHolder.item.setBackground(new SelectorBtn(mBackgroundColor, 0, 0, 0, 0));
170 } else {
171 viewHolder.item.setBackgroundDrawable(new SelectorBtn(mBackgroundColor, 0, 0,
172 0, 0));
173 }
174 }
175 viewHolder.item.setText(String.valueOf(getItem(position).toString()));
176 return convertView;
177 }
178 }
179 }
180
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/BodyProgressView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5 import android.os.Handler;
6 import android.os.Message;
7 import android.text.TextUtils;
8 import android.widget.LinearLayout;
9 import android.widget.ProgressBar;
10
11 import com.mylhyl.circledialog.params.ButtonParams;
12 import com.mylhyl.circledialog.params.CircleParams;
13 import com.mylhyl.circledialog.params.DialogParams;
14 import com.mylhyl.circledialog.params.ProgressParams;
15 import com.mylhyl.circledialog.params.TitleParams;
16 import com.mylhyl.circledialog.res.drawable.CircleDrawable;
17 import com.mylhyl.circledialog.res.values.CircleColor;
18 import com.mylhyl.circledialog.res.values.CircleDimen;
19
20 import java.lang.reflect.Field;
21 import java.lang.reflect.Modifier;
22
23 /**
24 * Created by hupei on 2017/3/31.
25 */
26
27 class BodyProgressView extends ScaleLinearLayout {
28 private ProgressParams mProgressParams;
29 private ProgressBar mProgressBar;
30 private Handler mViewUpdateHandler;
31
32 public BodyProgressView(Context context, CircleParams params) {
33 super(context);
34 init(context, params);
35 }
36
37 private void init(Context context, CircleParams params) {
38 setOrientation(LinearLayout.VERTICAL);
39 DialogParams dialogParams = params.dialogParams;
40 TitleParams titleParams = params.titleParams;
41 ButtonParams negativeParams = params.negativeParams;
42 ButtonParams positiveParams = params.positiveParams;
43 mProgressParams = params.progressParams;
44
45 //如果没有背景色,则使用默认色
46 int backgroundColor = mProgressParams.backgroundColor != 0 ? mProgressParams
47 .backgroundColor : CircleColor
48 .bgDialog;
49
50 //有标题没按钮则底部圆角
51 if (titleParams != null && negativeParams == null && positiveParams == null) {
52 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
53 setBackground(new CircleDrawable(backgroundColor, 0, 0, dialogParams.radius,
54 dialogParams.radius));
55 } else {
56 setBackgroundDrawable(new CircleDrawable(backgroundColor, 0, 0, dialogParams.radius,
57 dialogParams.radius));
58 }
59 }
60 //没标题有按钮则顶部圆角
61 else if (titleParams == null && (negativeParams != null || positiveParams != null)) {
62 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
63 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius, dialogParams
64 .radius, 0, 0));
65 } else {
66 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius,
67 dialogParams.radius, 0, 0));
68 }
69 }
70 //没标题没按钮则全部圆角
71 else if (titleParams == null && negativeParams == null && positiveParams == null) {
72 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
73 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius));
74 } else {
75 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius));
76 }
77 }
78 //有标题有按钮则不用考虑圆角
79 else setBackgroundColor(backgroundColor);
80
81 //自定义样式
82 int progressDrawableId = mProgressParams.progressDrawableId;
83 //水平样式
84 if (mProgressParams.style == ProgressParams.STYLE_HORIZONTAL) {
85 if (progressDrawableId != 0) {
86 mProgressBar = new ProgressBar(getContext());
87 setFieldValue(mProgressBar, "mOnlyIndeterminate", new Boolean(false));
88 mProgressBar.setIndeterminate(false);
89 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
90 mProgressBar.setProgressDrawableTiled(context.getDrawable(progressDrawableId));
91 else
92 mProgressBar.setProgressDrawable(context.getResources().getDrawable
93 (progressDrawableId));
94 } else {
95 mProgressBar = new ProgressBar(getContext(), null, android.R.attr
96 .progressBarStyleHorizontal);
97 }
98 mProgressParams.progressHeight = CircleDimen.PROGRESS_HEIGHT_HORIZONTAL;
99 }
100 //旋转样式
101 else {
102 if (progressDrawableId != 0) {
103 mProgressBar = new ProgressBar(getContext());
104 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
105 mProgressBar.setIndeterminateDrawableTiled(context.getDrawable
106 (progressDrawableId));
107 else
108 mProgressBar.setIndeterminateDrawable(context.getResources().getDrawable
109 (progressDrawableId));
110 } else {
111 mProgressBar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyle);
112 }
113 mProgressParams.progressHeight = CircleDimen.PROGRESS_HEIGHT_SPINNER;
114 }
115
116 LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, mProgressParams
117 .progressHeight);
118 int[] margins = mProgressParams.margins;
119 if (margins != null)
120 layoutParams.setMargins(margins[0], margins[1], margins[2], margins[3]);
121 addView(mProgressBar, layoutParams);
122
123 //构建文本
124 final ScaleTextView textView = new ScaleTextView(getContext());
125 textView.setTextSize(mProgressParams.textSize);
126 textView.setTextColor(mProgressParams.textColor);
127 int[] padding = mProgressParams.padding;
128 if (padding != null)
129 textView.setAutoPadding(padding[0], padding[1], padding[2], padding[3]);
130 addView(textView);
131
132 if (mProgressParams.style == ProgressParams.STYLE_HORIZONTAL) {
133 mViewUpdateHandler = new Handler() {
134 @Override
135 public void handleMessage(Message msg) {
136 super.handleMessage(msg);
137 int progress = mProgressBar.getProgress();
138 int max = mProgressBar.getMax();
139 int percent = (int) (((float) progress / (float) max) * 100);
140 String args = percent + "%";
141 if (!TextUtils.isEmpty(mProgressParams.text) && mProgressParams.text.contains
142 ("%s"))
143 textView.setText(String.format(mProgressParams.text, args));
144 else textView.setText(mProgressParams.text + args);
145 }
146 };
147 } else {
148 textView.setText(mProgressParams.text);
149 }
150 }
151
152
153 public void refreshProgress() {
154 mProgressBar.setMax(mProgressParams.max);
155 mProgressBar.setProgress(mProgressParams.progress);
156 mProgressBar.setSecondaryProgress(mProgressParams.progress + 10);
157 onProgressChanged();
158 }
159
160 private void onProgressChanged() {
161 if (mViewUpdateHandler != null && !mViewUpdateHandler.hasMessages(0))
162 mViewUpdateHandler.sendEmptyMessage(0);
163 }
164
165 /**
166 * 直接设置对象属性值,无视private/protected修饰符,不经过setter函数.
167 */
168 private static void setFieldValue(final Object object, final String fieldName, final Object
169 value) {
170 Field field = getDeclaredField(object, fieldName);
171 if (field == null)
172 throw new IllegalArgumentException("Could not find field [" + fieldName + "] on " +
173 "target [" + object + "]");
174 makeAccessible(field);
175 try {
176 field.set(object, value);
177 } catch (IllegalAccessException e) {
178 e.printStackTrace();
179 }
180 }
181
182 /**
183 * 循环向上转型,获取对象的DeclaredField.
184 */
185 protected static Field getDeclaredField(final Object object, final String fieldName) {
186 return getDeclaredField(object.getClass(), fieldName);
187 }
188
189 /**
190 * 循环向上转型,获取类的DeclaredField.
191 */
192 @SuppressWarnings("unchecked")
193 protected static Field getDeclaredField(final Class clazz, final String fieldName) {
194 for (Class superClass = clazz; superClass != Object.class; superClass = superClass
195 .getSuperclass()) {
196 try {
197 return superClass.getDeclaredField(fieldName);
198 } catch (NoSuchFieldException e) {
199 e.printStackTrace();// Field不在当前类定义,继续向上转型
200 }
201 }
202 return null;
203 }
204
205 /**
206 * 强制转换fileld可访问.
207 */
208 protected static void makeAccessible(Field field) {
209 if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field
210 .getDeclaringClass().getModifiers())) {
211 field.setAccessible(true);
212 }
213 }
214 }
215
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/BodyTextView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5
6 import com.mylhyl.circledialog.params.ButtonParams;
7 import com.mylhyl.circledialog.params.CircleParams;
8 import com.mylhyl.circledialog.params.DialogParams;
9 import com.mylhyl.circledialog.params.TextParams;
10 import com.mylhyl.circledialog.params.TitleParams;
11 import com.mylhyl.circledialog.res.drawable.CircleDrawable;
12 import com.mylhyl.circledialog.res.values.CircleColor;
13
14 /**
15 * 对话框纯文本视图
16 * Created by hupei on 2017/3/30.
17 */
18 class BodyTextView extends ScaleTextView {
19 private CircleParams mParams;
20
21 public BodyTextView(Context context, CircleParams params) {
22 super(context);
23 this.mParams = params;
24 init(params);
25 }
26
27 private void init(CircleParams params) {
28 DialogParams dialogParams = params.dialogParams;
29 TitleParams titleParams = params.titleParams;
30 TextParams textParams = params.textParams;
31 ButtonParams negativeParams = params.negativeParams;
32 ButtonParams positiveParams = params.positiveParams;
33
34 setGravity(textParams.gravity);
35
36 //如果标题没有背景色,则使用默认色
37 int backgroundColor = textParams.backgroundColor != 0 ? textParams.backgroundColor :
38 CircleColor.bgDialog;
39
40 //有标题没按钮则底部圆角
41 if (titleParams != null && negativeParams == null && positiveParams == null) {
42 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
43 setBackground(new CircleDrawable(backgroundColor, 0, 0, dialogParams.radius,
44 dialogParams.radius));
45 } else {
46 setBackgroundDrawable(new CircleDrawable(backgroundColor, 0, 0, dialogParams.radius,
47 dialogParams.radius));
48 }
49 }
50 //没标题有按钮则顶部圆角
51 else if (titleParams == null && (negativeParams != null || positiveParams != null)) {
52 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
53 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius, dialogParams
54 .radius, 0, 0));
55 } else {
56 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius,
57 dialogParams.radius, 0, 0));
58 }
59 }
60 //没标题没按钮则全部圆角
61 else if (titleParams == null && negativeParams == null && positiveParams == null) {
62 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
63 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius));
64 } else {
65 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius));
66 }
67 }
68 //有标题有按钮则不用考虑圆角
69 else setBackgroundColor(backgroundColor);
70
71 // setHeight(textParams.height);
72 setMinHeight(textParams.height);
73 setTextColor(textParams.textColor);
74 setTextSize(textParams.textSize);
75 setText(textParams.text);
76
77 int[] padding = textParams.padding;
78 if (padding != null) setAutoPadding(padding[0], padding[1], padding[2], padding[3]);
79 }
80
81 public void refreshText() {
82 if (mParams.textParams == null) return;
83 post(new Runnable() {
84 @Override
85 public void run() {
86 setText(mParams.textParams.text);
87 }
88 });
89 }
90 }
91
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/BuildViewImpl.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.view.View;
5 import android.widget.LinearLayout;
6
7 import com.mylhyl.circledialog.BuildView;
8 import com.mylhyl.circledialog.params.CircleParams;
9
10 /**
11 * Created by hupei on 2017/3/29.
12 */
13
14 public class BuildViewImpl implements BuildView {
15 private Context mContext;
16 private CircleParams mParams;
17 private LinearLayout mRoot;
18 private TitleView mTitleView;
19 private BodyTextView mBodyTextView;
20 private BodyItemsView mBodyItemsView;
21 private BodyProgressView mBodyProgressView;
22 private BodyInputView mBodyInputView;
23 private ItemsButton mItemsButton;
24 private MultipleButton mMultipleButton;
25 private SingleButton mSingleButton;
26
27 public BuildViewImpl(Context context, CircleParams params) {
28 this.mContext = context;
29 this.mParams = params;
30 }
31
32 @Override
33 public void buildRoot() {
34 if (mRoot == null) {
35 mRoot = new ScaleLinearLayout(mContext);
36 mRoot.setOrientation(LinearLayout.VERTICAL);
37 }
38 }
39
40 @Override
41 public void buildTitle() {
42 if (mTitleView == null) {
43 mTitleView = new TitleView(mContext, mParams);
44 mRoot.addView(mTitleView);
45 }
46 }
47
48 @Override
49 public void buildText() {
50 if (mBodyTextView == null) {
51 mBodyTextView = new BodyTextView(mContext, mParams);
52 mRoot.addView(mBodyTextView);
53 }
54 }
55
56 @Override
57 public void refreshText() {
58 if (mBodyTextView != null) mBodyTextView.refreshText();
59 }
60
61 @Override
62 public void buildItems() {
63 if (mBodyItemsView == null) {
64 mBodyItemsView = new BodyItemsView(mContext, mParams);
65 mRoot.addView(mBodyItemsView);
66 }
67 }
68
69 @Override
70 public void buildItemsButton() {
71 if (mItemsButton == null) {
72 mItemsButton = new ItemsButton(mContext, mParams);
73 mRoot.addView(mItemsButton);
74 }
75 }
76
77 @Override
78 public void refreshItems() {
79 if (mBodyItemsView != null) mBodyItemsView.refreshItems();
80 }
81
82 @Override
83 public void buildProgress() {
84 if (mBodyProgressView == null) {
85 mBodyProgressView = new BodyProgressView(mContext, mParams);
86 mRoot.addView(mBodyProgressView);
87 }
88 }
89
90
91 @Override
92 public void refreshProgress() {
93 if (mBodyProgressView != null) mBodyProgressView.refreshProgress();
94 }
95
96 @Override
97 public void buildInput() {
98 if (mBodyInputView == null) {
99 mBodyInputView = new BodyInputView(mContext, mParams);
100 mRoot.addView(mBodyInputView);
101 }
102 }
103
104 @Override
105 public void buildMultipleButton() {
106 if (mMultipleButton == null) {
107 mMultipleButton = new MultipleButton(mContext, mParams);
108 DividerView dividerView = new DividerView(mContext);
109 dividerView.setVertical();
110 mRoot.addView(dividerView);
111 mRoot.addView(mMultipleButton);
112 }
113 }
114
115 @Override
116 public void buildSingleButton() {
117 if (mSingleButton == null) {
118 mSingleButton = new SingleButton(mContext, mParams);
119 DividerView dividerViewV = new DividerView(mContext);
120 dividerViewV.setVertical();
121 mRoot.addView(dividerViewV);
122 mRoot.addView(mSingleButton);
123 }
124 }
125
126 @Override
127 public void regInputListener() {
128 if (mSingleButton != null && mBodyInputView != null)
129 mSingleButton.regOnInputClickListener(mBodyInputView.getInput());
130
131 if (mMultipleButton != null && mBodyInputView != null)
132 mMultipleButton.regOnInputClickListener(mBodyInputView.getInput());
133 }
134
135 @Override
136 public View getView() {
137 return mRoot;
138 }
139 }
140
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/DividerView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.view.View;
5 import android.widget.LinearLayout;
6
7 import com.mylhyl.circledialog.res.values.CircleColor;
8
9 /**
10 * 分隔线,默认垂直
11 * Created by hupei on 2017/3/30.
12 */
13 class DividerView extends View {
14 public DividerView(Context context) {
15 super(context);
16 init();
17 }
18
19 private void init() {
20 setLayoutParams(new LinearLayout.LayoutParams(1, LinearLayout.LayoutParams.MATCH_PARENT));
21 setBackgroundColor(CircleColor.divider);
22 }
23
24 /**
25 * 将分隔线设置为水平分隔
26 */
27 public void setVertical() {
28 setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
29 }
30 }
31
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/ItemsButton.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5 import android.view.View;
6 import android.view.ViewGroup;
7 import android.widget.LinearLayout;
8
9 import com.mylhyl.circledialog.scale.ScaleUtils;
10 import com.mylhyl.circledialog.params.ButtonParams;
11 import com.mylhyl.circledialog.params.CircleParams;
12 import com.mylhyl.circledialog.res.drawable.SelectorBtn;
13 import com.mylhyl.circledialog.res.values.CircleColor;
14 import com.mylhyl.circledialog.res.values.CircleDimen;
15
16 /**
17 * 列表对话框的取消按钮视图
18 * Created by hupei on 2017/3/30.
19 */
20 class ItemsButton extends ScaleTextView {
21
22 public ItemsButton(Context context, CircleParams params) {
23 super(context);
24 init(params);
25 }
26
27 private void init(CircleParams params) {
28 ButtonParams negativeParams = params.negativeParams;
29 final ButtonParams buttonParams = negativeParams != null ? negativeParams : params
30 .positiveParams;
31 //为列表显示时,设置列表与按钮之间的距离
32 if (params.itemsParams != null) buttonParams.topMargin = CircleDimen.BUTTON_ITEMS_MARGIN;
33
34 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup
35 .LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
36 layoutParams.topMargin = ScaleUtils.scaleValue(buttonParams.topMargin);
37 setLayoutParams(layoutParams);
38
39 setClickable(true);
40 setOnClickListener(new OnClickListener() {
41 @Override
42 public void onClick(View v) {
43 buttonParams.dismiss();
44 if (buttonParams.listener != null) buttonParams.listener.onClick(v);
45 }
46 });
47 setText(buttonParams.text);
48 setTextSize(buttonParams.textSize);
49 setTextColor(buttonParams.textColor);
50 setHeight(buttonParams.height);
51
52 //如果取消按钮没有背景色,则使用默认色
53 int backgroundColor = buttonParams.backgroundColor != 0 ? buttonParams.backgroundColor :
54 CircleColor.bgDialog;
55 int radius = params.dialogParams.radius;
56 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
57 setBackground(new SelectorBtn(backgroundColor, radius, radius, radius, radius));
58 } else {
59 setBackgroundDrawable(new SelectorBtn(backgroundColor, radius, radius, radius, radius));
60 }
61 }
62 }
63
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/MultipleButton.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5 import android.text.TextUtils;
6 import android.view.View;
7 import android.view.ViewGroup;
8 import android.widget.EditText;
9 import android.widget.LinearLayout;
10
11 import com.mylhyl.circledialog.params.ButtonParams;
12 import com.mylhyl.circledialog.params.CircleParams;
13 import com.mylhyl.circledialog.res.drawable.SelectorBtn;
14 import com.mylhyl.circledialog.res.values.CircleColor;
15
16 /**
17 * 对话框确定按钮与取消的视图
18 * Created by hupei on 2017/3/30.
19 */
20 class MultipleButton extends ScaleLinearLayout {
21 private ButtonParams mNegativeParams;
22 private ButtonParams mPositiveParams;
23 private ScaleTextView mNegativeButton;
24 private ScaleTextView mPositiveButton;
25
26 public MultipleButton(Context context, CircleParams params) {
27 super(context);
28 init(params);
29 }
30
31 private void init(CircleParams params) {
32 setOrientation(HORIZONTAL);
33
34 mNegativeParams = params.negativeParams;
35 mPositiveParams = params.positiveParams;
36
37 int radius = params.dialogParams.radius;
38
39 //取消按钮
40 createNegative(radius);
41
42 //添加二人按钮之间的分隔线
43 DividerView dividerView = new DividerView(getContext());
44 addView(dividerView);
45
46 //确定按钮
47 createPositive(radius);
48 }
49
50 private void createNegative(int radius) {
51 mNegativeButton = new ScaleTextView(getContext());
52 mNegativeButton.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
53 ViewGroup
54 .LayoutParams.WRAP_CONTENT, 1));
55
56 mNegativeButton.setText(mNegativeParams.text);
57 mNegativeButton.setTextSize(mNegativeParams.textSize);
58 mNegativeButton.setTextColor(mNegativeParams.textColor);
59 mNegativeButton.setHeight(mNegativeParams.height);
60
61 //如果取消按钮没有背景色,则使用默认色
62 int backgroundNegative = mNegativeParams.backgroundColor != 0 ? mNegativeParams
63 .backgroundColor : CircleColor.bgDialog;
64 //按钮左下方为圆角
65 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
66 mNegativeButton.setBackground(new SelectorBtn(backgroundNegative, 0, 0, 0, radius));
67 } else {
68 mNegativeButton.setBackgroundDrawable(new SelectorBtn(backgroundNegative, 0, 0, 0,
69 radius));
70 }
71
72 regNegativeListener();
73
74 addView(mNegativeButton);
75 }
76
77 private void createPositive(int radius) {
78
79 mPositiveButton = new ScaleTextView(getContext());
80 mPositiveButton.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
81 ViewGroup
82 .LayoutParams.WRAP_CONTENT, 1));
83
84 mPositiveButton.setText(mPositiveParams.text);
85 mPositiveButton.setTextSize(mPositiveParams.textSize);
86 mPositiveButton.setTextColor(mPositiveParams.textColor);
87 mPositiveButton.setHeight(mPositiveParams.height);
88
89 //如果取消按钮没有背景色,则使用默认色
90 int backgroundPositive = mPositiveParams.backgroundColor != 0 ? mPositiveParams
91 .backgroundColor : CircleColor
92 .bgDialog;
93
94 //取消按钮右下方为圆角
95 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
96 mPositiveButton.setBackground(new SelectorBtn(backgroundPositive, 0, 0, radius, 0));
97 } else {
98 mPositiveButton.setBackgroundDrawable(new SelectorBtn(backgroundPositive, 0, 0,
99 radius, 0));
100 }
101
102 regPositiveListener();
103
104 addView(mPositiveButton);
105 }
106
107 private void regNegativeListener() {
108 mNegativeButton.setOnClickListener(new OnClickListener() {
109 @Override
110 public void onClick(View v) {
111 mNegativeParams.dismiss();
112 if (mNegativeParams.listener != null) mNegativeParams.listener.onClick(v);
113 }
114 });
115 }
116
117 private void regPositiveListener() {
118 mPositiveButton.setOnClickListener(new OnClickListener() {
119 @Override
120 public void onClick(View v) {
121 mPositiveParams.dismiss();
122 if (mPositiveParams.listener != null) mPositiveParams.listener.onClick(v);
123 }
124 });
125 }
126
127 public void regOnInputClickListener(final EditText input) {
128 mPositiveButton.setOnClickListener(new OnClickListener() {
129 @Override
130 public void onClick(View v) {
131 String text = input.getText().toString();
132 if (!TextUtils.isEmpty(text))
133 mPositiveParams.dismiss();
134 if (mPositiveParams.inputListener != null)
135 mPositiveParams.inputListener.onClick(text, v);
136 }
137 });
138 }
139 }
140
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/ScaleEditText.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.util.TypedValue;
5 import android.view.Gravity;
6 import android.widget.EditText;
7
8 import com.mylhyl.circledialog.scale.ScaleUtils;
9
10 /**
11 * Created by hupei on 2017/3/31.
12 */
13 class ScaleEditText extends EditText {
14 public ScaleEditText(Context context) {
15 super(context);
16 config();
17 }
18
19 private void config() {
20 requestFocus();
21 setFocusable(true);
22 setFocusableInTouchMode(true);
23 setGravity(Gravity.TOP | Gravity.LEFT);
24 }
25
26 @Override
27 public void setHeight(int pixels) {
28 int dimenHeight = ScaleUtils.scaleValue(pixels);
29 super.setHeight(dimenHeight);
30 }
31
32 @Override
33 public void setTextSize(float size) {
34 int dimenTextSize = ScaleUtils.scaleValue((int) size);
35 setTextSize(TypedValue.COMPLEX_UNIT_PX, dimenTextSize);
36 }
37 }
38
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/ScaleLinearLayout.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.annotation.TargetApi;
4 import android.content.Context;
5 import android.os.Build;
6 import android.util.AttributeSet;
7 import android.widget.LinearLayout;
8
9 import com.mylhyl.circledialog.scale.ScaleLayoutConfig;
10
11
12 /**
13 * Created by hupei on 2017/3/29.
14 */
15 class ScaleLinearLayout extends LinearLayout {
16 public ScaleLinearLayout(Context context) {
17 this(context, null);
18 }
19
20 public ScaleLinearLayout(Context context, AttributeSet attrs) {
21 this(context, attrs, 0);
22 }
23
24 public ScaleLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
25 super(context, attrs, defStyleAttr);
26 ScaleLayoutConfig.init(context);
27 }
28
29 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
30 public ScaleLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
31 super(context, attrs, defStyleAttr, defStyleRes);
32 ScaleLayoutConfig.init(context);
33 }
34 }
35
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/ScaleTextView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.util.TypedValue;
5 import android.view.Gravity;
6 import android.widget.TextView;
7
8 import com.mylhyl.circledialog.scale.ScaleUtils;
9
10 /**
11 * Created by hupei on 2017/3/29.
12 */
13
14 class ScaleTextView extends TextView {
15 public ScaleTextView(Context context) {
16 super(context);
17 config();
18 }
19
20 private void config() {
21 setGravity(Gravity.CENTER);
22 }
23
24 @Override
25 public void setHeight(int pixels) {
26 int dimenHeight = ScaleUtils.scaleValue(pixels);
27 super.setHeight(dimenHeight);
28 }
29
30 @Override
31 public void setTextSize(float size) {
32 int dimenTextSize = ScaleUtils.scaleValue((int) size);
33 setTextSize(TypedValue.COMPLEX_UNIT_PX, dimenTextSize);
34 }
35
36 public void setAutoPadding(int left, int top, int right, int bottom) {
37 int dimenLeft = ScaleUtils.scaleValue(left);
38 int dimenTop = ScaleUtils.scaleValue(top);
39 int dimenRight = ScaleUtils.scaleValue(right);
40 int dimenBottom = ScaleUtils.scaleValue(bottom);
41 super.setPadding(dimenLeft, dimenTop, dimenRight, dimenBottom);
42 }
43 }
44
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/SingleButton.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5 import android.text.TextUtils;
6 import android.view.View;
7 import android.widget.EditText;
8
9 import com.mylhyl.circledialog.params.ButtonParams;
10 import com.mylhyl.circledialog.params.CircleParams;
11 import com.mylhyl.circledialog.res.drawable.SelectorBtn;
12 import com.mylhyl.circledialog.res.values.CircleColor;
13
14 /**
15 * 对话框单个按钮的视图
16 * Created by hupei on 2017/3/30.
17 */
18 class SingleButton extends ScaleTextView {
19 private ButtonParams mButtonParams;
20
21 public SingleButton(Context context, CircleParams params) {
22 super(context);
23 init(params);
24 }
25
26 private void init(CircleParams params) {
27 mButtonParams = params.negativeParams != null ? params.negativeParams : params
28 .positiveParams;
29
30 setText(mButtonParams.text);
31 setTextSize(mButtonParams.textSize);
32 setTextColor(mButtonParams.textColor);
33 setHeight(mButtonParams.height);
34
35 //如果取消按钮没有背景色,则使用默认色
36 int backgroundColor = mButtonParams.backgroundColor != 0 ? mButtonParams.backgroundColor
37 : CircleColor.bgDialog;
38
39 int radius = params.dialogParams.radius;
40 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
41 setBackground(new SelectorBtn(backgroundColor, 0, 0, radius, radius));
42 } else {
43 setBackgroundDrawable(new SelectorBtn(backgroundColor, 0, 0, radius, radius));
44 }
45
46 regOnClickListener();
47 }
48
49 private void regOnClickListener() {
50 setOnClickListener(new OnClickListener() {
51 @Override
52 public void onClick(View v) {
53 mButtonParams.dismiss();
54 if (mButtonParams.listener != null) mButtonParams.listener.onClick(v);
55 }
56 });
57 }
58
59 public void regOnInputClickListener(final EditText input) {
60 setOnClickListener(new OnClickListener() {
61 @Override
62 public void onClick(View v) {
63 String text = input.getText().toString();
64 if (!TextUtils.isEmpty(text))
65 mButtonParams.dismiss();
66 if (mButtonParams.inputListener != null)
67 mButtonParams.inputListener.onClick(text, v);
68 }
69 });
70 }
71 }
72
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/TitleView.java
File was created 1 package com.mylhyl.circledialog.view;
2
3 import android.content.Context;
4 import android.os.Build;
5
6 import com.mylhyl.circledialog.params.CircleParams;
7 import com.mylhyl.circledialog.params.DialogParams;
8 import com.mylhyl.circledialog.params.TitleParams;
9 import com.mylhyl.circledialog.res.drawable.CircleDrawable;
10 import com.mylhyl.circledialog.res.values.CircleColor;
11
12 /**
13 * 对话框标题
14 * Created by hupei on 2017/3/29.
15 */
16 class TitleView extends ScaleTextView {
17
18 public TitleView(Context context, CircleParams params) {
19 super(context);
20 init(params);
21 }
22
23 private void init(CircleParams params) {
24 DialogParams dialogParams = params.dialogParams;
25 TitleParams titleParams = params.titleParams;
26
27 setGravity(titleParams.gravity);
28
29 //如果标题没有背景色,则使用默认色
30 int backgroundColor = titleParams.backgroundColor != 0 ? titleParams.backgroundColor :
31 CircleColor.bgDialog;
32
33 //有内容则顶部圆角
34 if (params.textParams != null || params.itemsParams != null || params.progressParams != null
35 || params.inputParams != null) {
36 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
37 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius, dialogParams
38 .radius, 0, 0));
39 } else {
40 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius,
41 dialogParams.radius, 0, 0));
42 }
43 }
44 //无内容则全部圆角
45 else {
46 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
47 setBackground(new CircleDrawable(backgroundColor, dialogParams.radius));
48 } else {
49 setBackgroundDrawable(new CircleDrawable(backgroundColor, dialogParams.radius));
50 }
51 }
52
53 setHeight(titleParams.height);
54 setTextColor(titleParams.textColor);
55 setTextSize(titleParams.textSize);
56 setText(titleParams.text);
57 }
58 }
59
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/view/listener/OnInputClickListener.java
File was created 1 package com.mylhyl.circledialog.view.listener;
2
3 import android.view.View;
4
5 /**
6 * Created by hupei on 2017/3/30.
7 */
8 public interface OnInputClickListener {
9 void onClick(String text, View v);
10 }
11
PersonalCenter/settings.gradle
1 include ':app' 1 include ':app', ':circledialog'
2 2