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
| // Copyright 2022 Google LLC. | |
| // SPDX-License-Identifier: Apache-2.0 | |
| import android.content.Context | |
| import android.graphics.Bitmap | |
| import androidx.compose.runtime.Composable | |
| import androidx.compose.runtime.LaunchedEffect | |
| import androidx.compose.runtime.getValue | |
| import androidx.compose.runtime.mutableStateOf | |
| import androidx.compose.runtime.remember |
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
| /* | |
| * Copyright (c) 2015 Express Quality Food Global Service GmbH. All rights reserved. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
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
| /** | |
| * Copyright 2022 Google LLC. | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| @OptIn(ExperimentalGlanceRemoteViewsApi::class) | |
| @Preview | |
| @Composable | |
| fun SampleGlanceWidgetPreview() { | |
| // The size of the widget |
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
| /** | |
| * Copyright 2022 Google LLC. | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| @Composable | |
| fun MyScreen(glanceAppWidget: GlanceAppWidget) { | |
| val state = rememberAppWidgetHostState() | |
| // the available size for the widget | |
| val size = DpSize(200.dp, 200.dp) |
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 androidx.compose.Composable | |
| import androidx.compose.unaryPlus | |
| import androidx.ui.core.Text | |
| import androidx.ui.core.dp | |
| import androidx.ui.core.sp | |
| import androidx.ui.foundation.shape.corner.RoundedCornerShape | |
| import androidx.ui.graphics.Color | |
| import androidx.ui.layout.* | |
| import androidx.ui.material.MaterialTheme | |
| import androidx.ui.material.surface.Card |
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.eatfirst.android.ui.custom; | |
| /** | |
| * Copyright 2015 Bartosz Lipinski | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 |
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
| abstract class BaseSlice(val context: Context, val sliceUri: Uri) { | |
| /** | |
| * @return the slice implementation to be used by SliceProvider | |
| */ | |
| abstract fun buildSlice(): Slice | |
| /** | |
| * Call refresh to notify the SliceProvider to load again. | |
| */ |
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
| sealed class MyViewData { | |
| abstract val distance: Int | |
| data class Km(override val distance: Int): MyViewData() | |
| data class Miles(override val distance: Int): MyViewData() | |
| } | |
| class MyViewModel: ViewModel() { |
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
| data class MyViewData(val value: Int, val textId: Int, val labelId: Int) | |
| class MyViewModel: ViewModel() { | |
| private val _myViewData = MutableLiveData<MyViewData>() | |
| val myViewData: LiveData<MyViewData> = _myViewData | |
| fun updateViewData() { | |
| val value = getDistance() |
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
| data class MyViewData(val text: String) | |
| class MyViewModel(application: Application): AndroidViewModel(application) { | |
| private val _myViewData = MutableLiveData<MyViewData>() | |
| val myViewData: LiveData<MyViewData> = _myViewData | |
| fun updateViewData() { | |
| val value = getDistance() |
NewerOlder