浏览代码

Migrate search models to kotlin

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 年之前
父节点
当前提交
2884c6e01c

+ 1 - 1
app/src/main/java/com/nextcloud/talk/jobs/ContactAddressBookWorker.kt

@@ -143,7 +143,7 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
                     }
 
                     override fun onNext(foundContacts: ContactsByNumberOverall) {
-                        val contactsWithAssociatedPhoneNumbers = foundContacts.ocs.map
+                        val contactsWithAssociatedPhoneNumbers = foundContacts.ocs!!.map
                         deleteLinkedAccounts(contactsWithAssociatedPhoneNumbers)
                         createLinkedAccounts(contactsWithAssociatedPhoneNumbers)
                     }

+ 0 - 78
app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.java

@@ -1,78 +0,0 @@
-/*
- * Nextcloud Talk application
- *  
- * @author Tobias Kaminsky
- * Copyright (C) 2020 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
- *  
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
- *  
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *  
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.nextcloud.talk.models.json.search;
-
-import com.bluelinelabs.logansquare.annotation.JsonField;
-import com.bluelinelabs.logansquare.annotation.JsonObject;
-import com.nextcloud.talk.models.json.generic.GenericOCS;
-
-import org.parceler.Parcel;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@Parcel
-@JsonObject
-public class ContactsByNumberOCS extends GenericOCS {
-    @JsonField(name = "data")
-    public Map<String, String> map = new HashMap();
-
-    public Map<String, String> getMap() {
-        return this.map;
-    }
-
-    public void setMap(Map<String, String> map) {
-        this.map = map;
-    }
-
-    public boolean equals(final Object o) {
-        if (o == this) {
-            return true;
-        }
-        if (!(o instanceof ContactsByNumberOCS)) {
-            return false;
-        }
-        final ContactsByNumberOCS other = (ContactsByNumberOCS) o;
-        if (!other.canEqual((Object) this)) {
-            return false;
-        }
-        final Object this$map = this.getMap();
-        final Object other$map = other.getMap();
-
-        return this$map == null ? other$map == null : this$map.equals(other$map);
-    }
-
-    protected boolean canEqual(final Object other) {
-        return other instanceof ContactsByNumberOCS;
-    }
-
-    public int hashCode() {
-        final int PRIME = 59;
-        int result = 1;
-        final Object $map = this.getMap();
-        result = result * PRIME + ($map == null ? 43 : $map.hashCode());
-        return result;
-    }
-
-    public String toString() {
-        return "ContactsByNumberOCS(map=" + this.getMap() + ")";
-    }
-}

+ 39 - 0
app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.kt

@@ -0,0 +1,39 @@
+/*
+ * Nextcloud Talk application
+ *  
+ * @author Tobias Kaminsky
+ * @author Andy Scherzinger
+ * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
+ * Copyright (C) 2020 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
+ *  
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *  
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *  
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.models.json.search
+
+import android.os.Parcelable
+import com.nextcloud.talk.models.json.generic.GenericOCS
+import com.bluelinelabs.logansquare.annotation.JsonField
+import com.bluelinelabs.logansquare.annotation.JsonObject
+import java.util.HashMap
+import kotlinx.android.parcel.Parcelize
+
+@Parcelize
+@JsonObject
+data class ContactsByNumberOCS(
+    @JsonField(name = ["data"])
+    var map: Map<String, String> = HashMap()
+) : GenericOCS(), Parcelable {
+    // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
+    constructor() : this(HashMap())
+}

+ 0 - 74
app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.java

@@ -1,74 +0,0 @@
-/*
- * Nextcloud Talk application
- *  
- * @author Tobias Kaminsky
- * Copyright (C) 2020 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
- *  
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
- *  
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *  
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.nextcloud.talk.models.json.search;
-
-import com.bluelinelabs.logansquare.annotation.JsonField;
-import com.bluelinelabs.logansquare.annotation.JsonObject;
-
-import org.parceler.Parcel;
-
-@Parcel
-@JsonObject
-public class ContactsByNumberOverall {
-    @JsonField(name = "ocs")
-    public ContactsByNumberOCS ocs;
-
-    public ContactsByNumberOCS getOcs() {
-        return this.ocs;
-    }
-
-    public void setOcs(ContactsByNumberOCS ocs) {
-        this.ocs = ocs;
-    }
-
-    public boolean equals(final Object o) {
-        if (o == this) {
-            return true;
-        }
-        if (!(o instanceof ContactsByNumberOverall)) {
-            return false;
-        }
-        final ContactsByNumberOverall other = (ContactsByNumberOverall) o;
-        if (!other.canEqual((Object) this)) {
-            return false;
-        }
-        final Object this$ocs = this.getOcs();
-        final Object other$ocs = other.getOcs();
-
-        return this$ocs == null ? other$ocs == null : this$ocs.equals(other$ocs);
-    }
-
-    protected boolean canEqual(final Object other) {
-        return other instanceof ContactsByNumberOverall;
-    }
-
-    public int hashCode() {
-        final int PRIME = 59;
-        int result = 1;
-        final Object $ocs = this.getOcs();
-        result = result * PRIME + ($ocs == null ? 43 : $ocs.hashCode());
-        return result;
-    }
-
-    public String toString() {
-        return "ContactsByNumberOverall(ocs=" + this.getOcs() + ")";
-    }
-}

+ 37 - 0
app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.kt

@@ -0,0 +1,37 @@
+/*
+ * Nextcloud Talk application
+ *  
+ * @author Tobias Kaminsky
+ * @author Andy Scherzinger
+ * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
+ * Copyright (C) 2020 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
+ *  
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *  
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *  
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.models.json.search
+
+import android.os.Parcelable
+import com.bluelinelabs.logansquare.annotation.JsonField
+import com.bluelinelabs.logansquare.annotation.JsonObject
+import kotlinx.android.parcel.Parcelize
+
+@Parcelize
+@JsonObject
+data class ContactsByNumberOverall(
+    @JsonField(name = ["ocs"])
+    var ocs: ContactsByNumberOCS?
+) : Parcelable {
+    // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
+    constructor() : this(null)
+}