aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-01-02 19:03:39 +0100
committerBananeweizen <bananeweizen@gmx.de>2012-01-02 19:03:39 +0100
commit0e29296fcf6585a5aa654537f88f07166bc2a8fb (patch)
tree6806d72ca2fb8944e55337d00a4f04dc9f567e8d /main/src/cgeo/geocaching/ui
parentcb69be1b19bd9c52ef9062c3e272d98952fed2f2 (diff)
downloadcgeo-0e29296fcf6585a5aa654537f88f07166bc2a8fb.zip
cgeo-0e29296fcf6585a5aa654537f88f07166bc2a8fb.tar.gz
cgeo-0e29296fcf6585a5aa654537f88f07166bc2a8fb.tar.bz2
refactoring: replace useless super class by nested interface
Diffstat (limited to 'main/src/cgeo/geocaching/ui')
-rw-r--r--main/src/cgeo/geocaching/ui/DateDialog.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/ui/DateDialog.java b/main/src/cgeo/geocaching/ui/DateDialog.java
new file mode 100644
index 0000000..f8996ce
--- /dev/null
+++ b/main/src/cgeo/geocaching/ui/DateDialog.java
@@ -0,0 +1,61 @@
+package cgeo.geocaching.ui;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.R.id;
+import cgeo.geocaching.R.layout;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
+import android.widget.DatePicker;
+
+import java.util.Calendar;
+
+public class DateDialog extends Dialog {
+
+ public interface DateDialogParent {
+ abstract public void setDate(final Calendar date);
+ }
+
+ private final DateDialogParent parent;
+ private final Calendar date;
+
+ public DateDialog(Activity contextIn, DateDialogParent parentIn, Calendar dateIn) {
+ super(contextIn);
+
+ // init
+ this.date = dateIn;
+ this.parent = parentIn;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ try {
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
+ } catch (Exception e) {
+ // nothing
+ }
+
+ setContentView(R.layout.date);
+
+ final DatePicker picker = (DatePicker) findViewById(R.id.picker);
+ picker.init(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DATE), new DatePickerListener());
+ }
+
+ private class DatePickerListener implements DatePicker.OnDateChangedListener {
+
+ @Override
+ public void onDateChanged(DatePicker picker, int year, int month, int day) {
+ if (parent != null) {
+ date.set(year, month, day);
+
+ parent.setDate(date);
+ }
+ }
+ }
+} \ No newline at end of file