mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 05:55:39 +03:00
Add model to ArbitraryStorage db layer
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
a207ad7b97
commit
3b1d4b86a9
5 changed files with 91 additions and 9 deletions
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2022 Andy Scherzinger <infoi@andy-scherzinger.de>
|
||||
*
|
||||
* model 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.
|
||||
*
|
||||
* model 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 model program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.data.storage
|
||||
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
|
||||
|
||||
object ArbitraryStorageMapper {
|
||||
fun toModel(entity: ArbitraryStorageEntity?): ArbitraryStorage? {
|
||||
return if (entity == null) {
|
||||
null
|
||||
} else {
|
||||
ArbitraryStorage(
|
||||
entity.accountIdentifier,
|
||||
entity.key,
|
||||
entity.storageObject,
|
||||
entity.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toEntity(model: ArbitraryStorage): ArbitraryStorageEntity {
|
||||
return ArbitraryStorageEntity(
|
||||
accountIdentifier = model.accountIdentifier,
|
||||
key = model.key,
|
||||
storageObject = model.storageObject,
|
||||
value = model.value
|
||||
)
|
||||
}
|
||||
}
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
package com.nextcloud.talk.data.storage
|
||||
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
||||
|
||||
interface ArbitraryStoragesRepository {
|
||||
fun getStorageSetting(accountIdentifier: Long, key: String, objectString: String): ArbitraryStorageEntity
|
||||
fun getStorageSetting(accountIdentifier: Long, key: String, objectString: String): ArbitraryStorage
|
||||
suspend fun deleteArbitraryStorage(accountIdentifier: Long)
|
||||
fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorageEntity): Long
|
||||
fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorage): Long
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
package com.nextcloud.talk.data.storage
|
||||
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
||||
|
||||
class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: ArbitraryStoragesDao) :
|
||||
ArbitraryStoragesRepository {
|
||||
|
@ -28,15 +28,17 @@ class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: Arbitrar
|
|||
accountIdentifier: Long,
|
||||
key: String,
|
||||
objectString: String
|
||||
): ArbitraryStorageEntity {
|
||||
return arbitraryStoragesDao.getStorageSetting(accountIdentifier, key, objectString)
|
||||
): ArbitraryStorage {
|
||||
return ArbitraryStorageMapper.toModel(
|
||||
arbitraryStoragesDao.getStorageSetting(accountIdentifier, key, objectString)
|
||||
)!!
|
||||
}
|
||||
|
||||
override suspend fun deleteArbitraryStorage(accountIdentifier: Long) {
|
||||
arbitraryStoragesDao.deleteArbitraryStorage(accountIdentifier)
|
||||
}
|
||||
|
||||
override fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorageEntity): Long {
|
||||
return arbitraryStoragesDao.saveArbitraryStorage(arbitraryStorage)
|
||||
override fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorage): Long {
|
||||
return arbitraryStoragesDao.saveArbitraryStorage(ArbitraryStorageMapper.toEntity(arbitraryStorage))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2022 Andy Scherzinger <infoi@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.data.storage.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class ArbitraryStorage(
|
||||
var accountIdentifier: Long = 0,
|
||||
var key: String? = null,
|
||||
var storageObject: String? = null,
|
||||
var value: String? = null
|
||||
) : Parcelable
|
|
@ -80,8 +80,8 @@ import com.google.android.material.chip.ChipDrawable;
|
|||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.data.user.model.User;
|
||||
import com.nextcloud.talk.data.user.model.UserEntity;
|
||||
import com.nextcloud.talk.events.UserMentionClickEvent;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.utils.text.Spans;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
|
Loading…
Reference in a new issue