Commit 1f9a8191 authored by wanglei's avatar wanglei

...

parent f36f11ea
package com.base.filerecoveryrecyclebin.utils
import android.provider.MediaStore.Audio.Radio
import java.io.File
import kotlin.random.Random
object SimilarHelper {
fun calculate(list: ArrayList<File>) {
var result = arrayListOf<ArrayList<File>>()
val result = HashMap<String, ArrayList<File>>()
val eachArrayList = arrayListOf<File>().apply {
addAll(list)
}
val comparedFile = arrayListOf<File>()
val iterator = list.iterator()
val compareIterator = eachArrayList.iterator()
while (iterator.hasNext()) {
val item = iterator.next()
if (!comparedFile.contains(item)) {
while (compareIterator.hasNext()) {
val compareItem = compareIterator.next()
if (item.absoluteFile != compareItem.absoluteFile) {
val percent = similarPercent(item, compareItem)
if (percent > 80) {
if (result[item.absolutePath] == null) {
result[item.absolutePath] = arrayListOf()
}
result[item.absolutePath]?.add(item)
result[item.absolutePath]?.add(compareItem)
comparedFile.add(compareItem)
compareIterator.remove()
}
}
}
}
}
}
private fun similarPercent(srcFile: File, compareFile: File): Int {
return Random.nextInt(60, 100)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment