From a1cf58e0eee8d16576380e05a8d87e128242bf05 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 4 Jan 2019 13:56:12 -0500 Subject: Use coroutine version in kau --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/build.gradle') diff --git a/app/build.gradle b/app/build.gradle index 562de936..0cb401fb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -204,7 +204,7 @@ dependencies { // androidTestImplementation "io.mockk:mockk:${MOCKK}" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${COROUTINES}" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${kau.coroutines}" implementation "org.apache.commons:commons-text:${COMMONS_TEXT}" -- cgit v1.2.3 From 5d2722b2205e404ee90cbb7e141ac63ca6570e1a Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 4 Jan 2019 23:59:30 -0500 Subject: Remove unused dependencies and remove reactivex from username fetcher --- app/build.gradle | 4 +-- .../com/pitchedapps/frost/dbflow/CookiesDb.kt | 28 +++++++----------- .../frost/facebook/requests/FbRequestTest.kt | 2 +- .../com/pitchedapps/frost/internal/Internal.kt | 34 ---------------------- gradle.properties | 6 ++-- 5 files changed, 16 insertions(+), 58 deletions(-) (limited to 'app/build.gradle') diff --git a/app/build.gradle b/app/build.gradle index 0cb401fb..23d26fd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -253,8 +253,8 @@ dependencies { //Reactive Libs implementation "io.reactivex.rxjava2:rxjava:${RX_JAVA}" - implementation "io.reactivex.rxjava2:rxkotlin:${RX_KOTLIN}" - implementation "io.reactivex.rxjava2:rxandroid:${RX_ANDROID}" +// implementation "io.reactivex.rxjava2:rxkotlin:${RX_KOTLIN}" +// implementation "io.reactivex.rxjava2:rxandroid:${RX_ANDROID}" implementation "com.github.pwittchen:reactivenetwork-rx2:${RX_NETWORK}" } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt index f7d97833..d7dd71ed 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt @@ -17,7 +17,7 @@ package com.pitchedapps.frost.dbflow import android.os.Parcelable -import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork +import com.pitchedapps.frost.dbflow.CookieModel_Table.cookie import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.frostJsoup @@ -34,11 +34,10 @@ import com.raizlabs.android.dbflow.kotlinextensions.save import com.raizlabs.android.dbflow.kotlinextensions.select import com.raizlabs.android.dbflow.kotlinextensions.where import com.raizlabs.android.dbflow.structure.BaseModel -import io.reactivex.disposables.Disposable -import io.reactivex.schedulers.Schedulers import kotlinx.android.parcel.Parcelize import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeoutOrNull import java.net.UnknownHostException /** @@ -98,25 +97,20 @@ fun removeCookie(id: Long) { } } -inline fun CookieModel.fetchUsername(crossinline callback: (String) -> Unit): Disposable = - ReactiveNetwork.checkInternetConnectivity().subscribeOn(Schedulers.io()).subscribe { yes, _ -> - if (!yes) return@subscribe callback("") - var result = "" +suspend fun CookieModel.fetchUsername(): String? = withContext(Dispatchers.IO) { + withTimeoutOrNull(5000) { + var result: String? = null try { result = frostJsoup(cookie, FbItem.PROFILE.url).title() L.d { "Fetch username found" } } catch (e: Exception) { if (e !is UnknownHostException) e.logFrostEvent("Fetch username failed") - } finally { - if (result.isBlank() && (name?.isNotBlank() == true)) { - callback(name!!) - return@subscribe - } - if (name != result) { - name = result - saveFbCookie(this@fetchUsername) - } - callback(result) } + if (name?.isNotBlank() == false && result != null && result != name) { + name = result + saveFbCookie(this@fetchUsername) + } + result } +} \ No newline at end of file diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbRequestTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbRequestTest.kt index ec765448..8610436a 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbRequestTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbRequestTest.kt @@ -84,7 +84,7 @@ class FbRequestTest { val data = AUTH.getMenuData().invoke() assertNotNull(data) println(ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(data)) - assertTrue(data!!.data.isNotEmpty()) + assertTrue(data.data.isNotEmpty()) assertTrue(data.footer.hasContent, "Footer may be badly parsed") val items = data.flatMapValid() assertTrue(items.size > 15, "Something may be badly parsed") diff --git a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt index 061e7c38..b8d9635a 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt @@ -22,13 +22,10 @@ import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.facebook.requests.RequestAuth import com.pitchedapps.frost.facebook.requests.getAuth import com.pitchedapps.frost.utils.frostJsoup -import io.reactivex.Completable import org.junit.Assume -import org.junit.Test import java.io.File import java.io.FileInputStream import java.util.Properties -import java.util.concurrent.TimeUnit import kotlin.reflect.full.starProjectedType import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -97,34 +94,3 @@ fun Any.assertComponentsNotEmpty() { fun > List.assertDescending(tag: String) { assertEquals(sortedDescending(), this, "$tag not sorted in descending order") } - -interface CompletableCallback { - fun onComplete() - fun onError(message: String) -} - -inline fun concurrentTest(crossinline caller: (callback: CompletableCallback) -> Unit) { - val result = Completable.create { emitter -> - caller(object : CompletableCallback { - override fun onComplete() = emitter.onComplete() - override fun onError(message: String) = emitter.onError(Throwable(message)) - }) - }.blockingGet(5, TimeUnit.SECONDS) - if (result != null) - throw RuntimeException("Concurrent fail: ${result.message}") -} - -class InternalTest { - @Test - fun concurrentTest() = try { - concurrentTest { result -> - Thread().run { - Thread.sleep(100) - result.onError("Intentional fail") - } - } - fail("Did not throw exception") - } catch (e: Exception) { - // pass - } -} diff --git a/gradle.properties b/gradle.properties index dcdb5630..691544bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro APP_ID=Frost APP_GROUP=com.pitchedapps -KAU=af43e82 +KAU=72d6461 KOTLIN=1.3.11 # https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google @@ -28,7 +28,7 @@ BUGSNAG=4.9.3 # https://github.com/bugsnag/bugsnag-android-gradle-plugin/releases BUGSNAG_PLUGIN=3.6.0 # https://github.com/KeepSafe/dexcount-gradle-plugin/releases -DEX_PLUGIN=0.8.4 +DEX_PLUGIN=0.8.5 # https://github.com/gladed/gradle-android-git-version/releases GIT_PLUGIN=0.4.7 # https://mvnrepository.com/artifact/org.apache.commons/commons-text @@ -59,8 +59,6 @@ OKHTTP=3.12.1 ROBOELECTRIC=4.1 # https://github.com/ReactiveX/RxAndroid/releases RX_ANDROID=2.1.0 -# https://github.com/JakeWharton/RxBinding/releases -RX_BINDING=2.2.0 # https://github.com/ReactiveX/RxJava/releases RX_JAVA=2.2.4 # https://github.com/ReactiveX/RxKotlin/releases -- cgit v1.2.3 From 635bdddebbc52ec67cfb157830c3fc8b32f9a6e7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 5 Jan 2019 00:12:45 -0500 Subject: Remove all rx libraries --- app/build.gradle | 6 ------ .../main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt | 3 --- app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt | 2 +- app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt | 1 - gradle.properties | 8 -------- 5 files changed, 1 insertion(+), 19 deletions(-) (limited to 'app/build.gradle') diff --git a/app/build.gradle b/app/build.gradle index 23d26fd8..5fc249bf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -251,12 +251,6 @@ dependencies { implementation "com.sothree.slidinguppanel:library:${SLIDING_PANEL}" - //Reactive Libs - implementation "io.reactivex.rxjava2:rxjava:${RX_JAVA}" -// implementation "io.reactivex.rxjava2:rxkotlin:${RX_KOTLIN}" -// implementation "io.reactivex.rxjava2:rxandroid:${RX_ANDROID}" - implementation "com.github.pwittchen:reactivenetwork-rx2:${RX_NETWORK}" - } // Validates code and generates apk diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index 283477d7..8d849bff 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -66,9 +66,7 @@ class AboutActivity : AboutActivityBase(null, { val include = arrayOf( "AboutLibraries", "AndroidIconics", - "androidin_appbillingv3", "androidslidinguppanel", - "Crashlytics", "dbflow", "fastadapter", "glide", @@ -77,7 +75,6 @@ class AboutActivity : AboutActivityBase(null, { "kotterknife", "materialdialogs", "materialdrawer", - "rxjava", "subsamplingscaleimageview" ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt index 10746b75..67953144 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt @@ -89,4 +89,4 @@ fun removeCookie(id: Long) { L.d { "Fb cookie deleted" } L._d { id } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt index cceabcae..870e2ccd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt @@ -27,7 +27,6 @@ import com.bumptech.glide.load.resource.bitmap.CircleCrop import com.bumptech.glide.module.AppGlideModule import com.bumptech.glide.request.RequestOptions import com.pitchedapps.frost.facebook.FbCookie -import com.pitchedapps.frost.utils.L import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.Response diff --git a/gradle.properties b/gradle.properties index 691544bc..aabfd255 100644 --- a/gradle.properties +++ b/gradle.properties @@ -57,14 +57,6 @@ MATERIAL_DRAWER_KT=2.0.1 OKHTTP=3.12.1 # http://robolectric.org/getting-started/ ROBOELECTRIC=4.1 -# https://github.com/ReactiveX/RxAndroid/releases -RX_ANDROID=2.1.0 -# https://github.com/ReactiveX/RxJava/releases -RX_JAVA=2.2.4 -# https://github.com/ReactiveX/RxKotlin/releases -RX_KOTLIN=2.3.0 -# https://github.com/pwittchen/ReactiveNetwork/releases -RX_NETWORK=2.1.0 # https://github.com/davemorrissey/subsampling-scale-image-view#quick-start SCALE_IMAGE_VIEW=3.10.0 # https://github.com/umano/AndroidSlidingUpPanel#importing-the-library -- cgit v1.2.3