Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit c4ae22d

Browse files
oscar-adjafu888
authored andcommitted
Minor improvements to ComposeGraph3D
Also mede it so that it can be launched on 'release' variant, which is significantly faster.
1 parent 8e64192 commit c4ae22d

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

demoProjects/ComposeGraph3d/app/build.gradle

+14-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ android {
1919
useSupportLibrary true
2020
}
2121
}
22-
22+
signingConfigs {
23+
debug {
24+
// For Linux & mac:
25+
storeFile file(System.getenv("HOME") + '/.android/debug.keystore')
26+
// For Windows:
27+
// storeFile file('/Users/USERNAME/.android/debug.keystore')
28+
storePassword 'android'
29+
keyAlias 'androiddebugkey'
30+
keyPassword 'android'
31+
}
32+
}
2333
buildTypes {
2434
release {
2535
minifyEnabled false
2636
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
37+
signingConfig signingConfigs.debug
2738
}
2839
}
2940
compileOptions {
@@ -37,7 +48,7 @@ android {
3748
compose true
3849
}
3950
composeOptions {
40-
kotlinCompilerExtensionVersion '1.2.0'
51+
kotlinCompilerExtensionVersion '1.4.7'
4152
}
4253
packagingOptions {
4354
resources {
@@ -53,6 +64,7 @@ dependencies {
5364
implementation 'androidx.activity:activity-compose:1.3.1'
5465
implementation "androidx.compose.ui:ui:$compose_ui_version"
5566
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
67+
implementation "androidx.compose.runtime:runtime-android:1.5.0-beta02"
5668
implementation 'androidx.compose.material:material:1.2.0'
5769
testImplementation 'junit:junit:4.13.2'
5870
androidTestImplementation 'androidx.test.ext:junit:1.1.5'

demoProjects/ComposeGraph3d/app/src/main/java/android/support/composegraph3d/MainActivity.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ fun Greeting(name: String) {
6262

6363
@Composable
6464
fun Graph3D(modifier: Modifier) {
65-
var graph = remember { Graph() }
66-
val time = remember { mutableStateOf(System.nanoTime()) }
65+
val graph = remember { Graph() }
66+
val time = remember { mutableLongStateOf(System.nanoTime()) }
6767

6868
LaunchedEffect(Unit) {
6969
while (isActive) {
7070
withFrameNanos {
71-
time.value = System.nanoTime()
71+
time.longValue = System.nanoTime()
72+
graph.getImageForTime(time.longValue)
7273
}
7374
}
7475
}
7576

76-
var bitmap = graph.getImageForTime(time.value)
77-
7877
Canvas(modifier = modifier
7978
.onPlaced {
8079
graph.setSize(it.size.width, it.size.width)
@@ -95,8 +94,9 @@ fun Graph3D(modifier: Modifier) {
9594
}
9695
)
9796
}) {
97+
time.longValue
9898
scale(2.0f, pivot = Offset(0f,0f)) {
99-
drawImage(bitmap)
99+
drawImage(graph.bitmap)
100100
}
101101
}
102102

demoProjects/ComposeGraph3d/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ buildscript {
66
plugins {
77
id 'com.android.application' version '7.4.2' apply false
88
id 'com.android.library' version '7.4.2' apply false
9-
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
9+
id 'org.jetbrains.kotlin.android' version '1.8.21' apply false
1010
}

0 commit comments

Comments
 (0)