Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit 57f7c29

Browse files
committed
fix build and bump java version to 17
1 parent 27cc7ce commit 57f7c29

File tree

9 files changed

+25
-64
lines changed

9 files changed

+25
-64
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ dependencies {
8080

8181
```gradle
8282
compileOptions {
83-
sourceCompatibility = 1.8
84-
targetCompatibility = 1.8
83+
sourceCompatibility = 17
84+
targetCompatibility = 17
8585
}
8686
8787
kotlinOptions {
88-
jvmTarget = "1.8"
88+
jvmTarget = "17"
8989
}
9090
9191
```

app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TestViewHolder(private val binding: CustomizableCardViewBinding) : Recycle
3131
animation.end()
3232
binding.content.setBackgroundResource(0)
3333
binding.title.setBackgroundResource(0)
34-
binding.image.setImageResource(R.drawable.pin_code_highlight_state)
34+
binding.image.setImageResource(com.crazylegend.customviews.R.drawable.pin_code_highlight_state)
3535
}
3636

3737
fun showPlaceHolder() {

app/src/main/java/com/crazylegend/setofusefulkotlinextensions/adapter/TestViewHolderShimmer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestViewHolderShimmer(private val binding: CustomizableCardViewBinding) :
3030
animation.end()
3131
binding.content.setBackgroundResource(0)
3232
binding.title.setBackgroundResource(0)
33-
binding.image.setImageResource(R.drawable.pin_code_highlight_state)
33+
binding.image.setImageResource(com.crazylegend.customviews.R.drawable.pin_code_highlight_state)
3434
binding.content.setPrecomputedText(item.body)
3535
binding.title.setPrecomputedText(item.title)
3636
}

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ def applyAndroid(project, buildConfigCase) {
167167
}
168168

169169
compileOptions {
170-
sourceCompatibility = 1.8
171-
targetCompatibility = 1.8
170+
sourceCompatibility = 17
171+
targetCompatibility = 17
172172
}
173173

174174
kotlinOptions {
175-
jvmTarget = "1.8"
175+
jvmTarget = "17"
176176
}
177177

