Commit 61a1f848 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

update converters

parent 690c8b44
......@@ -8,6 +8,8 @@ apply plugin: 'kotlin-android-extensions'
apply from: '../dependencies.gradle'
apply plugin: 'kotlinx-serialization'
//apply plugin: 'io.fabric'
android {
......@@ -66,6 +68,8 @@ dependencies {
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.13.0" // JVM dependency
//Material
implementation "com.google.android.material:material:$materialVersion"
......
......@@ -17,7 +17,7 @@ class AuthRepository @Inject constructor(
override fun signIn(email: String, password: String): Observable<AuthInfoModel> =
roomparkApi.authenticate(email,password)
.map { }
.map { AuthInfoModel("",2,"","") }
override fun signOut(): Completable {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
......
package com.biganto.visual.roompark.data.repository.db.requrey
import android.os.Parcel
import android.os.Parcelable
import kotlinx.serialization.Serializable
/**
* Created by Vladislav Bogdashkin on 15.06.2018.
......@@ -29,7 +28,7 @@ class RevisionString(private val value:String, private val revision:String?){
@Serializable
class TitledPhoto(val title:String, val url:String){
companion object{
......@@ -43,39 +42,10 @@ class TitledPhoto(val title:String, val url:String){
}
//@Serializable
@Serializable
data class ResolutionRaw(
val res_name:String,
val url:String,
val width:Int,
val height:Int
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString(),
parcel.readString(),
parcel.readInt(),
parcel.readInt()
) {
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(res_name)
parcel.writeString(url)
parcel.writeInt(width)
parcel.writeInt(height)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<ResolutionRaw> {
override fun createFromParcel(parcel: Parcel): ResolutionRaw {
return ResolutionRaw(parcel)
}
override fun newArray(size: Int): Array<ResolutionRaw?> {
return arrayOfNulls(size)
}
}
}
\ No newline at end of file
)
package com.biganto.visual.roompark.data.repository.db.requrey.model
import com.biganto.visual.roompark.data.repository.db.requrey.TitledPhoto
import com.biganto.visual.roompark.data.repository.db.requrey.utils.TitledPhotoConverter
import com.biganto.visual.roompark.data.repository.db.requrey.utils.TitledPhotoListConverter
import io.requery.*
import java.util.*
......@@ -25,6 +25,6 @@ interface Article : Persistable {
@get:ForeignKey(references = Feed::class, referencedColumn = "alias")
@get:ManyToOne
val feed_alias : Feed
@get:Convert(TitledPhotoConverter::class)
@get:Convert(TitledPhotoListConverter::class)
val photo : List<TitledPhoto>?
}
\ No newline at end of file
......@@ -2,8 +2,8 @@ package com.biganto.visual.roompark.data.repository.db.requrey.utils;
import com.biganto.visual.roompark.data.repository.db.requrey.TitledPhoto;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.ArrayList;
import java.util.List;
import io.requery.Converter;
import timber.log.Timber;
......@@ -13,15 +13,12 @@ import timber.log.Timber;
*/
public class TitledPhotoConverter implements Converter<TitledPhoto, String> {
private SimpleDateFormat apiFormat =new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+hh:mm", Locale.ROOT);
//SimpleDateFormat dbFormat =new SimpleDateFormat("YYYYMMDDThhmmss", Locale.ROOT);
public class TitledPhotoListConverter implements Converter<List<TitledPhoto>, String> {
@SuppressWarnings("unchecked")
@Override
public Class<TitledPhoto> getMappedType() {
return TitledPhoto.class;
public Class<List<TitledPhoto>> getMappedType() {
return (Class) List.class;
}
@Override
......@@ -35,20 +32,20 @@ public class TitledPhotoConverter implements Converter<TitledPhoto, String> {
}
@Override
public String convertToPersisted(TitledPhoto value) {
return value == null ? null : apiFormat.format(value);
public String convertToPersisted(List<TitledPhoto> value) {
return value == null ? null : null; //Json.Companion.stringify(TitledPhoto(),value)
}
@Override
public TitledPhoto convertToMapped(Class<? extends TitledPhoto> type,
public List<TitledPhoto> convertToMapped(Class<? extends List<TitledPhoto>> type,
String value) {
try {
return value == null ? null : new TitledPhoto(value);
return value == null ? null : null;//new TitledPhoto(value);
}
catch (Exception e){
Timber.e("Wrong stored data format! {%s}",value);
return new TitledPhoto("","");
return new ArrayList<TitledPhoto>(1);//TitledPhoto("",""));
}
}
......
......@@ -13,6 +13,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.5.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment