This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.skyyo.ext | |
| import android.content.res.Resources | |
| fun Float.dp(): Float = this * density + 0.5f | |
| fun Int.dp(): Int = (this * density + 0.5f).toInt() | |
| fun Int.sp(): Float = (this * scaledDensity + 0.5f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implementation 'com.google.android.material:material:1.3.0-alpha01' | |
| <CoordinatorLayout | |
| <AppBarLayout | |
| style="@style/Widget.MaterialComponents.AppBarLayout.Surface" | |
| app:liftOnScroll="true"/> | |
| <RecyclerView | |
| app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <View | |
| android:id="@+id/view" | |
| android:background="@color/colorAccent" | |
| android:stateListAnimator="@animator/toolbar_elevator"/> | |
| <-- res/animator/toolbar_elevator.xml --> | |
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <item android:state_selected="true"> | |
| <objectAnimator | |
| android:duration="350" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object InternetConnectionTracker : LiveData<Boolean>() { | |
| private val manager: ConnectivityManager by lazy { | |
| Injector.get().appContext() | |
| .getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| } | |
| private val netCallback = object : ConnectivityManager.NetworkCallback() { | |
| override fun onAvailable(network: Network) { | |
| postValue(true) | |
| super.onAvailable(network) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object NetworkUtils : ConnectivityManager.NetworkCallback() { | |
| private val networkLiveData: MutableLiveData<Boolean> = MutableLiveData() | |
| override fun onAvailable(network: Network) { | |
| networkLiveData.postValue(true) | |
| } | |
| override fun onLost(network: Network) { | |
| networkLiveData.postValue(false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.view.View | |
| import androidx.fragment.app.Fragment | |
| import androidx.lifecycle.DefaultLifecycleObserver | |
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleOwner | |
| import androidx.lifecycle.Observer | |
| import androidx.viewbinding.ViewBinding | |
| import kotlin.properties.ReadOnlyProperty | |
| import kotlin.reflect.KProperty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun String.emoji(): String = | |
| String(Character.toChars(Integer.parseInt(replace("U+", ""), 16))) | |
| inline fun <T> tryOrNull(f: () -> T) = | |
| try { | |
| f() | |
| } catch (_: Exception) { | |
| null | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.util.Log | |
| import android.widget.Toast | |
| import androidx.activity.result.contract.ActivityResultContracts | |
| import androidx.fragment.app.Fragment | |
| fun Fragment.shortToast(text: String) { | |
| context ?: return | |
| Toast.makeText(requireContext(), text, Toast.LENGTH_SHORT).show() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val behavior = from(bottomSheetRv) | |
| behavior.addBottomSheetCallback(object : BottomSheetCallback() { | |
| override fun onStateChanged( | |
| @NonNull bottomSheet: View, | |
| newState: Int | |
| ) { | |
| if (newState == STATE_EXPANDED) { | |
| // In the EXPANDED STATE apply a new MaterialShapeDrawable with rounded cornes | |
| val newMaterialShapeDrawable: MaterialShapeDrawable = createMaterialShapeDrawable(bottomSheetRv) | |
| ViewCompat.setBackground( |