Skip to content

Instantly share code, notes, and snippets.

View davidvavra's full-sized avatar

David Vavra davidvavra

View GitHub Profile
@Composable
fun AppGreeting() {
Text(text = "Hello from app module!")
}
@Preview(name = "App module greeting", group = "Greetings")
@Composable
fun DefaultPreview() {
ShowkaseTheme {
AppGreeting()
@ShowkaseScreenshot(rootShowkaseClass = ShowkaseRoot::class)
abstract class ComposeTests : ShowkaseScreenshotTest {
override fun onScreenshot(
id: String,
name: String,
group: String,
styleName: String?,
screenshotType: ShowkaseScreenshotType,
screenshotBitmap: Bitmap
lateinit var manager: ReviewManager
var reviewInfo: ReviewInfo? = null
// Call this method asap, for example in onCreate()
private fun initReviews() {
manager = ReviewManagerFactory.create(this)
manager.requestReviewFlow().addOnCompleteListener { request ->
if (request.isSuccessful) {
reviewInfo = request.result
} else {
@davidvavra
davidvavra / NonNullAssertionDetector.kt
Created March 22, 2019 17:06
Lint check for detecting non-null assertion (!!) in your code
import com.android.tools.lint.client.api.UElementHandler
import com.android.tools.lint.detector.api.*
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UPostfixExpression
class NonNullAssertionDetector : Detector(), Detector.UastScanner {
override fun getApplicableUastTypes(): List<Class<out UElement>>? {
return listOf(UPostfixExpression::class.java)
}
fun navigateBackWithResult(result: Bundle) {
val childFragmentManager = supportFragmentManager.findFragmentById(R.id.nav_host_fragment)?.childFragmentManager
var backStackListener: FragmentManager.OnBackStackChangedListener by Delegates.notNull()
backStackListener = FragmentManager.OnBackStackChangedListener {
(childFragmentManager?.fragments?.get(0) as NavigationResult).onNavigationResult(result)
childFragmentManager.removeOnBackStackChangedListener(backStackListener)
}
childFragmentManager?.addOnBackStackChangedListener(backStackListener)
navController().popBackStack()
}
/**
* Vrátí html kód pro přihlášení / odhlášení / informaci o zaplněnosti pro
* daného uživatele. Pokud není zadán, vrací prázdný řetězec.
* @todo v rodině instancí maximálně jedno přihlášení?
* @todo konstanty pro jména POST proměnných? viz prihlasovatkoZpracuj
*/
function prihlasovatko(Uzivatel $u = null, $parametry = 0) {
$out = '';
if($u && $u->gcPrihlasen() && $this->prihlasovatelna($parametry)) {
if (($stav = $this->prihlasenStav($u)) > -1) {
uploadPhoto(requireNotNull(intent.getStringExtra("PHOTO_URL"), { "Activity parameter 'PHOTO_URL' is missing" }))
uploadPhoto(intent.getStringExtra("PHOTO_URL")!!)
fun getUserName(): String {
return mUserName ?: "Anonymous"
}
fun getUserName(): String {
if (mUserName != null) {
return mUserName!!
} else {
return "Anonymous"
}
}