From b656c239e5bb4c863f2a7091bf84f3d012ee5237 Mon Sep 17 00:00:00 2001 From: activesince93 Date: Mon, 5 Oct 2020 13:09:04 +0530 Subject: [PATCH 1/5] Don't show date in time picker --- app/src/main/AndroidManifest.xml | 2 +- .../SingleDatePickerMainActivityWithDoublePicker.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f0377e3f..4b6b4a8e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java index d543e691..4eb66658 100644 --- a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java +++ b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java @@ -94,7 +94,7 @@ public void simpleTimeClicked() { .displayMinutes(true) .displayHours(true) - .displayDays(true) +// .displayDays(true) //.displayMonth(true) //.displayYears(true) From 0834caeb86a9941ef466f0fae181d6275edd67b4 Mon Sep 17 00:00:00 2001 From: activesince93 Date: Mon, 5 Oct 2020 13:19:50 +0530 Subject: [PATCH 2/5] Dialog listener 'onClosed()' added along with 'onDisplayed()' --- README.md | 8 ++++-- ...atePickerMainActivityWithDoublePicker.java | 26 ++++++++++++++++++- .../dialog/SingleDateAndTimePickerDialog.java | 5 ++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 910b5ac7..22b63df9 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,12 @@ new SingleDateAndTimePickerDialog.Builder(context) public void onDisplayed(SingleDateAndTimePicker picker) { //retrieve the SingleDateAndTimePicker } - }) - + + @Override + public void onClosed(SingleDateAndTimePicker picker) { + + } + }) .title("Simple") .listener(new SingleDateAndTimePickerDialog.Listener() { @Override diff --git a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java index 4eb66658..b7cd6c49 100644 --- a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java +++ b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java @@ -1,8 +1,11 @@ package com.github.florent37.sample.singledateandtimepicker; import android.os.Bundle; +import android.util.Log; import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; + import com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker; import com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog; import com.github.florent37.singledateandtimepicker.dialog.SingleDateAndTimePickerDialog; @@ -15,7 +18,6 @@ import java.util.TimeZone; import java.util.concurrent.TimeUnit; -import androidx.appcompat.app.AppCompatActivity; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -45,6 +47,8 @@ public class SingleDatePickerMainActivityWithDoublePicker extends AppCompatActiv SingleDateAndTimePickerDialog.Builder singleBuilder; DoubleDateAndTimePickerDialog.Builder doubleBuilder; + private static String TAG = "SingleDatePickerMainActivityWithDoublePicker"; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -101,7 +105,12 @@ public void simpleTimeClicked() { .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() { @Override public void onDisplayed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog displayed"); + } + @Override + public void onClosed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog closed"); } }) @@ -138,7 +147,12 @@ public void simpleDateClicked() { .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() { @Override public void onDisplayed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog displayed"); + } + @Override + public void onClosed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog closed"); } }) @@ -192,7 +206,12 @@ public void simpleClicked() { .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() { @Override public void onDisplayed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog displayed"); + } + @Override + public void onClosed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog closed"); } }) @@ -268,7 +287,12 @@ public void singleDateLocaleClicked() { .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() { @Override public void onDisplayed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog displayed"); + } + @Override + public void onClosed(SingleDateAndTimePicker picker) { + Log.d(TAG, "Dialog closed"); } }) diff --git a/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java b/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java index 49263935..7307e624 100644 --- a/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java +++ b/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java @@ -64,6 +64,10 @@ public void onLoaded(View view) { @Override public void onClose() { SingleDateAndTimePickerDialog.this.onClose(); + + if (displayListener != null) { + displayListener.onClosed(picker); + } } }); } @@ -330,6 +334,7 @@ public interface Listener { public interface DisplayListener { void onDisplayed(SingleDateAndTimePicker picker); + void onClosed(SingleDateAndTimePicker picker); } public static class Builder { From dad690c8a6a17f54f16934e80b3897a9d9013584 Mon Sep 17 00:00:00 2001 From: activesince93 Date: Mon, 5 Oct 2020 13:45:18 +0530 Subject: [PATCH 3/5] README.md updated --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 22b63df9..57a1764e 100644 --- a/README.md +++ b/README.md @@ -22,15 +22,15 @@ new SingleDateAndTimePickerDialog.Builder(context) //.displayMinutes(false) //.todayText("aujourd'hui") .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() { - @Override - public void onDisplayed(SingleDateAndTimePicker picker) { - //retrieve the SingleDateAndTimePicker - } + @Override + public void onDisplayed(SingleDateAndTimePicker picker) { + // Retrieve the SingleDateAndTimePicker + } - @Override - public void onClosed(SingleDateAndTimePicker picker) { - - } + @Override + public void onClosed(SingleDateAndTimePicker picker) { + // On dialog closed + } }) .title("Simple") .listener(new SingleDateAndTimePickerDialog.Listener() { From 6bd7f6c9ca1d051e7f618eb469acc3adffe3e4f5 Mon Sep 17 00:00:00 2001 From: activesince93 Date: Mon, 5 Oct 2020 14:25:37 +0530 Subject: [PATCH 4/5] DoubleDateAndTimePickerDialog crash resolved --- .../dialog/DoubleDateAndTimePickerDialog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/DoubleDateAndTimePickerDialog.java b/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/DoubleDateAndTimePickerDialog.java index 4bd6cfcf..54d3c8c3 100644 --- a/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/DoubleDateAndTimePickerDialog.java +++ b/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/DoubleDateAndTimePickerDialog.java @@ -424,8 +424,8 @@ public DoubleDateAndTimePickerDialog setFocusable(boolean focusable) { private DoubleDateAndTimePickerDialog setTimeZone(TimeZone timeZone) { dateHelper.setTimeZone(timeZone); - pickerTab0.setTimeZone(timeZone); - pickerTab1.setTimeZone(timeZone); +// pickerTab0.setTimeZone(timeZone); +// pickerTab1.setTimeZone(timeZone); return this; } From 336865ff12f6f30dba1aa6c8d5fca9f298b7cefb Mon Sep 17 00:00:00 2001 From: activesince93 Date: Mon, 5 Oct 2020 14:35:09 +0530 Subject: [PATCH 5/5] Show time only in time picker --- .../SingleDatePickerMainActivityWithDoublePicker.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java index b7cd6c49..c6846449 100644 --- a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java +++ b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java @@ -3,8 +3,7 @@ import android.os.Bundle; import android.util.Log; import android.widget.TextView; - -import androidx.appcompat.app.AppCompatActivity; +import android.widget.Toast; import com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker; import com.github.florent37.singledateandtimepicker.dialog.DoubleDateAndTimePickerDialog; @@ -18,6 +17,7 @@ import java.util.TimeZone; import java.util.concurrent.TimeUnit; +import androidx.appcompat.app.AppCompatActivity; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -98,7 +98,7 @@ public void simpleTimeClicked() { .displayMinutes(true) .displayHours(true) -// .displayDays(true) + .displayDays(false) //.displayMonth(true) //.displayYears(true)