Reader
parent
d46bbda0d0
commit
82fda9394d
@ -0,0 +1,36 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.common
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import androidx.annotation.LayoutRes
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
|
||||||
|
abstract class AlertDialogFragment(@LayoutRes private val layoutResId: Int) : DialogFragment() {
|
||||||
|
|
||||||
|
private var rootView: View? = null
|
||||||
|
|
||||||
|
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val view = activity?.layoutInflater?.inflate(layoutResId, null)
|
||||||
|
rootView = view
|
||||||
|
if (view != null) {
|
||||||
|
onViewCreated(view, savedInstanceState)
|
||||||
|
}
|
||||||
|
return AlertDialog.Builder(requireContext(), theme)
|
||||||
|
.setView(view)
|
||||||
|
.also(::onBuildDialog)
|
||||||
|
.create()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
rootView = null
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getView(): View? {
|
||||||
|
return rootView
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun onBuildDialog(builder: AlertDialog.Builder) = Unit
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import kotlinx.android.synthetic.main.dialog_chapters.*
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaChapter
|
||||||
|
import org.koitharu.kotatsu.ui.common.AlertDialogFragment
|
||||||
|
import org.koitharu.kotatsu.ui.common.list.OnRecyclerItemClickListener
|
||||||
|
import org.koitharu.kotatsu.ui.details.ChaptersAdapter
|
||||||
|
import org.koitharu.kotatsu.utils.ext.withArgs
|
||||||
|
|
||||||
|
class ChaptersDialog : AlertDialogFragment(R.layout.dialog_chapters), OnRecyclerItemClickListener<MangaChapter> {
|
||||||
|
|
||||||
|
override fun onBuildDialog(builder: AlertDialog.Builder) {
|
||||||
|
builder.setTitle(R.string.chapters)
|
||||||
|
.setNegativeButton(R.string.close, null)
|
||||||
|
.setCancelable(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
recyclerView_chapters.addItemDecoration(DividerItemDecoration(requireContext(), RecyclerView.VERTICAL))
|
||||||
|
recyclerView_chapters.adapter = ChaptersAdapter(this).apply {
|
||||||
|
arguments?.getParcelableArrayList<MangaChapter>(ARG_CHAPTERS)?.let(this::replaceData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClick(item: MangaChapter, position: Int, view: View) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private const val TAG = "ChaptersDialog"
|
||||||
|
|
||||||
|
private const val ARG_CHAPTERS = "chapters"
|
||||||
|
|
||||||
|
fun show(fm: FragmentManager, chapters: List<MangaChapter>) = ChaptersDialog()
|
||||||
|
.withArgs(1) {
|
||||||
|
putParcelableArrayList(ARG_CHAPTERS, ArrayList(chapters))
|
||||||
|
}.show(fm, TAG)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||||
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
|
import kotlinx.android.synthetic.main.item_page.*
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaPage
|
||||||
|
import org.koitharu.kotatsu.ui.common.list.BaseViewHolder
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
|
|
||||||
|
class PageHolder(parent: ViewGroup, private val loader: PageLoader) : BaseViewHolder<MangaPage>(parent, R.layout.item_page),
|
||||||
|
SubsamplingScaleImageView.OnImageEventListener {
|
||||||
|
|
||||||
|
init {
|
||||||
|
ssiv.setOnImageEventListener(this)
|
||||||
|
button_retry.setOnClickListener {
|
||||||
|
onBind(boundData ?: return@setOnClickListener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(data: MangaPage) {
|
||||||
|
layout_error.isVisible = false
|
||||||
|
progressBar.show()
|
||||||
|
ssiv.recycle()
|
||||||
|
loader.load(data.url) {
|
||||||
|
ssiv.setImage(ImageSource.uri(it.toUri()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReady() {
|
||||||
|
progressBar.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onImageLoadError(e: Exception) {
|
||||||
|
textView_error.text = e.getDisplayMessage(context.resources)
|
||||||
|
layout_error.isVisible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onImageLoaded() = Unit
|
||||||
|
|
||||||
|
override fun onTileLoadError(e: Exception?) = Unit
|
||||||
|
|
||||||
|
override fun onPreviewReleased() = Unit
|
||||||
|
|
||||||
|
override fun onPreviewLoadError(e: Exception?) = Unit
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.LongSparseArray
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import org.koin.core.KoinComponent
|
||||||
|
import org.koin.core.inject
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaPage
|
||||||
|
import org.koitharu.kotatsu.utils.ext.await
|
||||||
|
import org.koitharu.kotatsu.utils.ext.longHashCode
|
||||||
|
import java.io.Closeable
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
|
class PageLoader(context: Context) : KoinComponent, CoroutineScope, DisposableHandle {
|
||||||
|
|
||||||
|
private val job = SupervisorJob()
|
||||||
|
private val tasks = HashMap<String, Job>()
|
||||||
|
private val okHttp by inject<OkHttpClient>()
|
||||||
|
private val cacheDir = File(context.externalCacheDir ?: context.cacheDir, "pages")
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (!cacheDir.exists()) {
|
||||||
|
cacheDir.mkdir()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val coroutineContext: CoroutineContext
|
||||||
|
get() = Dispatchers.Main + job
|
||||||
|
|
||||||
|
fun load(url: String, callback: (File) -> Unit) = launch {
|
||||||
|
val result = withContext(Dispatchers.IO) {
|
||||||
|
loadFile(url, false)
|
||||||
|
}
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun loadFile(url: String, force: Boolean): File {
|
||||||
|
val file = File(cacheDir, url.longHashCode().toString())
|
||||||
|
if (!force && file.exists()) {
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.get()
|
||||||
|
.build()
|
||||||
|
okHttp.newCall(request).await().use { response ->
|
||||||
|
file.outputStream().use { out ->
|
||||||
|
response.body!!.byteStream().copyTo(out)
|
||||||
|
}
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
coroutineContext.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaPage
|
||||||
|
import org.koitharu.kotatsu.ui.common.list.BaseRecyclerAdapter
|
||||||
|
import org.koitharu.kotatsu.ui.common.list.BaseViewHolder
|
||||||
|
|
||||||
|
class PagesAdapter(private val loader: PageLoader) : BaseRecyclerAdapter<MangaPage>() {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup) = PageHolder(parent, loader)
|
||||||
|
|
||||||
|
override fun onGetItemId(item: MangaPage) = item.id
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import kotlinx.android.synthetic.main.activity_reader.*
|
||||||
|
import moxy.ktx.moxyPresenter
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.core.model.Manga
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaChapter
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaPage
|
||||||
|
import org.koitharu.kotatsu.ui.common.BaseActivity
|
||||||
|
import org.koitharu.kotatsu.utils.ext.showDialog
|
||||||
|
|
||||||
|
class ReaderActivity : BaseActivity(), ReaderView {
|
||||||
|
|
||||||
|
private val presenter by moxyPresenter { ReaderPresenter() }
|
||||||
|
|
||||||
|
private val manga by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
|
intent.getParcelableExtra<Manga>(EXTRA_MANGA)!!
|
||||||
|
}
|
||||||
|
private val chapterId by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
|
intent.getLongExtra(EXTRA_CHAPTER_ID, 0L)
|
||||||
|
}
|
||||||
|
|
||||||
|
private lateinit var loader: PageLoader
|
||||||
|
private lateinit var adapter: PagesAdapter
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_reader)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
bottomBar.inflateMenu(R.menu.opt_reader_bottom)
|
||||||
|
|
||||||
|
val chapter = manga.chapters?.find { x -> x.id == chapterId }
|
||||||
|
if (chapter == null) {
|
||||||
|
// TODO
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
title = chapter.name
|
||||||
|
manga.chapters?.run {
|
||||||
|
supportActionBar?.subtitle = getString(R.string.chapter_d_of_d, chapter.number, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
loader = PageLoader(this)
|
||||||
|
adapter = PagesAdapter(loader)
|
||||||
|
pager.adapter = adapter
|
||||||
|
presenter.loadChapter(chapter)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
loader.dispose()
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.opt_reader_top, menu)
|
||||||
|
return super.onCreateOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem) = when(item.itemId) {
|
||||||
|
R.id.action_chapters -> {
|
||||||
|
ChaptersDialog.show(supportFragmentManager, manga.chapters.orEmpty())
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPagesReady(pages: List<MangaPage>) {
|
||||||
|
adapter.replaceData(pages)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLoadingStateChanged(isLoading: Boolean) {
|
||||||
|
layout_loading.isVisible = isLoading
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Exception) {
|
||||||
|
showDialog {
|
||||||
|
setTitle(R.string.error_occurred)
|
||||||
|
setMessage(e.message)
|
||||||
|
setPositiveButton(R.string.close, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private const val EXTRA_MANGA = "manga"
|
||||||
|
private const val EXTRA_CHAPTER_ID = "chapter_id"
|
||||||
|
|
||||||
|
fun newIntent(context: Context, manga: Manga, chapterId: Long) = Intent(context, ReaderActivity::class.java)
|
||||||
|
.putExtra(EXTRA_MANGA, manga)
|
||||||
|
.putExtra(EXTRA_CHAPTER_ID, chapterId)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import moxy.InjectViewState
|
||||||
|
import org.koitharu.kotatsu.BuildConfig
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaChapter
|
||||||
|
import org.koitharu.kotatsu.domain.MangaProviderFactory
|
||||||
|
import org.koitharu.kotatsu.ui.common.BasePresenter
|
||||||
|
|
||||||
|
@InjectViewState
|
||||||
|
class ReaderPresenter() : BasePresenter<ReaderView>() {
|
||||||
|
|
||||||
|
fun loadChapter(chapter: MangaChapter) {
|
||||||
|
launch {
|
||||||
|
viewState.onLoadingStateChanged(isLoading = true)
|
||||||
|
try {
|
||||||
|
val pages = withContext(Dispatchers.IO) {
|
||||||
|
MangaProviderFactory.create(chapter.source).getPages(chapter)
|
||||||
|
}
|
||||||
|
viewState.onPagesReady(pages)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
viewState.onError(e)
|
||||||
|
} finally {
|
||||||
|
viewState.onLoadingStateChanged(isLoading = false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader
|
||||||
|
|
||||||
|
import moxy.MvpView
|
||||||
|
import moxy.viewstate.strategy.AddToEndSingleStrategy
|
||||||
|
import moxy.viewstate.strategy.OneExecutionStateStrategy
|
||||||
|
import moxy.viewstate.strategy.StateStrategyType
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaPage
|
||||||
|
|
||||||
|
interface ReaderView : MvpView {
|
||||||
|
|
||||||
|
@StateStrategyType(AddToEndSingleStrategy::class)
|
||||||
|
fun onPagesReady(pages: List<MangaPage>)
|
||||||
|
|
||||||
|
@StateStrategyType(AddToEndSingleStrategy::class)
|
||||||
|
fun onLoadingStateChanged(isLoading: Boolean)
|
||||||
|
|
||||||
|
@StateStrategyType(OneExecutionStateStrategy::class)
|
||||||
|
fun onError(e: Exception)
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package org.koitharu.kotatsu.utils.ext
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
|
||||||
|
fun Context.showDialog(block: AlertDialog.Builder.() -> Unit): AlertDialog {
|
||||||
|
return AlertDialog.Builder(this)
|
||||||
|
.apply(block)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<vector
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?android:textColorPrimary"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M7,10l5,5 5,-5z" />
|
||||||
|
</vector>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<vector
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:tint="@color/error"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
|
||||||
|
</vector>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<vector
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z" />
|
||||||
|
</vector>
|
||||||
@ -1,14 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:tint="?attr/colorControlNormal"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<group>
|
|
||||||
<clip-path android:pathData="M0,0h24v24H0V0z M 0,0" />
|
|
||||||
<path
|
|
||||||
android:fillColor="@android:color/white"
|
|
||||||
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4V6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z" />
|
|
||||||
</group>
|
|
||||||
</vector>
|
|
||||||
|
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.google.android.material.circularreveal.CircularRevealFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/dim"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light" />
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/bottomBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:background="@color/dim"
|
||||||
|
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_loading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView_loading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/loading_"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.circularreveal.CircularRevealFrameLayout>
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/recyclerView_chapters"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_chapter" />
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
|
android:id="@+id/ssiv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<androidx.core.widget.ContentLoadingProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginStart="60dp"
|
||||||
|
android:layout_marginEnd="60dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:id="@+id/layout_error" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:drawableTop="@drawable/ic_error_large"
|
||||||
|
android:id="@+id/textView_error"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
tools:text="@tools:sample/lorem[6]"
|
||||||
|
android:drawablePadding="12dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_retry"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
|
android:text="@string/try_again" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
</menu>
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_chapters"
|
||||||
|
android:icon="@drawable/ic_drop_down"
|
||||||
|
android:title="@string/chapters"
|
||||||
|
android:orderInCategory="0"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
</menu>
|
||||||
@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#0288D1</color>
|
<color name="primary">#0288D1</color>
|
||||||
<color name="colorPrimaryDark">#0D47A1</color>
|
<color name="primary_dark">#0D47A1</color>
|
||||||
<color name="colorAccent">#F4511E</color>
|
<color name="accent">#F4511E</color>
|
||||||
|
<color name="dim">#99000000</color>
|
||||||
|
<color name="error">#D32F2F</color>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue