Skip to content

Commit

Permalink
1. Added new dialog for difference events like success, error, warnin…
Browse files Browse the repository at this point in the history
…g, info, etc.
  • Loading branch information
amitjangid80 committed May 22, 2018
1 parent b878161 commit ae81f84
Show file tree
Hide file tree
Showing 32 changed files with 1,082 additions and 34 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
}
repositories {
mavenCentral()
Expand Down
68 changes: 68 additions & 0 deletions app/src/main/java/com/amit/anim/AnimLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.amit.anim;

import android.content.Context;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;

/**
* Created by Amit Jangid on 22,May,2018
**/
public class AnimLoader
{
public static AnimationSet getInAnimation(Context context)
{
AnimationSet in = new AnimationSet(context, null);

AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
alpha.setDuration(90);

ScaleAnimation scale1 = new ScaleAnimation(
0.8f, 1.05f, 0.8f, 1.05f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);

scale1.setDuration(135);

ScaleAnimation scale2 = new ScaleAnimation(
1.05f, 0.95f, 1.05f, 0.95f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);

scale2.setDuration(105);
scale2.setStartOffset(135);

ScaleAnimation scale3 = new ScaleAnimation(
0.95f, 1f, 0.95f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);

scale3.setDuration(60);
scale3.setStartOffset(240);

in.addAnimation(alpha);
in.addAnimation(scale1);
in.addAnimation(scale2);
in.addAnimation(scale3);

return in;
}

public static AnimationSet getOutAnimation(Context context)
{
AnimationSet out = new AnimationSet(context, null);
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
alpha.setDuration(150);

ScaleAnimation scale = new ScaleAnimation(
1.0f, 0.6f, 1.0f, 0.6f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);

scale.setDuration(150);
out.addAnimation(alpha);
out.addAnimation(scale);
return out;
}
}
77 changes: 57 additions & 20 deletions app/src/main/java/com/amit/dialog/AlertDialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.view.View;
import android.view.Window;
import android.widget.Button;
Expand All @@ -23,44 +25,57 @@
@SuppressWarnings({"WeakerAcces", "unused"})
public class AlertDialogBox
{
private String title, message, positiveBtnText, negativeBtnText;
private Activity activity;
private int icon;
private Anim Anim;
private boolean cancel;
private Icon visibility;
private com.amit.dialog.Anim Anim;
private Activity activity;

private AlertDialogListener pListener, nListener;
private int pBtnColor, nBtnColor, bgColor;
private boolean cancel;
private String title, message, positiveBtnText, negativeBtnText;

@DrawableRes
private int icon;

@ColorInt
private int pBtnColor, nBtnColor, bgColor, pBtnTextColor, nBtnTextColor;

private AlertDialogBox(Builder builder)
{
this.icon = builder.icon;
this.Anim = builder.Anim;
this.title = builder.title;
this.cancel = builder.cancel;

this.message = builder.message;
this.bgColor = builder.bgColor;
this.activity = builder.activity;
this.icon = builder.icon;
this.Anim = builder.Anim;
this.visibility = builder.visibility;

this.pListener = builder.pListener;
this.nListener = builder.nListener;
this.positiveBtnText = builder.positiveBtnText;
this.negativeBtnText = builder.negativeBtnText;

this.pBtnColor = builder.pBtnColor;
this.nBtnColor = builder.nBtnColor;
this.bgColor = builder.bgColor;
this.cancel = builder.cancel;
}
this.visibility = builder.visibility;

this.pBtnTextColor = builder.pBtnTextColor;
this.nBtnTextColor = builder.nBtnTextColor;

this.positiveBtnText = builder.positiveBtnText;
this.negativeBtnText = builder.negativeBtnText;
}

public static class Builder
{
private String title, message, positiveBtnText, negativeBtnText;
private Activity activity;
private int icon;
private Anim Anim;
private Icon visibility;
private com.amit.dialog.Anim Anim;
private AlertDialogListener pListener, nListener;
private int pBtnColor, nBtnColor, bgColor;
private Activity activity;

private boolean cancel;
private AlertDialogListener pListener, nListener;
private String title, message, positiveBtnText, negativeBtnText;

@DrawableRes private int icon;
@ColorInt private int pBtnColor, pBtnTextColor, nBtnColor, nBtnTextColor, bgColor;

public Builder(Activity activity)
{
Expand Down Expand Up @@ -91,6 +106,12 @@ public Builder setPositiveBtnText(String positiveBtnText)
return this;
}

public Builder setPositiveBtnTextColor(int pBtnTextColor)
{
this.pBtnTextColor = pBtnTextColor;
return this;
}

public Builder setPositiveBtnBackground(int pBtnColor)
{
this.pBtnColor = pBtnColor;
Expand All @@ -103,6 +124,12 @@ public Builder setNegativeBtnText(String negativeBtnText)
return this;
}

public Builder setNegativeBtnTextColor(int nBtnTextColor)
{
this.nBtnTextColor = nBtnTextColor;
return this;
}

public Builder setNegativeBtnBackground(int nBtnColor)
{
this.nBtnColor = nBtnColor;
Expand Down Expand Up @@ -195,12 +222,22 @@ else if (Anim == SLIDE)
bgShape.setColor(pBtnColor);
}

if (pBtnTextColor != 0)
{
pBtn.setTextColor(pBtnTextColor);
}

if (nBtnColor != 0)
{
GradientDrawable bgShape = (GradientDrawable) nBtn.getBackground();
bgShape.setColor(nBtnColor);
}

if (nBtnTextColor != 0)
{
nBtn.setTextColor(nBtnTextColor);
}

if (negativeBtnText != null)
{
nBtn.setText(negativeBtnText);
Expand Down
Loading

0 comments on commit ae81f84

Please sign in to comment.