diff --git a/README.md b/README.md index 711a1cc8a..e9fa23284 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,12 @@ dependencies { ```gradle compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = 17 + targetCompatibility = 17 } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "17" } ``` diff --git a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolder.kt b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolder.kt index dd33dd95e..174821ffa 100644 --- a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolder.kt +++ b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolder.kt @@ -31,7 +31,7 @@ class TestViewHolder(private val binding: CustomizableCardViewBinding) : Recycle animation.end() binding.content.setBackgroundResource(0) binding.title.setBackgroundResource(0) - binding.image.setImageResource(R.drawable.pin_code_highlight_state) + binding.image.setImageResource(com.crazylegend.customviews.R.drawable.pin_code_highlight_state) } fun showPlaceHolder() { diff --git a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolderShimmer.kt b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolderShimmer.kt index 0c2d376d3..dd84ce4f0 100644 --- a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolderShimmer.kt +++ b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolderShimmer.kt @@ -30,7 +30,7 @@ class TestViewHolderShimmer(private val binding: CustomizableCardViewBinding) : animation.end() binding.content.setBackgroundResource(0) binding.title.setBackgroundResource(0) - binding.image.setImageResource(R.drawable.pin_code_highlight_state) + binding.image.setImageResource(com.crazylegend.customviews.R.drawable.pin_code_highlight_state) binding.content.setPrecomputedText(item.body) binding.title.setPrecomputedText(item.title) } diff --git a/build.gradle b/build.gradle index a2407a4b1..d175cd618 100644 --- a/build.gradle +++ b/build.gradle @@ -167,12 +167,12 @@ def applyAndroid(project, buildConfigCase) { } compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = 17 + targetCompatibility = 17 } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "17" } testOptions.unitTests { diff --git a/color/src/main/java/com/crazylegend/color/ColorExtensions.kt b/color/src/main/java/com/crazylegend/color/ColorExtensions.kt index 6621de0e9..fe506b69a 100644 --- a/color/src/main/java/com/crazylegend/color/ColorExtensions.kt +++ b/color/src/main/java/com/crazylegend/color/ColorExtensions.kt @@ -199,8 +199,8 @@ fun Context.textColorStateList(@ColorInt color: Int): ColorStateList { intArrayOf() ) val colors = intArrayOf( - resolveColor(R.attr.colorControlNormal), - resolveColor(R.attr.colorControlNormal), + resolveColor(androidx.appcompat.R.attr.colorControlNormal), + resolveColor(androidx.appcompat.R.attr.colorControlNormal), color ) return ColorStateList(states, colors) diff --git a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/views/MenuExtensions.kt b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/views/MenuExtensions.kt index b53356dbd..85ab26337 100644 --- a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/views/MenuExtensions.kt +++ b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/views/MenuExtensions.kt @@ -24,8 +24,10 @@ import com.crazylegend.kotlinextensions.R */ @UiThread @JvmOverloads -fun colorMenu(activity: Activity, menu: Menu, @ColorInt color: Int, - alpha: Int = 0) { +fun colorMenu( + activity: Activity, menu: Menu, @ColorInt color: Int, + alpha: Int = 0 +) { for (i in 0 until menu.size()) { val menuItem = menu.getItem(i) colorMenuItem(menuItem, color, alpha) @@ -33,7 +35,7 @@ fun colorMenu(activity: Activity, menu: Menu, @ColorInt color: Int, if (menuItem.hasSubMenu()) { val subMenu = menuItem.subMenu - for (j in 0 until (subMenu?.size()?:0)) { + for (j in 0 until (subMenu?.size() ?: 0)) { subMenu?.getItem(j)?.let { colorMenuItem(it, color, alpha) } } } @@ -73,16 +75,20 @@ fun colorMenuItem(menuItem: MenuItem, @ColorInt color: Int, alpha: Int = 0) { */ @SuppressLint("PrivateResource") @UiThread -private fun setOverflowButtonColor(activity: Activity, - colorFilter: PorterDuffColorFilter, alpha: Int) { - val overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description) +private fun setOverflowButtonColor( + activity: Activity, + colorFilter: PorterDuffColorFilter, alpha: Int +) { + val overflowDescription = activity.getString(com.google.android.material.R.string.abc_action_menu_overflow_description) val decorView = activity.window.decorView as ViewGroup val viewTreeObserver = decorView.viewTreeObserver viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { override fun onGlobalLayout() { val outViews = ArrayList() - decorView.findViewsWithText(outViews, overflowDescription, - View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION) + decorView.findViewsWithText( + outViews, overflowDescription, + View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION + ) if (outViews.isEmpty()) { return diff --git a/rx/src/main/java/com/crazylegend/rx/RxExtensions.kt b/rx/src/main/java/com/crazylegend/rx/RxExtensions.kt index e695d2579..fb14c7596 100644 --- a/rx/src/main/java/com/crazylegend/rx/RxExtensions.kt +++ b/rx/src/main/java/com/crazylegend/rx/RxExtensions.kt @@ -1,8 +1,6 @@ package com.crazylegend.rx -import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData -import androidx.lifecycle.LiveDataReactiveStreams import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers import io.reactivex.rxjava3.core.* import io.reactivex.rxjava3.disposables.CompositeDisposable @@ -13,7 +11,6 @@ import io.reactivex.rxjava3.kotlin.addTo import io.reactivex.rxjava3.processors.FlowableProcessor import io.reactivex.rxjava3.schedulers.Schedulers import io.reactivex.rxjava3.subjects.Subject -import org.reactivestreams.Publisher import java.util.concurrent.TimeUnit @@ -145,17 +142,6 @@ fun Observable.asFlowable(backpressureStrategy: BackpressureStrateg return this.toFlowable(backpressureStrategy) } -fun Flowable.asLiveData(): LiveData { - return LiveDataReactiveStreams.fromPublisher(this) -} - -fun Observable.asLiveData(backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST) - : LiveData { - - return LiveDataReactiveStreams.fromPublisher(this.toFlowable(backpressureStrategy)) - -} - fun Flowable>.mapToList(mapper: (T) -> R): Flowable> { return this.map { it.map { mapper(it) } } } @@ -355,34 +341,6 @@ inline fun ObservableEmitter.ifNotDisposed(body: ObservableEmitter< if (!isDisposed) body() } - -/** - * In this scenario, you must also manage the Rx publisher subscription across the life of your fragment or activity. - * Note that LiveData does NOT handle errors and it expects that errors are treated as states in the data that's held. - * In case of an error being emitted by the publisher, an error will be propagated to the main thread and the app will crash. - * @receiver Flowable - * @return LiveData - */ -inline fun Flowable.asReactivePublisher(): LiveData { - return LiveDataReactiveStreams.fromPublisher(this) -} - -/** - * Flowables, most consumers will be able to let the library deal with backpressure using operators and not need to worry about ever manually calling request(long). - * @receiver LiveData - * On subscription to the publisher, the observer will attach to the given LiveData. - * Once {@link Subscription#request) is called on the subscription object, an observer will be connected to the data stream. - * Calling request(Long.MAX_VALUE) is equivalent to creating an unbounded stream with no backpressure. - * If request with a finite count reaches 0, the observer will buffer the latest item and emit it to the subscriber when data is again requested. - * Any other items emitted during the time there was no backpressure requested will be dropped. - * @param lifecycleOwner LifecycleOwner - * @return Publisher - */ -inline fun LiveData.toReactivePublisher(lifecycleOwner: LifecycleOwner): Publisher { - return LiveDataReactiveStreams.toPublisher(lifecycleOwner, this) -} - - fun Completable?.makeDBCall(compositeDisposable: CompositeDisposable, onThrow: (error: Throwable) -> Unit = { _ -> }, onComplete: () -> Unit = {}) { this?.subscribeOn(ioThreadScheduler)?.observeOn(mainThreadScheduler)?.subscribe({ onComplete() diff --git a/rx/src/main/java/com/crazylegend/rx/Utils.kt b/rx/src/main/java/com/crazylegend/rx/Utils.kt index 9975e6670..6c9e7009d 100644 --- a/rx/src/main/java/com/crazylegend/rx/Utils.kt +++ b/rx/src/main/java/com/crazylegend/rx/Utils.kt @@ -2,7 +2,6 @@ package com.crazylegend.rx import android.graphics.Bitmap import android.graphics.BitmapFactory -import androidx.lifecycle.LiveDataReactiveStreams import io.reactivex.rxjava3.core.Flowable import io.reactivex.rxjava3.core.Single import java.io.ByteArrayOutputStream @@ -33,8 +32,6 @@ fun Bitmap.toByteArray(compressFormat: Bitmap.CompressFormat, quality: Int): Sin } -fun Flowable.toLiveData() = LiveDataReactiveStreams.fromPublisher(this) - /*fun Context.cacheImage(url: String): Observable { return Observable.create { diff --git a/view/src/main/java/com/crazylegend/view/ViewExtensions6.kt b/view/src/main/java/com/crazylegend/view/ViewExtensions6.kt index d1c6a118b..010988e18 100644 --- a/view/src/main/java/com/crazylegend/view/ViewExtensions6.kt +++ b/view/src/main/java/com/crazylegend/view/ViewExtensions6.kt @@ -131,7 +131,7 @@ fun View.changeBackgroundColor(@ColorInt newColor: Int, duration: Int = 300) { inline fun Snackbar.maxLines(lines: Int): Snackbar { - view.findViewById(R.id.snackbar_text).maxLines = lines + view.findViewById(com.google.android.material.R.id.snackbar_action).maxLines = lines return this }