Fix no hits found
This commit is contained in:
1 parent
e9f51e2b1f
commit
f589124cc8
3 files changed
+32
-5
No files matched your search
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.hippo.ehviewer.client;
|
||||
|
||||
/**
|
||||
* The exception about EH
|
||||
*/
|
||||
public class EhException extends Exception {
|
||||
|
||||
public EhException(String detailMessage) {
|
||||
|
||||
@@ -34,14 +34,11 @@ public class GalleryListParser {
|
||||
|
||||
public static class Result {
|
||||
|
||||
public static final int NOT_FOUND = 0;
|
||||
|
||||
public static final int CURRENT_PAGE_IS_LAST = -1;
|
||||
|
||||
public static final int KEEP_LOADING = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* If NOT FOUND, pageNum is 0.<br>
|
||||
* For lofi, we can not get pages number,
|
||||
* so pageNum is {@link java.lang.Integer#MAX_VALUE} when it is not the last page,
|
||||
* pageNum is {@link #CURRENT_PAGE_IS_LAST} when it is the last page
|
||||
@@ -74,7 +71,7 @@ public class GalleryListParser {
|
||||
if (m.find()) {
|
||||
result.pages = ParserUtils.parseInt(m.group(1));
|
||||
} else if (body.contains("No hits found</p>")) {
|
||||
result.pages = Result.NOT_FOUND;
|
||||
throw new NotFoundException();
|
||||
} else {
|
||||
// Can not get page number
|
||||
throw new ParseException("Can't parse gallery list", body);
|
||||
@@ -187,7 +184,7 @@ public class GalleryListParser {
|
||||
|
||||
if (list.size() == 0) {
|
||||
if (body.contains("No hits found</div>")) {
|
||||
result.pages = Result.NOT_FOUND;
|
||||
throw new NotFoundException();
|
||||
} else if (body.contains("No more hits found</div>")) {
|
||||
throw new EhException("Index is out of range");
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.client;
|
||||
|
||||
/**
|
||||
* Get nothing in search
|
||||
*/
|
||||
public class NotFoundException extends EhException {
|
||||
|
||||
public NotFoundException() {
|
||||
super("Nobody here but us chickens!");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user