Giter VIP home page Giter VIP logo

snippets's Introduction

Android Snippets

This repository holds code snippets used in Android documentation on developer.android.com.

The idea is that by having a small sample project that contains the code snippets from documentation, developers will gain more context on how to implement a specific API.

In addition, by having CI running on this repo, we can ensure that the code snippets on developer.android.com is in a working condition.

It is a work in progress, as many snippets are still embedded as static HTML.

Contributing

We love contributions! See CONTRIBUTING.md for guidelines.

snippets's People

Contributors

alexvanyo avatar arriolac avatar astamato avatar bentrengrove avatar calren avatar compose-devrel-github-bot avatar dependabot[bot] avatar dougsig avatar florina-muntenescu avatar iangclifton avatar jakeroseman avatar jolandaverhoef avatar jonasfa avatar magicalmeghan avatar marcelpinto avatar metalhead8816 avatar mlykotom avatar oas004 avatar riggaroo avatar secondsun avatar simona-anomis avatar tomriddle25 avatar zsmb13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snippets's Issues

The following code may encounter issues when using AnimatedVisibility, as the animation is very uneven



@Preview
@Composable
fun AnimatedVisibilityCookbook() {
    var visible1 by remember {
        mutableStateOf(true)
    }

    var visible2 by remember {
        mutableStateOf(true)
    }
    Row(
        modifier = Modifier.padding(top = 20.dp).fillMaxWidth(),
        horizontalArrangement = Arrangement.spacedBy(6.dp)
    ) {
        Button(
            modifier = Modifier,
            onClick = {
                visible1 = !visible1
            },
            shape = RoundedCornerShape(6.dp),
            colors = ButtonDefaults.buttonColors(containerColor = Color.White),
            contentPadding = PaddingValues(horizontal = 8.dp)
        ) {
            Text(
                text = "text",
                color = Color.Black,
                textAlign = TextAlign.Center
            )
        }
        AnimatedVisibility(
            modifier =  Modifier.weight(1f),
            visible = visible1
        ) {
            Button(
                modifier = Modifier,
                onClick = {  },
                shape = RoundedCornerShape(6.dp),
                colors =  ButtonDefaults.buttonColors(containerColor = Color.White),
                contentPadding = PaddingValues(horizontal = 8.dp)
            ) {
                Text(
                    text = "text1",
                    color = Color.Black,
                    textAlign = TextAlign.Center
                )
            }
        }
        AnimatedVisibility(
            modifier = Modifier.weight(1f),
            visible = visible2
        ) {
            Button(
                modifier = Modifier,
                onClick = {  },
                shape = RoundedCornerShape(6.dp),
                colors =  ButtonDefaults.buttonColors(containerColor = Color.White),
                contentPadding = PaddingValues(horizontal = 8.dp)
            ) {
                Text(
                    text = "text2",
                    color = Color.Black,
                    textAlign = TextAlign.Center
                )
            }
        }
    }
}

Allow pull requests from forks to pass

Some GitHub actions fail when PRs are created from a forked repo. This prevents external contributors from making contributions to the repo. I wasn't able to fix the issue after several attempts (see fdc1b8e and 0d296b9) which only partly fixed the issue. I'm filing this to track that we still need to make changes to our GH actions to unblock external contributions.

See #198 as an example.

ConstraintLayout Compose LintDebug fails

Running ./gradlew :compose:snippets:lintDebug and ConstraintLayout snippets throw the following error:
Github/snippets/compose/snippets/src/main/java/com/example/compose/snippets/layouts/ConstraintLayoutSnippets.kt: Error: Unexpected failure during lint analysis of ConstraintLayoutSnippets.kt (this is a bug in lint or one of the libraries it depends on)

Running with --stacktrace, gives the following error:

java.lang.AbstractMethodError: Method androidx/constraintlayout/compose/lint/ConstraintLayoutDslDetectorKt$findChildIdentifier$1.afterVisitSimpleNameReferenceExpression(Lorg/jetbrains/uast/USimpleNameReferenceExpression;)V is abstract
        at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetectorKt$findChildIdentifier$1.afterVisitSimpleNameReferenceExpression(ConstraintLayoutDslDetector.kt)
        at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression.accept(KotlinUSimpleReferenceExpression.kt:47)
        at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetectorKt.findChildIdentifier(ConstraintLayoutDslDetector.kt:732)
        at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetector$createUastHandler$1.detectChainParamsUsage(ConstraintLayoutDslDetector.kt:338)
        at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetector$createUastHandler$1.visitCallExpression(ConstraintLayoutDslDetector.kt:145)
        at com.android.tools.lint.client.api.UElementVisitor$DispatchPsiVisitor.visitCallExpression(UElementVisitor.kt:523)
        at com.android.tools.lint.client.api.UElementVisitor$DelegatingPsiVisitor.visitCallExpression(UElementVisitor.kt:1071)
        at org.jetbrains.uast.kotlin.KotlinUFunctionCallExpression.accept(KotlinUFunctionCallExpression.kt:165)
        at org.jetbrains.uast.kotlin.KotlinULocalVariable.accept(KotlinULocalVariable.kt:46)
        at org.jetbrains.uast.internal.ImplementationUtilsKt.acceptList(implementationUtils.kt:15)
        at org.jetbrains.uast.UDeclarationsExpression$DefaultImpls.accept(UDeclarationsExpression.kt:22)
        at org.jetbrains.uast.kotlin.KotlinUDeclarationsExpression.accept(KotlinUDeclarationsExpression.kt:10)
        at org.jetbrains.uast.internal.ImplementationUtilsKt.acceptList(implementationUtils.kt:15)
        at org.jetbrains.uast.UBlockExpression$DefaultImpls.accept(UBlockExpression.kt:21)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.