Skip to content

Commit

Permalink
optimize no title select dialog, no title tip dialog and title tip di…
Browse files Browse the repository at this point in the history
…aolog
  • Loading branch information
redrain39 committed Jan 8, 2019
1 parent 78f6fa8 commit b83a33f
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public void onSureClick() {
Log.d("111111", "确定了!!!");
}
})
.setCancelable(true)
.show(this, "");
}

Expand All @@ -98,7 +97,6 @@ public void onSureClick() {
Log.d("111111", "确定了!!!");
}
})
.setCancelable(true)
.show(this, "");
}

Expand All @@ -116,7 +114,6 @@ public void onNegativeClick() {
Log.d("111111", "取消了!!!");
}
})
.setCancelable(true)
.show(this, "");
}

Expand Down
24 changes: 12 additions & 12 deletions dialoglib/src/main/java/com/nasduck/dialoglib/Base/DuckDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ public static ToastTextAndImageConfigBean assignTextAndImageToast(String content
public static DialogTipNoTitleConfigBean assignNoTitleTipDialog(String contentText
, NoTitleTipDialog.onSureClickListener listener) {
DialogTipNoTitleConfigBean configBean = new DialogTipNoTitleConfigBean();
configBean.setBackground(R.drawable.bg_default)
configBean.setBackground(R.drawable.bg_dialog_white)
.setCancelable(false)
.setHasShade(true)
.setContentText(contentText)
.setContentTextSize(16)
.setContentTextColor(R.color.text_black)
.setContentTextColor(R.color.text_black_light)
.setButtonText("确定")
.setButtonTextSize(18)
.setButtonTextColor(R.color.text_black)
.setButtonTextColor(R.color.text_blue)
.setListener(listener);
return configBean;
}
Expand All @@ -159,18 +159,18 @@ public static DialogTipNoTitleConfigBean assignNoTitleTipDialog(String contentTe
public static DialogTipTitleConfigBean assignTitleTipDialog(String titleText
, String contentText, TitleTipDialog.onSureClickListener listener) {
DialogTipTitleConfigBean configBean = new DialogTipTitleConfigBean();
configBean.setBackground(R.drawable.bg_default)
configBean.setBackground(R.drawable.bg_dialog_white)
.setCancelable(false)
.setHasShade(true)
.setTitleText(titleText)
.setTitleTextSize(18)
.setTitleTextColor(R.color.text_black)
.setContentText(contentText)
.setContentTextSize(16)
.setContentTextColor(R.color.text_black)
.setContentTextColor(R.color.text_black_light)
.setButtonText("确定")
.setButtonTextSize(18)
.setButtonTextColor(R.color.text_black)
.setTitleText(titleText)
.setTitleTextSize(18)
.setTitleTextColor(R.color.text_black)
.setButtonTextColor(R.color.text_blue)
.setListener(listener);
return configBean;
}
Expand All @@ -183,15 +183,15 @@ public static DialogTipTitleConfigBean assignTitleTipDialog(String titleText
public static DialogSelectNoTitleConfigBean assignNoTitleSelectDialog(String contentText
, NoTitleSelectDialog.onSelectClickListener listener) {
DialogSelectNoTitleConfigBean configBean = new DialogSelectNoTitleConfigBean();
configBean.setBackground(R.drawable.bg_default)
configBean.setBackground(R.drawable.bg_dialog_white)
.setCancelable(false)
.setHasShade(true)
.setContentText(contentText)
.setContentTextSize(16)
.setContentTextColor(R.color.text_black)
.setContentTextColor(R.color.text_black_light)
.setPositiveButtonText("确定")
.setPositiveButtonTextSize(18)
.setPositiveButtonTextColor(R.color.text_black)
.setPositiveButtonTextColor(R.color.text_blue)
.setNegativeButtonText("取消")
.setNegativeButtonTextSize(18)
.setNegativeButtonTextColor(R.color.text_black)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.nasduck.dialoglib.R;
import com.nasduck.dialoglib.config.DialogSelectNoTitleConfigBean;
import com.nasduck.dialoglib.interfaces.BaseDialogFragment;
import com.nasduck.dialoglib.utils.DensityUtils;

import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

public class NoTitleSelectDialog extends BaseDialogFragment {

Expand Down Expand Up @@ -72,11 +75,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
mPositiveButtonTextColor = getArguments().getInt(ConfigName.POSITIVE_BUTTON_TEXT_COLOR);
mPositiveButtonTextSize = getArguments().getInt(ConfigName.POSITIVE_BUTTON_TEXT_SIZE);
mNegativeButtonText = getArguments().getString(ConfigName.NEGATIVE_BUTTON_TEXT);
mNegativeButtonTextColor = getArguments().getInt(ConfigName.POSITIVE_BUTTON_TEXT_COLOR);
mNegativeButtonTextSize = getArguments().getInt(ConfigName.POSITIVE_BUTTON_TEXT_SIZE);
mNegativeButtonTextColor = getArguments().getInt(ConfigName.NEGATIVE_BUTTON_TEXT_COLOR);
mNegativeButtonTextSize = getArguments().getInt(ConfigName.NEGATIVE_BUTTON_TEXT_SIZE);
}
}

@Override
public void onResume() {
super.onResume();
getDialog().getWindow().setLayout(DensityUtils.dp2px(mContext, 280), WRAP_CONTENT);
}

@Override
protected int getLayoutId() {
return R.layout.dialog_select_no_title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.nasduck.dialoglib.R;
import com.nasduck.dialoglib.config.DialogTipNoTitleConfigBean;
import com.nasduck.dialoglib.interfaces.BaseDialogFragment;
import com.nasduck.dialoglib.utils.DensityUtils;

import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

public class NoTitleTipDialog extends BaseDialogFragment {

Expand Down Expand Up @@ -67,6 +70,12 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
}

@Override
public void onResume() {
super.onResume();
getDialog().getWindow().setLayout(DensityUtils.dp2px(mContext, 280), WRAP_CONTENT);
}

@Override
protected int getLayoutId() {
return R.layout.dialog_tip_no_title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.nasduck.dialoglib.R;
import com.nasduck.dialoglib.config.DialogTipTitleConfigBean;
import com.nasduck.dialoglib.interfaces.BaseDialogFragment;
import com.nasduck.dialoglib.utils.DensityUtils;

import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

public class TitleTipDialog extends BaseDialogFragment {

Expand Down Expand Up @@ -77,6 +80,12 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
}

@Override
public void onResume() {
super.onResume();
getDialog().getWindow().setLayout(DensityUtils.dp2px(mContext, 280), WRAP_CONTENT);
}

@Override
protected int getLayoutId() {
return R.layout.dialog_tip_title;
Expand Down
31 changes: 24 additions & 7 deletions dialoglib/src/main/res/layout/dialog_select_no_title.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,50 @@
android:id="@+id/background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp">
android:layout_height="wrap_content">

<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="18dp"
android:layout_marginLeft="62dp"
android:layout_marginRight="62dp"
android:layout_gravity="center_horizontal"/>

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:background="@color/line_gray"/>

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

<Button
android:id="@+id/btn_negative"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="44dp" />
android:layout_height="46dp"
android:background="@null"/>

<View
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:layout_marginTop="13dp"
android:layout_marginBottom="13dp"
android:background="@color/line_gray"/>

<Button
android:id="@+id/btn_positive"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="44dp" />
android:layout_height="46dp"
android:background="@null"/>

</LinearLayout>

Expand Down
19 changes: 14 additions & 5 deletions dialoglib/src/main/res/layout/dialog_tip_no_title.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp">
android:orientation="vertical">

<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="18dp"
android:layout_marginLeft="62dp"
android:layout_marginRight="62dp"
android:layout_gravity="center_horizontal"/>

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:background="@color/line_gray"/>

<Button
android:id="@+id/btn_sure"
android:layout_width="match_parent"
android:layout_height="44dp" />
android:layout_height="46dp"
android:background="@null"/>

</LinearLayout>
21 changes: 15 additions & 6 deletions dialoglib/src/main/res/layout/dialog_tip_title.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,36 @@
android:id="@+id/background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp">
android:layout_height="wrap_content">

<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="30dp"
android:layout_gravity="center_horizontal"/>

<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="18dp"
android:layout_marginLeft="62dp"
android:layout_marginRight="62dp"
android:layout_gravity="center_horizontal"/>

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:background="@color/line_gray"/>

<Button
android:id="@+id/btn_sure"
android:layout_width="match_parent"
android:layout_height="44dp" />
android:layout_height="46dp"
android:background="@null"/>

</LinearLayout>

0 comments on commit b83a33f

Please sign in to comment.