This file contains 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
/** | |
* Should warn when making unattended a viewmodel function in a composable without considering | |
* potential recompositions | |
* | |
* Should warn when: | |
* | |
* @Composable | |
* fun MyComposable(viewModel : MyViewModel) { | |
* | |
* viewModel.startOperation() |
This file contains 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 productmeister.com.productmeister.view; | |
import android.annotation.TargetApi; | |
import android.os.Build; | |
import android.support.design.widget.AppBarLayout; | |
import android.support.v4.view.ViewCompat; | |
import android.support.v7.app.ActionBar; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.Toolbar; |
This file contains 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 androidx.compose.ui.Modifier | |
import androidx.compose.ui.draw.DrawModifier | |
import androidx.compose.ui.geometry.Rect | |
import androidx.compose.ui.graphics.BlendMode | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.ColorFilter | |
import androidx.compose.ui.graphics.Paint | |
import androidx.compose.ui.graphics.drawscope.ContentDrawScope | |
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas |
This file contains 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 androidx.camera.core.CameraSelector | |
import androidx.camera.view.CameraController | |
import androidx.camera.view.LifecycleCameraController | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.CompositionLocalProvider | |
import androidx.compose.runtime.LaunchedEffect | |
import androidx.compose.runtime.compositionLocalOf | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.mutableStateOf | |
import androidx.compose.runtime.remember |
This file contains 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 com.google.devtools.ksp.getClassDeclarationByName | |
import com.google.devtools.ksp.processing.Resolver | |
import com.google.devtools.ksp.symbol.* | |
/** | |
* Reified function to check if receiver [KSType] is assignable from [T] class | |
*/ | |
inline fun <reified T> KSType.isAssignableFrom(resolver: Resolver): Boolean { | |
val classDeclaration = requireNotNull(resolver.getClassDeclarationByName<T>()) { | |
"Unable to resolve ${KSClassDeclaration::class.simpleName} for type ${T::class.simpleName}" |
This file contains 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
/** | |
* Converts [MlKitAnalyzer.Result] into [kotlin.Result] | |
* @param detector Any [Detector] | |
* @returns [kotlin.Result] | |
*/ | |
fun <T> MlKitAnalyzer.Result.toResult(detector: Detector<T>): Result<T> = | |
kotlin.runCatching { | |
val value = getValue(detector) ?: throw getThrowable(detector)!! | |
value | |
} |
This file contains 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
/** | |
* Cancels current flow when the predicate is matched, throws [CancellationException] up in | |
* current coroutine. | |
* @param cause class that will be used as cause for [CancellationException] | |
* @param predicate if result of this function is [true] then the flow is stopped | |
*/ | |
inline fun <T> Flow<T>.cancelWhen( | |
cause: KClass<out Throwable>? = null, | |
crossinline predicate: (T) -> Boolean | |
): Flow<T> = transform { |
NewerOlder