use of net.dean.jraw.http.NetworkException in project Slide by ccrama.
the class UserSubscriptions method syncMultiReddits.
public static void syncMultiReddits(Context c) {
try {
multireddits = new ArrayList<>(new MultiRedditManager(Authentication.reddit).mine());
for (MultiReddit multiReddit : multireddits) {
if (MainActivity.multiNameToSubsMap.containsKey(ReorderSubreddits.MULTI_REDDIT + multiReddit.getDisplayName())) {
StringBuilder concatenatedSubs = new StringBuilder();
for (MultiSubreddit subreddit : multiReddit.getSubreddits()) {
concatenatedSubs.append(subreddit.getDisplayName());
concatenatedSubs.append("+");
}
MainActivity.multiNameToSubsMap.put(ReorderSubreddits.MULTI_REDDIT + multiReddit.getDisplayName(), concatenatedSubs.toString());
UserSubscriptions.setSubNameToProperties(ReorderSubreddits.MULTI_REDDIT + multiReddit.getDisplayName(), concatenatedSubs.toString());
}
}
} catch (ApiException e) {
e.printStackTrace();
} catch (NetworkException e) {
e.printStackTrace();
}
}
use of net.dean.jraw.http.NetworkException in project Slide by ccrama.
the class CommentCacheAsync method getSubmission.
public JsonNode getSubmission(SubmissionRequest request) throws NetworkException {
Map<String, String> args = new HashMap<>();
if (request.getDepth() != null)
args.put("depth", Integer.toString(request.getDepth()));
if (request.getContext() != null) {
args.put("context", Integer.toString(request.getContext()));
}
if (request.getLimit() != null)
args.put("limit", Integer.toString(request.getLimit()));
if (request.getFocus() != null && !JrawUtils.isFullname(request.getFocus())) {
args.put("comment", request.getFocus());
}
CommentSort sort = request.getSort();
if (sort == null) // Reddit sorts by confidence by default
{
sort = CommentSort.CONFIDENCE;
}
args.put("sort", sort.name().toLowerCase(Locale.ENGLISH));
try {
RestResponse response = Authentication.reddit.execute(Authentication.reddit.request().path(String.format("/comments/%s", request.getId())).query(args).build());
return response.getJson();
} catch (Exception e) {
return null;
}
}
Aggregations