Skip to content

Commit

Permalink
🐛 Fix progress bar bug and add workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed Jan 31, 2020
1 parent 882e01c commit 4f9d7b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .idea/codestream.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ class SongListActivity : AppCompatActivity() {
}
val publisher: (Int, Int, MusicInfo?) -> Unit = { total, progress, info ->
CoroutineScope(Dispatchers.Main).launch {
circularType.setProgressMax(total)
val progress100 = progress.toDouble()/total.toDouble() * 100.0
circularType.setProgressMax(100)
if (info != null)
adapter.addItem(info)
snackProgressBarManager.setProgress(progress)
snackProgressBarManager.setProgress(progress100.toInt())
}
}
val onFinish: () -> Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ class DereDatabaseHelper(context: Context) {
)
musicIDToInfo[musicDataId] = musicInfo
currentCount++
publisher(currentCount, totalCount, musicInfo)
publisher(totalCount, currentCount, musicInfo)
}
cursorLiveData.close()
fumensDB.close()
}

var musicNumberToFumenFile: MutableMap<Int, File> = HashMap()
suspend fun indexFumens(publisher: (Int, Int, MusicInfo?) -> Unit) {
fun indexFumens(publisher: (Int, Int, MusicInfo?) -> Unit) {
var cursorFumens: Cursor? = null
val fileList = fumenFolder.listFiles()
for (fileWithIndex in fileList.withIndex()) {
Expand Down Expand Up @@ -262,9 +262,12 @@ class DereDatabaseHelper(context: Context) {
publisher(musicIDToInfo.size, musicInfo.index, musicInfo.value)
}
} else {
//publisher(100,0,null)
parseDatabases(publisher)
indexFumens(publisher)
publisher(100,50,null)
saveToCache(context)
publisher(100,100,null)
}
Log.d(TAG, "size of databases:${musicIDToInfo.size}")
Log.d(TAG, "Number of fumens:${musicNumberToFumenFile.size}")
Expand Down

0 comments on commit 4f9d7b4

Please sign in to comment.