From e73dea21a9794cccd0113a06bf18cd00099a19bb Mon Sep 17 00:00:00 2001 From: Kagura Date: Sun, 20 Oct 2024 16:21:12 +0800 Subject: [PATCH] feat: use custom base activity --- .../com/dazuoye/filemanager/BaseActivity.kt | 18 ++++++++++++++++++ .../com/dazuoye/filemanager/document_page.kt | 2 +- .../java/com/dazuoye/filemanager/music_page.kt | 2 +- .../com/dazuoye/filemanager/picture_page.kt | 7 +------ .../java/com/dazuoye/filemanager/video_page.kt | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/dazuoye/filemanager/BaseActivity.kt diff --git a/app/src/main/java/com/dazuoye/filemanager/BaseActivity.kt b/app/src/main/java/com/dazuoye/filemanager/BaseActivity.kt new file mode 100644 index 0000000..d38ec39 --- /dev/null +++ b/app/src/main/java/com/dazuoye/filemanager/BaseActivity.kt @@ -0,0 +1,18 @@ +package com.dazuoye.filemanager + +import androidx.appcompat.app.AppCompatActivity +import com.dazuoye.filemanager.fileSystem.DeleteHelper.Companion.delete +import java.io.File + +open class BaseActivity: AppCompatActivity() { + + + override fun onDestroy() { + super.onDestroy() + val clipFile = File(this.cacheDir,"clipboard") + if (clipFile.exists()){ + delete(clipFile.path) + } + System.gc() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dazuoye/filemanager/document_page.kt b/app/src/main/java/com/dazuoye/filemanager/document_page.kt index 2ace693..de260d0 100644 --- a/app/src/main/java/com/dazuoye/filemanager/document_page.kt +++ b/app/src/main/java/com/dazuoye/filemanager/document_page.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.launch import org.apache.commons.io.IOUtils import java.io.File -class document_page : AppCompatActivity() { +class document_page : BaseActivity() { private var documentList = listOf() private val pasteDir = "${Environment.getExternalStorageDirectory().path}/Documents/pasted" private var listOrderType = 0 diff --git a/app/src/main/java/com/dazuoye/filemanager/music_page.kt b/app/src/main/java/com/dazuoye/filemanager/music_page.kt index 15eabab..0f0ee06 100644 --- a/app/src/main/java/com/dazuoye/filemanager/music_page.kt +++ b/app/src/main/java/com/dazuoye/filemanager/music_page.kt @@ -35,7 +35,7 @@ import kotlinx.coroutines.launch import org.apache.commons.io.IOUtils import java.io.File -class music_page : AppCompatActivity() { +class music_page : BaseActivity() { private var musicList = listOf() private val pasteDir = "${Environment.getExternalStorageDirectory().path}/Music/pasted" private var listOrderType = 0 diff --git a/app/src/main/java/com/dazuoye/filemanager/picture_page.kt b/app/src/main/java/com/dazuoye/filemanager/picture_page.kt index 01d8ddc..199335b 100644 --- a/app/src/main/java/com/dazuoye/filemanager/picture_page.kt +++ b/app/src/main/java/com/dazuoye/filemanager/picture_page.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.launch import org.apache.commons.io.IOUtils import java.io.File -class picture_page : AppCompatActivity() { +class picture_page : BaseActivity() { private var imageList = listOf() private val pasteDir = "${Environment.getExternalStorageDirectory().path}/Pictures/pasted" private var imageListOrderType = 0 @@ -292,9 +292,4 @@ class picture_page : AppCompatActivity() { loadingText(loadingTextView, defaultText, next) } } - - override fun onDestroy() { - super.onDestroy() - System.gc() - } } \ No newline at end of file diff --git a/app/src/main/java/com/dazuoye/filemanager/video_page.kt b/app/src/main/java/com/dazuoye/filemanager/video_page.kt index cc0f22a..d256625 100644 --- a/app/src/main/java/com/dazuoye/filemanager/video_page.kt +++ b/app/src/main/java/com/dazuoye/filemanager/video_page.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.launch import org.apache.commons.io.IOUtils import java.io.File -class video_page : AppCompatActivity() { +class video_page : BaseActivity() { private var videoList = listOf() private val pasteDir = "${Environment.getExternalStorageDirectory().path}/Movies/pasted" private var videoListOrderType = 0