Skip to content

Commit

Permalink
v2.5.0 Rollup
Browse files Browse the repository at this point in the history
*Version Bump to v2.5.0.
*Fix CustomAlertDialogue crash on restore from background. Dismiss dialog on pause.
*Create Parcelable write implementation.
  • Loading branch information
rayliverified committed Aug 26, 2018
1 parent 4805ba0 commit 41ecc86
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 26 deletions.
4 changes: 2 additions & 2 deletions customalert/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.searchy2'
version = '2.4.2'
version = '2.5.0'

android {
compileSdkVersion 28
Expand All @@ -26,7 +26,7 @@ dependencies {
maven { url "https://maven.google.com" }
}
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.0.0-alpha3'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'com.github.Dimezis.BlurView:blurview:version-1.4.0'
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class CustomAlertDialogue extends DialogFragment {
public static final String TAG = CustomAlertDialogue.class.getSimpleName();
private Builder builder;
private Style style = Style.DIALOGUE;
private Integer gravity = Gravity.CENTER;
private ArrayList<String> inputList;
private TextView positiveText;
private ArrayList<String> tagList;
Expand All @@ -61,10 +60,12 @@ public static CustomAlertDialogue getInstance() {

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
Log.d("Builder", "Restore");

if (savedInstanceState != null) {
if (builder != null) {
if (builder == null) {
builder = savedInstanceState.getParcelable(Builder.class.getSimpleName());
Log.d("Builder", "Restore Not Null");
}
}
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.CustomDialog);
Expand All @@ -90,6 +91,12 @@ public void onSaveInstanceState(Bundle outState) {
outState.putParcelable(Builder.class.getSimpleName(), builder);
}

@Override
public void onPause() {
super.onPause();
dismiss();
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Expand Down Expand Up @@ -125,7 +132,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
if (builder.getGravity() != null)
{
wlp.gravity = builder.getGravity();
switch (gravity)
switch (builder.getGravity())
{
case Gravity.CENTER:
wlp.windowAnimations = R.style.CustomDialogAnimation;
Expand All @@ -148,6 +155,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
if (builder.getStyle() != null)
{
style = builder.getStyle();
Log.d("View Inflator", "Inflated");
}

switch (style)
Expand Down Expand Up @@ -198,11 +206,7 @@ private void initCommonView(View view) {
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!builder.getCancelable())
{

}
else
if (builder.getCancelable())
{
dismiss();
}
Expand Down Expand Up @@ -312,7 +316,7 @@ private void initActionsheetView(View view) {

float radius = 5;

TextView cancelButton = view.findViewById(R.id.cancel);
final TextView cancelButton = view.findViewById(R.id.cancel);
if(builder.getCancelText() != null){
cancelButton.setVisibility(View.VISIBLE);
cancelButton.setText(builder.getCancelText());
Expand Down Expand Up @@ -577,7 +581,7 @@ public static class Builder implements Parcelable {
private boolean autoHide;
private boolean cancelable = true;

private Integer gravity;
private Integer gravity = Gravity.CENTER;
private Style style;
private View decorView;
private Context context;
Expand All @@ -603,20 +607,10 @@ protected Builder(Parcel in) {
boxInputText = in.createStringArrayList();
autoHide = in.readByte() != 0;
cancelable = in.readByte() != 0;
gravity = in.readInt();
style = Style.valueOf(in.readString());
}

public static final Creator<Builder> CREATOR = new Creator<Builder>() {
@Override
public Builder createFromParcel(Parcel in) {
return new Builder(in);
}

@Override
public Builder[] newArray(int size) {
return new Builder[size];
}
};

/**
* @param style - set DIALOGUE, ACTIONSHEET, SELECTOR, INPUT to select AlertView type.
* @return
Expand All @@ -630,7 +624,9 @@ public Builder setStyle(Style style) {
public Style getStyle() { return style; }

public Builder setGravity(Integer gravity) {
this.gravity = gravity;
if(gravity != null) {
this.gravity = gravity;
}
return this;
}
public Integer getGravity() { return gravity; }
Expand Down Expand Up @@ -1029,13 +1025,47 @@ public Dialog show() {
return CustomAlertDialogue.getInstance().show(((Activity) context), this);
}

public static final Creator<Builder> CREATOR = new Creator<Builder>() {
@Override
public Builder createFromParcel(Parcel in) {
return new Builder(in);
}

@Override
public Builder[] newArray(int size) {
return new Builder[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(title);
parcel.writeString(message);
parcel.writeString(positiveText);
parcel.writeString(negativeText);
parcel.writeString(cancelText);
parcel.writeInt(titleColor);
parcel.writeInt(messageColor);
parcel.writeInt(positiveColor);
parcel.writeInt(negativeColor);
parcel.writeInt(cancelColor);
parcel.writeInt(backgroundColor);
parcel.writeInt(timeToHide);
parcel.writeStringList(destructive);
parcel.writeStringList(others);
parcel.writeStringList(lineInputHint);
parcel.writeStringList(lineInputText);
parcel.writeStringList(boxInputHint);
parcel.writeStringList(boxInputText);
parcel.writeByte((byte) (autoHide ? 1 : 0));
parcel.writeByte((byte) (cancelable ? 1 : 0));
parcel.writeInt(gravity);
parcel.writeString(style.toString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

0 comments on commit 41ecc86

Please sign in to comment.