mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-12 10:32:36 +00:00
migrate generic OCS to kotlin data classes + interface
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
f7fa14a117
commit
0c824120e3
@ -968,7 +968,7 @@ public class SettingsController extends BaseController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
|
public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
|
||||||
int statusCode = genericOverall.ocs.meta.statusCode;
|
int statusCode = Objects.requireNonNull(genericOverall.getMeta()).getStatusCode();
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
Toast.makeText(context, context.getResources().getString(
|
Toast.makeText(context, context.getResources().getString(
|
||||||
|
@ -55,6 +55,7 @@ import javax.inject.Inject;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.CookieManager;
|
import java.net.CookieManager;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
@ -104,13 +105,13 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
.blockingSubscribe(new Observer<GenericOverall>() {
|
.blockingSubscribe(new Observer<GenericOverall>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NotNull Disposable d) {
|
public void onSubscribe(@NotNull Disposable d) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@NotNull GenericOverall genericOverall) {
|
public void onNext(@NotNull GenericOverall genericOverall) {
|
||||||
if (genericOverall.getOcs().getMeta().getStatusCode() == 200
|
if (Objects.requireNonNull(genericOverall.getMeta()).getStatusCode() == 200 ||
|
||||||
|| genericOverall.getOcs().getMeta().getStatusCode() == 202) {
|
genericOverall.getMeta().getStatusCode() == 202) {
|
||||||
HashMap<String, String> queryMap = new HashMap<>();
|
HashMap<String, String> queryMap = new HashMap<>();
|
||||||
queryMap.put("deviceIdentifier",
|
queryMap.put("deviceIdentifier",
|
||||||
finalPushConfigurationState.getDeviceIdentifier());
|
finalPushConfigurationState.getDeviceIdentifier());
|
||||||
@ -128,7 +129,7 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.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.generic;
|
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
@JsonObject(serializeNullObjects = true)
|
|
||||||
public class GenericMeta {
|
|
||||||
@JsonField(name = "status")
|
|
||||||
public String status;
|
|
||||||
|
|
||||||
@JsonField(name = "statuscode")
|
|
||||||
public int statusCode;
|
|
||||||
|
|
||||||
@JsonField(name = "message")
|
|
||||||
public String message;
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return this.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStatusCode() {
|
|
||||||
return this.statusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return this.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatusCode(int statusCode) {
|
|
||||||
this.statusCode = statusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
if (o == this) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof GenericMeta)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final GenericMeta other = (GenericMeta) o;
|
|
||||||
if (!other.canEqual((Object) this)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Object this$status = this.getStatus();
|
|
||||||
final Object other$status = other.getStatus();
|
|
||||||
if (this$status == null ? other$status != null : !this$status.equals(other$status)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.getStatusCode() != other.getStatusCode()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Object this$message = this.getMessage();
|
|
||||||
final Object other$message = other.getMessage();
|
|
||||||
|
|
||||||
return this$message == null ? other$message == null : this$message.equals(other$message);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof GenericMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
final int PRIME = 59;
|
|
||||||
int result = 1;
|
|
||||||
final Object $status = this.getStatus();
|
|
||||||
result = result * PRIME + ($status == null ? 43 : $status.hashCode());
|
|
||||||
result = result * PRIME + this.getStatusCode();
|
|
||||||
final Object $message = this.getMessage();
|
|
||||||
result = result * PRIME + ($message == null ? 43 : $message.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "GenericMeta(status=" + this.getStatus() + ", statusCode=" + this.getStatusCode() + ", message=" + this.getMessage() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* @author Andy Scherzinger
|
||||||
|
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
|
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.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.generic
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
@JsonObject(serializeNullObjects = true)
|
||||||
|
data class GenericMeta(
|
||||||
|
@JsonField(name = ["status"])
|
||||||
|
var status: String? = null,
|
||||||
|
@JsonField(name = ["statuscode"])
|
||||||
|
var statusCode: Int = 0,
|
||||||
|
@JsonField(name = ["message"])
|
||||||
|
var message: String? = null
|
||||||
|
) : Parcelable {
|
||||||
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
|
constructor() : this(null, 0, null)
|
||||||
|
}
|
@ -30,45 +30,4 @@ import org.parceler.Parcel;
|
|||||||
public class GenericOCS {
|
public class GenericOCS {
|
||||||
@JsonField(name = "meta")
|
@JsonField(name = "meta")
|
||||||
public GenericMeta meta;
|
public GenericMeta meta;
|
||||||
|
|
||||||
public GenericMeta getMeta() {
|
|
||||||
return this.meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMeta(GenericMeta meta) {
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
if (o == this) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof GenericOCS)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final GenericOCS other = (GenericOCS) o;
|
|
||||||
if (!other.canEqual((Object) this)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Object this$meta = this.getMeta();
|
|
||||||
final Object other$meta = other.getMeta();
|
|
||||||
|
|
||||||
return this$meta == null ? other$meta == null : this$meta.equals(other$meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof GenericOCS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
final int PRIME = 59;
|
|
||||||
int result = 1;
|
|
||||||
final Object $meta = this.getMeta();
|
|
||||||
result = result * PRIME + ($meta == null ? 43 : $meta.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "GenericOCS(meta=" + this.getMeta() + ")";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.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.generic;
|
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
@JsonObject
|
|
||||||
public class GenericOverall {
|
|
||||||
@JsonField(name = "ocs")
|
|
||||||
public GenericOCS ocs;
|
|
||||||
|
|
||||||
public GenericOCS getOcs() {
|
|
||||||
return this.ocs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOcs(GenericOCS ocs) {
|
|
||||||
this.ocs = ocs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
if (o == this) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof GenericOverall)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final GenericOverall other = (GenericOverall) 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 GenericOverall;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 "GenericOverall(ocs=" + this.getOcs() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.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.generic
|
||||||
|
|
||||||
|
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 GenericOverall(
|
||||||
|
@JsonField(name = ["meta"])
|
||||||
|
var meta: GenericMeta? = null
|
||||||
|
) : IGenericOCS, Parcelable {
|
||||||
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
|
constructor() : this(null)
|
||||||
|
|
||||||
|
override fun getGenericMeta(): GenericMeta? {
|
||||||
|
return meta
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Andy Scherzinger
|
||||||
|
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
|
*
|
||||||
|
* 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.generic
|
||||||
|
|
||||||
|
interface IGenericOCS {
|
||||||
|
fun getGenericMeta(): GenericMeta?
|
||||||
|
}
|
@ -24,15 +24,23 @@ package com.nextcloud.talk.models.json.notifications
|
|||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
import com.nextcloud.talk.models.json.generic.GenericMeta
|
||||||
import com.nextcloud.talk.models.json.generic.GenericOCS
|
import com.nextcloud.talk.models.json.generic.GenericOCS
|
||||||
|
import com.nextcloud.talk.models.json.generic.IGenericOCS
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@JsonObject
|
@JsonObject
|
||||||
data class NotificationOCS(
|
data class NotificationOCS(
|
||||||
|
@JsonField(name = ["meta"])
|
||||||
|
var meta: GenericMeta?,
|
||||||
@JsonField(name = ["data"])
|
@JsonField(name = ["data"])
|
||||||
var notification: Notification?
|
var notification: Notification?
|
||||||
) : GenericOCS(), Parcelable {
|
) : IGenericOCS, Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null)
|
constructor() : this(null, null)
|
||||||
|
|
||||||
|
override fun getGenericMeta(): GenericMeta? {
|
||||||
|
return meta
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ class MessageActionsDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(@NonNull genericOverall: GenericOverall) {
|
override fun onNext(@NonNull genericOverall: GenericOverall) {
|
||||||
val statusCode = genericOverall.ocs.meta.statusCode
|
val statusCode = genericOverall.meta?.statusCode
|
||||||
if (statusCode == HTTP_CREATED) {
|
if (statusCode == HTTP_CREATED) {
|
||||||
chatController.updateAdapterAfterSendReaction(message, emoji)
|
chatController.updateAdapterAfterSendReaction(message, emoji)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user