Skip to content

Commit

Permalink
-converted project to Kotlin. Code can be shortened a lot, but requir…
Browse files Browse the repository at this point in the history
…es 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
  • Loading branch information
AndroidDeveloperLB committed May 7, 2018
1 parent 472162d commit 2b59062
Show file tree
Hide file tree
Showing 33 changed files with 3,515 additions and 4,099 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.41'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
3 changes: 3 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

repositories {
mavenCentral()
Expand All @@ -19,6 +21,7 @@ configurations {
dependencies {
compile 'com.android.support:appcompat-v7:27.1.1'
javadocDeps 'com.android.support:appcompat-v7:27.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply from: 'gradle-mvn-push.gradle'
4 changes: 2 additions & 2 deletions library/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
return !VERSION_NAME.contains("SNAPSHOT")
}

def getReleaseRepositoryUrl() {
Expand Down Expand Up @@ -112,4 +112,4 @@ afterEvaluate { project ->
archives androidSourcesJar
// archives androidJavadocsJar
}
}
}
2 changes: 1 addition & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.alamkanak.weekview"></manifest>
<manifest package="com.alamkanak.weekview"/>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.alamkanak.weekview

import java.util.*

/**
* Created by Raquib on 1/6/2015.
*/
interface DateTimeInterpreter {
fun interpretDate(date: Calendar): String

fun interpretTime(hour: Int, minutes: Int): String
}
44 changes: 0 additions & 44 deletions library/src/main/java/com/alamkanak/weekview/MonthLoader.java

This file was deleted.

30 changes: 30 additions & 0 deletions library/src/main/java/com/alamkanak/weekview/MonthLoader.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.alamkanak.weekview

import java.util.*

class MonthLoader(var onMonthChangeListener: MonthChangeListener?) : WeekViewLoader {

override fun toWeekViewPeriodIndex(instance: Calendar): Double {
return (instance.get(Calendar.YEAR) * 12).toDouble() + instance.get(Calendar.MONTH).toDouble() + (instance.get(Calendar.DAY_OF_MONTH) - 1) / 30.0
}

override fun onLoad(periodIndex: Int): List<WeekViewEvent>? {
return onMonthChangeListener!!.onMonthChange(periodIndex / 12, periodIndex % 12 + 1)
}

interface MonthChangeListener {
/**
*
* Very important interface, it's the base to load events in the calendar.
* 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.
* **That's why you can have three times the same event at the same place if you mess up with the configuration**
*
* @param newYear : year of the events required by the view.
* @param newMonth :
*
*month of the events required by the view **1 based (not like JAVA API) : January = 1 and December = 12**.
* @return a list of the events happening **during the specified month**.
*/
fun onMonthChange(newYear: Int, newMonth: Int): List<WeekViewEvent>?
}
}
10 changes: 0 additions & 10 deletions library/src/main/java/com/alamkanak/weekview/TextColorPicker.java

This file was deleted.

10 changes: 10 additions & 0 deletions library/src/main/java/com/alamkanak/weekview/TextColorPicker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.alamkanak.weekview

import android.support.annotation.ColorInt

interface TextColorPicker {

@ColorInt
fun getTextColor(event: WeekViewEvent): Int

}
Loading

0 comments on commit 2b59062

Please sign in to comment.