-
Notifications
You must be signed in to change notification settings - Fork 65
A lot of changes: Kotlin, time/date formatting fixes, demo activity for whole view snapping... #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
472162d
2b59062
9865f5e
1406c08
1f9e199
c37823c
3438aad
9523d1b
291461b
8873a5d
b1a88c0
e58f6f5
078b791
99c423a
0be2f1d
0228dad
79d8e04
1bc68ab
f2a4226
10a7614
4241b17
ae17dee
7cb7cd8
edd87c1
50585ff
ef94b8d
8ebc646
9d6f070
0be8d77
d021bc1
2c8ca57
eacd593
610bd21
068fdfb
3e11806
09435f8
b73991c
125c9dc
46e5259
7fd7e08
da67353
b0b098f
a6ff5c8
6f829dd
2f9b1b9
5688b50
91ab45f
88c9020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,13 @@ | ||
[Join our slack](https://join.slack.com/t/androidweekview/shared_invite/enQtMzEyMDE3NzU3NTM3LWQyZGRhNjRlMTUzNzNlNjNlM2M0OTMyMDhjMzE1NDMzOGQzYzhjNzI2YjZhZWM3MzJiY2I1YmY2NGEwOTlkNTY) | ||
A fork of this repository: | ||
https://github.com/Quachero/Android-Week-View | ||
Which is a fork of this: | ||
https://github.com/Quivr/Android-Week-View | ||
Which is a fork of this: | ||
https://github.com/alamkanak/Android-Week-View | ||
|
||
All because all of those aren't functional anymore... | ||
|
||
Android Week View | ||
================= | ||
I've added so many things compared to them. You can read about them in a pull request I've made: | ||
https://github.com/Quivr/Android-Week-View/pull/97 | ||
https://github.com/Quachero/Android-Week-View/pull/1 | ||
|
||
**Android Week View** is an android library to display calendars (week view or day view) within the app. It supports custom styling. | ||
|
||
[Why this fork? (features + community & contributing)](https://github.com/Quivr/Android-Week-View/issues/45) | ||
|
||
 | ||
|
||
Features | ||
------------ | ||
|
||
* Week view calendar | ||
* Day view calendar | ||
* Custom styling | ||
* Vertical scrolling and zooming | ||
* Infinite horizontal scrolling | ||
* Possibility to set min and max date | ||
* Possibility to set range of visible hours | ||
* All day events at the top | ||
* Live preview of custom styling in xml preview window | ||
|
||
Who uses it | ||
--------------- | ||
|
||
* [Quivr](https://quivr.be/en/) | ||
* [Series Addict](https://play.google.com/store/apps/details?id=com.alamkanak.seriesaddict) | ||
* [Unicaen Timetable](https://play.google.com/store/apps/details?id=fr.skyost.timetable) | ||
* Using the library? Just make an issue | ||
|
||
Getting Started | ||
--------------- | ||
|
||
See the [wiki](https://github.com/Quivr/Android-Week-View/wiki) | ||
|
||
Sample | ||
---------- | ||
|
||
There is also a [sample app](https://github.com/quivr/Android-Week-View/tree/master/sample) to get you started. | ||
|
||
|
||
License | ||
---------- | ||
|
||
Copyright 2014 Raquib-ul-Alam | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sun Aug 06 18:02:35 CEST 2017 | ||
#Fri Feb 08 08:07:15 IST 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
compileSdkVersion 28 | ||
|
||
defaultConfig { | ||
minSdkVersion 9 | ||
targetSdkVersion 25 | ||
minSdkVersion 14 | ||
targetSdkVersion 28 | ||
} | ||
} | ||
|
||
configurations { | ||
javadocDeps | ||
} | ||
dependencies { | ||
compile 'com.android.support:appcompat-v7:25.1.0' | ||
javadocDeps 'com.android.support:appcompat-v7:25.1.0' | ||
implementation 'androidx.appcompat:appcompat:1.0.2' | ||
javadocDeps 'androidx.appcompat:appcompat:1.0.2' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} | ||
|
||
apply from: 'gradle-mvn-push.gradle' | ||
apply from: 'gradle-mvn-push.gradle' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
android.library=true | ||
# suppress inspection "UnusedProperty" for whole file | ||
android.library=true |
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,11 @@ | ||
package com.alamkanak.weekview | ||
|
||
import java.util.* | ||
|
||
interface DateTimeInterpreter { | ||
fun getFormattedWeekDayTitle(date: Calendar): String | ||
|
||
fun getFormattedTimeOfDay(hour: Int, minutes: Int): String | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.alamkanak.weekview | ||
|
||
import android.util.Log | ||
|
||
class DrawPerformanceTester(val measureDrawTime: Boolean = true) { | ||
var drawSamplesCount = 0L | ||
var drawTotalTime = 0L | ||
|
||
private var startTime: Long = 0L | ||
|
||
fun startMeasure() { | ||
if (!measureDrawTime) | ||
return | ||
startTime = System.currentTimeMillis() | ||
} | ||
|
||
fun endMeasure() { | ||
if (!measureDrawTime) | ||
return | ||
val endTime = System.currentTimeMillis() | ||
val totalTime = endTime - startTime | ||
++drawSamplesCount | ||
drawTotalTime += totalTime | ||
val drawAverageTime = drawTotalTime.toFloat() / drawSamplesCount.toFloat() | ||
Log.d("AppLog", "currentTime:$totalTime average:$drawAverageTime") | ||
} | ||
} |
This file was deleted.
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): MutableList<out WeekViewEvent>? { | ||
return onMonthChangeListener!!.onMonthChange(periodIndex / 12, periodIndex % 12 + 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can you be sure that "onMonthChangeListener" will not be null here ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are both correct and incorrect. For some reason the library has code to check it that when you use it, you must set a listener:
and then when you set it:
So you can't escape it from being non null. But why this requirement exists at all? For now I will let it stay how it is. |
||
} | ||
|
||
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): MutableList<out WeekViewEvent>? | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.alamkanak.weekview | ||
|
||
import androidx.annotation.IntRange | ||
import java.util.* | ||
|
||
/** | ||
* <h1>PrefetchingWeekViewLoader</h1> | ||
* This class provides prefetching data loading behaviour. | ||
* By setting a specific period of N, data is retrieved for the current period, | ||
* the next N periods and the previous N periods. | ||
*/ | ||
/** | ||
* @param weekViewLoader An instance of the WeekViewLoader class | ||
* @param prefetchingPeriod The amount of periods to be fetched before and after the | ||
* current period. Must be 1 or greater. | ||
*/ | ||
class PrefetchingWeekViewLoader(val weekViewLoader: WeekViewLoader, @IntRange(from = 1L) val prefetchingPeriod: Int = 1) : WeekViewLoader { | ||
|
||
init { | ||
if (prefetchingPeriod < 1) | ||
throw IllegalArgumentException("Must specify prefetching period of at least 1!") | ||
} | ||
|
||
override fun onLoad(periodIndex: Int): MutableList<WeekViewEvent>? { | ||
// fetch the current period | ||
var loadedEvents = weekViewLoader.onLoad(periodIndex) | ||
val events = ArrayList<WeekViewEvent>() | ||
if (loadedEvents != null) | ||
events.addAll(loadedEvents) | ||
// fetch periods before/after | ||
for (i in 1..this.prefetchingPeriod) { | ||
loadedEvents = weekViewLoader.onLoad(periodIndex - i) | ||
if (loadedEvents != null) | ||
events.addAll(loadedEvents) | ||
loadedEvents = weekViewLoader.onLoad(periodIndex + i) | ||
if (loadedEvents != null) | ||
events.addAll(loadedEvents) | ||
} | ||
// return list of all events together | ||
return events | ||
} | ||
|
||
override fun toWeekViewPeriodIndex(instance: Calendar) = weekViewLoader.toWeekViewPeriodIndex(instance) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.alamkanak.weekview | ||
|
||
import java.util.* | ||
|
||
data class SimpleDate(val year: Int, val month: Int, val dayOfMonth: Int) { | ||
override fun toString(): String = "$year-$month-$dayOfMonth" | ||
|
||
constructor(cal: Calendar) : this(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.alamkanak.weekview | ||
|
||
import androidx.annotation.ColorInt | ||
|
||
interface TextColorPicker { | ||
|
||
@ColorInt | ||
fun getTextColor(event: WeekViewEvent): Int | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can you be sure that "onMonthChangeListener" will not be null here ?
I think that nullable "?" is better. It returns nullable List btw.