|
|
|
@ -1,13 +1,25 @@ |
|
|
|
|
package io.legado.app.ui.about |
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import androidx.fragment.app.FragmentManager |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
|
import io.legado.app.base.adapter.ItemViewHolder |
|
|
|
|
import io.legado.app.base.adapter.RecyclerAdapter |
|
|
|
|
import io.legado.app.constant.AppLog |
|
|
|
|
import io.legado.app.databinding.DialogRecyclerViewBinding |
|
|
|
|
import io.legado.app.databinding.ItemAppLogBinding |
|
|
|
|
import io.legado.app.lib.theme.primaryColor |
|
|
|
|
import io.legado.app.utils.LogUtils |
|
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
|
import io.legado.app.utils.windowSize |
|
|
|
|
import splitties.views.onClick |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
class AppLogDialog : BaseDialogFragment() { |
|
|
|
|
|
|
|
|
@ -17,6 +29,11 @@ class AppLogDialog : BaseDialogFragment() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private val binding by viewBinding(DialogRecyclerViewBinding::bind) |
|
|
|
|
private val adapter by lazy { |
|
|
|
|
LogAdapter(requireContext()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onStart() { |
|
|
|
|
super.onStart() |
|
|
|
|
val dm = requireActivity().windowSize |
|
|
|
@ -31,10 +48,40 @@ class AppLogDialog : BaseDialogFragment() { |
|
|
|
|
container: ViewGroup?, |
|
|
|
|
savedInstanceState: Bundle? |
|
|
|
|
): View? { |
|
|
|
|
return inflater.inflate(R.layout.dialog_book_group_edit, container) |
|
|
|
|
return inflater.inflate(R.layout.dialog_recycler_view, container) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
binding.run { |
|
|
|
|
toolBar.setBackgroundColor(primaryColor) |
|
|
|
|
recyclerView.layoutManager = LinearLayoutManager(requireContext()) |
|
|
|
|
recyclerView.adapter = adapter |
|
|
|
|
} |
|
|
|
|
adapter.setItems(AppLog.logs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class LogAdapter(context: Context) : |
|
|
|
|
RecyclerAdapter<Triple<Long, String, Throwable?>, ItemAppLogBinding>(context) { |
|
|
|
|
|
|
|
|
|
override fun getViewBinding(parent: ViewGroup): ItemAppLogBinding { |
|
|
|
|
return ItemAppLogBinding.inflate(inflater, parent, false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun convert( |
|
|
|
|
holder: ItemViewHolder, |
|
|
|
|
binding: ItemAppLogBinding, |
|
|
|
|
item: Triple<Long, String, Throwable?>, |
|
|
|
|
payloads: MutableList<Any> |
|
|
|
|
) { |
|
|
|
|
binding.textTime.text = LogUtils.logTimeFormat.format(Date(item.first)) |
|
|
|
|
binding.textMessage.text = item.second |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun registerListener(holder: ItemViewHolder, binding: ItemAppLogBinding) { |
|
|
|
|
binding.root.onClick { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|