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() {
@Override
public void onClick(View view) {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
.setMessage(R.string.title_account_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
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();
args.putLong("id", id);
@ -544,9 +546,15 @@ public class FragmentAccount extends FragmentEx {
return null;
}
@Override
protected void onLoaded(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
// TODO: recover from error
}
}.load(FragmentAccount.this, args);
}

@ -302,15 +302,16 @@ public class FragmentIdentity extends FragmentEx {
ibDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
.setMessage(R.string.title_identity_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
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();
args.putLong("id", id);
@ -323,9 +324,15 @@ public class FragmentIdentity extends FragmentEx {
return null;
}
@Override
protected void onLoaded(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
// TODO: recover from error
}
}.load(FragmentIdentity.this, args);
}

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

Loading…
Cancel
Save