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
enum class CellType { | |
Space, Wall | |
} | |
data class MazeTile(val x: Int, val y: Int, var type: CellType = CellType.Wall) | |
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) | |
class Maze(private val width: Int, private val height: Int) { | |
val maze: Array<Array<MazeTile>> = Array(height) { y -> | |
Array(width) { x -> MazeTile(x, y) } |
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
@Composable | |
fun AnimatedTextSwitcher() { | |
var isYellowBoxVisibility by remember { mutableStateOf(true) } | |
LaunchedEffect(Unit) { | |
while (true) { | |
delay(3000) | |
isYellowBoxVisibility = !isYellowBoxVisibility | |
} | |
} |
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.annotation.FloatRange | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.LinearOutSlowInEasing | |
import androidx.compose.animation.core.tween | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.foundation.layout.requiredSize | |
import androidx.compose.material3.MaterialTheme | |
import androidx.compose.material3.Slider |
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
Apache License | |
Version 2.0, January 2004 | |
http://www.apache.org/licenses/ | |
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |
1. Definitions. | |
"License" shall mean the terms and conditions for use, reproduction, | |
and distribution as defined by Sections 1 through 9 of this document. |
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
class CertificateHelper @Inject constructor(@ApplicationContext context: Context) { | |
private val applicationContext = context | |
fun createTrustManagers(): Array<TrustManager> { | |
val certificateInputStream = applicationContext.resources.openRawResource( | |
R.raw.test) | |
val certificateFactory = CertificateFactory.getInstance("X.509") | |
val certificate = certificateFactory.generateCertificate(certificateInputStream) | |
val trustManagerFactory = TrustManagerFactory.getInstance( | |
TrustManagerFactory.getDefaultAlgorithm()) | |
val keyStore = KeyStore.getInstance(KeyStore.getDefaultType()) |
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
@Singleton | |
@Provides | |
fun provideOkhttpClient(authInterceptor: AuthInterceptor, | |
certificateHelper: CertificateHelper | |
) :OkHttpClient{ | |
val trustManagers = certificateHelper.createTrustManagers() | |
val sslContext = SSLContext.getInstance("TLS") | |
sslContext.init(null, trustManagers, null) | |
return OkHttpClient().newBuilder() | |
.readTimeout(2, TimeUnit.MINUTES) |
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
val filename = "myFile.txt" | |
val content = "Hello, World!" | |
val documentsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) | |
val file = File(documentsDir, filename) | |
file.outputStream().use { outputStream -> | |
outputStream.write(content.toByteArray()) | |
} |
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
val contentResolver = this.contentResolver | |
val contentValues = ContentValues().apply { | |
put(MediaStore.MediaColumns.DISPLAY_NAME, "applounge") | |
put(MediaStore.MediaColumns.MIME_TYPE, "text/plain") | |
put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS) | |
} | |
val uri = contentResolver.insert(MediaStore.Files.getContentUri("external"), contentValues) | |
uri?.let { | |
contentResolver.openOutputStream(it)?.use { outputStream -> |
NewerOlder