Browse Source

Show spinner when deleting account/identity

main
M66B 6 years ago
parent
commit
56c6381557
3 changed files with 26 additions and 7 deletions
  1. +11
    -3
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  2. +10
    -3
      app/src/main/java/eu/faircode/email/FragmentIdentity.java
  3. +5
    -1
      app/src/main/java/eu/faircode/email/Helper.java

+ 11
- 3
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -520,15 +520,17 @@ public class FragmentAccount extends FragmentEx {
ibDelete.setOnClickListener(new View.OnClickListener() { ibDelete.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder builder
.setMessage(R.string.title_account_delete) .setMessage(R.string.title_account_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
// TODO: spinner
getFragmentManager().popBackStack();
Helper.setViewsEnabled(view, false);
btnCheck.setEnabled(false);
btnSave.setEnabled(false);
pbWait.setVisibility(View.VISIBLE);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);
@ -544,9 +546,15 @@ public class FragmentAccount extends FragmentEx {
return null; return null;
} }
@Override
protected void onLoaded(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
// TODO: recover from error
} }
}.load(FragmentAccount.this, args); }.load(FragmentAccount.this, args);
} }


+ 10
- 3
app/src/main/java/eu/faircode/email/FragmentIdentity.java View File

@ -302,15 +302,16 @@ public class FragmentIdentity extends FragmentEx {
ibDelete.setOnClickListener(new View.OnClickListener() { ibDelete.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder builder
.setMessage(R.string.title_identity_delete) .setMessage(R.string.title_identity_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
// TODO: spinner
getFragmentManager().popBackStack();
Helper.setViewsEnabled(view, false);
btnSave.setEnabled(false);
pbWait.setVisibility(View.VISIBLE);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);
@ -323,9 +324,15 @@ public class FragmentIdentity extends FragmentEx {
return null; return null;
} }
@Override
protected void onLoaded(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
// TODO: recover from error
} }
}.load(FragmentIdentity.this, args); }.load(FragmentIdentity.this, args);
} }


+ 5
- 1
app/src/main/java/eu/faircode/email/Helper.java View File

@ -31,6 +31,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner; import android.widget.Spinner;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -63,7 +64,10 @@ public class Helper {
static void setViewsEnabled(ViewGroup view, boolean enabled) { static void setViewsEnabled(ViewGroup view, boolean enabled) {
for (int i = 0; i < view.getChildCount(); i++) { for (int i = 0; i < view.getChildCount(); i++) {
View child = view.getChildAt(i); View child = view.getChildAt(i);
if (child instanceof Spinner || child instanceof EditText || child instanceof CheckBox)
if (child instanceof Spinner ||
child instanceof EditText ||
child instanceof CheckBox ||
child instanceof ImageButton)
child.setEnabled(enabled); child.setEnabled(enabled);
else if (child instanceof ViewGroup) else if (child instanceof ViewGroup)
setViewsEnabled((ViewGroup) child, enabled); setViewsEnabled((ViewGroup) child, enabled);


Loading…
Cancel
Save