mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-16 09:11:02 +00:00
Just formatting again
This commit is contained in:
1 parent
a0f490835b
commit
8a09013584
6 files changed
+226
-226
No files matched your search
+28
-28
@@ -1,28 +1,28 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
|
||||
public abstract class ActivityDialogFragment extends BaseDialogFragment {
|
||||
|
||||
protected DialogFragmentButtonListener hostActivity;
|
||||
|
||||
public void onAttach(android.app.Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
if (activity instanceof DialogFragmentButtonListener) {
|
||||
this.hostActivity = (DialogFragmentButtonListener) activity;
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"Instance of %s must be attached to instances of %s. Tried to attach to %s.",
|
||||
ActivityDialogFragment.class.getName(),
|
||||
DialogFragmentButtonListener.class.getName(),
|
||||
activity.getClass().getName()));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected DialogFragmentButtonListener getHost() {
|
||||
return this.hostActivity;
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
|
||||
public abstract class ActivityDialogFragment extends BaseDialogFragment {
|
||||
|
||||
protected DialogFragmentButtonListener hostActivity;
|
||||
|
||||
public void onAttach(android.app.Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
if (activity instanceof DialogFragmentButtonListener) {
|
||||
this.hostActivity = (DialogFragmentButtonListener) activity;
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"Instance of %s must be attached to instances of %s. Tried to attach to %s.",
|
||||
ActivityDialogFragment.class.getName(),
|
||||
DialogFragmentButtonListener.class.getName(),
|
||||
activity.getClass().getName()));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected DialogFragmentButtonListener getHost() {
|
||||
return this.hostActivity;
|
||||
}
|
||||
|
||||
}
|
||||
+54
-54
@@ -1,54 +1,54 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
|
||||
public abstract class BaseDialogFragment extends DialogFragment {
|
||||
private final static String TAG = BaseDialogFragment.class.getName();
|
||||
|
||||
protected abstract CharSequence getNegativeButtonLabel();
|
||||
protected abstract CharSequence getPositiveButtonLabel();
|
||||
protected abstract Builder createDialog(AlertDialog.Builder builder);
|
||||
|
||||
protected abstract DialogFragmentButtonListener getHost();
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return createDialog(new Builder(getActivity())
|
||||
.setNegativeButton(getNegativeButtonLabel(), new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
onNegativeButton();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(getPositiveButtonLabel(), new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
onPositiveButton();
|
||||
}
|
||||
})
|
||||
).create();
|
||||
}
|
||||
|
||||
protected void onNegativeButton() {
|
||||
if (getHost() != null) {
|
||||
getHost().onDialogNegativeButton();
|
||||
} else {
|
||||
ExLog.w(TAG, "Dialog host was null.");
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPositiveButton() {
|
||||
if (getHost() != null) {
|
||||
getHost().onDialogPositiveButton();
|
||||
} else {
|
||||
ExLog.w(TAG, "Dialog host was null.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
|
||||
public abstract class BaseDialogFragment extends DialogFragment {
|
||||
private final static String TAG = BaseDialogFragment.class.getName();
|
||||
|
||||
protected abstract CharSequence getNegativeButtonLabel();
|
||||
protected abstract CharSequence getPositiveButtonLabel();
|
||||
protected abstract Builder createDialog(AlertDialog.Builder builder);
|
||||
|
||||
protected abstract DialogFragmentButtonListener getHost();
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return createDialog(new Builder(getActivity())
|
||||
.setNegativeButton(getNegativeButtonLabel(), new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
onNegativeButton();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(getPositiveButtonLabel(), new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
onPositiveButton();
|
||||
}
|
||||
})
|
||||
).create();
|
||||
}
|
||||
|
||||
protected void onNegativeButton() {
|
||||
if (getHost() != null) {
|
||||
getHost().onDialogNegativeButton();
|
||||
} else {
|
||||
ExLog.w(TAG, "Dialog host was null.");
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPositiveButton() {
|
||||
if (getHost() != null) {
|
||||
getHost().onDialogPositiveButton();
|
||||
} else {
|
||||
ExLog.w(TAG, "Dialog host was null.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
public interface DialogFragmentButtonListener {
|
||||
void onDialogNegativeButton();
|
||||
void onDialogPositiveButton();
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
public interface DialogFragmentButtonListener {
|
||||
void onDialogNegativeButton();
|
||||
void onDialogPositiveButton();
|
||||
}
|
||||
+20
-20
@@ -1,20 +1,20 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.Fragment;
|
||||
|
||||
public abstract class FragmentDialogFragment extends BaseDialogFragment {
|
||||
|
||||
@Override
|
||||
protected DialogFragmentButtonListener getHost() {
|
||||
Fragment targetFragment = getTargetFragment();
|
||||
if (targetFragment instanceof DialogFragmentButtonListener) {
|
||||
return (DialogFragmentButtonListener) targetFragment;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"Instance of %s must be attached to instances of %s.",
|
||||
FragmentDialogFragment.class.getName(),
|
||||
DialogFragmentButtonListener.class.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.Fragment;
|
||||
|
||||
public abstract class FragmentDialogFragment extends BaseDialogFragment {
|
||||
|
||||
@Override
|
||||
protected DialogFragmentButtonListener getHost() {
|
||||
Fragment targetFragment = getTargetFragment();
|
||||
if (targetFragment instanceof DialogFragmentButtonListener) {
|
||||
return (DialogFragmentButtonListener) targetFragment;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"Instance of %s must be attached to instances of %s.",
|
||||
FragmentDialogFragment.class.getName(),
|
||||
DialogFragmentButtonListener.class.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
+40
-40
@@ -1,40 +1,40 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class LoadFailedDialog extends FragmentDialogFragment {
|
||||
private static final String ARGS_ERROR_MSG = LoadFailedDialog.class.getName() + ".errorMessage";
|
||||
|
||||
public static LoadFailedDialog create(String errorMessage) {
|
||||
LoadFailedDialog dialog = new LoadFailedDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARGS_ERROR_MSG, errorMessage);
|
||||
dialog.setArguments(args);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getPositiveButtonLabel() {
|
||||
return "Retry";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getNegativeButtonLabel() {
|
||||
return "Cancel";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder createDialog(Builder builder) {
|
||||
return builder
|
||||
.setMessage(String.format(
|
||||
"There was an error loading the requested data:\n%s\nDo you want to retry?",
|
||||
getArguments().getString(ARGS_ERROR_MSG)))
|
||||
.setTitle("Load failure")
|
||||
.setIcon(R.drawable.ic_dialog_alert_holo_light);
|
||||
}
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class LoadFailedDialog extends FragmentDialogFragment {
|
||||
private static final String ARGS_ERROR_MSG = LoadFailedDialog.class.getName() + ".errorMessage";
|
||||
|
||||
public static LoadFailedDialog create(String errorMessage) {
|
||||
LoadFailedDialog dialog = new LoadFailedDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARGS_ERROR_MSG, errorMessage);
|
||||
dialog.setArguments(args);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getPositiveButtonLabel() {
|
||||
return "Retry";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getNegativeButtonLabel() {
|
||||
return "Cancel";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder createDialog(Builder builder) {
|
||||
return builder
|
||||
.setMessage(String.format(
|
||||
"There was an error loading the requested data:\n%s\nDo you want to retry?",
|
||||
getArguments().getString(ARGS_ERROR_MSG)))
|
||||
.setTitle("Load failure")
|
||||
.setIcon(R.drawable.ic_dialog_alert_holo_light);
|
||||
}
|
||||
}
|
||||
+78
-78
@@ -1,78 +1,78 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
|
||||
public class LoginDialog extends ActivityDialogFragment {
|
||||
|
||||
private static final LoginType DefaultLoginType = LoginType.OFFICER;
|
||||
public enum LoginType {
|
||||
OFFICER, VIEWER;
|
||||
}
|
||||
|
||||
private CharSequence[] loginTypeDescriptions;
|
||||
private LoginType selectedLoginType = DefaultLoginType;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
loginTypeDescriptions = new CharSequence[2];
|
||||
loginTypeDescriptions[0] = getString(R.string.login_type_officer);
|
||||
loginTypeDescriptions[1] = getString(R.string.login_type_viewer);
|
||||
}
|
||||
|
||||
public LoginType getSelectedLoginType() {
|
||||
return selectedLoginType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getNegativeButtonLabel() {
|
||||
return "Cancel";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getPositiveButtonLabel() {
|
||||
return "Login";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder createDialog(Builder builder) {
|
||||
return builder
|
||||
.setTitle("Login onto course area")
|
||||
.setIcon(R.drawable.ic_menu_login)
|
||||
.setSingleChoiceItems(loginTypeDescriptions, 0, new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
selectedLoginType = LoginType.OFFICER;
|
||||
break;
|
||||
case 1:
|
||||
selectedLoginType = LoginType.VIEWER;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown login type selected.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNegativeButton() {
|
||||
selectedLoginType = DefaultLoginType;
|
||||
ExLog.i(ExLog.LOGIN_BUTTON_NEGATIVE, String.valueOf(selectedLoginType), getActivity());
|
||||
super.onNegativeButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPositiveButton() {
|
||||
ExLog.i(ExLog.LOGIN_BUTTON_POSITIVE, String.valueOf(selectedLoginType), getActivity());
|
||||
super.onPositiveButton();
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.dialogs;
|
||||
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
|
||||
public class LoginDialog extends ActivityDialogFragment {
|
||||
|
||||
private static final LoginType DefaultLoginType = LoginType.OFFICER;
|
||||
public enum LoginType {
|
||||
OFFICER, VIEWER;
|
||||
}
|
||||
|
||||
private CharSequence[] loginTypeDescriptions;
|
||||
private LoginType selectedLoginType = DefaultLoginType;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
loginTypeDescriptions = new CharSequence[2];
|
||||
loginTypeDescriptions[0] = getString(R.string.login_type_officer);
|
||||
loginTypeDescriptions[1] = getString(R.string.login_type_viewer);
|
||||
}
|
||||
|
||||
public LoginType getSelectedLoginType() {
|
||||
return selectedLoginType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getNegativeButtonLabel() {
|
||||
return "Cancel";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getPositiveButtonLabel() {
|
||||
return "Login";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder createDialog(Builder builder) {
|
||||
return builder
|
||||
.setTitle("Login onto course area")
|
||||
.setIcon(R.drawable.ic_menu_login)
|
||||
.setSingleChoiceItems(loginTypeDescriptions, 0, new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
selectedLoginType = LoginType.OFFICER;
|
||||
break;
|
||||
case 1:
|
||||
selectedLoginType = LoginType.VIEWER;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown login type selected.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNegativeButton() {
|
||||
selectedLoginType = DefaultLoginType;
|
||||
ExLog.i(ExLog.LOGIN_BUTTON_NEGATIVE, String.valueOf(selectedLoginType), getActivity());
|
||||
super.onNegativeButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPositiveButton() {
|
||||
ExLog.i(ExLog.LOGIN_BUTTON_POSITIVE, String.valueOf(selectedLoginType), getActivity());
|
||||
super.onPositiveButton();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user