fix: memory
This commit is contained in:
parent
7741898163
commit
eacb4abddd
4 changed files with 10 additions and 4 deletions
|
@ -27,7 +27,7 @@ class WrappedFile(private val f: File, skipCalculateDirectorySize: Boolean = fal
|
|||
var unit = SizeUnit.B
|
||||
|
||||
while (sizeFirst > 1024u && unit != SizeUnit.GB) {
|
||||
sizeLast = size.mod(1024u).toInt()
|
||||
sizeLast = sizeFirst.mod(1024u).toInt()
|
||||
sizeFirst /= 1024u
|
||||
unit = when (unit) {
|
||||
SizeUnit.B -> SizeUnit.KB
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.dazuoye.filemanager.fileSystem.adapters
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.ThumbnailUtils
|
||||
import android.util.Size
|
||||
import android.view.LayoutInflater
|
||||
|
@ -25,7 +26,7 @@ class ImageModel(image: File) {
|
|||
if (!image.isFile) {
|
||||
throw RuntimeException("No such Image")
|
||||
}
|
||||
thumbnail = ThumbnailUtils.createImageThumbnail(image, Size(512, 512), null)
|
||||
thumbnail = ThumbnailUtils.createImageThumbnail(image, Size(80, 120), null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -291,4 +291,9 @@ class picture_page : AppCompatActivity() {
|
|||
loadingText(loadingTextView, defaultText, next)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
System.gc()
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ pub extern "system" fn Java_com_dazuoye_filemanager_utils_FSHelper_getFolderSize
|
|||
.expect("failed to parse input")
|
||||
.into();
|
||||
|
||||
if !fs::exists(&dir).expect(format!("Cannot stat {}", dir).as_str()) {
|
||||
if !fs::exists(&dir).expect(format!("Cannot stat {dir}").as_str()) {
|
||||
return env
|
||||
.new_string(format!("{} not exists!", dir))
|
||||
.expect("Couldn't create java string!")
|
||||
|
@ -30,7 +30,7 @@ pub extern "system" fn Java_com_dazuoye_filemanager_utils_FSHelper_getFolderSize
|
|||
match item.metadata() {
|
||||
Ok(metadata) => size += metadata.len(),
|
||||
Err(e) => {
|
||||
eprintln!("Error getting metadata for item: {:?}", e);
|
||||
eprintln!("Error getting metadata for item: {e:?}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue