Skip to content

Commit

Permalink
update: move to libs.versions.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
amirisback committed Aug 5, 2024
1 parent d4074ca commit e99b554
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 118 deletions.
17 changes: 9 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ dependencies {
implementation(project(DependencyGradle.FROGO_PATH_CORE_SDK))
implementation(project(DependencyGradle.FROGO_PATH_SDK))

implementation(Androidx.Work.runtimeKtx)
implementation(Google.material)

implementation(Koin.core)
implementation(Koin.android)
implementation(Koin.androidCompat)
implementation(Koin.androidxWorkManager)
implementation(libs.androidx.work.ktx)
implementation(libs.material)

ksp(Androidx.Lifecycle.compiler)
ksp(Androidx.Room.compiler)
implementation(libs.koin.core)
implementation(libs.koin.android)
implementation(libs.koin.android.compat)
implementation(libs.koin.androidx.workmanager)

ksp(libs.androidx.lifecycle.compiler)
ksp(libs.androidx.room.compiler)

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import com.frogobox.appsdk.databinding.ActivityNewsBinding
import com.frogobox.appsdk.model.Article
import com.frogobox.appsdk.news.NewsViewAdapter
import com.frogobox.coresdk.source.FrogoResult
import com.frogobox.sdk.ext.gone
import com.frogobox.sdk.ext.progressViewHandle
import com.frogobox.sdk.ext.visible
import org.koin.androidx.viewmodel.ext.android.viewModel

class NewsResultActivity : BaseActivity<ActivityNewsBinding>() {
Expand All @@ -24,12 +26,14 @@ class NewsResultActivity : BaseActivity<ActivityNewsBinding>() {

articles.observe(this@NewsResultActivity) {
when (it) {
is FrogoResult.Error -> {}
is FrogoResult.Finish -> {}
is FrogoResult.Error -> {
binding.progressCircular.gone()
}
is FrogoResult.Loading -> {
binding.progressCircular.progressViewHandle(it.isLoading)
binding.progressCircular.visible()
}
is FrogoResult.Success -> {
binding.progressCircular.gone()
it.result.articles?.let { list ->
setupRecyclerView(list)
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.3.1" apply false
id("com.android.library") version "8.3.1" apply false
id("com.android.application") version "8.3.2" apply false
id("com.android.library") version "8.3.2" apply false
id("com.google.devtools.ksp") version "1.9.23-1.0.19" apply false
id("org.jetbrains.kotlin.android") version DependencyGradle.KOTLIN_VERSION apply false
id("org.jetbrains.kotlin.jvm") version DependencyGradle.KOTLIN_VERSION apply false
Expand Down
5 changes: 0 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ plugins {
repositories {
mavenCentral()
maven("https://jitpack.io")
}

dependencies {
// library frogo-build-src
implementation("com.github.frogobox:open-build-src:3.0.4")
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/DependencyGradle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

object DependencyGradle {

const val KOTLIN_VERSION = Version.JetBrains.kotlin
const val KOTLIN_VERSION = "1.9.23"

const val FROGO_PATH_CORE_SDK = ":${ProjectSetting.MODULE_NAME_CORE_SDK}"
const val FROGO_PATH_SDK = ":${ProjectSetting.MODULE_NAME_SDK}"
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/ProjectSetting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ object ProjectSetting {

// ---------------------------------------------------------------------------------------------

const val PROJECT_MIN_SDK = Version.Gradle.minSdk
const val PROJECT_COMPILE_SDK = Version.Gradle.compileSdk
const val PROJECT_MIN_SDK = 21
const val PROJECT_COMPILE_SDK = 34
const val PROJECT_TARGET_SDK = PROJECT_COMPILE_SDK

// ---------------------------------------------------------------------------------------------
Expand Down
22 changes: 11 additions & 11 deletions core-sdk-android-util/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ android {
dependencies {
api(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

api(Androidx.appCompat)
api(libs.androidx.appcompat)

api(Androidx.activityKtx)
api(Androidx.fragmentKtx)
api(libs.androidx.activity.ktx)
api(libs.androidx.fragment.ktx)

api(Androidx.constraintLayout)
api(Androidx.viewPager2)
api(libs.androidx.constraintlayout)
api(libs.androidx.viewpager2)

api(Androidx.Core.ktx)
api(libs.androidx.core.ktx)

api(Androidx.Lifecycle.runtimeKtx)
api(Androidx.Lifecycle.viewmodelKtx)
api(Androidx.Lifecycle.livedataKtx)
api(libs.androidx.lifecycle.runtime.ktx)
api(libs.androidx.lifecycle.viewmodel.ktx)
api(libs.androidx.lifecycle.livedata.ktx)
api(libs.androidx.preference)

api(Androidx.preference)
api(Google.material)
api(libs.material)

}

Expand Down
21 changes: 10 additions & 11 deletions core-sdk-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@ dependencies {
api(project(DependencyGradle.FROGO_PATH_CORE_SDK))
api(project(DependencyGradle.FROGO_PATH_SDK_UTIL))

api(Androidx.Room.ktx)
api(Androidx.Room.runtime)
api(Androidx.Room.rxJava3)
api(libs.androidx.room.ktx)
api(libs.androidx.room.runtime)
api(libs.androidx.room.rxjava3)

api(Reactivex.rxAndroid3)
api(libs.reactivex.rxandroid3)

api(GitHub.chucker)
api(GitHub.glide)
api(libs.github.chucker)
api(libs.github.glide)
api(libs.github.customactivityoncrash)

api(GitHub.customActivityOnCrash)

ksp(Androidx.Lifecycle.compiler)
ksp(Androidx.Room.compiler)
ksp(GitHub.glideCompiler)
ksp(libs.androidx.lifecycle.compiler)
ksp(libs.androidx.room.compiler)
ksp(libs.github.glide.compiler)

}

Expand Down
106 changes: 45 additions & 61 deletions core-sdk-android/src/main/java/com/frogobox/sdk/ext/FrogoRxJavaExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import com.frogobox.coresdk.source.FrogoResultState
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Observer
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.core.SingleObserver
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.schedulers.Schedulers

Expand All @@ -28,6 +31,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
*
*/


fun <T : Any> Observable<T>.doApiRequest(
callback: FrogoDataResponse<T>,
addCallbackSubscribe: (d: Disposable) -> Unit
Expand Down Expand Up @@ -61,32 +65,29 @@ fun <T : Any> Observable<T>.doApiRequest(

fun <T : Any> Observable<T>.doApiRequestResult(
result: MutableLiveData<FrogoResult<T>>,
addCallbackSubscribe: (d: Disposable) -> Unit
addCallbackSubscribe: (d: Disposable) -> Unit,
) {
doApiRequest(object : FrogoDataResponse<T> {
override fun onShowProgress() {
result.value = FrogoResult.Loading(true)
}

override fun onHideProgress() {
result.value = FrogoResult.Loading(false)
subscribeOn(Schedulers.io())
.doOnSubscribe {
result.value = FrogoResult.Loading()
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<T>{
override fun onSubscribe(d: Disposable) {
addCallbackSubscribe(d)
}

override fun onSuccess(data: T) {
result.value = FrogoResult.Success(data)
}
override fun onError(e: Throwable) {
result.value = FrogoResult.Error(message = e.message)
}

override fun onFailed(statusCode: Int, errorMessage: String) {
result.value = FrogoResult.Error(statusCode, errorMessage)
}
override fun onComplete() {}

override fun onFinish() {
result.value = FrogoResult.Finish()
}
override fun onNext(t: T) {
result.value = FrogoResult.Success(t)
}
})

}) {
addCallbackSubscribe(it)
}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -130,29 +131,24 @@ fun <T : Any> Single<T>.fetchRoomDBResult(
result: MutableLiveData<FrogoResult<T>>,
addCallbackSubscribe: (d: Disposable) -> Unit
) {
fetchRoomDB(object : FrogoDataResponse<T> {
override fun onShowProgress() {
result.value = FrogoResult.Loading(true)
}

override fun onHideProgress() {
result.value = FrogoResult.Loading(false)
}

override fun onSuccess(data: T) {
result.value = FrogoResult.Success(data)
subscribeOn(Schedulers.io())
.doOnSubscribe {
result.value = FrogoResult.Loading()
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : SingleObserver<T>{
override fun onSubscribe(d: Disposable) {
addCallbackSubscribe(d)
}

override fun onFailed(statusCode: Int, errorMessage: String) {
result.value = FrogoResult.Error(statusCode, errorMessage)
}
override fun onError(e: Throwable) {
result.value = FrogoResult.Error(message = e.message)
}

override fun onFinish() {
result.value = FrogoResult.Finish()
}
}) {
addCallbackSubscribe(it)
}
override fun onSuccess(t: T) {
result.value = FrogoResult.Success(t)
}
})
}

fun <T : Any> Observable<T>.fetchPreference(callback: FrogoDataResponse<T>) {
Expand All @@ -179,8 +175,8 @@ fun Completable.executeRoomDB(callback: FrogoStateResponse) {
subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
callback.onSuccess()
callback.onHideProgress()
callback.onSuccess()
callback.onFinish()
}) {
it.message?.let { it1 -> callback.onFailed(200, it1) }
Expand All @@ -190,28 +186,16 @@ fun Completable.executeRoomDB(callback: FrogoStateResponse) {
}

fun Completable.executeRoomDBResult(result: MutableLiveData<FrogoResultState>) {
executeRoomDB(object : FrogoStateResponse {
override fun onSuccess() {
result.value = FrogoResultState.Success()
}

override fun onFailed(statusCode: Int, errorMessage: String) {
result.value = FrogoResultState.Error(statusCode, errorMessage)
}

override fun onFinish() {
result.value = FrogoResultState.Finish()
}

override fun onHideProgress() {
result.value = FrogoResultState.Loading(false)
subscribeOn(Schedulers.io())
.doOnSubscribe {
result.value = FrogoResultState.Loading()
}

override fun onShowProgress() {
result.value = FrogoResultState.Loading(true)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
result.value = FrogoResultState.Success()
}) {
it.message?.let { it1 ->result.value = FrogoResultState.Error(message = it1) }
}
})

}

fun Completable.executePreference(callback: FrogoStateResponse) {
Expand Down
16 changes: 8 additions & 8 deletions core-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ tasks.withType<KotlinCompile> {

dependencies {

api(Google.gson)
api(libs.gson)

api(Square.OkHttp.okhttp)
api(Square.OkHttp.loggingInterceptor)
api(libs.square.okhttp)
api(libs.square.logging.interceptor)

api(Square.Retrofit2.retrofit)
api(Square.Retrofit2.converterGson)
api(Square.Retrofit2.adapterRxJava3)
api(libs.square.retrofit)
api(libs.square.retrofit.converter.gson)
api(libs.square.retrofit.adapter.rxjava3)

api(Reactivex.rxJava3)
api(libs.reactivex.rxjava3)
}

publishing {
Expand Down Expand Up @@ -59,7 +59,7 @@ publishing {
}

repositories {
maven(Util.jitpackUrl)
maven("https://jitpack.io")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ sealed class FrogoResult<T> {

class Error<T>(val code: Int? = 500, val message: String? = "") : FrogoResult<T>()

class Loading<T>(val isLoading: Boolean = true) : FrogoResult<T>()

class Finish<T> : FrogoResult<T>()
class Loading<T> : FrogoResult<T>()

}

Expand All @@ -29,8 +27,6 @@ sealed class FrogoResultState {

class Error(val code: Int? = 500, val message: String? = "") : FrogoResultState()

class Loading(val isLoading: Boolean = true) : FrogoResultState()

class Finish : FrogoResultState()
class Loading : FrogoResultState()

}
Loading

0 comments on commit e99b554

Please sign in to comment.