Skip to content

Commit

Permalink
Dependency, CI and code style updates.
Browse files Browse the repository at this point in the history
- Replace kotlinx synthetic with ViewBinding in the example project.
- Replace Travis with GitHub Actions.
- Add ktlint.
- Update dependencies.
  • Loading branch information
kizitonwose authored Jun 7, 2020
2 parents b5528a6 + 29c2187 commit 6be23be
Show file tree
Hide file tree
Showing 40 changed files with 440 additions and 444 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI
on: [push, pull_request]
jobs:
check:
name: Check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v1
with:
java-version: 11

- name: Check style
run: ./gradlew ktlintCheck

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v1
with:
java-version: 11

- name: Unit tests
run: ./gradlew testDebugUnitTest

instrumentation-tests:
name: Instrumentation tests
runs-on: macOS-latest
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
api-level: [22, 25, 29]
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v1
with:
java-version: 11

- name: Instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86
script: ./gradlew connectedDebugAndroidTest
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A highly customizable calendar library for Android, powered by RecyclerView.

[![Build Status](https://travis-ci.org/kizitonwose/CalendarView.svg?branch=master)](https://travis-ci.org/kizitonwose/CalendarView)
[![CI](https://github.com/kizitonwose/CalendarView/workflows/CI/badge.svg?branch=master)](https://github.com/kizitonwose/CalendarView/actions)
[![JitPack](https://jitpack.io/v/kizitonwose/CalendarView.svg)](https://jitpack.io/#kizitonwose/CalendarView)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/kizitonwose/CalendarView/blob/master/LICENSE.md)
[![Twitter](https://img.shields.io/badge/[email protected])](https://twitter.com/kizitonwose)
Expand Down
30 changes: 19 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@ buildscript {
'compile_sdk' : 28,
'version_code' : 1,
'version_name' : '0.3.1',
'kotlin_lang' : '1.3.71',
'material_library' : '1.1.0',
'kotlin_lang' : '1.3.72',
'material_library' : '1.2.0-beta01',
'androidx_appcompat' : '1.2.0-beta01',
'androidx_legacy' : '1.0.0',
'androidx_core_ktx' : '1.3.0-beta01',
'constraint_layout' : '2.0.0-beta4',
'constraint_layout' : '2.0.0-beta6',
'cardview' : '1.0.0',
'recyclerview' : '1.1.0',
'threetenabp' : '1.2.3',
'threetenabp' : '1.2.4',
'junit' : '4.12',
'espresso' : '3.1.1',
'androidx_test_runner': '1.1.1',
'androidx_test_rules' : '1.1.1',
'androidx_test_junit' : '1.1.0'
'espresso' : '3.2.0',
'androidx_test_runner': '1.2.0',
'androidx_test_rules' : '1.2.0',
'androidx_test_junit' : '1.1.1'
]
repositories {
google()
jcenter()

gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_lang"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'org.jlleitschuh.gradle:ktlint-gradle:9.2.1'
}
}

Expand All @@ -38,8 +39,15 @@ allprojects {
google()
jcenter()
}

apply plugin: 'org.jlleitschuh.gradle.ktlint'

ktlint {
version = "0.36.0"
disabledRules = ["no-wildcard-imports", "import-ordering"]
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Apr 05 08:20:22 CEST 2020
#Sun Jun 07 13:13:35 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
api "androidx.recyclerview:recyclerview:$versions.recyclerview"

testImplementation "junit:junit:$versions.junit"
testImplementation('org.threeten:threetenbp:1.4.2') {
testImplementation('org.threeten:threetenbp:1.4.4') {
// Use threetenBP library for tests as context will
// not be available to initialise threetenABP
exclude group: 'com.jakewharton.threetenabp', module: 'threetenabp'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.threeten.bp.DayOfWeek
import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth


open class CalendarView : RecyclerView {

/**
Expand Down Expand Up @@ -274,7 +273,6 @@ open class CalendarView : RecyclerView {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}


/**
* The width, in pixels for each day cell view.
* Set this to [DAY_SIZE_SQUARE] to have a nice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.threeten.bp.LocalDate
import org.threeten.bp.YearMonth
import java.io.Serializable


data class CalendarDay internal constructor(val date: LocalDate, val owner: DayOwner) :
Comparable<CalendarDay>, Serializable {

Expand All @@ -28,7 +27,7 @@ data class CalendarDay internal constructor(val date: LocalDate, val owner: DayO
override fun compareTo(other: CalendarDay): Int {
throw UnsupportedOperationException(
"Compare using the `date` parameter instead. " +
"Out and In dates can have the same date values as CalendarDay in another month."
"Out and In dates can have the same date values as CalendarDay in another month."
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ data class CalendarMonth(

override fun hashCode(): Int {
return 31 * yearMonth.hashCode() +
weekDays.first().first().hashCode() +
weekDays.last().last().hashCode()
weekDays.first().first().hashCode() +
weekDays.last().last().hashCode()
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

(other as CalendarMonth)
return yearMonth == other.yearMonth
&& weekDays.first().first() == other.weekDays.first().first()
&& weekDays.last().last() == other.weekDays.last().last()
return yearMonth == other.yearMonth &&
weekDays.first().first() == other.weekDays.first().first() &&
weekDays.last().last() == other.weekDays.last().last()
}

override fun compareTo(other: CalendarMonth): Int {
Expand All @@ -39,6 +39,6 @@ data class CalendarMonth(

override fun toString(): String {
return "CalendarMonth { first = ${weekDays.first().first()}, last = ${weekDays.last().last()}} " +
"indexInSameMonth = $indexInSameMonth, numberOfSameMonth = $numberOfSameMonth"
"indexInSameMonth = $indexInSameMonth, numberOfSameMonth = $numberOfSameMonth"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ enum class InDateStyle {
NONE
}


/**
* The scrolling behavior of the calendar.
*/
Expand All @@ -85,4 +84,4 @@ enum class ScrollMode {
* The calendar scrolls normally.
*/
PAGED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal data class MonthConfig(
val calendarMonths = mutableListOf<CalendarMonth>()
val calMonthsCount = allDaysGroup.size roundDiv maxRowCount
allDaysGroup.chunked(maxRowCount) { ephemeralMonthWeeks ->
val monthWeeks = ephemeralMonthWeeks.toMutableList()
val monthWeeks = ephemeralMonthWeeks.toMutableList()

// Add the outDates for the last row if needed.
if (monthWeeks.last().size < 7 && outDateStyle == OutDateStyle.END_OF_ROW || outDateStyle == OutDateStyle.END_OF_GRID) {
Expand Down Expand Up @@ -213,7 +213,6 @@ internal data class MonthConfig(
thisMonthDays.chunked(7).toMutableList()
}


if (outDateStyle == OutDateStyle.END_OF_ROW || outDateStyle == OutDateStyle.END_OF_GRID) {
// Add out-dates for the last row.
if (weekDaysGroup.last().size < 7) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ internal class CalendarAdapter(
visibleItemPos
}
}

}

return visibleItemPos
}

Expand All @@ -324,4 +322,4 @@ internal class CalendarAdapter(
dayRect.intersect(monthRect)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.kizitonwose.calendarview.model.ScrollMode
import com.kizitonwose.calendarview.utils.NO_INDEX
import org.threeten.bp.YearMonth


internal class CalendarLayoutManager(private val calView: CalendarView, @RecyclerView.Orientation orientation: Int) :
LinearLayoutManager(calView.context, orientation, false) {

Expand Down Expand Up @@ -97,4 +96,4 @@ internal class CalendarLayoutManager(private val calView: CalendarView, @Recycle
return dx - offset
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ internal class DayHolder(private val config: DayConfig) {
fun reloadView() {
bindDayView(day)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ internal class MonthViewHolder constructor(
fun reloadDay(day: CalendarDay) {
weekHolders.map { it.dayHolders }.flatten().firstOrNull { it.day == day }?.reloadView()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ interface MonthHeaderFooterBinder<T : ViewContainer> {
fun bind(container: T, month: CalendarMonth)
}

typealias MonthScrollListener = (CalendarMonth) -> Unit
typealias MonthScrollListener = (CalendarMonth) -> Unit
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ val YearMonth.previous: YearMonth
internal const val NO_INDEX = -1

internal val Rect.namedString: String
get() = "[L: $left, T: $top][R: $right, B: $bottom]"
get() = "[L: $left, T: $top][R: $right, B: $bottom]"
9 changes: 3 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion versions.compile_sdk
defaultConfig {
Expand All @@ -14,6 +11,9 @@ android {
versionName versions.version_name
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
minifyEnabled false
Expand All @@ -27,9 +27,6 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
androidExtensions {
experimental true
}
}

dependencies {
Expand Down
Loading

0 comments on commit 6be23be

Please sign in to comment.