diff --git a/bottomsheettimerangepicker/src/main/java/me/adawoud/bottomsheettimepicker/BottomSheetTimeRangePicker.kt b/bottomsheettimerangepicker/src/main/java/me/adawoud/bottomsheettimepicker/BottomSheetTimeRangePicker.kt index 2cc4d78..ea33af8 100644 --- a/bottomsheettimerangepicker/src/main/java/me/adawoud/bottomsheettimepicker/BottomSheetTimeRangePicker.kt +++ b/bottomsheettimerangepicker/src/main/java/me/adawoud/bottomsheettimepicker/BottomSheetTimeRangePicker.kt @@ -10,7 +10,6 @@ import android.widget.TabHost import kotlinx.android.synthetic.main.time_range_picker.* import me.adawoud.bottomsheetpickers.R - @Suppress("DEPRECATION") // We deal with it below class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { private lateinit var listener: OnTimeRangeSelectedListener @@ -23,8 +22,11 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { private var endHour = -1 private var endMinute = -1 - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = - LayoutInflater.from(context).inflate(R.layout.time_range_picker, container, false) + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? = LayoutInflater.from(context).inflate(R.layout.time_range_picker, container, false) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -34,7 +36,7 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { startMinute = bundle.getInt(KEY_START_MINUTE) endHour = bundle.getInt(KEY_END_HOUR) endMinute = bundle.getInt(KEY_END_MINUTE) - doActionBasedOnSdkLevel( + setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM = { startTimePicker.hour = startHour startTimePicker.minute = startMinute @@ -79,7 +81,7 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { btnSetTimeRange.setOnClickListener { // Pass these values to the calling Activity/Fragment if (::listener.isInitialized) { - doActionBasedOnSdkLevel( + setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM = { listener.onTimeRangeSelected( startTimePicker.hour, @@ -140,7 +142,7 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { // Set initial values if the user has changed them before initializing private fun initInitialTimeValuesIfAdjusted() { doActionIfValueIsNotNegative(startHour, action = { - doActionBasedOnSdkLevel( + setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM = { startTimePicker.hour = startHour } @@ -150,7 +152,7 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { }) }) doActionIfValueIsNotNegative(startMinute, action = { - doActionBasedOnSdkLevel( + setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM = { startTimePicker.minute = startMinute } @@ -160,7 +162,7 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { }) }) doActionIfValueIsNotNegative(endHour, action = { - doActionBasedOnSdkLevel( + setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM = { endTimePicker.hour = endHour } @@ -171,9 +173,9 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { }) doActionIfValueIsNotNegative(endMinute, action = { - doActionBasedOnSdkLevel( + setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM = { - endTimePicker.hour = endMinute + endTimePicker.hour = endHour } , actionIfSdkLevelIsLowerThanM = { @@ -224,7 +226,7 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { } } - private fun doActionBasedOnSdkLevel( + private fun setInitialValuesBasedOnSdkLevel( actionIfSdkLevelIsHigherThanOrEqualToM: () -> Unit, actionIfSdkLevelIsLowerThanM: () -> Unit ) { @@ -350,4 +352,5 @@ class BottomSheetTimeRangePicker : BottomSheetDialogFragment() { return timeRangePicker } } + } \ No newline at end of file diff --git a/bottomsheettimerangepicker/src/main/res/values/public.xml b/bottomsheettimerangepicker/src/main/res/values/public.xml new file mode 100644 index 0000000..22d1406 --- /dev/null +++ b/bottomsheettimerangepicker/src/main/res/values/public.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 65e0797..8cfbf94 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -22,6 +22,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(":bottomsheettimerangepicker") implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' @@ -29,5 +30,4 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - implementation project(":bottomsheettimerangepicker") } \ No newline at end of file diff --git a/sample/proguard-rules.pro b/sample/proguard-rules.pro index f1b4245..481bb43 100644 --- a/sample/proguard-rules.pro +++ b/sample/proguard-rules.pro @@ -18,4 +18,4 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/sample/src/main/java/me/adawoud/bottomsheettimepicker/MainActivity.kt b/sample/src/main/java/me/adawoud/bottomsheettimepicker/MainActivity.kt index 9a76969..e275cd4 100644 --- a/sample/src/main/java/me/adawoud/bottomsheettimepicker/MainActivity.kt +++ b/sample/src/main/java/me/adawoud/bottomsheettimepicker/MainActivity.kt @@ -47,4 +47,5 @@ class MainActivity : AppCompatActivity(), OnTimeRangeSelectedListener { private fun String.prependZero(): String { return "0".plus(this) } + } \ No newline at end of file