diff --git a/app/build.gradle b/app/build.gradle index 24e4b73..c498423 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ plugins { id 'kotlin-multiplatform' - id 'kotlinx-serialization' version '1.3.0' + id 'kotlinx-serialization' } repositories { maven { url "https://kotlin.bintray.com/ktor" } @@ -13,7 +13,9 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android-extensions' apply plugin: "com.squareup.sqldelight" sqldelight { - packageName = "sample.db" + MyDatabase { + packageName = "sample.db" + } } android { @@ -32,6 +34,25 @@ android { minifyEnabled false } } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/NOTICE' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/notice.txt' + exclude 'META-INF/ASL2.0' + exclude 'META-INF/ktor-http.kotlin_module' + exclude 'META-INF/main.kotlin_module' + exclude 'META-INF/kotlinx-io.kotlin_module' + exclude 'META-INF/atomicfu.kotlin_module' + exclude 'META-INF/kotlinx-coroutines-io.kotlin_module' + exclude 'META-INF/ktor-utils.kotlin_module' + exclude 'META-INF/ktor-client-json.kotlin_module' + exclude 'META-INF/ktor-client-core.kotlin_module' + + } } dependencies { @@ -39,14 +60,14 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' androidTestImplementation 'com.android.support.test:runner:1.0.2' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1' - implementation "io.ktor:ktor-client-android:1.0.0-beta-4" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' + implementation "io.ktor:ktor-client-okhttp:1.1.3" implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'com.android.support:design:28.0.0' implementation 'de.hdodenhof:circleimageview:2.2.0' implementation 'com.github.bumptech.glide:glide:4.8.0' + implementation "com.squareup.sqldelight:android-driver:1.1.0" annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0' - implementation "com.squareup.sqldelight:android-driver:1.0.0" } kotlin { @@ -62,9 +83,9 @@ kotlin { commonMain { dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib-common' - implementation "io.ktor:ktor-client:1.0.0-beta-4" - implementation "io.ktor:ktor-client-json:1.0.0-beta-4" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.9.0" + implementation "io.ktor:ktor-client-core:1.1.3" + implementation "io.ktor:ktor-client-json:1.1.3" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.10.0" } } commonTest { @@ -77,9 +98,8 @@ kotlin { androidMain { dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib' - implementation "io.ktor:ktor-client-core-jvm:1.0.0-beta-4" - implementation "io.ktor:ktor-client-json-jvm:1.0.0-beta-4" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.9.0" + implementation "io.ktor:ktor-client-json-jvm:1.1.3" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0" } } androidTest { @@ -91,12 +111,12 @@ kotlin { } iosMain { dependencies { - implementation "io.ktor:ktor-client-ios:1.0.0-beta-4" - implementation "io.ktor:ktor-client-core-ios:1.0.0-beta-4" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.0.1" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.9.0" - implementation "io.ktor:ktor-client-json-ios:1.0.0-beta-4" - implementation "com.squareup.sqldelight:native-driver:1.0.0" + implementation "io.ktor:ktor-client-core-native:1.1.3" + implementation "io.ktor:ktor-client-json-native:1.1.3" + implementation "io.ktor:ktor-client-ios:1.1.3" + implementation "com.squareup.sqldelight:ios-driver:1.1.1" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.1.1" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.10.0" } } iosTest { diff --git a/app/src/commonMain/kotlin/sample/api/NetworkApi.kt b/app/src/commonMain/kotlin/sample/api/NetworkApi.kt index a81b1b3..e51a2b4 100644 --- a/app/src/commonMain/kotlin/sample/api/NetworkApi.kt +++ b/app/src/commonMain/kotlin/sample/api/NetworkApi.kt @@ -18,7 +18,7 @@ import sample.AllData class NetworkApi(private val endPoint: String) { private val httpClient = HttpClient { - install(JsonFeature){ + install(JsonFeature) { serializer = KotlinxSerializer().apply { setMapper(AllData::class, AllData.serializer()) } diff --git a/app/src/commonTest/kotlin/sample/presentation/MainPresenterTest.kt b/app/src/commonTest/kotlin/sample/presentation/MainPresenterTest.kt index b8dbbed..7d17147 100644 --- a/app/src/commonTest/kotlin/sample/presentation/MainPresenterTest.kt +++ b/app/src/commonTest/kotlin/sample/presentation/MainPresenterTest.kt @@ -1,8 +1,8 @@ package sample.presentation -import io.mockk.* -import kotlinx.coroutines.Dispatchers -import sample.* +//import io.mockk.* +//import kotlinx.coroutines.Dispatchers +//import sample.* import kotlin.test.* /** @@ -11,104 +11,104 @@ import kotlin.test.* @Ignore open class MainPresenterTest { - lateinit var view: MainView - lateinit var repository: DataRepository - lateinit var presenter: MainPresenter - - - @BeforeTest - fun initDeps() { - - view = mockk(relaxed = true) - repository = mockk(relaxed = true) - - presenter = MainPresenter( - view = view, - repository = repository, - uiContext = Dispatchers.Default - ) - } - - @Test - fun `when load data is empty, it shows an error message`() { - - presenter.loadData("") - verify { - view.showError(USER_NAME_NOT_VALID) - - } - } - - @Test - fun `shows loader while calling an API`() { - - presenter.loadData("iamBedant") - verify { - view.showLoader() - } - } - - @Test - fun `calls getData and displays result if call is successfull`() = runTest { - - every { repository.data } returns allData - presenter.loadData("iamBedant") - coVerify { - repository.getData("iamBedant") - } - verify(ordering = Ordering.ORDERED) { - view.showLoader() - view.hideLoader() - } - } - - - @Test - fun `if user name is valid show actual name`() { - val displayData = presenter.getDisplayData(allData.copy("Test Name")) - assertEquals(displayData.name, allData.name) - } - - @Test - fun `if user name is empty or null show login id as name`() { - val displayData = presenter.getDisplayData(allData.copy(name = null)) - assertEquals(displayData.name, allData.login) - } - - @Test - fun `if user bio is valid show bio`() { - val displayData = presenter.getDisplayData(allData.copy(bio = "This is test Bio")) - assertEquals(displayData.bio, "This is test Bio") - } - - @Test - fun `if user bio is empty or null show no bio available`() { - val displayData = presenter.getDisplayData(allData.copy(bio = null)) - assertEquals(displayData.bio, NO_BIO_AVAILABLE) - } - - @Test - fun `if user avatar is valid show avatar`() { - val displayData = presenter.getDisplayData(allData.copy(avatar_url = "https://abc.def")) - assertEquals(displayData.avatarUrl, "https://abc.def") - } - - - @Test - fun `if user avatar is empty or null show default avatar`() { - val displayData = presenter.getDisplayData(allData.copy(avatar_url = null)) - assertEquals(displayData.avatarUrl, DEFAULT_AVATAR) - } - - @Test - fun `shows gists and repos in proper format`() { - val displayData = presenter.getDisplayData(allData.copy(public_gists = 4, public_repos = 5)) - assertEquals(displayData.publicGists, "4 $PUBLIC_GISTS") - assertEquals(displayData.publicRepos, "5 $PUBLIC_REPOS") - } - - @AfterTest - fun tearDown() { - - } +// lateinit var view: MainView +// lateinit var repository: DataRepository +// lateinit var presenter: MainPresenter +// +// +// @BeforeTest +// fun initDeps() { +// +// view = mockk(relaxed = true) +// repository = mockk(relaxed = true) +// +// presenter = MainPresenter( +// view = view, +// repository = repository, +// uiContext = Dispatchers.Default +// ) +// } +// +// @Test +// fun `when load data is empty, it shows an error message`() { +// +// presenter.loadData("") +// verify { +// view.showError(USER_NAME_NOT_VALID) +// +// } +// } +// +// @Test +// fun `shows loader while calling an API`() { +// +// presenter.loadData("iamBedant") +// verify { +// view.showLoader() +// } +// } +// +// @Test +// fun `calls getData and displays result if call is successfull`() = runTest { +// +// every { repository.data } returns allData +// presenter.loadData("iamBedant") +// coVerify { +// repository.getData("iamBedant") +// } +// verify(ordering = Ordering.ORDERED) { +// view.showLoader() +// view.hideLoader() +// } +// } +// +// +// @Test +// fun `if user name is valid show actual name`() { +// val displayData = presenter.getDisplayData(allData.copy("Test Name")) +// assertEquals(displayData.name, allData.name) +// } +// +// @Test +// fun `if user name is empty or null show login id as name`() { +// val displayData = presenter.getDisplayData(allData.copy(name = null)) +// assertEquals(displayData.name, allData.login) +// } +// +// @Test +// fun `if user bio is valid show bio`() { +// val displayData = presenter.getDisplayData(allData.copy(bio = "This is test Bio")) +// assertEquals(displayData.bio, "This is test Bio") +// } +// +// @Test +// fun `if user bio is empty or null show no bio available`() { +// val displayData = presenter.getDisplayData(allData.copy(bio = null)) +// assertEquals(displayData.bio, NO_BIO_AVAILABLE) +// } +// +// @Test +// fun `if user avatar is valid show avatar`() { +// val displayData = presenter.getDisplayData(allData.copy(avatar_url = "https://abc.def")) +// assertEquals(displayData.avatarUrl, "https://abc.def") +// } +// +// +// @Test +// fun `if user avatar is empty or null show default avatar`() { +// val displayData = presenter.getDisplayData(allData.copy(avatar_url = null)) +// assertEquals(displayData.avatarUrl, DEFAULT_AVATAR) +// } +// +// @Test +// fun `shows gists and repos in proper format`() { +// val displayData = presenter.getDisplayData(allData.copy(public_gists = 4, public_repos = 5)) +// assertEquals(displayData.publicGists, "4 $PUBLIC_GISTS") +// assertEquals(displayData.publicRepos, "5 $PUBLIC_REPOS") +// } +// +// @AfterTest +// fun tearDown() { +// +// } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7bb1ef0..3513187 100644 --- a/build.gradle +++ b/build.gradle @@ -7,8 +7,9 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' - classpath 'com.squareup.sqldelight:gradle-plugin:1.0.0' + classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.squareup.sqldelight:gradle-plugin:1.1.1' + classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.21" } } repositories { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index addd515..82b7852 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Nov 13 15:19:23 IST 2018 +#Mon Mar 25 15:09:01 IST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/iosApp/iosApp/BaseView.swift b/iosApp/iosApp/BaseView.swift index fcefe8c..db4f046 100644 --- a/iosApp/iosApp/BaseView.swift +++ b/iosApp/iosApp/BaseView.swift @@ -9,6 +9,7 @@ import Foundation import UIKit import app + var firstUpdateError = true extension UIViewController: BaseView { diff --git a/projectFilesBackup/.idea/workspace.xml b/projectFilesBackup/.idea/workspace.xml new file mode 100644 index 0000000..36a4ce5 --- /dev/null +++ b/projectFilesBackup/.idea/workspace.xml @@ -0,0 +1,3644 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1542272352667 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/app/src/commonMain/kotlin/sample/presentation/MainPresenter.kt + 28 + + + + + + + + + JSON.parse(AllData.serializer(),data) + kotlin + EXPRESSION + + + data + kotlin + EXPRESSION + + + cause + kotlin + EXPRESSION + + + e + kotlin + EXPRESSION + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file