Fix rss request bug

This commit is contained in:
Shinokuni 2019-02-22 12:22:49 +00:00
parent ba4a0f0db0
commit 9e13b3aca0
2 changed files with 5 additions and 4 deletions

View File

@ -60,7 +60,7 @@ public class LocalFeedRepository extends ARepository implements QueryCallback {
if (feed.getLastModified() != null) if (feed.getLastModified() != null)
headers.put(LibUtils.IF_MODIFIED_HEADER, feed.getLastModified()); headers.put(LibUtils.IF_MODIFIED_HEADER, feed.getLastModified());
rssNet.request(feed.getUrl(), headers); rssNet.requestUrl(feed.getUrl(), headers);
} catch (Exception e) { } catch (Exception e) {
failureCallBackInMainThread(e); failureCallBackInMainThread(e);
} }
@ -76,7 +76,7 @@ public class LocalFeedRepository extends ARepository implements QueryCallback {
try { try {
RSSNetwork rssNet = new RSSNetwork(); RSSNetwork rssNet = new RSSNetwork();
rssNet.setCallback(this); rssNet.setCallback(this);
rssNet.request(result.getUrl(), new HashMap<>()); rssNet.requestUrl(result.getUrl(), new HashMap<>());
postCallBackSuccess(); postCallBackSuccess();
} catch (Exception e) { } catch (Exception e) {

View File

@ -40,7 +40,7 @@ public class RSSNetwork {
* @param url url to request * @param url url to request
* @throws Exception * @throws Exception
*/ */
public void request(String url, Map<String, String> headers) throws Exception { public void requestUrl(String url, Map<String, String> headers) throws Exception {
if (callback == null) if (callback == null)
throw new NullPointerException("Callback can't be null"); throw new NullPointerException("Callback can't be null");
@ -137,7 +137,8 @@ public class RSSNetwork {
if (contentType == RSSType.RSS_UNKNOWN) { if (contentType == RSSType.RSS_UNKNOWN) {
callback.onSyncFailure(new Exception("Unknown content format")); callback.onSyncFailure(new Exception("Unknown content format"));
return; return;
} } else
type = contentType;
} }
String etag = response.header(LibUtils.ETAG_HEADER); String etag = response.header(LibUtils.ETAG_HEADER);