diff --git a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/MainAbstractActivity.kt b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/MainAbstractActivity.kt index a0cd63ae2..3ea0854b1 100644 --- a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/MainAbstractActivity.kt +++ b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/MainAbstractActivity.kt @@ -19,6 +19,7 @@ import com.crazylegend.customviews.databinding.CustomizableCardViewBinding import com.crazylegend.kotlinextensions.context.getCompatColor import com.crazylegend.kotlinextensions.context.isGestureNavigationEnabled import com.crazylegend.kotlinextensions.delegates.activityAVM +import com.crazylegend.kotlinextensions.effects.circularRevealEnter import com.crazylegend.kotlinextensions.exhaustive import com.crazylegend.kotlinextensions.gestureNavigation.EdgeToEdge import com.crazylegend.kotlinextensions.log.debug @@ -96,12 +97,12 @@ class MainAbstractActivity : AppCompatActivity() { debug("SECURITY isDebuggable ${isDebuggable()}") debug("SECURITY isDebuggerAttached ${isDebuggerAttached()}") debug("SECURITY zygoteCallCount ${zygoteCallCount()}") - debug("SECURITY getSingInfoMD5 ${getSingInfoMD5(BuildConfig.APPLICATION_ID)}") + debug("SECURITY getSingInfoMD5 ${getSingInfoMD5("com.crazylegend.setofusefulkotlinextensions")}") debug("SECURITY isEmulator ${isEmulator()}") - debug("SECURITY getShaSignature ${getShaSignature(BuildConfig.APPLICATION_ID)}") + debug("SECURITY getShaSignature ${getShaSignature("com.crazylegend.setofusefulkotlinextensions")}") activityMainBinding.test.setOnClickListenerCooldown { - testAVM.getposts() + it.circularRevealEnter() } lifecycleScope.launchWhenResumed { testAVM.posts.collect { diff --git a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/gestureNavigation/EdgeToEdge.kt b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/gestureNavigation/EdgeToEdge.kt index e73842faf..f37f6a457 100644 --- a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/gestureNavigation/EdgeToEdge.kt +++ b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/gestureNavigation/EdgeToEdge.kt @@ -83,8 +83,7 @@ insets } */ -object EdgeToEdge - : EdgeToEdgeImpl by if (Build.VERSION.SDK_INT >= 21) EdgeToEdgeApi21() else EdgeToEdgeBase() +object EdgeToEdge : EdgeToEdgeImpl by EdgeToEdgeApi21() private interface EdgeToEdgeImpl { @@ -92,18 +91,17 @@ private interface EdgeToEdgeImpl { * Configures a root view of an Activity in edge-to-edge display. * @param root A root view of an Activity. */ - fun setUpRoot(root: ViewGroup) {} + fun setUpRoot(root: ViewGroup) @RequiresApi(Build.VERSION_CODES.R) - fun setUpRoot(activity: Activity, root: ViewGroup, @ColorRes navBarColor: Int = android.R.color.transparent) { - } + fun setUpRoot(activity: Activity, root: ViewGroup, @ColorRes navBarColor: Int = android.R.color.transparent) /** * Configures an app bar and a toolbar for edge-to-edge display. * @param appBar An [AppBarLayout]. * @param toolbar A [Toolbar] in the [appBar]. */ - fun setUpAppBar(appBar: AppBarLayout, toolbar: Toolbar) {} + fun setUpAppBar(appBar: AppBarLayout, toolbar: Toolbar) /** * Configures a scrolling content for edge-to-edge display. @@ -111,17 +109,16 @@ private interface EdgeToEdgeImpl { * ScrollView. It should be as wide as the screen, and should touch the bottom edge of * the screen. */ - fun setUpScrollingContent(scrollingContent: ViewGroup) {} + fun setUpScrollingContent(scrollingContent: ViewGroup, includePaddingBottom: Boolean = false) /** * Tell the window that we want to handle/fit any system windows */ - fun setDecorFitsSystemWindows(window: Window, setDecor: Boolean = true) {} + fun setDecorFitsSystemWindows(window: Window, setDecor: Boolean = true) + fun setDecorFitsSystemWindows(activity: Activity, setDecor: Boolean = true) } -private class EdgeToEdgeBase : EdgeToEdgeImpl - -@RequiresApi(21) +@Suppress("DEPRECATION") private class EdgeToEdgeApi21 : EdgeToEdgeImpl { override fun setUpRoot(root: ViewGroup) { @@ -161,27 +158,39 @@ private class EdgeToEdgeApi21 : EdgeToEdgeImpl { } } + override fun setDecorFitsSystemWindows(activity: Activity, setDecor: Boolean) { + WindowCompat.setDecorFitsSystemWindows(activity.window, setDecor) + + } + override fun setDecorFitsSystemWindows(window: Window, setDecor: Boolean) { WindowCompat.setDecorFitsSystemWindows(window, setDecor) } - override fun setUpScrollingContent(scrollingContent: ViewGroup) { + override fun setUpScrollingContent(scrollingContent: ViewGroup, includePaddingBottom: Boolean) { val originalPaddingLeft = scrollingContent.paddingLeft val originalPaddingRight = scrollingContent.paddingRight val originalPaddingBottom = scrollingContent.paddingBottom + val originalPaddingTop = scrollingContent.paddingTop + + scrollingContent.setOnApplyWindowInsetsListener { _, windowInsets -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { val insets = windowInsets.getInsets(WindowInsets.Type.systemBars()) + val bottomPadding = if (includePaddingBottom) originalPaddingBottom + insets.bottom else originalPaddingBottom scrollingContent.updatePadding( left = originalPaddingLeft + insets.left, right = originalPaddingRight + insets.right, - bottom = originalPaddingBottom + insets.bottom + bottom = bottomPadding, + top = originalPaddingTop + insets.top ) } else { + val paddingBottomCompat = if (includePaddingBottom) originalPaddingBottom + windowInsets.systemWindowInsetBottom else originalPaddingBottom scrollingContent.updatePadding( left = originalPaddingLeft + windowInsets.systemWindowInsetLeft, right = originalPaddingRight + windowInsets.systemWindowInsetRight, - bottom = originalPaddingBottom + windowInsets.systemWindowInsetBottom + bottom = paddingBottomCompat, + top = originalPaddingTop + windowInsets.systemWindowInsetTop ) } windowInsets diff --git a/retrofit/src/main/java/com/crazylegend/retrofit/paging/PagingExtensions.kt b/retrofit/src/main/java/com/crazylegend/retrofit/paging/PagingExtensions.kt index 92828c698..461d80454 100644 --- a/retrofit/src/main/java/com/crazylegend/retrofit/paging/PagingExtensions.kt +++ b/retrofit/src/main/java/com/crazylegend/retrofit/paging/PagingExtensions.kt @@ -15,7 +15,7 @@ fun PagingStateResult.handle( loadingMore: () -> Unit, cantLoadMore: () -> Unit, emptyData: () -> Unit, - calError: (throwable: Throwable) -> Unit = { _ -> }, + callError: (throwable: Throwable) -> Unit = { _ -> }, apiError: (errorBody: ResponseBody?, responseCode: Int) -> Unit = { _, _ -> }, success: () -> Unit ) { @@ -37,7 +37,7 @@ fun PagingStateResult.handle( emptyData() } is PagingStateResult.Error -> { - calError(throwable) + callError(throwable) } is PagingStateResult.ApiError -> { apiError(errorBody, responseCode) @@ -157,7 +157,7 @@ fun MutableLiveData.cantLoadMore() { fun MutableLiveData.subscribe(response: Response?, includeEmptyData: Boolean = false) { response?.let { serverResponse -> if (serverResponse.isSuccessful) { - serverResponse.body()?.apply { + serverResponse.body().apply { value = if (includeEmptyData) { if (this == null) { PagingStateResult.EmptyData @@ -177,7 +177,7 @@ fun MutableLiveData.subscribe(response: Response?, inc fun MutableLiveData.subscribePost(response: Response?, includeEmptyData: Boolean = false) { response?.let { serverResponse -> if (serverResponse.isSuccessful) { - serverResponse.body()?.apply { + serverResponse.body().apply { if (includeEmptyData) { if (this == null) { postValue(PagingStateResult.EmptyData) @@ -198,7 +198,7 @@ fun MutableLiveData.subscribePost(response: Response?, fun MutableLiveData.subscribeList(response: Response?, includeEmptyData: Boolean = false) { response?.let { serverResponse -> if (serverResponse.isSuccessful) { - serverResponse.body()?.apply { + serverResponse.body().apply { if (includeEmptyData) { value = if (this == null) { PagingStateResult.EmptyData @@ -228,7 +228,7 @@ fun MutableLiveData.subscribeList(response: Response?, fun MutableLiveData.subscribeListPost(response: Response?, includeEmptyData: Boolean = false) { response?.let { serverResponse -> if (serverResponse.isSuccessful) { - serverResponse.body()?.apply { + serverResponse.body().apply { if (includeEmptyData) { if (this == null) { postValue(PagingStateResult.EmptyData) diff --git a/retrofit/src/main/java/com/crazylegend/retrofit/retrofitResult/RetrofitResultExtensions.kt b/retrofit/src/main/java/com/crazylegend/retrofit/retrofitResult/RetrofitResultExtensions.kt index 76d70ecb5..48025f567 100644 --- a/retrofit/src/main/java/com/crazylegend/retrofit/retrofitResult/RetrofitResultExtensions.kt +++ b/retrofit/src/main/java/com/crazylegend/retrofit/retrofitResult/RetrofitResultExtensions.kt @@ -16,7 +16,7 @@ import retrofit2.Response inline fun RetrofitResult.handle( loading: () -> Unit = {}, emptyData: () -> Unit = {}, - calError: (throwable: Throwable) -> Unit = { _ -> }, + callError: (throwable: Throwable) -> Unit = { _ -> }, apiError: (errorBody: ResponseBody?, responseCode: Int) -> Unit = { _, _ -> }, success: T.() -> Unit ) { @@ -32,7 +32,7 @@ inline fun RetrofitResult.handle( emptyData() } is RetrofitResult.Error -> { - calError(throwable) + callError(throwable) } is RetrofitResult.ApiError -> { apiError(errorBody, responseCode)