Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
dd25b0a6
Commit
dd25b0a6
authored
Mar 04, 2021
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 公用dialog,CommonDialog加入按钮背景设置方法
parent
07b06f0d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
44 deletions
+89
-44
config.gradle
config.gradle
+4
-4
CommonDialog.java
ydl-platform/src/main/java/com/ydl/ydlcommon/view/dialog/CommonDialog.java
+85
-40
No files found.
config.gradle
View file @
dd25b0a6
...
...
@@ -8,7 +8,7 @@ ext {
"m-confide"
:
"0.0.48.91"
,
"m-consultant"
:
"0.0.59.40"
,
"m-fm"
:
"0.0.30.00"
,
"m-user"
:
"0.0.60.4
2
"
,
"m-user"
:
"0.0.60.4
5
"
,
"m-home"
:
"0.0.22.51"
,
"m-im"
:
"0.0.18.30"
,
"m-dynamic"
:
"0.0.7.13"
,
...
...
@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.
63
"
,
"ydl-platform"
:
"0.0.39.
84
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.33"
,
...
...
@@ -91,7 +91,7 @@ ext {
"m-confide"
:
"0.0.48.91"
,
"m-consultant"
:
"0.0.51.16"
,
"m-fm"
:
"0.0.23.5"
,
"m-user"
:
"0.0.60.
37
"
,
"m-user"
:
"0.0.60.
45
"
,
"m-home"
:
"0.0.22.51"
,
"m-im"
:
"0.0.3.15"
,
"m-dynamic"
:
"0.0.1.7"
,
...
...
@@ -114,7 +114,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.
61
"
,
"ydl-platform"
:
"0.0.39.
84
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.32"
,
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/view/dialog/CommonDialog.java
View file @
dd25b0a6
...
...
@@ -4,6 +4,7 @@ import android.app.Activity;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.graphics.drawable.GradientDrawable
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -13,6 +14,7 @@ import android.widget.ImageView;
import
android.widget.TextView
;
import
com.ydl.ydlcommon.R
;
import
com.ydl.ydlcommon.utils.DisplayUtils
;
/**
...
...
@@ -35,7 +37,7 @@ public class CommonDialog extends Dialog {
private
View
view_vertical_line
;
//按钮之间的分割线
private
Button
right_btn
;
//右边确定按钮
public
static
CommonDialog
create
(
Context
context
){
public
static
CommonDialog
create
(
Context
context
)
{
return
new
CommonDialog
(
context
);
}
...
...
@@ -43,16 +45,16 @@ public class CommonDialog extends Dialog {
super
(
context
,
R
.
style
.
platform_normaldialog_style
);
this
.
context
=
context
;
View
v
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
platform_dialog_common_layout
,
null
);
View
v
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
platform_dialog_common_layout
,
null
);
title_tv
=((
TextView
)
v
.
findViewById
(
R
.
id
.
title
)
);
imageCenter
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
img_tip
);
message_tv
=((
TextView
)
v
.
findViewById
(
R
.
id
.
message
)
);
left_btn
=((
Button
)
v
.
findViewById
(
R
.
id
.
cancel_btn
)
);
title_tv
=
v
.
findViewById
(
R
.
id
.
title
);
imageCenter
=
v
.
findViewById
(
R
.
id
.
img_tip
);
message_tv
=
v
.
findViewById
(
R
.
id
.
message
);
left_btn
=
v
.
findViewById
(
R
.
id
.
cancel_btn
);
view_vertical_line
=
v
.
findViewById
(
R
.
id
.
view_vertical_line
);
right_btn
=
((
Button
)
v
.
findViewById
(
R
.
id
.
confirm_btn
)
);
right_btn
=
v
.
findViewById
(
R
.
id
.
confirm_btn
);
setContentView
(
v
,
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
));
setContentView
(
v
,
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
));
}
public
CommonDialog
(
Context
context
,
int
theme
)
{
...
...
@@ -62,11 +64,12 @@ public class CommonDialog extends Dialog {
/**
* 设置左下角按钮的隐藏与显示
* @return
*
* @return 当前CommonDialog本身
*/
public
CommonDialog
setCancleIsVisibility
(
int
visibility
){
public
CommonDialog
setCancleIsVisibility
(
int
visibility
)
{
if
(
left_btn
!=
null
)
{
if
(
left_btn
!=
null
)
{
left_btn
.
setVisibility
(
visibility
);
}
return
this
;
...
...
@@ -74,7 +77,7 @@ public class CommonDialog extends Dialog {
/*设置对话框信息*/
public
CommonDialog
setMessage
(
String
message
)
{
if
(
message
!=
null
)
{
if
(
message
!=
null
)
{
message_tv
.
setText
(
message
);
}
return
this
;
...
...
@@ -83,16 +86,17 @@ public class CommonDialog extends Dialog {
/**
* 设置message文本抖动动画
*/
public
CommonDialog
setMessageShake
(
boolean
isShake
){
if
(
isShake
){
message_tv
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
platform_shake_smail
));
public
CommonDialog
setMessageShake
(
boolean
isShake
)
{
if
(
isShake
)
{
message_tv
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
platform_shake_smail
));
}
return
this
;
}
/**
* 设置信息颜色
*/
public
CommonDialog
setMessageColor
(
int
resColor
){
public
CommonDialog
setMessageColor
(
int
resColor
)
{
message_tv
.
setTextColor
(
getContext
().
getResources
().
getColor
(
resColor
));
return
this
;
}
...
...
@@ -100,13 +104,13 @@ public class CommonDialog extends Dialog {
/**
* Set the Dialog title from String
*
* @param title
* @return
* @param title
标题
* @return
当前CommonDialog本身
*/
public
CommonDialog
setTitle
(
String
title
)
{
if
(
""
.
equals
(
title
)||
title
==
null
)
{
if
(
""
.
equals
(
title
)
||
title
==
null
)
{
title_tv
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
title_tv
.
setVisibility
(
View
.
VISIBLE
);
title_tv
.
setText
(
title
);
title_tv
.
getPaint
().
setFakeBoldText
(
true
);
//仿粗体
...
...
@@ -114,35 +118,76 @@ public class CommonDialog extends Dialog {
return
this
;
}
public
CommonDialog
setTitle_color
(
int
res_color
){
/**
* 设置描述
*/
public
CommonDialog
setMessageTextGravity
(
int
gravity
)
{
message_tv
.
setGravity
(
gravity
);
return
this
;
}
/**
* 设置标题颜色
*/
public
CommonDialog
setTitle_color
(
int
res_color
)
{
title_tv
.
setTextColor
(
getContext
().
getResources
().
getColor
(
res_color
));
return
this
;
}
//设置消息颜色
public
CommonDialog
setContent_color
(
int
content_color
){
public
CommonDialog
setContent_color
(
int
content_color
)
{
message_tv
.
setTextColor
(
getContext
().
getResources
().
getColor
(
content_color
));
return
this
;
}
public
CommonDialog
setLeftButton_color
(
int
left_color
){
/**
* 设置左侧按钮文字颜色
*/
public
CommonDialog
setLeftButton_color
(
int
left_color
)
{
left_btn
.
setTextColor
(
getContext
().
getResources
().
getColor
(
left_color
));
return
this
;
}
public
CommonDialog
setRightButton_color
(
int
right_color
){
/**
* 设置右侧按钮文字颜色
*/
public
CommonDialog
setRightButton_color
(
int
right_color
)
{
right_btn
.
setTextColor
(
getContext
().
getResources
().
getColor
(
right_color
));
return
this
;
}
public
CommonDialog
setCancelAble
(
boolean
flag
){
/**
* 设置左侧按钮背景
*/
public
CommonDialog
setLeftButtonBackgroundColor
(
int
left_background_color
)
{
GradientDrawable
gd
=
new
GradientDrawable
();
gd
.
setCornerRadii
(
new
float
[]{
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
0
f
,
(
float
)
DisplayUtils
.
dp2px
(
getContext
(),
10
),
(
float
)
DisplayUtils
.
dp2px
(
getContext
(),
10
)});
gd
.
setColor
(
getContext
().
getResources
().
getColor
(
left_background_color
));
left_btn
.
setBackground
(
gd
);
return
this
;
}
/**
* 设置右侧按钮背景
*/
public
CommonDialog
setRightButtonBackgroundColor
(
int
right_background_color
)
{
GradientDrawable
gd
=
new
GradientDrawable
();
gd
.
setCornerRadii
(
new
float
[]{
0
f
,
0
f
,
0
f
,
0
f
,
(
float
)
DisplayUtils
.
dp2px
(
getContext
(),
10
),
(
float
)
DisplayUtils
.
dp2px
(
getContext
(),
10
),
0
f
,
0
f
});
gd
.
setColor
(
getContext
().
getResources
().
getColor
(
right_background_color
));
right_btn
.
setBackground
(
gd
);
return
this
;
}
public
CommonDialog
setCancelAble
(
boolean
flag
)
{
setCancelable
(
flag
);
setCanceledOnTouchOutside
(
flag
);
return
this
;
}
//设置中间图片资源
public
CommonDialog
setImageCenter
(
int
resId
){
/**
* 设置中间图片资源
*/
public
CommonDialog
setImageCenter
(
int
resId
)
{
imageCenter
.
setImageResource
(
resId
);
imageCenter
.
setVisibility
(
View
.
VISIBLE
);
return
this
;
...
...
@@ -154,46 +199,46 @@ public class CommonDialog extends Dialog {
@Override
public
void
onClick
(
View
v
)
{
dismiss
();
if
(
listener
!=
null
)
{
if
(
listener
!=
null
)
{
listener
.
onClick
(
v
);
}
}
});
right_btn
.
setVisibility
(
View
.
VISIBLE
);
if
(
left_btn
.
getVisibility
()
==
View
.
GONE
){
if
(
left_btn
.
getVisibility
()
==
View
.
GONE
)
{
view_vertical_line
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
view_vertical_line
.
setVisibility
(
View
.
VISIBLE
);
}
return
this
;
}
public
CommonDialog
setLeftOnclick
(
String
cancel_btnText
,
final
View
.
OnClickListener
listener
)
{
public
CommonDialog
setLeftOnclick
(
String
cancel_btnText
,
final
View
.
OnClickListener
listener
)
{
left_btn
.
setText
(
cancel_btnText
);
left_btn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
dismiss
();
if
(
listener
!=
null
)
{
if
(
listener
!=
null
)
{
listener
.
onClick
(
v
);
}
}
});
left_btn
.
setVisibility
(
View
.
VISIBLE
);
if
(
right_btn
.
getVisibility
()
==
View
.
GONE
){
if
(
right_btn
.
getVisibility
()
==
View
.
GONE
)
{
view_vertical_line
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
view_vertical_line
.
setVisibility
(
View
.
VISIBLE
);
}
return
this
;
}
public
CommonDialog
setMessageOnclick
(
final
View
.
OnClickListener
listener
){
public
CommonDialog
setMessageOnclick
(
final
View
.
OnClickListener
listener
)
{
message_tv
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
dismiss
();
if
(
listener
!=
null
)
{
if
(
listener
!=
null
)
{
listener
.
onClick
(
v
);
}
}
...
...
@@ -201,7 +246,7 @@ public class CommonDialog extends Dialog {
return
this
;
}
public
CommonDialog
setOnDismiss
(
final
OnDismissListener
listener
){
public
CommonDialog
setOnDismiss
(
final
OnDismissListener
listener
)
{
this
.
setOnDismissListener
(
new
OnDismissListener
()
{
@Override
public
void
onDismiss
(
DialogInterface
dialog
)
{
...
...
@@ -214,11 +259,11 @@ public class CommonDialog extends Dialog {
@Override
public
void
show
()
{
if
(
null
==
context
){
if
(
null
==
context
)
{
return
;
}
if
(
context
instanceof
Activity
){
if
(((
Activity
)
context
).
isFinishing
())
{
if
(
context
instanceof
Activity
)
{
if
(((
Activity
)
context
).
isFinishing
())
{
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment