Initial commit
This commit is contained in:
commit
21bfbfb139
520 changed files with 47819 additions and 0 deletions
45
app/src/main/java/ani/dantotsu/settings/FAQAdapter.kt
Normal file
45
app/src/main/java/ani/dantotsu/settings/FAQAdapter.kt
Normal file
|
@ -0,0 +1,45 @@
|
|||
package ani.dantotsu.settings
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.databinding.ItemQuestionBinding
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.setAnimation
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||
|
||||
class FAQAdapter(private val questions: List<Triple<Int, String, String>>, private val manager: FragmentManager) :
|
||||
RecyclerView.Adapter<FAQAdapter.FAQViewHolder>() {
|
||||
private val uiSettings = loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
|
||||
|
||||
inner class FAQViewHolder(val binding: ItemQuestionBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FAQViewHolder {
|
||||
return FAQViewHolder(ItemQuestionBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: FAQViewHolder, position: Int) {
|
||||
val b = holder.binding.root
|
||||
setAnimation(b.context, b, uiSettings)
|
||||
val faq = questions[position]
|
||||
b.text = faq.second
|
||||
b.setCompoundDrawablesWithIntrinsicBounds(faq.first, 0, 0, 0)
|
||||
b.setOnClickListener {
|
||||
CustomBottomDialog.newInstance().apply {
|
||||
setTitleText(faq.second)
|
||||
addView(
|
||||
TextView(b.context).apply {
|
||||
val markWon = Markwon.builder(b.context).usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
markWon.setMarkdown(this, faq.third)
|
||||
}
|
||||
)
|
||||
}.show(manager, "dialog")
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = questions.size
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue