Skip to content

Commit

Permalink
Update sample app project
Browse files Browse the repository at this point in the history
  • Loading branch information
rAseri committed Apr 7, 2019
1 parent 5737bf6 commit e50d6ad
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 75 deletions.
6 changes: 2 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +63,7 @@ class DateIndicatorsSampleFragment : Fragment() {
}

if (savedInstanceState == null) {
calendarView.setupCalendar(selectionMode = CalendarView.SelectionMode.NON)
calendarView.setupCalendar(selectionMode = CalendarView.SelectionMode.NONE)
}
}

Expand Down Expand Up @@ -131,8 +131,11 @@ class DateIndicatorsSampleFragment : Fragment() {
}

val event = getItem(position)
view.findViewById<View>(R.id.color_view).setBackgroundColor(event.color)
view.findViewById<TextView>(R.id.event_name_view).text = event.eventName

if (event != null) {
view.findViewById<View>(R.id.color_view).setBackgroundColor(event.color)
view.findViewById<TextView>(R.id.event_name_view).text = event.eventName
}

return view
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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<CalendarView>(R.id.calendar_view)
if (savedInstanceState == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions sample/src/main/res/layout/fragment_custom_style_sample.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand Down
5 changes: 3 additions & 2 deletions sample/src/main/res/layout/fragment_dialog_sample.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ru.cleverpumpkin.calendar.CalendarView xmlns:android="http://schemas.android.com/apk/res/android"
<ru.cleverpumpkin.calendar.CalendarView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="440dp"
Expand Down
7 changes: 4 additions & 3 deletions sample/src/main/res/layout/fragment_sample.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:title="@string/app_name"
app:titleTextColor="@android:color/white" />

<ru.cleverpumpkin.calendar.CalendarView xmlns:android="http://schemas.android.com/apk/res/android"
<ru.cleverpumpkin.calendar.CalendarView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/res/layout/fragment_sample_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:title="@string/app_name"
app:titleTextColor="@android:color/white" />

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
11 changes: 1 addition & 10 deletions sample/src/main/res/layout/fragment_selection_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand Down Expand Up @@ -56,15 +56,6 @@
android:text="@string/range"
android:textAllCaps="true" />

<RadioButton
android:id="@+id/week_custom_selection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:text="@string/week"
android:textAllCaps="true" />

<RadioButton
android:id="@+id/boundaries_selection"
android:layout_width="wrap_content"
Expand Down

0 comments on commit e50d6ad

Please sign in to comment.