Skip to content

Commit c864c00

Browse files
author
tanpengcheng
committed
[opt] Format code.
1 parent f4cfff9 commit c864c00

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

app/src/main/java/com/tans/tfiletransporter/ui/commomdialog/DialogCoroutineUtils.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.tans.tfiletransporter.ui.commomdialog
22

3-
import androidx.fragment.app.DialogFragment
43
import androidx.fragment.app.FragmentManager
4+
import com.tans.tuiutils.dialog.BaseDialogFragment
55
import com.tans.tuiutils.dialog.DialogCancelableResultCallback
66
import com.tans.tuiutils.dialog.DialogForceResultCallback
77
import kotlinx.coroutines.CancellableContinuation
@@ -44,9 +44,9 @@ class CoroutineDialogForceResultCallback<T : Any>(
4444

4545
}
4646

47-
fun FragmentManager.coroutineShowSafe(dialog: DialogFragment, tag: String, cont: CancellableContinuation<*>): Boolean {
47+
fun FragmentManager.coroutineShowSafe(dialog: BaseDialogFragment, tag: String, cont: CancellableContinuation<*>): Boolean {
4848
return if (!isDestroyed) {
49-
dialog.show(this, tag)
49+
dialog.showSafe(this, tag)
5050
val wd = WeakReference(dialog)
5151
cont.invokeOnCancellation {
5252
if (!isDestroyed) {

app/src/main/java/com/tans/tfiletransporter/ui/commomdialog/LoadingDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ suspend fun <T> FragmentManager.loadingDialogSuspend(job: suspend () -> T): T {
3232
val loadingDialog = LoadingDialog()
3333
val isShowLoading = withContext(Dispatchers.Main.immediate) {
3434
if (!isDestroyed) {
35-
loadingDialog.show(this@loadingDialogSuspend, "LoadingDialog#${System.currentTimeMillis()}")
35+
loadingDialog.showSafe(this@loadingDialogSuspend, "LoadingDialog#${System.currentTimeMillis()}")
3636
true
3737
} else {
3838
false

app/src/main/java/com/tans/tfiletransporter/ui/commomdialog/SettingsDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ class SettingsDialog : BaseCoroutineStateDialogFragment<Settings.SettingsData>(
9090
fun FragmentManager.showSettingsDialog() {
9191
val d = SettingsDialog()
9292
if (!isDestroyed) {
93-
d.show(this, "SettingsDialog#${System.currentTimeMillis()}")
93+
d.showSafe(this, "SettingsDialog#${System.currentTimeMillis()}")
9494
}
9595
}

app/src/main/res/layout/connection_activity.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<androidx.coordinatorlayout.widget.CoordinatorLayout
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5+
android:saveEnabled="false"
56
xmlns:android="http://schemas.android.com/apk/res/android"
67
xmlns:app="http://schemas.android.com/apk/res-auto">
78

app/src/main/res/layout/file_transport_activity.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
android:layout_height="match_parent"
99
android:background="@color/white"
1010
android:fitsSystemWindows="true"
11-
android:keepScreenOn="true">
11+
android:keepScreenOn="true"
12+
android:saveEnabled="false">
1213

1314
<com.google.android.material.appbar.AppBarLayout
1415
android:id="@+id/appbar_layout"

app/src/main/res/layout/folder_select_activity.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
android:layout_height="match_parent"
88
android:background="@color/white"
99
android:keepScreenOn="true"
10-
android:fitsSystemWindows="true">
10+
android:fitsSystemWindows="true"
11+
android:saveEnabled="false">
1112

1213
<com.google.android.material.appbar.AppBarLayout
1314
android:id="@+id/appbar_layout"

app/src/main/res/layout/scan_qrcode_activity.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
android:fitsSystemWindows="false"
6+
android:saveEnabled="false"
67
xmlns:android="http://schemas.android.com/apk/res/android"
78
xmlns:app="http://schemas.android.com/apk/res-auto">
89

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package com.tans.tfiletransporter
22

3+
import java.util.Locale
4+
35
const val KB = 1024
46
const val MB = 1024 * 1024
57
const val GB = 1024 * 1024 * 1024
68

79

810
fun Long.toSizeString(): String {
911
return when (this) {
10-
in 0 until KB -> String.format("%d B", this)
11-
in KB until MB -> String.format("%.2f KB", this.toDouble() / KB)
12-
in MB until GB -> String.format("%.2f MB", this.toDouble() / MB)
13-
in GB until Long.MAX_VALUE -> String.format("%.2f GB", this.toDouble() / GB)
12+
in 0 until KB -> String.format(Locale.US, "%d B", this)
13+
in KB until MB -> String.format(Locale.US,"%.2f KB", this.toDouble() / KB)
14+
in MB until GB -> String.format(Locale.US,"%.2f MB", this.toDouble() / MB)
15+
in GB until Long.MAX_VALUE -> String.format(Locale.US,"%.2f GB", this.toDouble() / GB)
1416
else -> ""
1517
}
1618
}

0 commit comments

Comments
 (0)