クラッシュレポート対応

This commit is contained in:
tateisu 2018-09-15 02:08:13 +09:00
parent 3e95bb7064
commit 5e032e1eef
2 changed files with 25 additions and 19 deletions

View File

@ -2360,23 +2360,23 @@ class ActMain : AppCompatActivity()
phoneOnly { env -> env.pager.adapter = null }
val ie = app_state.column_list.size
val tmp_list = ArrayList<Column>()
val used_set = HashSet<Int>()
// copy by new_order
for(i in new_order) {
used_set.add(i)
tmp_list.add(app_state.column_list[i])
if( 0<= i && i < ie ){
used_set.add(i)
tmp_list.add(app_state.column_list[i])
}
}
var i = 0
val ie = app_state.column_list.size
while(i < ie) {
if(used_set.contains(i)) {
++ i
continue
}
// dispose unused elements.
for( i in 0 until ie ){
if(used_set.contains(i)) continue
app_state.column_list[i].dispose()
++ i
}
app_state.column_list.clear()
app_state.column_list.addAll(tmp_list)

View File

@ -280,15 +280,21 @@ class AppState(internal val context : Context, internal val pref : SharedPrefere
enableSpeech()
// 背景フォルダの掃除
val backgroundImageDir = Column.getBackgroundImageDir(context)
backgroundImageDir.list().forEach {name->
val file = File(backgroundImageDir,name)
if( file.isFile ){
val delm = name.indexOf(':')
val id = if(delm!=-1) name.substring(0, delm) else name
val column = Column.findColumnById( id )
if( column == null) file.delete()
try {
val backgroundImageDir = Column.getBackgroundImageDir(context)
backgroundImageDir.list().forEach { name ->
val file = File(backgroundImageDir, name)
if(file.isFile) {
val delm = name.indexOf(':')
val id = if(delm != - 1) name.substring(0, delm) else name
val column = Column.findColumnById(id)
if(column == null) file.delete()
}
}
}catch(ex:Throwable){
// クラッシュレポートによると状態が悪いとダメらしい
// java.lang.IllegalStateException
log.trace(ex)
}
}