Skip to content

Commit 2b59062

Browse files
-converted project to Kotlin. Code can be shortened a lot, but requires some delicate work.
-fixed some time/date formatting related issues: alamkanak#497 alamkanak#495 (but not fixed RTL alignment issue) -created a new activity to demonstrate the paging of entire view (example: week by week snapping), based on this pull request: Quivr#88
1 parent 472162d commit 2b59062

33 files changed

+3515
-4099
lines changed

build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4+
ext.kotlin_version = '1.2.41'
45
repositories {
56
jcenter()
67
google()
78
}
89
dependencies {
910
classpath 'com.android.tools.build:gradle:3.2.0-alpha13'
11+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1012

1113
// NOTE: Do not place your application dependencies here; they belong
1214
// in the individual module build.gradle files

library/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
24

35
repositories {
46
mavenCentral()
@@ -19,6 +21,7 @@ configurations {
1921
dependencies {
2022
compile 'com.android.support:appcompat-v7:27.1.1'
2123
javadocDeps 'com.android.support:appcompat-v7:27.1.1'
24+
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
2225
}
2326

2427
apply from: 'gradle-mvn-push.gradle'

library/gradle-mvn-push.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ apply plugin: 'maven'
1818
apply plugin: 'signing'
1919

2020
def isReleaseBuild() {
21-
return VERSION_NAME.contains("SNAPSHOT") == false
21+
return !VERSION_NAME.contains("SNAPSHOT")
2222
}
2323

2424
def getReleaseRepositoryUrl() {
@@ -112,4 +112,4 @@ afterEvaluate { project ->
112112
archives androidSourcesJar
113113
// archives androidJavadocsJar
114114
}
115-
}
115+
}

library/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<manifest package="com.alamkanak.weekview"></manifest>
1+
<manifest package="com.alamkanak.weekview"/>

library/src/main/java/com/alamkanak/weekview/DateTimeInterpreter.java

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.alamkanak.weekview
2+
3+
import java.util.*
4+
5+
/**
6+
* Created by Raquib on 1/6/2015.
7+
*/
8+
interface DateTimeInterpreter {
9+
fun interpretDate(date: Calendar): String
10+
11+
fun interpretTime(hour: Int, minutes: Int): String
12+
}

library/src/main/java/com/alamkanak/weekview/MonthLoader.java

-44
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.alamkanak.weekview
2+
3+
import java.util.*
4+
5+
class MonthLoader(var onMonthChangeListener: MonthChangeListener?) : WeekViewLoader {
6+
7+
override fun toWeekViewPeriodIndex(instance: Calendar): Double {
8+
return (instance.get(Calendar.YEAR) * 12).toDouble() + instance.get(Calendar.MONTH).toDouble() + (instance.get(Calendar.DAY_OF_MONTH) - 1) / 30.0
9+
}
10+
11+
override fun onLoad(periodIndex: Int): List<WeekViewEvent>? {
12+
return onMonthChangeListener!!.onMonthChange(periodIndex / 12, periodIndex % 12 + 1)
13+
}
14+
15+
interface MonthChangeListener {
16+
/**
17+
*
18+
* Very important interface, it's the base to load events in the calendar.
19+
* This method is called three times: once to load the previous month, once to load the next month and once to load the current month.
20+
* **That's why you can have three times the same event at the same place if you mess up with the configuration**
21+
*
22+
* @param newYear : year of the events required by the view.
23+
* @param newMonth :
24+
*
25+
*month of the events required by the view **1 based (not like JAVA API) : January = 1 and December = 12**.
26+
* @return a list of the events happening **during the specified month**.
27+
*/
28+
fun onMonthChange(newYear: Int, newMonth: Int): List<WeekViewEvent>?
29+
}
30+
}

library/src/main/java/com/alamkanak/weekview/TextColorPicker.java

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.alamkanak.weekview
2+
3+
import android.support.annotation.ColorInt
4+
5+
interface TextColorPicker {
6+
7+
@ColorInt
8+
fun getTextColor(event: WeekViewEvent): Int
9+
10+
}

0 commit comments

Comments
 (0)