diff --git a/sample/build.gradle b/sample/build.gradle index 9d01834..81bb513 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -42,14 +42,12 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation project(':crunchycalendar') // Kotlin language standard lib implementation "org.jetbrains.kotlin:kotlin-stdlib:$libs.kotlin_version" // Support libraries - implementation "com.android.support:appcompat-v7:$libs.support_lib_version" - implementation "com.android.support:recyclerview-v7:$libs.support_lib_version" + implementation "androidx.appcompat:appcompat:$libs.supportX" + implementation "androidx.recyclerview:recyclerview:$libs.supportX" } diff --git a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/CustomStyleSampleFragment.kt b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/CustomStyleSampleFragment.kt index 710f8fa..693f9b2 100644 --- a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/CustomStyleSampleFragment.kt +++ b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/CustomStyleSampleFragment.kt @@ -1,11 +1,11 @@ package ru.cleverpumpkin.calendar.sample import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v7.widget.Toolbar import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.appcompat.widget.Toolbar +import androidx.fragment.app.Fragment import ru.cleverpumpkin.calendar.CalendarDate import ru.cleverpumpkin.calendar.CalendarView import ru.cleverpumpkin.calendar.CalendarView.SelectionMode diff --git a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DateIndicatorsSampleFragment.kt b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DateIndicatorsSampleFragment.kt index f979af7..c8561cb 100644 --- a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DateIndicatorsSampleFragment.kt +++ b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DateIndicatorsSampleFragment.kt @@ -2,14 +2,14 @@ package ru.cleverpumpkin.calendar.sample import android.content.Context import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v7.app.AlertDialog -import android.support.v7.widget.Toolbar import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.TextView +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.widget.Toolbar +import androidx.fragment.app.Fragment import ru.cleverpumpkin.calendar.CalendarDate import ru.cleverpumpkin.calendar.CalendarView import ru.cleverpumpkin.calendar.utils.getColorInt @@ -63,7 +63,7 @@ class DateIndicatorsSampleFragment : Fragment() { } if (savedInstanceState == null) { - calendarView.setupCalendar(selectionMode = CalendarView.SelectionMode.NON) + calendarView.setupCalendar(selectionMode = CalendarView.SelectionMode.NONE) } } @@ -131,8 +131,11 @@ class DateIndicatorsSampleFragment : Fragment() { } val event = getItem(position) - view.findViewById(R.id.color_view).setBackgroundColor(event.color) - view.findViewById(R.id.event_name_view).text = event.eventName + + if (event != null) { + view.findViewById(R.id.color_view).setBackgroundColor(event.color) + view.findViewById(R.id.event_name_view).text = event.eventName + } return view } diff --git a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DialogSampleFragment.kt b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DialogSampleFragment.kt index e32d1cb..ee62239 100644 --- a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DialogSampleFragment.kt +++ b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/DialogSampleFragment.kt @@ -1,11 +1,11 @@ package ru.cleverpumpkin.calendar.sample import android.os.Bundle -import android.support.v4.app.DialogFragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.Window +import androidx.fragment.app.DialogFragment import ru.cleverpumpkin.calendar.CalendarView class DialogSampleFragment : DialogFragment() { @@ -21,7 +21,7 @@ class DialogSampleFragment : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - dialog.window.requestFeature(Window.FEATURE_NO_TITLE) + dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE) val calendarView = view.findViewById(R.id.calendar_view) if (savedInstanceState == null) { diff --git a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/MainActivity.kt b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/MainActivity.kt index 93029cc..390e6d4 100644 --- a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/MainActivity.kt +++ b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/MainActivity.kt @@ -1,9 +1,9 @@ package ru.cleverpumpkin.calendar.sample import android.os.Bundle -import android.support.v4.app.DialogFragment -import android.support.v4.app.FragmentTransaction -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.DialogFragment +import androidx.fragment.app.FragmentTransaction import ru.cleverpumpkin.calendar.sample.SampleListFragment.SampleItem class MainActivity : AppCompatActivity(), diff --git a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SampleListFragment.kt b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SampleListFragment.kt index d0cde3b..3592431 100644 --- a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SampleListFragment.kt +++ b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SampleListFragment.kt @@ -2,15 +2,15 @@ package ru.cleverpumpkin.calendar.sample import android.content.Context import android.os.Bundle -import android.support.annotation.StringRes -import android.support.v4.app.Fragment -import android.support.v7.widget.DividerItemDecoration -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView +import androidx.annotation.StringRes +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView class SampleListFragment : Fragment() { diff --git a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SelectionSampleFragment.kt b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SelectionSampleFragment.kt index 8e657c6..d960730 100644 --- a/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SelectionSampleFragment.kt +++ b/sample/src/main/java/ru/cleverpumpkin/calendar/sample/SelectionSampleFragment.kt @@ -1,14 +1,14 @@ package ru.cleverpumpkin.calendar.sample import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v7.widget.Toolbar import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.RadioGroup import android.widget.TextView import android.widget.Toast +import androidx.appcompat.widget.Toolbar +import androidx.fragment.app.Fragment import ru.cleverpumpkin.calendar.CalendarDate import ru.cleverpumpkin.calendar.CalendarView import ru.cleverpumpkin.calendar.CalendarView.SelectionMode @@ -79,10 +79,6 @@ class SelectionSampleFragment : Fragment() { R.id.range_selection -> { setupCalendar(SelectionMode.RANGE, preselectedDatesRange()) } - R.id.week_custom_selection -> { - - setupCalendarWithWeekSelection() - } R.id.boundaries_selection -> { setupCalendarWithBoundaries() } @@ -128,34 +124,6 @@ class SelectionSampleFragment : Fragment() { ) } - private fun setupCalendarWithWeekSelection() { - setupCalendar(SelectionMode.RANGE, emptyList()) - - calendarView.onDateClickListener = { date -> - val weekStart = getWeekStart(date) - val weekEnd = getWeekEnd(date) - - calendarView.updateSelectedDates(listOf(weekStart, weekEnd)) - updateSelectedDatesView() - } - } - - private fun getWeekStart(date: CalendarDate): CalendarDate { - val tmpCalendar = Calendar.getInstance() - tmpCalendar.firstDayOfWeek = calendarView.firstDayOfWeek - tmpCalendar.time = date.date - tmpCalendar.set(Calendar.DAY_OF_WEEK, tmpCalendar.firstDayOfWeek) - return CalendarDate(tmpCalendar.time) - } - - private fun getWeekEnd(date: CalendarDate): CalendarDate { - val tmpCalendar = Calendar.getInstance() - tmpCalendar.firstDayOfWeek = calendarView.firstDayOfWeek - tmpCalendar.time = date.date - tmpCalendar.set(Calendar.DAY_OF_WEEK, tmpCalendar.firstDayOfWeek + 6) - return CalendarDate(tmpCalendar.time) - } - private fun setupCalendarWithBoundaries() { val calendar = Calendar.getInstance() calendar.set(2018, Calendar.JUNE, 1) diff --git a/sample/src/main/res/layout/fragment_custom_style_sample.xml b/sample/src/main/res/layout/fragment_custom_style_sample.xml index da336f1..76c9fd6 100644 --- a/sample/src/main/res/layout/fragment_custom_style_sample.xml +++ b/sample/src/main/res/layout/fragment_custom_style_sample.xml @@ -1,9 +1,10 @@ - - - - - - - - - - - -