Show spinner when deleting account/identity

pull/50/head
M66B 6 years ago
parent 096919e307
commit 56c6381557

@ -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 Helper.setViewsEnabled(view, false);
getFragmentManager().popBackStack(); 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);
} }

@ -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 Helper.setViewsEnabled(view, false);
getFragmentManager().popBackStack(); 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);
} }

@ -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