Skip to content
This repository was archived by the owner on Jan 22, 2023. It is now read-only.

Commit b4fe6ea

Browse files
author
Jonas Schubert
committed
refactors some methods
1 parent 5d70c28 commit b4fe6ea

File tree

5 files changed

+28
-50
lines changed

5 files changed

+28
-50
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![API](https://img.shields.io/badge/API-14+-blue.svg)](https://android-arsenal.com/api?level=14)
55
[![](https://jitpack.io/v/TimeXt/TimeXt-Kotlin.svg)](https://jitpack.io/#TimeXt/TimeXt-Kotlin)
66

7-
[![Version](https://img.shields.io/badge/version-v0.5.0-blue.svg)](https://github.com/TimeXt/TimeXt-Kotlin/releases/tag/0.5.0)
7+
[![Version](https://img.shields.io/badge/version-v0.5.1-blue.svg)](https://github.com/TimeXt/TimeXt-Kotlin/releases/tag/0.5.1)
88
[![Build](https://img.shields.io/badge/build-success-green.svg)](timext)
99
[![CodeCoverage](https://img.shields.io/badge/codeCoverage-64-orange.svg)](timext)
1010

@@ -156,15 +156,15 @@ Add the dependency to your `build.gradle`:
156156

157157
```groovy
158158
dependencies {
159-
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext:0.5.0'
159+
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext:0.5.1'
160160
}
161161
```
162162

163163
- For **Android** projects:
164164

165165
```groovy
166166
dependencies {
167-
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext-android:0.5.0'
167+
implementation 'com.github.TimeXt.TimeXt-Kotlin:timext-android:0.5.1'
168168
}
169169
```
170170

timext-android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
defaultConfig {
1313
minSdkVersion 14
1414
targetSdkVersion 28
15-
versionCode 500
16-
versionName "0.5.0"
15+
versionCode 501
16+
versionName "0.5.1"
1717
}
1818

1919
buildTypes {

timext-android/timext-android.iml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,19 @@
118118
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_zip" />
119119
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
120120
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
121+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compile_only_not_namespaced_r_class_jar" />
121122
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/consumer_proguard_file" />
122123
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
123124
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
124125
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
125126
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_and_local_jars_jni" />
126127
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_assets" />
128+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_manifest" />
127129
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
130+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_publish_jar" />
131+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_jni_libs" />
128132
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
133+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_shaders" />
129134
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-classes" />
130135
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
131136
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />

timext/src/main/kotlin/com/github/guepardoapps/timext/kotlin/TimeXt.kt

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,25 @@ class TimeXt(var value: Double, private var unit: Double) {
2323
val inMilliseconds: Double
2424
get() = this.value * this.unit / TimeXtUnit.millisecond
2525

26-
fun toYears(): TimeXt {
27-
return TimeXt(this.inYears, TimeXtUnit.year)
28-
}
26+
fun toYears(): TimeXt = TimeXt(this.inYears, TimeXtUnit.year)
2927

30-
fun toWeeks(): TimeXt {
31-
return TimeXt(this.inWeeks, TimeXtUnit.week)
32-
}
28+
fun toWeeks(): TimeXt = TimeXt(this.inWeeks, TimeXtUnit.week)
3329

34-
fun toDays(): TimeXt {
35-
return TimeXt(this.inDays, TimeXtUnit.day)
36-
}
30+
fun toDays(): TimeXt = TimeXt(this.inDays, TimeXtUnit.day)
3731

38-
fun toHours(): TimeXt {
39-
return TimeXt(this.inHours, TimeXtUnit.hour)
40-
}
32+
fun toHours(): TimeXt = TimeXt(this.inHours, TimeXtUnit.hour)
4133

42-
fun toMinutes(): TimeXt {
43-
return TimeXt(this.inMinutes, TimeXtUnit.minute)
44-
}
34+
fun toMinutes(): TimeXt = TimeXt(this.inMinutes, TimeXtUnit.minute)
4535

46-
fun toSeconds(): TimeXt {
47-
return TimeXt(this.inSeconds, TimeXtUnit.second)
48-
}
36+
fun toSeconds(): TimeXt = TimeXt(this.inSeconds, TimeXtUnit.second)
4937

50-
fun toMilliseconds(): TimeXt {
51-
return TimeXt(this.inMilliseconds, TimeXtUnit.millisecond)
52-
}
38+
fun toMilliseconds(): TimeXt = TimeXt(this.inMilliseconds, TimeXtUnit.millisecond)
5339

54-
operator fun plus(timeXt: TimeXt): TimeXt {
55-
val newValue = ((this.inMilliseconds + timeXt.inMilliseconds) / this.unit) * TimeXtUnit.millisecond
56-
return TimeXt(newValue, this.unit)
57-
}
40+
operator fun plus(timeXt: TimeXt): TimeXt = TimeXt(((this.inMilliseconds + timeXt.inMilliseconds) / this.unit) * TimeXtUnit.millisecond, this.unit)
5841

59-
operator fun minus(timeXt: TimeXt): TimeXt {
60-
val newValue = ((this.inMilliseconds - timeXt.inMilliseconds) / this.unit) * TimeXtUnit.millisecond
61-
return TimeXt(newValue, this.unit)
62-
}
42+
operator fun minus(timeXt: TimeXt): TimeXt = TimeXt(((this.inMilliseconds - timeXt.inMilliseconds) / this.unit) * TimeXtUnit.millisecond, this.unit)
6343

64-
operator fun times(timesValue: Number): TimeXt {
65-
return TimeXt(value * timesValue.toDouble(), this.unit)
66-
}
44+
operator fun times(timesValue: Number): TimeXt = TimeXt(value * timesValue.toDouble(), this.unit)
6745

6846
operator fun div(divValue: Number): TimeXt {
6947
if (divValue == 0) {
@@ -80,12 +58,12 @@ class TimeXt(var value: Double, private var unit: Double) {
8058

8159
operator fun contains(compareTimeXt: TimeXt) = inMilliseconds >= compareTimeXt.inMilliseconds
8260

83-
override operator fun equals(other: Any?): Boolean {
84-
if (other == null || other !is TimeXt) {
85-
return false
86-
}
87-
return compareTo(other) == 0
88-
}
61+
override operator fun equals(other: Any?): Boolean =
62+
if (other == null || other !is TimeXt) {
63+
false
64+
} else {
65+
compareTo(other) == 0
66+
}
8967

9068
override fun hashCode() = inMilliseconds.hashCode()
9169
}

timext/src/main/kotlin/com/github/guepardoapps/timext/kotlin/extensions/CalendarExtensions.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ operator fun Calendar.plus(timeXt: TimeXt): Calendar {
1010
return newCalendar
1111
}
1212

13-
operator fun Calendar.minus(timeXt: TimeXt): Calendar {
14-
return this + (timeXt * -1)
15-
}
13+
operator fun Calendar.minus(timeXt: TimeXt): Calendar = this + (timeXt * -1)
1614

17-
operator fun Calendar.minus(calendar: Calendar): TimeXt {
18-
val difference = this.timeInMillis - calendar.timeInMillis
19-
return TimeXt(difference.toDouble(), TimeXtUnit.millisecond)
20-
}
15+
operator fun Calendar.minus(calendar: Calendar): TimeXt = TimeXt((this.timeInMillis - calendar.timeInMillis).toDouble(), TimeXtUnit.millisecond)

0 commit comments

Comments
 (0)