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

update converters

parent 690c8b44
...@@ -8,6 +8,8 @@ apply plugin: 'kotlin-android-extensions' ...@@ -8,6 +8,8 @@ apply plugin: 'kotlin-android-extensions'
apply from: '../dependencies.gradle' apply from: '../dependencies.gradle'
apply plugin: 'kotlinx-serialization'
//apply plugin: 'io.fabric' //apply plugin: 'io.fabric'
android { android {
...@@ -66,6 +68,8 @@ dependencies { ...@@ -66,6 +68,8 @@ dependencies {
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'androidx.core:core-ktx:1.1.0' 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 //Material
implementation "com.google.android.material:material:$materialVersion" implementation "com.google.android.material:material:$materialVersion"
......
...@@ -17,7 +17,7 @@ class AuthRepository @Inject constructor( ...@@ -17,7 +17,7 @@ class AuthRepository @Inject constructor(
override fun signIn(email: String, password: String): Observable<AuthInfoModel> = override fun signIn(email: String, password: String): Observable<AuthInfoModel> =
roomparkApi.authenticate(email,password) roomparkApi.authenticate(email,password)
.map { } .map { AuthInfoModel("",2,"","") }
override fun signOut(): Completable { override fun signOut(): Completable {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
......
package com.biganto.visual.roompark.data.repository.db.requrey package com.biganto.visual.roompark.data.repository.db.requrey
import android.os.Parcel import kotlinx.serialization.Serializable
import android.os.Parcelable
/** /**
* Created by Vladislav Bogdashkin on 15.06.2018. * Created by Vladislav Bogdashkin on 15.06.2018.
...@@ -29,7 +28,7 @@ class RevisionString(private val value:String, private val revision:String?){ ...@@ -29,7 +28,7 @@ class RevisionString(private val value:String, private val revision:String?){
@Serializable
class TitledPhoto(val title:String, val url:String){ class TitledPhoto(val title:String, val url:String){
companion object{ companion object{
...@@ -43,39 +42,10 @@ class TitledPhoto(val title:String, val url:String){ ...@@ -43,39 +42,10 @@ class TitledPhoto(val title:String, val url:String){
} }
//@Serializable @Serializable
data class ResolutionRaw( data class ResolutionRaw(
val res_name:String, val res_name:String,
val url:String, val url:String,
val width:Int, val width:Int,
val height: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 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.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 io.requery.*
import java.util.* import java.util.*
...@@ -25,6 +25,6 @@ interface Article : Persistable { ...@@ -25,6 +25,6 @@ interface Article : Persistable {
@get:ForeignKey(references = Feed::class, referencedColumn = "alias") @get:ForeignKey(references = Feed::class, referencedColumn = "alias")
@get:ManyToOne @get:ManyToOne
val feed_alias : Feed val feed_alias : Feed
@get:Convert(TitledPhotoConverter::class) @get:Convert(TitledPhotoListConverter::class)
val photo : List<TitledPhoto>? val photo : List<TitledPhoto>?
} }
\ No newline at end of file
...@@ -2,8 +2,8 @@ package com.biganto.visual.roompark.data.repository.db.requrey.utils; ...@@ -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 com.biganto.visual.roompark.data.repository.db.requrey.TitledPhoto;
import java.text.SimpleDateFormat; import java.util.ArrayList;
import java.util.Locale; import java.util.List;
import io.requery.Converter; import io.requery.Converter;
import timber.log.Timber; import timber.log.Timber;
...@@ -13,15 +13,12 @@ import timber.log.Timber; ...@@ -13,15 +13,12 @@ import timber.log.Timber;
*/ */
public class TitledPhotoConverter implements Converter<TitledPhoto, String> { public class TitledPhotoListConverter implements Converter<List<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);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Class<TitledPhoto> getMappedType() { public Class<List<TitledPhoto>> getMappedType() {
return TitledPhoto.class; return (Class) List.class;
} }
@Override @Override
...@@ -35,20 +32,20 @@ public class TitledPhotoConverter implements Converter<TitledPhoto, String> { ...@@ -35,20 +32,20 @@ public class TitledPhotoConverter implements Converter<TitledPhoto, String> {
} }
@Override @Override
public String convertToPersisted(TitledPhoto value) { public String convertToPersisted(List<TitledPhoto> value) {
return value == null ? null : apiFormat.format(value); return value == null ? null : null; //Json.Companion.stringify(TitledPhoto(),value)
} }
@Override @Override
public TitledPhoto convertToMapped(Class<? extends TitledPhoto> type, public List<TitledPhoto> convertToMapped(Class<? extends List<TitledPhoto>> type,
String value) { String value) {
try { try {
return value == null ? null : new TitledPhoto(value); return value == null ? null : null;//new TitledPhoto(value);
} }
catch (Exception e){ catch (Exception e){
Timber.e("Wrong stored data format! {%s}",value); Timber.e("Wrong stored data format! {%s}",value);
return new TitledPhoto("",""); return new ArrayList<TitledPhoto>(1);//TitledPhoto("",""));
} }
} }
......
...@@ -13,6 +13,7 @@ buildscript { ...@@ -13,6 +13,7 @@ buildscript {
dependencies { dependencies {
classpath "com.android.tools.build:gradle:3.5.0" classpath "com.android.tools.build:gradle:3.5.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // 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