Make TF happy, cleanup the more info menu

This commit is contained in:
Jobobby04 2020-10-26 13:57:23 -04:00
parent 35217036ce
commit 05269c557d
4 changed files with 18 additions and 21 deletions

View File

@ -6,7 +6,6 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.databinding.MetadataViewItemBinding
import eu.kanade.tachiyomi.util.system.copyToClipboard
import exh.util.floor
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -36,28 +35,26 @@ class MetadataViewAdapter(private var data: List<Pair<String, String>>) :
}
// 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
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private var dataPosition: Int? = null
fun bind(position: Int) {
if (data.isEmpty() || !binding.infoText.text.isNullOrBlank()) return
dataPosition = (position / 2F).floor()
binding.infoText.text = if (position % 2 == 0) data[dataPosition!!].first else data[dataPosition!!].second
binding.infoTitle.text = data[position].first
binding.infoText.text = data[position].second
binding.infoText.clicks()
.onEach {
itemView.context.copyToClipboard(data[dataPosition!!].second, data[dataPosition!!].second)
itemView.context.copyToClipboard(data[position].second, data[position].second)
}
.launchIn(scope)
}
override fun equals(other: Any?): Boolean {
return dataPosition.hashCode() == other.hashCode()
return binding.infoText.hashCode() == other.hashCode()
}
override fun hashCode(): Int {
return dataPosition.hashCode()
return binding.infoText.hashCode()
}
}

View File

@ -5,7 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
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.models.Manga
import eu.kanade.tachiyomi.databinding.MetadataViewControllerBinding
@ -68,7 +68,7 @@ class MetadataViewController : NucleusController<MetadataViewControllerBinding,
super.onViewCreated(view)
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)
binding.recycler.adapter = adapter
binding.recycler.setHasFixedSize(true)

View File

@ -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>

View File

@ -2,14 +2,21 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
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
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_margin="5dp"
style="@style/TextAppearance.Regular" />
android:layout_marginStart="8dp"
style="@style/TextAppearance.Regular.Body1.Secondary" />
</LinearLayout>