Commit 3a4e2163 authored by Ricki Hirner's avatar Ricki Hirner

Minor cleanup (lint)

parent a0d592c7
......@@ -66,8 +66,8 @@ dependencies {
compile "org.mnode.ical4j:ical4j:$ical4j_version"
compile 'org.slf4j:slf4j-jdk14:1.7.25'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
testCompile 'junit:junit:4.12'
}
......@@ -72,7 +72,7 @@ class MiscUtilsTest {
assertEquals(TimeZones.UTC_ID, MiscUtils.getTzId(DtStart(DateTime(1438607288000L))))
// DATE-TIME with time zone
assertEquals(tzVienna.getID(), MiscUtils.getTzId(DtStart(DateTime("20150101T000000", tzVienna))))
assertEquals(tzVienna.id, MiscUtils.getTzId(DtStart(DateTime("20150101T000000", tzVienna))))
}
@Test
......
......@@ -25,7 +25,7 @@ class TestCalendar(
companion object {
fun findOrCreate(account: Account, provider: ContentProviderClient): TestCalendar {
val calendars = AndroidCalendar.find(account, provider, Factory, null, null)
if (calendars.isEmpty()) {
return if (calendars.isEmpty()) {
val values = ContentValues(3)
values.put(CalendarContract.Calendars.NAME, "TestCalendar")
values.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, "ical4android Test Calendar")
......@@ -33,9 +33,9 @@ class TestCalendar(
CalendarContract.Reminders.METHOD_DEFAULT)
val uri = AndroidCalendar.create(account, provider, values)
return TestCalendar(account, provider, ContentUris.parseId(uri))
TestCalendar(account, provider, ContentUris.parseId(uri))
} else
return calendars.first()
calendars.first()
}
}
......
......@@ -8,12 +8,12 @@
package at.bitfire.ical4android.impl
import android.content.ContentValues;
import android.content.ContentValues
import at.bitfire.ical4android.AndroidTask;
import at.bitfire.ical4android.AndroidTaskFactory;
import at.bitfire.ical4android.AndroidTaskList;
import at.bitfire.ical4android.Task;
import at.bitfire.ical4android.AndroidTask
import at.bitfire.ical4android.AndroidTaskFactory
import at.bitfire.ical4android.AndroidTaskList
import at.bitfire.ical4android.Task
class TestTask: AndroidTask {
......
......@@ -578,11 +578,11 @@ abstract class AndroidEvent(
event.organizer?.let { organizer ->
val email: String?
val uri = organizer.calAddress
if (uri.scheme.equals("mailto", true))
email = uri.schemeSpecificPart
email = if (uri.scheme.equals("mailto", true))
uri.schemeSpecificPart
else {
val emailParam = organizer.getParameter(ICalendar.Email.PARAMETER_NAME) as ICalendar.Email?
email = emailParam?.value
emailParam?.value
}
if (email != null)
builder.withValue(Events.ORGANIZER, email)
......
......@@ -35,7 +35,7 @@ abstract class AndroidTaskList<out T: AndroidTask>(
companion object {
/**
* Acquires a [ContentProviderClient] for a supported task provider. If multiple providers are
* Acquires a [android.content.ContentProviderClient] for a supported task provider. If multiple providers are
* available, a pre-defined priority list is taken into account.
* @return A [TaskProvider], or null if task storage is not available/accessible.
* Caller is responsible for calling release()!
......
......@@ -67,7 +67,7 @@ class BatchOperation(
try {
val ops = toCPO(start, end)
Constants.log.fine("Running {${ops.size}} operations ($start .. ${end-1})")
Constants.log.fine("Running ${ops.size} operations ($start .. ${end-1})")
val partResults = providerClient.applyBatch(ops)
val n = end - start
......
......@@ -113,14 +113,14 @@ class Event: ICalendar() {
// If the SEQUENCE is identical, use latest version.
val event = masterEvents[uid]
if (event == null || (event.sequence != null && sequence >= event.sequence.sequenceNo))
masterEvents.put(uid, vEvent)
masterEvents[uid] = vEvent
} else {
// exception (RECURRENCE-ID)
var ex = exceptions[uid]
// first index level: UID
if (ex == null) {
ex = mutableMapOf<String,VEvent>()
ex = mutableMapOf()
exceptions[uid] = ex
}
// second index level: RECURRENCE-ID
......
......@@ -11,6 +11,7 @@ package at.bitfire.ical4android
/**
* Represents an RGBA COLOR value, as specified in https://tools.ietf.org/html/rfc7986#section-5.9
*/
@Suppress("EnumEntryName")
enum class EventColor(val rgba: Int) {
// values taken from https://www.w3.org/TR/2011/REC-css3-color-20110607/#svg-color
aliceblue(0xfff0f8ff.toInt()),
......
......@@ -190,8 +190,8 @@ class Task: ICalendar() {
fun isAllDay(): Boolean {
val dtStart = dtStart
val due = due
return (dtStart != null && !(dtStart.date is DateTime)) ||
(due != null && !(due.date is DateTime))
return (dtStart != null && dtStart.date !is DateTime) ||
(due != null && due.date !is DateTime)
}
}
......@@ -9,6 +9,7 @@
package at.bitfire.ical4android
import android.accounts.Account
import android.annotation.SuppressLint
import android.content.ContentProviderClient
import android.content.Context
import android.content.pm.PackageManager
......@@ -40,12 +41,13 @@ class TaskProvider private constructor(
/**
* Acquires a content provider for a given task provider. The content provider will
* be released when the TaskProvider is closed.
* be released when the TaskProvider is closed with [close].
* @param context will be used to acquire the content provider client
* @param name task provider to acquire content provider for
* @return content provider for the given task provider (may be {@code null})
* @throws [ProviderTooOldException] if the tasks provider is installed, but doesn't meet the minimum version requirement
*/
@SuppressLint("Recycle")
fun acquire(context: Context, name: TaskProvider.ProviderName): TaskProvider? {
return try {
checkVersion(context, name)
......
......@@ -68,25 +68,25 @@ class DateUtilsTest {
assertEquals(Value.DATE_TIME, exDates.type)
assertTrue(exDates.isUtc)
assertEquals(2, exDates.size)
assertEquals(1420108210000L, exDates.get(0).time)
assertEquals(1435833020000L, exDates.get(1).time)
assertEquals(1420108210000L, exDates[0].time)
assertEquals(1435833020000L, exDates[1].time)
// list of time zone times
exDate = DateUtils.androidStringToRecurrenceSet(tzIdToronto + ";20150103T113030,20150704T113040", ExDate::class.java, false)
exDate = DateUtils.androidStringToRecurrenceSet("$tzIdToronto;20150103T113030,20150704T113040", ExDate::class.java, false)
exDates = exDate.dates
assertEquals(Value.DATE_TIME, exDates.type)
assertEquals(DateUtils.tzRegistry.getTimeZone(tzIdToronto), exDates.timeZone)
assertEquals(2, exDates.size)
assertEquals(1420302630000L, exDates.get(0).time)
assertEquals(1436023840000L, exDates.get(1).time)
assertEquals(1420302630000L, exDates[0].time)
assertEquals(1436023840000L, exDates[1].time)
// list of dates
exDate = DateUtils.androidStringToRecurrenceSet("20150101T103010Z,20150702T103020Z", ExDate::class.java, true)
exDates = exDate.dates
assertEquals(Value.DATE, exDates.type)
assertEquals(2, exDates.size)
assertEquals("20150101", exDates.get(0).toString())
assertEquals("20150702", exDates.get(1).toString())
assertEquals("20150101", exDates[0].toString())
assertEquals("20150702", exDates[1].toString())
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment