Make TF happy, cleanup the more info menu
This commit is contained in:
parent
35217036ce
commit
05269c557d
@ -6,7 +6,6 @@ import android.view.ViewGroup
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import eu.kanade.tachiyomi.databinding.MetadataViewItemBinding
|
import eu.kanade.tachiyomi.databinding.MetadataViewItemBinding
|
||||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import exh.util.floor
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@ -36,28 +35,26 @@ class MetadataViewAdapter(private var data: List<Pair<String, String>>) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
// total number of cells
|
// total number of cells
|
||||||
override fun getItemCount(): Int = data.size * 2
|
override fun getItemCount(): Int = data.size
|
||||||
|
|
||||||
// stores and recycles views as they are scrolled off screen
|
// stores and recycles views as they are scrolled off screen
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
private var dataPosition: Int? = null
|
|
||||||
fun bind(position: Int) {
|
fun bind(position: Int) {
|
||||||
if (data.isEmpty() || !binding.infoText.text.isNullOrBlank()) return
|
binding.infoTitle.text = data[position].first
|
||||||
dataPosition = (position / 2F).floor()
|
binding.infoText.text = data[position].second
|
||||||
binding.infoText.text = if (position % 2 == 0) data[dataPosition!!].first else data[dataPosition!!].second
|
|
||||||
binding.infoText.clicks()
|
binding.infoText.clicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
itemView.context.copyToClipboard(data[dataPosition!!].second, data[dataPosition!!].second)
|
itemView.context.copyToClipboard(data[position].second, data[position].second)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return dataPosition.hashCode() == other.hashCode()
|
return binding.infoText.hashCode() == other.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return dataPosition.hashCode()
|
return binding.infoText.hashCode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.databinding.MetadataViewControllerBinding
|
import eu.kanade.tachiyomi.databinding.MetadataViewControllerBinding
|
||||||
@ -68,7 +68,7 @@ class MetadataViewController : NucleusController<MetadataViewControllerBinding,
|
|||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
if (manga == null || source == null) return
|
if (manga == null || source == null) return
|
||||||
binding.recycler.layoutManager = GridLayoutManager(view.context, 2)
|
binding.recycler.layoutManager = LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false)
|
||||||
adapter = MetadataViewAdapter(data)
|
adapter = MetadataViewAdapter(data)
|
||||||
binding.recycler.adapter = adapter
|
binding.recycler.adapter = adapter
|
||||||
binding.recycler.setHasFixedSize(true)
|
binding.recycler.setHasFixedSize(true)
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<stroke
|
|
||||||
android:width="1dip"
|
|
||||||
android:color="?attr/colorOnSurface" />
|
|
||||||
</shape>
|
|
@ -2,14 +2,21 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/border">
|
android:layout_margin="8dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/info_title"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
style="@style/TextAppearance.Regular.Body1" />
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/info_text"
|
android:id="@+id/info_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_margin="5dp"
|
android:layout_marginStart="8dp"
|
||||||
style="@style/TextAppearance.Regular" />
|
style="@style/TextAppearance.Regular.Body1.Secondary" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user