Show gallery ID
Fixed paging problem when tag searched made gallery info clickable
This commit is contained in:
@@ -39,7 +39,6 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.content
|
||||
import kotlinx.serialization.list
|
||||
import kotlinx.serialization.parseList
|
||||
import kotlinx.serialization.stringify
|
||||
import ru.noties.markwon.Markwon
|
||||
import xyz.quaver.hitomi.*
|
||||
@@ -116,6 +115,13 @@ class MainActivity : AppCompatActivity() {
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
if (cacheDir.exists())
|
||||
cacheDir.deleteRecursively()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
when {
|
||||
main_drawer_layout.isDrawerOpen(GravityCompat.START) -> main_drawer_layout.closeDrawer(GravityCompat.START)
|
||||
@@ -249,7 +255,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val msg = extractReleaseNote(update, Locale.getDefault().language)
|
||||
setMessage(Markwon.create(context).toMarkdown(msg))
|
||||
setPositiveButton(android.R.string.yes) { _, _ ->
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.home_page))))
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.update))))
|
||||
}
|
||||
setNegativeButton(android.R.string.no) { _, _ ->}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package xyz.quaver.pupil.adapters
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.util.Log
|
||||
@@ -7,6 +9,7 @@ import android.util.SparseBooleanArray
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.LinearLayout
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -23,6 +26,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
import kotlinx.serialization.list
|
||||
import xyz.quaver.hitomi.GalleryBlock
|
||||
import xyz.quaver.hitomi.ReaderItem
|
||||
import xyz.quaver.pupil.BuildConfig
|
||||
import xyz.quaver.pupil.Pupil
|
||||
import xyz.quaver.pupil.R
|
||||
import xyz.quaver.pupil.types.Tag
|
||||
@@ -64,7 +68,10 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
if (!File(cache).exists())
|
||||
return@launch
|
||||
|
||||
val bitmap = BitmapFactory.decodeFile(thumbnail.await())
|
||||
val bitmap = when {
|
||||
BuildConfig.DEBUG -> Bitmap.createScaledBitmap(BitmapFactory.decodeFile(thumbnail.await()), 5, 8, true)
|
||||
else -> BitmapFactory.decodeFile(thumbnail.await())
|
||||
}
|
||||
|
||||
post {
|
||||
galleryblock_thumbnail.setImageBitmap(bitmap)
|
||||
@@ -157,6 +164,19 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
artists.isNotEmpty() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
setOnClickListener {
|
||||
if (artists.size > 1) {
|
||||
AlertDialog.Builder(context).apply {
|
||||
setAdapter(ArrayAdapter(context, android.R.layout.select_dialog_item, artists)) { _, index ->
|
||||
for (callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("artist", artists[index]))
|
||||
}
|
||||
}.show()
|
||||
} else {
|
||||
for(callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("artist", artists.first()))
|
||||
}
|
||||
}
|
||||
}
|
||||
with(galleryblock_series) {
|
||||
text =
|
||||
@@ -167,8 +187,31 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
series.isNotEmpty() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
setOnClickListener {
|
||||
setOnClickListener {
|
||||
if (series.size > 1) {
|
||||
AlertDialog.Builder(context).apply {
|
||||
setAdapter(ArrayAdapter(context, android.R.layout.select_dialog_item, series)) { _, index ->
|
||||
for (callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("series", series[index]))
|
||||
}
|
||||
}.show()
|
||||
} else {
|
||||
for(callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("series", series.first()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
with(galleryblock_type) {
|
||||
text = resources.getString(R.string.galleryblock_type, gallery.type).wordCapitalize()
|
||||
setOnClickListener {
|
||||
setOnClickListener {
|
||||
for(callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("type", gallery.type))
|
||||
}
|
||||
}
|
||||
}
|
||||
galleryblock_type.text = resources.getString(R.string.galleryblock_type, gallery.type).wordCapitalize()
|
||||
with(galleryblock_language) {
|
||||
text =
|
||||
resources.getString(R.string.galleryblock_language, languages[gallery.language])
|
||||
@@ -176,11 +219,22 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
gallery.language.isNotEmpty() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
setOnClickListener {
|
||||
setOnClickListener {
|
||||
for(callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("language", gallery.language))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
galleryblock_tag_group.removeAllViews()
|
||||
gallery.relatedTags.forEach {
|
||||
val tag = Tag.parse(it)
|
||||
val tag = Tag.parse(it).let { tag ->
|
||||
when {
|
||||
tag.area != null -> tag
|
||||
else -> Tag("tag", it)
|
||||
}
|
||||
}
|
||||
|
||||
val chip = LayoutInflater.from(context)
|
||||
.inflate(R.layout.tag_chip, this, false) as Chip
|
||||
@@ -209,6 +263,8 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
galleryblock_tag_group.addView(chip)
|
||||
}
|
||||
|
||||
galleryblock_id.text = gallery.id.toString()
|
||||
|
||||
if (!::favorites.isInitialized)
|
||||
favorites = (context.applicationContext as Pupil).favorites
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import xyz.quaver.pupil.BuildConfig
|
||||
import xyz.quaver.pupil.R
|
||||
|
||||
class ReaderAdapter(private val images: List<String>) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
||||
@@ -37,7 +38,10 @@ class ReaderAdapter(private val images: List<String>) : RecyclerView.Adapter<Rea
|
||||
|
||||
options.inJustDecodeBounds = false
|
||||
|
||||
val image = BitmapFactory.decodeFile(images[position], options)
|
||||
val image = when {
|
||||
BuildConfig.DEBUG -> Bitmap.createScaledBitmap(BitmapFactory.decodeFile(images[position], options), 5, 8, true)
|
||||
else -> BitmapFactory.decodeFile(images[position], options)
|
||||
}
|
||||
|
||||
post { setImageBitmap(image) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user