Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OnSuccessCallback and OnFailCallback not being called when .withProcessVisibility(false) #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public BackgroundMail(Context context) {
this.mContext = context;
this.sendingMessage = context.getString(R.string.msg_sending_email);
this.sendingMessageSuccess = context.getString(R.string.msg_email_sent_successfully);
this.sendingMessageError=context.getString(R.string.msg_error_sending_email);
this.sendingMessageError = context.getString(R.string.msg_error_sending_email);
}

private BackgroundMail(Builder builder) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public void addAttachments(@NonNull List<String> attachments) {
this.attachments.addAll(attachments);
}

public void addAttachments(String...attachments) {
public void addAttachments(String... attachments) {
this.attachments.addAll(Arrays.asList(attachments));
}

Expand Down Expand Up @@ -298,22 +298,23 @@ protected Boolean doInBackground(String... arg0) {
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
if (processVisibility) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
if (result) {
if (!TextUtils.isEmpty(sendingMessageSuccess)) {
Toast.makeText(mContext, sendingMessageSuccess, Toast.LENGTH_SHORT).show();
}
if (onSuccessCallback != null) {
onSuccessCallback.onSuccess();
}
}else {
if (!TextUtils.isEmpty(sendingMessageError)) {
Toast.makeText(mContext, sendingMessageError, Toast.LENGTH_SHORT).show();
}
if (onFailCallback != null) {
onFailCallback.onFail();
}
}

if (result) {
if (processVisibility && !TextUtils.isEmpty(sendingMessageSuccess)) {
Toast.makeText(mContext, sendingMessageSuccess, Toast.LENGTH_SHORT).show();
}
if (onSuccessCallback != null) {
onSuccessCallback.onSuccess();
}
} else {
if (processVisibility && !TextUtils.isEmpty(sendingMessageError)) {
Toast.makeText(mContext, sendingMessageError, Toast.LENGTH_SHORT).show();
}
if (onFailCallback != null) {
onFailCallback.onFail();
}
}
}
Expand All @@ -339,7 +340,7 @@ private Builder(Context context) {
this.context = context;
this.sendingMessage = context.getString(R.string.msg_sending_email);
this.sendingMessageSuccess = context.getString(R.string.msg_email_sent_successfully);
this.sendingMessageError=context.getString(R.string.msg_error_sending_email);
this.sendingMessageError = context.getString(R.string.msg_error_sending_email);
}

public Builder withUsername(@NonNull String username) {
Expand Down Expand Up @@ -408,7 +409,7 @@ public Builder withAttachments(@NonNull ArrayList<String> attachments) {
return this;
}

public Builder withAttachments(String...attachments) {
public Builder withAttachments(String... attachments) {
this.attachments.addAll(Arrays.asList(attachments));
return this;
}
Expand Down