pull/1319/head
parent
f1788ed904
commit
ec970564cd
@ -1,24 +1,16 @@ |
||||
package io.legado.app.constant |
||||
|
||||
import android.annotation.SuppressLint |
||||
import java.text.SimpleDateFormat |
||||
import java.util.* |
||||
|
||||
object AppLog { |
||||
|
||||
@SuppressLint("ConstantLocale") |
||||
private val logTimeFormat = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault()) |
||||
|
||||
val logs = arrayListOf<String>() |
||||
val logs = arrayListOf<Triple<Long, String, Throwable?>>() |
||||
|
||||
fun addLog(log: String?) { |
||||
log ?: return |
||||
synchronized(logs) { |
||||
if (logs.size > 1000) { |
||||
logs.removeLastOrNull() |
||||
} |
||||
logs.add(0, logTimeFormat.format(Date()) + " " + log) |
||||
@Synchronized |
||||
fun addLog(message: String?, throwable: Throwable?) { |
||||
message ?: return |
||||
if (logs.size > 1000) { |
||||
logs.removeLastOrNull() |
||||
} |
||||
logs.add(0, Triple(System.currentTimeMillis(), message, throwable)) |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@ |
||||
package io.legado.app.ui.about |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import androidx.fragment.app.FragmentManager |
||||
import io.legado.app.R |
||||
import io.legado.app.base.BaseDialogFragment |
||||
import io.legado.app.utils.windowSize |
||||
|
||||
class AppLogDialog : BaseDialogFragment() { |
||||
|
||||
companion object { |
||||
fun show(fragmentManager: FragmentManager) { |
||||
AppLogDialog().show(fragmentManager, "appLogDialog") |
||||
} |
||||
} |
||||
|
||||
override fun onStart() { |
||||
super.onStart() |
||||
val dm = requireActivity().windowSize |
||||
dialog?.window?.setLayout( |
||||
(dm.widthPixels * 0.9).toInt(), |
||||
ViewGroup.LayoutParams.WRAP_CONTENT |
||||
) |
||||
} |
||||
|
||||
override fun onCreateView( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup?, |
||||
savedInstanceState: Bundle? |
||||
): View? { |
||||
return inflater.inflate(R.layout.dialog_book_group_edit, container) |
||||
} |
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue