Several design changes

This commit is contained in:
tom5079
2019-05-17 10:18:11 +09:00
parent 234f9b069a
commit 369fa679a6
11 changed files with 60 additions and 27 deletions

View File

@@ -1,6 +1,7 @@
package xyz.quaver.pupil
import android.os.Bundle
import android.util.Log
import android.view.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
@@ -255,7 +256,7 @@ class ReaderActivity : AppCompatActivity() {
menu?.findItem(R.id.reader_menu_page_indicator)?.title = "$currentPage/$gallerySize"
}
reader.chunked(8).forEach { chunked ->
reader.chunked(4).forEach { chunked ->
chunked.map {
async(Dispatchers.IO) {
val url = if (it.galleryInfo?.haswebp == 1) webpUrlFromUrl(it.url) else it.url

View File

@@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.cardview.widget.CardView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip
import kotlinx.android.synthetic.main.item_galleryblock.view.*
@@ -14,8 +15,8 @@ import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import xyz.quaver.hitomi.GalleryBlock
import xyz.quaver.hitomi.toTag
import xyz.quaver.pupil.R
import xyz.quaver.pupil.types.Tag
class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferred<String>>>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
@@ -110,11 +111,29 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
galleryblock_tag_group.removeAllViews()
gallery.relatedTags.forEach {
galleryblock_tag_group.addView(
Chip(context).apply {
text = it.toTag().wordCapitalize()
val tag = Tag.parse(it)
val chip = LayoutInflater
.from(context)
.inflate(R.layout.tag_chip, holder.view, false) as Chip
val icon = when(tag.area) {
"male" -> {
chip.setChipBackgroundColorResource(R.color.material_blue_100)
chip.setTextColor(ContextCompat.getColor(context, android.R.color.white))
ContextCompat.getDrawable(context, R.drawable.ic_gender_male_white)
}
)
"female" -> {
chip.setChipBackgroundColorResource(R.color.material_pink_100)
chip.setTextColor(ContextCompat.getColor(context, android.R.color.white))
ContextCompat.getDrawable(context, R.drawable.ic_gender_female_white)
}
else -> null
}
chip.chipIcon = icon
chip.text = Tag.parse(it).tag.wordCapitalize()
galleryblock_tag_group.addView(chip)
}
}
}

View File

@@ -2,7 +2,7 @@ package xyz.quaver.pupil.types
data class Tag(val area: String?, val tag: String, val isNegative: Boolean = false) {
companion object {
fun parseTag(tag: String) : Tag {
fun parse(tag: String) : Tag {
if (tag.first() == '-') {
tag.substring(1).split(Regex(":"), 2).let {
return when(it.size) {
@@ -49,7 +49,7 @@ class Tags(tag: List<Tag?>?) : ArrayList<Tag>() {
return Tags(
tags.split(' ').map {
if (it.isNotEmpty())
Tag.parseTag(it)
Tag.parse(it)
else
null
}
@@ -74,7 +74,7 @@ class Tags(tag: List<Tag?>?) : ArrayList<Tag>() {
}
fun add(element: String): Boolean {
return super.add(Tag.parseTag(element))
return super.add(Tag.parse(element))
}
fun remove(element: String) {