Show post gallery comment error
This commit is contained in:
1 parent
c81145d46e
commit
cc39e0dda3
3 files changed
+27
-1
No files matched your search
@@ -55,6 +55,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -391,6 +392,12 @@ public class EhEngine {
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
Document document = Jsoup.parse(body);
|
||||
|
||||
Elements elements = document.select("#chd + p");
|
||||
if (elements.size() > 0) {
|
||||
throw new EhException(elements.get(0).text());
|
||||
}
|
||||
|
||||
return GalleryDetailParser.parseComments(document);
|
||||
} catch (Exception e) {
|
||||
throwException(call, code, headers, body, e);
|
||||
|
||||
@@ -40,6 +40,14 @@ public abstract class EhCallback<E extends SceneFragment, T> implements EhClient
|
||||
|
||||
public abstract boolean isInstance(SceneFragment scene);
|
||||
|
||||
public Context getContent() {
|
||||
Context context = getStageActivity();
|
||||
if (context == null) {
|
||||
context = getApplication();
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
public EhApplication getApplication() {
|
||||
return mApplication;
|
||||
}
|
||||
@@ -71,4 +79,14 @@ public abstract class EhCallback<E extends SceneFragment, T> implements EhClient
|
||||
length == BaseScene.LENGTH_LONG ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void showTip(String tip, int length) {
|
||||
StageActivity activity = getStageActivity();
|
||||
if (activity instanceof MainActivity) {
|
||||
((MainActivity) activity).showTip(tip, length);
|
||||
} else {
|
||||
Toast.makeText(getApplication(), tip,
|
||||
length == BaseScene.LENGTH_LONG ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,7 @@ import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.util.TextUrl;
|
||||
import com.hippo.view.ViewTransition;
|
||||
@@ -737,7 +738,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(R.string.comment_failed, LENGTH_SHORT);
|
||||
showTip(getContent().getString(R.string.comment_failed) + "\n" + ExceptionUtils.getReadableString(e), LENGTH_SHORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user