Skip to content

Commit ae81f84

Browse files
committed
1. Added new dialog for difference events like success, error, warning, info, etc.
1 parent b878161 commit ae81f84

32 files changed

+1082
-34
lines changed
0 Bytes
Binary file not shown.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323
implementation fileTree(include: ['*.jar'], dir: 'libs')
2424
implementation 'com.android.support:appcompat-v7:27.1.1'
2525
implementation 'com.android.support:design:27.1.1'
26+
implementation 'com.android.support:cardview-v7:27.1.1'
2627
}
2728
repositories {
2829
mavenCentral()
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.amit.anim;
2+
3+
import android.content.Context;
4+
import android.view.animation.AlphaAnimation;
5+
import android.view.animation.Animation;
6+
import android.view.animation.AnimationSet;
7+
import android.view.animation.ScaleAnimation;
8+
9+
/**
10+
* Created by Amit Jangid on 22,May,2018
11+
**/
12+
public class AnimLoader
13+
{
14+
public static AnimationSet getInAnimation(Context context)
15+
{
16+
AnimationSet in = new AnimationSet(context, null);
17+
18+
AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
19+
alpha.setDuration(90);
20+
21+
ScaleAnimation scale1 = new ScaleAnimation(
22+
0.8f, 1.05f, 0.8f, 1.05f,
23+
Animation.RELATIVE_TO_SELF, 0.5f,
24+
Animation.RELATIVE_TO_SELF, 0.5f);
25+
26+
scale1.setDuration(135);
27+
28+
ScaleAnimation scale2 = new ScaleAnimation(
29+
1.05f, 0.95f, 1.05f, 0.95f,
30+
Animation.RELATIVE_TO_SELF, 0.5f,
31+
Animation.RELATIVE_TO_SELF, 0.5f);
32+
33+
scale2.setDuration(105);
34+
scale2.setStartOffset(135);
35+
36+
ScaleAnimation scale3 = new ScaleAnimation(
37+
0.95f, 1f, 0.95f, 1.0f,
38+
Animation.RELATIVE_TO_SELF, 0.5f,
39+
Animation.RELATIVE_TO_SELF, 0.5f);
40+
41+
scale3.setDuration(60);
42+
scale3.setStartOffset(240);
43+
44+
in.addAnimation(alpha);
45+
in.addAnimation(scale1);
46+
in.addAnimation(scale2);
47+
in.addAnimation(scale3);
48+
49+
return in;
50+
}
51+
52+
public static AnimationSet getOutAnimation(Context context)
53+
{
54+
AnimationSet out = new AnimationSet(context, null);
55+
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
56+
alpha.setDuration(150);
57+
58+
ScaleAnimation scale = new ScaleAnimation(
59+
1.0f, 0.6f, 1.0f, 0.6f,
60+
Animation.RELATIVE_TO_SELF, 0.5f,
61+
Animation.RELATIVE_TO_SELF, 0.5f);
62+
63+
scale.setDuration(150);
64+
out.addAnimation(alpha);
65+
out.addAnimation(scale);
66+
return out;
67+
}
68+
}

app/src/main/java/com/amit/dialog/AlertDialogBox.java

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import android.graphics.Color;
66
import android.graphics.drawable.ColorDrawable;
77
import android.graphics.drawable.GradientDrawable;
8+
import android.support.annotation.ColorInt;
9+
import android.support.annotation.DrawableRes;
810
import android.view.View;
911
import android.view.Window;
1012
import android.widget.Button;
@@ -23,44 +25,57 @@
2325
@SuppressWarnings({"WeakerAcces", "unused"})
2426
public class AlertDialogBox
2527
{
26-
private String title, message, positiveBtnText, negativeBtnText;
27-
private Activity activity;
28-
private int icon;
28+
private Anim Anim;
29+
private boolean cancel;
2930
private Icon visibility;
30-
private com.amit.dialog.Anim Anim;
31+
private Activity activity;
32+
3133
private AlertDialogListener pListener, nListener;
32-
private int pBtnColor, nBtnColor, bgColor;
33-
private boolean cancel;
34+
private String title, message, positiveBtnText, negativeBtnText;
35+
36+
@DrawableRes
37+
private int icon;
38+
39+
@ColorInt
40+
private int pBtnColor, nBtnColor, bgColor, pBtnTextColor, nBtnTextColor;
3441

3542
private AlertDialogBox(Builder builder)
3643
{
44+
this.icon = builder.icon;
45+
this.Anim = builder.Anim;
3746
this.title = builder.title;
47+
this.cancel = builder.cancel;
48+
3849
this.message = builder.message;
50+
this.bgColor = builder.bgColor;
3951
this.activity = builder.activity;
40-
this.icon = builder.icon;
41-
this.Anim = builder.Anim;
42-
this.visibility = builder.visibility;
52+
4353
this.pListener = builder.pListener;
4454
this.nListener = builder.nListener;
45-
this.positiveBtnText = builder.positiveBtnText;
46-
this.negativeBtnText = builder.negativeBtnText;
55+
4756
this.pBtnColor = builder.pBtnColor;
4857
this.nBtnColor = builder.nBtnColor;
49-
this.bgColor = builder.bgColor;
50-
this.cancel = builder.cancel;
51-
}
58+
this.visibility = builder.visibility;
5259

60+
this.pBtnTextColor = builder.pBtnTextColor;
61+
this.nBtnTextColor = builder.nBtnTextColor;
62+
63+
this.positiveBtnText = builder.positiveBtnText;
64+
this.negativeBtnText = builder.negativeBtnText;
65+
}
5366

5467
public static class Builder
5568
{
56-
private String title, message, positiveBtnText, negativeBtnText;
57-
private Activity activity;
58-
private int icon;
69+
private Anim Anim;
5970
private Icon visibility;
60-
private com.amit.dialog.Anim Anim;
61-
private AlertDialogListener pListener, nListener;
62-
private int pBtnColor, nBtnColor, bgColor;
71+
private Activity activity;
72+
6373
private boolean cancel;
74+
private AlertDialogListener pListener, nListener;
75+
private String title, message, positiveBtnText, negativeBtnText;
76+
77+
@DrawableRes private int icon;
78+
@ColorInt private int pBtnColor, pBtnTextColor, nBtnColor, nBtnTextColor, bgColor;
6479

6580
public Builder(Activity activity)
6681
{
@@ -91,6 +106,12 @@ public Builder setPositiveBtnText(String positiveBtnText)
91106
return this;
92107
}
93108

109+
public Builder setPositiveBtnTextColor(int pBtnTextColor)
110+
{
111+
this.pBtnTextColor = pBtnTextColor;
112+
return this;
113+
}
114+
94115
public Builder setPositiveBtnBackground(int pBtnColor)
95116
{
96117
this.pBtnColor = pBtnColor;
@@ -103,6 +124,12 @@ public Builder setNegativeBtnText(String negativeBtnText)
103124
return this;
104125
}
105126

127+
public Builder setNegativeBtnTextColor(int nBtnTextColor)
128+
{
129+
this.nBtnTextColor = nBtnTextColor;
130+
return this;
131+
}
132+
106133
public Builder setNegativeBtnBackground(int nBtnColor)
107134
{
108135
this.nBtnColor = nBtnColor;
@@ -195,12 +222,22 @@ else if (Anim == SLIDE)
195222
bgShape.setColor(pBtnColor);
196223
}
197224

225+
if (pBtnTextColor != 0)
226+
{
227+
pBtn.setTextColor(pBtnTextColor);
228+
}
229+
198230
if (nBtnColor != 0)
199231
{
200232
GradientDrawable bgShape = (GradientDrawable) nBtn.getBackground();
201233
bgShape.setColor(nBtnColor);
202234
}
203235

236+
if (nBtnTextColor != 0)
237+
{
238+
nBtn.setTextColor(nBtnTextColor);
239+
}
240+
204241
if (negativeBtnText != null)
205242
{
206243
nBtn.setText(negativeBtnText);

0 commit comments

Comments
 (0)