From 54ad6caf8324471d97c0aac2922bebd84662a7b0 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 7 Mar 2021 14:37:05 +0100 Subject: [PATCH] interfaces -> kt --- .../TreatmentsProfileSwitchFragment.kt | 2 +- .../androidaps/interfaces/Interval.java | 28 ------ .../androidaps/interfaces/Interval.kt | 20 ++++ .../interfaces/PluginDescription.java | 96 ------------------- .../interfaces/PluginDescription.kt | 34 +++++++ .../androidaps/interfaces/PluginType.java | 14 --- .../androidaps/interfaces/PluginType.kt | 5 + 7 files changed, 60 insertions(+), 139 deletions(-) delete mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/Interval.java create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/Interval.kt delete mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.kt delete mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index cbb2d009db..41dad45632 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -129,7 +129,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { holder.binding.clone.tag = profileSwitch holder.binding.name.tag = profileSwitch holder.binding.date.tag = profileSwitch - holder.binding.invalid.visibility = if (profileSwitch.isValid()) View.GONE else View.VISIBLE + holder.binding.invalid.visibility = if (profileSwitch.isValid) View.GONE else View.VISIBLE } override fun getItemCount(): Int { diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.java b/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.java deleted file mode 100644 index 0d8b5abb49..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.java +++ /dev/null @@ -1,28 +0,0 @@ -package info.nightscout.androidaps.interfaces; - -import dagger.android.HasAndroidInjector; - -/** - * Created by mike on 21.05.2017. - */ - -public interface Interval { - long durationInMsec(); - long start(); - - // planned end time at time of creation - long originalEnd(); - - // end time after cut - long end(); - - void cutEndTo(long end); - boolean match(long time); - boolean before(long time); - boolean after(long time); - - boolean isInProgress(); - boolean isEndingEvent(); - - boolean isValid(); -} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.kt new file mode 100644 index 0000000000..47c1d64bcf --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.kt @@ -0,0 +1,20 @@ +package info.nightscout.androidaps.interfaces + +interface Interval { + + fun durationInMsec(): Long + fun start(): Long + + // planned end time at time of creation + fun originalEnd(): Long + + // end time after cut + fun end(): Long + fun cutEndTo(end: Long) + fun match(time: Long): Boolean + fun before(time: Long): Boolean + fun after(time: Long): Boolean + val isInProgress: Boolean + val isEndingEvent: Boolean + val isValid: Boolean +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java deleted file mode 100644 index c45631b93e..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java +++ /dev/null @@ -1,96 +0,0 @@ -package info.nightscout.androidaps.interfaces; - -public class PluginDescription { - PluginType mainType = PluginType.GENERAL; - String fragmentClass = null; - public boolean alwaysVisible = false; - public boolean neverVisible = false; - public boolean alwaysEnabled = false; - boolean showInList = true; - int pluginName = -1; - int shortName = -1; - int description = -1; - int preferencesId = -1; - public boolean enableByDefault = false; - public boolean visibleByDefault = false; - boolean defaultPlugin = false; - int pluginIcon = -1; - - public PluginDescription mainType(PluginType mainType) { - this.mainType = mainType; - return this; - } - - public PluginDescription fragmentClass(String fragmentClass) { - this.fragmentClass = fragmentClass; - return this; - } - - public PluginDescription alwaysEnabled(boolean alwaysEnabled) { - this.alwaysEnabled = alwaysEnabled; - return this; - } - - public PluginDescription alwaysVisible(boolean alwaysVisible) { - this.alwaysVisible = alwaysVisible; - return this; - } - - public PluginDescription neverVisible(boolean neverVisible) { - this.neverVisible = neverVisible; - return this; - } - - public PluginDescription showInList(boolean showInList) { - this.showInList = showInList; - return this; - } - - public PluginDescription pluginIcon(int pluginIcon) { - this.pluginIcon = pluginIcon; - return this; - } - - public PluginDescription pluginName(int pluginName) { - this.pluginName = pluginName; - return this; - } - - public PluginDescription shortName(int shortName) { - this.shortName = shortName; - return this; - } - - public PluginDescription preferencesId(int preferencesId) { - this.preferencesId = preferencesId; - return this; - } - - public PluginDescription enableByDefault(boolean enableByDefault) { - this.enableByDefault = enableByDefault; - return this; - } - - public PluginDescription visibleByDefault(boolean visibleByDefault) { - this.visibleByDefault = visibleByDefault; - return this; - } - - public PluginDescription description(int description) { - this.description = description; - return this; - } - - public PluginDescription setDefault() { - defaultPlugin = true; - return this; - } - - public String getFragmentClass() { - return fragmentClass; - } - - public PluginType getType() { - return mainType; - } -} diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.kt new file mode 100644 index 0000000000..94ee64cb67 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.kt @@ -0,0 +1,34 @@ +package info.nightscout.androidaps.interfaces + +class PluginDescription { + + var mainType = PluginType.GENERAL + var fragmentClass: String? = null + var alwaysVisible = false + var neverVisible = false + var alwaysEnabled = false + var showInList = true + var pluginName = -1 + var shortName = -1 + var description = -1 + var preferencesId = -1 + var enableByDefault = false + var visibleByDefault = false + var defaultPlugin = false + var pluginIcon = -1 + + fun mainType(mainType: PluginType): PluginDescription = this.also { it.mainType = mainType } + fun fragmentClass(fragmentClass: String?): PluginDescription = this.also { it.fragmentClass = fragmentClass } + fun alwaysEnabled(alwaysEnabled: Boolean): PluginDescription = this.also { it.alwaysEnabled = alwaysEnabled } + fun alwaysVisible(alwaysVisible: Boolean): PluginDescription = this.also { it.alwaysVisible = alwaysVisible } + fun neverVisible(neverVisible: Boolean): PluginDescription = this.also { it.neverVisible = neverVisible } + fun showInList(showInList: Boolean): PluginDescription = this.also { it.showInList = showInList } + fun pluginIcon(pluginIcon: Int): PluginDescription = this.also { it.pluginIcon = pluginIcon } + fun pluginName(pluginName: Int): PluginDescription = this.also { it.pluginName = pluginName } + fun shortName(shortName: Int): PluginDescription = this.also { it.shortName = shortName } + fun preferencesId(preferencesId: Int): PluginDescription = this.also { it.preferencesId = preferencesId } + fun enableByDefault(enableByDefault: Boolean): PluginDescription = this.also { it.enableByDefault = enableByDefault } + fun visibleByDefault(visibleByDefault: Boolean): PluginDescription = this.also { it.visibleByDefault = visibleByDefault } + fun description(description: Int): PluginDescription = this.also { it.description = description } + fun setDefault(): PluginDescription = this.also { it.defaultPlugin = true } +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java deleted file mode 100644 index 1e5685f2ac..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java +++ /dev/null @@ -1,14 +0,0 @@ -package info.nightscout.androidaps.interfaces; - -public enum PluginType { - GENERAL, - TREATMENT, - SENSITIVITY, - PROFILE, - APS, - PUMP, - CONSTRAINTS, - LOOP, - BGSOURCE, - INSULIN -} diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.kt new file mode 100644 index 0000000000..68ea553a64 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.kt @@ -0,0 +1,5 @@ +package info.nightscout.androidaps.interfaces + +enum class PluginType { + GENERAL, TREATMENT, SENSITIVITY, PROFILE, APS, PUMP, CONSTRAINTS, LOOP, BGSOURCE, INSULIN +} \ No newline at end of file