178178
testOptions.unitTests {

color/src/main/java/com/crazylegend/color/ColorExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ fun Context.textColorStateList(@ColorInt color: Int): ColorStateList {
199199
intArrayOf()
200200
)
201201
val colors = intArrayOf(
202-
resolveColor(R.attr.colorControlNormal),
203-
resolveColor(R.attr.colorControlNormal),
202+
resolveColor(androidx.appcompat.R.attr.colorControlNormal),
203+
resolveColor(androidx.appcompat.R.attr.colorControlNormal),
204204
color
205205
)
206206
return ColorStateList(states, colors)

kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/views/MenuExtensions.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ import com.crazylegend.kotlinextensions.R
2424
*/
2525
@UiThread
2626
@JvmOverloads
27-
fun colorMenu(activity: Activity, menu: Menu, @ColorInt color: Int,
28-
alpha: Int = 0) {
27+
fun colorMenu(
28+
activity: Activity, menu: Menu, @ColorInt color: Int,
29+
alpha: Int = 0
30+
) {
2931
for (i in 0 until menu.size()) {
3032
val menuItem = menu.getItem(i)
3133
colorMenuItem(menuItem, color, alpha)
3234

3335
if (menuItem.hasSubMenu()) {
3436
val subMenu = menuItem.subMenu
3537

36-
for (j in 0 until (subMenu?.size()?:0)) {
38+
for (j in 0 until (subMenu?.size() ?: 0)) {
3739
subMenu?.getItem(j)?.let { colorMenuItem(it, color, alpha) }
3840
}
3941
}
@@ -73,16 +75,20 @@ fun colorMenuItem(menuItem: MenuItem, @ColorInt color: Int, alpha: Int = 0) {
7375
*/
7476
@SuppressLint("PrivateResource")
7577
@UiThread
76-
private fun setOverflowButtonColor(activity: Activity,
77-
colorFilter: PorterDuffColorFilter, alpha: Int) {
78-
val overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description)
78+
private fun setOverflowButtonColor(
79+
activity: Activity,
80+
colorFilter: PorterDuffColorFilter, alpha: Int
81+
) {
82+
val overflowDescription = activity.getString(com.google.android.material.R.string.abc_action_menu_overflow_description)
7983
val decorView = activity.window.decorView as ViewGroup
8084
val viewTreeObserver = decorView.viewTreeObserver
8185
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
8286
override fun onGlobalLayout() {
8387
val outViews = ArrayList<View>()
84-
decorView.findViewsWithText(outViews, overflowDescription,
85-
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION)
88+
decorView.findViewsWithText(
89+
outViews, overflowDescription,
90+
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
91+
)
8692

8793
if (outViews.isEmpty()) {
8894
return

rx/src/main/java/com/crazylegend/rx/RxExtensions.kt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.crazylegend.rx
22

3-
import androidx.lifecycle.LifecycleOwner
43
import androidx.lifecycle.LiveData
5-
import androidx.lifecycle.LiveDataReactiveStreams
64
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
75
import io.reactivex.rxjava3.core.*
86
import io.reactivex.rxjava3.disposables.CompositeDisposable
@@ -13,7 +11,6 @@ import io.reactivex.rxjava3.kotlin.addTo
1311
import io.reactivex.rxjava3.processors.FlowableProcessor
1412
import io.reactivex.rxjava3.schedulers.Schedulers
1513
import io.reactivex.rxjava3.subjects.Subject
16-
import org.reactivestreams.Publisher
1714
import java.util.concurrent.TimeUnit
1815

1916

@@ -145,17 +142,6 @@ fun <T : Any> Observable<T>.asFlowable(backpressureStrategy: BackpressureStrateg
145142
return this.toFlowable(backpressureStrategy)
146143
}
147144

148-
fun <T : Any> Flowable<T>.asLiveData(): LiveData<T> {
149-
return LiveDataReactiveStreams.fromPublisher(this)
150-
}
151-
152-
fun <T : Any> Observable<T>.asLiveData(backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST)
153-
: LiveData<T> {
154-
155-
return LiveDataReactiveStreams.fromPublisher(this.toFlowable(backpressureStrategy))
156-
157-
}
158-
159145
fun <T, R> Flowable<List<T>>.mapToList(mapper: (T) -> R): Flowable<List<R>> {
160146
return this.map { it.map { mapper(it) } }
161147
}
@@ -355,34 +341,6 @@ inline fun <T : Any> ObservableEmitter<T>.ifNotDisposed(body: ObservableEmitter<
355341
if (!isDisposed) body()
356342
}
357343

358-
359-
/**
360-
* In this scenario, you must also manage the Rx publisher subscription across the life of your fragment or activity.
361-
* Note that LiveData does NOT handle errors and it expects that errors are treated as states in the data that's held.
362-
* In case of an error being emitted by the publisher, an error will be propagated to the main thread and the app will crash.
363-
* @receiver Flowable<T>
364-
* @return LiveData<T>
365-
*/
366-
inline fun <reified T : Any> Flowable<T>.asReactivePublisher(): LiveData<T> {
367-
return LiveDataReactiveStreams.fromPublisher(this)
368-
}
369-
370-
/**
371-
* 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).
372-
* @receiver LiveData<T>
373-
* On subscription to the publisher, the observer will attach to the given LiveData.
374-
* Once {@link Subscription#request) is called on the subscription object, an observer will be connected to the data stream.
375-
* Calling request(Long.MAX_VALUE) is equivalent to creating an unbounded stream with no backpressure.
376-
* 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.
377-
* Any other items emitted during the time there was no backpressure requested will be dropped.
378-
* @param lifecycleOwner LifecycleOwner
379-
* @return Publisher<T>
380-
*/
381-
inline fun <reified T> LiveData<T>.toReactivePublisher(lifecycleOwner: LifecycleOwner): Publisher<T> {
382-
return LiveDataReactiveStreams.toPublisher(lifecycleOwner, this)
383-
}
384-
385-
386344
fun Completable?.makeDBCall(compositeDisposable: CompositeDisposable, onThrow: (error: Throwable) -> Unit = { _ -> }, onComplete: () -> Unit = {}) {
387345
this?.subscribeOn(ioThreadScheduler)?.observeOn(mainThreadScheduler)?.subscribe({
388346
onComplete()

rx/src/main/java/com/crazylegend/rx/Utils.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.crazylegend.rx
22

33
import android.graphics.Bitmap
44
import android.graphics.BitmapFactory
5-
import androidx.lifecycle.LiveDataReactiveStreams
65
import io.reactivex.rxjava3.core.Flowable
76
import io.reactivex.rxjava3.core.Single
87
import java.io.ByteArrayOutputStream
@@ -33,8 +32,6 @@ fun Bitmap.toByteArray(compressFormat: Bitmap.CompressFormat, quality: Int): Sin
3332

3433
}
3534

36-
fun <T : Any> Flowable<T>.toLiveData() = LiveDataReactiveStreams.fromPublisher(this)
37-
3835

3936
/*fun Context.cacheImage(url: String): Observable<Boolean> {
4037
return Observable.create {

view/src/main/java/com/crazylegend/view/ViewExtensions6.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fun View.changeBackgroundColor(@ColorInt newColor: Int, duration: Int = 300) {
131131

132132

133133
inline fun Snackbar.maxLines(lines: Int): Snackbar {
134-
view.findViewById<TextView>(R.id.snackbar_text).maxLines = lines
134+
view.findViewById<TextView>(com.google.android.material.R.id.snackbar_action).maxLines = lines
135135
return this
136136
}
137137

0 commit comments

Comments
 (0)