Add error message support for reader, Resolve #788

This commit is contained in:
tarsin committed 2023-02-14 12:33:33 +08:00
1 parent 8dcf5a3654
commit a6f1e91747
7 files changed
+15 -9

No files matched your search

@@ -293,7 +293,7 @@ public class ArchivePageLoader extends PageLoader2 {
// Check index valid
if (index < 0 || index >= size) {
notifyPageFailed(index);
notifyPageFailed(index, null);
continue;
}
@@ -343,7 +343,7 @@ public class ArchivePageLoader extends PageLoader2 {
if (image != null) {
notifyPageSucceed(index, image);
} else {
notifyPageFailed(index);
notifyPageFailed(index, null);
}
}
}
@@ -127,8 +127,8 @@ public class EhPageLoader extends PageLoader2 implements SpiderQueen.OnSpiderLis
Object object = mSpiderQueen.request(index);
if (object instanceof Float) {
notifyPagePercent(index, (Float) object);
} else if (object instanceof String) {
notifyPageFailed(index);
} else if (object instanceof String error) {
notifyPageFailed(index, error);
} else if (object == null) {
notifyPageWait(index);
}
@@ -141,8 +141,8 @@ public class EhPageLoader extends PageLoader2 implements SpiderQueen.OnSpiderLis
Object object = mSpiderQueen.forceRequest(index);
if (object instanceof Float) {
notifyPagePercent(index, (Float) object);
} else if (object instanceof String) {
notifyPageFailed(index);
} else if (object instanceof String error) {
notifyPageFailed(index, error);
} else if (object == null) {
notifyPageWait(index);
}
@@ -191,7 +191,7 @@ public class EhPageLoader extends PageLoader2 implements SpiderQueen.OnSpiderLis
@Override
public void onPageFailure(int index, String error, int finished, int downloaded, int total) {
notifyPageFailed(index);
notifyPageFailed(index, error);
}
@Override
@@ -205,7 +205,7 @@ public class EhPageLoader extends PageLoader2 implements SpiderQueen.OnSpiderLis
@Override
public void onGetImageFailure(int index, String error) {
notifyPageFailed(index);
notifyPageFailed(index, error);
}
@Override
@@ -10,6 +10,8 @@ open class Page(val index: Int) {
var status = MutableStateFlow(State.QUEUE)
var errorMsg: String? = null
private val _progressFlow = MutableStateFlow(0)
val progressFlow = _progressFlow.asStateFlow()
@@ -89,7 +89,8 @@ abstract class PageLoader {
mPages[index].status.value = Page.State.READY
}
fun notifyPageFailed(index: Int) {
fun notifyPageFailed(index: Int, error: String?) {
mPages[index].errorMsg = error
mPages[index].status.value = Page.State.ERROR
}
@@ -205,6 +205,7 @@ class PagerPageHolder(
viewer.activity.mGalleryProvider?.retryPage(page)
}
}
page.errorMsg?.let { errorLayout!!.errorMessage.text = it }
errorLayout?.root?.isVisible = true
return errorLayout!!
}
@@ -255,6 +255,7 @@ class WebtoonPageHolder(
viewer.activity.mGalleryProvider?.retryPage(page!!)
}
}
page?.errorMsg?.let { errorLayout!!.errorMessage.text = it }
return errorLayout!!
}
+1
View File
@@ -7,6 +7,7 @@
android:gravity="center">
<TextView
android:id="@+id/error_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"