Skip to content

Commit

Permalink
fix build and bump java version to 17
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyMuse committed May 18, 2023
1 parent 27cc7ce commit 57f7c29
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 64 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ dependencies {

```gradle
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 17
targetCompatibility = 17
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions color/src/main/java/com/crazylegend/color/ColorExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ 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)

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) }
}
}
Expand Down Expand Up @@ -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<View>()
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION)
decorView.findViewsWithText(
outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
)

if (outViews.isEmpty()) {
return
Expand Down
42 changes: 0 additions & 42 deletions rx/src/main/java/com/crazylegend/rx/RxExtensions.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


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

fun <T : Any> Flowable<T>.asLiveData(): LiveData<T> {
return LiveDataReactiveStreams.fromPublisher(this)
}

fun <T : Any> Observable<T>.asLiveData(backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST)
: LiveData<T> {

return LiveDataReactiveStreams.fromPublisher(this.toFlowable(backpressureStrategy))

}

fun <T, R> Flowable<List<T>>.mapToList(mapper: (T) -> R): Flowable<List<R>> {
return this.map { it.map { mapper(it) } }
}
Expand Down Expand Up @@ -355,34 +341,6 @@ inline fun <T : Any> ObservableEmitter<T>.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<T>
* @return LiveData<T>
*/
inline fun <reified T : Any> Flowable<T>.asReactivePublisher(): LiveData<T> {
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<T>
* 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<T>
*/
inline fun <reified T> LiveData<T>.toReactivePublisher(lifecycleOwner: LifecycleOwner): Publisher<T> {
return LiveDataReactiveStreams.toPublisher(lifecycleOwner, this)
}


fun Completable?.makeDBCall(compositeDisposable: CompositeDisposable, onThrow: (error: Throwable) -> Unit = { _ -> }, onComplete: () -> Unit = {}) {
this?.subscribeOn(ioThreadScheduler)?.observeOn(mainThreadScheduler)?.subscribe({
onComplete()
Expand Down
3 changes: 0 additions & 3 deletions rx/src/main/java/com/crazylegend/rx/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -33,8 +32,6 @@ fun Bitmap.toByteArray(compressFormat: Bitmap.CompressFormat, quality: Int): Sin

}

fun <T : Any> Flowable<T>.toLiveData() = LiveDataReactiveStreams.fromPublisher(this)


/*fun Context.cacheImage(url: String): Observable<Boolean> {
return Observable.create {
Expand Down
2 changes: 1 addition & 1 deletion view/src/main/java/com/crazylegend/view/ViewExtensions6.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fun View.changeBackgroundColor(@ColorInt newColor: Int, duration: Int = 300) {


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

Expand Down

0 comments on commit 57f7c29

Please sign in to comment.