@@ -29,7 +29,6 @@ import androidx.compose.material3.SnackbarHostState
2929import androidx.compose.material3.Surface
3030import androidx.compose.material3.Text
3131import androidx.compose.runtime.Composable
32- import androidx.compose.runtime.DisposableEffect
3332import androidx.compose.runtime.getValue
3433import androidx.compose.runtime.mutableStateOf
3534import androidx.compose.runtime.remember
@@ -60,7 +59,7 @@ private var lastUpdate: Long = 0
6059private var lastX: Float = 0f
6160private var lastY: Float = 0f
6261private var lastZ: Float = 0f
63- private val SHAKE_THRESHOLD = 800
62+ private const val SHAKE_THRESHOLD = 800
6463
6564class DownloadActivity : ComponentActivity () {
6665 override fun onCreate (savedInstanceState : Bundle ? ) {
@@ -71,14 +70,14 @@ class DownloadActivity : ComponentActivity() {
7170 val database: Database = Room .databaseBuilder(applicationContext, Database ::class .java, " data" ).build()
7271
7372 setContent {
74- val coroutineScope = rememberCoroutineScope()
75- val snackbarHostState = remember { SnackbarHostState () }
73+ rememberCoroutineScope()
74+ remember { SnackbarHostState () }
7675 DataBackupAppTheme {
7776 Surface (
7877 modifier = Modifier .fillMaxSize(),
7978 color = MaterialTheme .colorScheme.background
8079 ) {
81- DownloadScreen (database, coroutineScope, snackbarHostState )
80+ DownloadScreen (database)
8281 }
8382 }
8483 }
@@ -109,7 +108,7 @@ class DownloadActivity : ComponentActivity() {
109108 val z = event.values[2 ]
110109
111110 if (isDeviceMoving(x, y, z)) {
112- showToast(" Device movement detected. Download paused. " )
111+ showToast()
113112 }
114113 }
115114 }
@@ -124,7 +123,7 @@ class DownloadActivity : ComponentActivity() {
124123 }
125124 }
126125
127- private fun showToast (message : String ) {
126+ private fun showToast () {
128127// runOnUiThread {
129128// Toast.makeText(this@MainActivity, message, Toast.LENGTH_SHORT).show()
130129// }
@@ -154,11 +153,11 @@ class DownloadActivity : ComponentActivity() {
154153}
155154
156155@Composable
157- fun DownloadScreen (database : Database , coroutineScope : CoroutineScope , snackbarHostState : SnackbarHostState ) {
156+ fun DownloadScreen (database : Database ) {
158157 val storage = Firebase .storage
159158 val listRef = storage.reference
160159 var listItems by remember { mutableStateOf(listOf<String >()) }
161- var id by remember { mutableStateOf(" " ) }
160+ val id by remember { mutableStateOf(" " ) }
162161 val snackbarHostState = remember { SnackbarHostState () }
163162 val coroutineScope = rememberCoroutineScope()
164163 val context = LocalContext .current
@@ -274,7 +273,7 @@ private fun isDeviceMoving(x: Float, y: Float, z: Float): Boolean {
274273 return false
275274}
276275fun downloadFile (url : String , database : Database , snackbarHostState : SnackbarHostState ,coroutineScope : CoroutineScope ) {
277- var result = " "
276+ " "
278277 val cloudStorage = Firebase .storage.reference
279278 val storageRef = cloudStorage.child(" /$url " )
280279
0 commit comments