use of com.odysee.app.model.ClaimCacheKey in project odysee-android by OdyseeTeam.
the class Lbry method get.
public static LbryFile get(boolean saveFile) throws ApiCallException {
LbryFile file = null;
Map<String, Object> params = new HashMap<>();
params.put("save_file", saveFile);
try {
JSONObject result = (JSONObject) parseResponse(apiCall(METHOD_GET, params));
file = LbryFile.fromJSONObject(result);
if (file != null) {
String fileClaimId = file.getClaimId();
if (!Helper.isNullOrEmpty(fileClaimId)) {
ClaimCacheKey key = new ClaimCacheKey();
key.setClaimId(fileClaimId);
if (claimCache.containsKey(key)) {
claimCache.get(key).setFile(file);
}
}
}
} catch (LbryRequestException | LbryResponseException ex) {
throw new ApiCallException("Could not execute resolve call", ex);
}
return file;
}
use of com.odysee.app.model.ClaimCacheKey in project odysee-android by OdyseeTeam.
the class Lbry method addClaimToCache.
public static void addClaimToCache(Claim claim) {
ClaimCacheKey fullKey = ClaimCacheKey.fromClaim(claim);
ClaimCacheKey shortUrlKey = ClaimCacheKey.fromClaimShortUrl(claim);
ClaimCacheKey permanentUrlKey = ClaimCacheKey.fromClaimPermanentUrl(claim);
if (!Helper.isNullOrEmpty(fullKey.getUrl())) {
claimCache.put(fullKey, claim);
}
if (!Helper.isNullOrEmpty(permanentUrlKey.getUrl())) {
claimCache.put(permanentUrlKey, claim);
}
if (!Helper.isNullOrEmpty(shortUrlKey.getUrl())) {
claimCache.put(shortUrlKey, claim);
}
}
use of com.odysee.app.model.ClaimCacheKey in project odysee-android by OdyseeTeam.
the class SearchFragment method resolveFeaturedItem.
private void resolveFeaturedItem(String vanityUrl) {
final ClaimCacheKey key = new ClaimCacheKey();
key.setUrl(vanityUrl);
if (Lbry.claimCache.containsKey(key)) {
Claim cachedClaim = Lbry.claimCache.get(key);
updateFeaturedItemFromResolvedClaim(cachedClaim);
return;
}
ResolveTask task = new ResolveTask(vanityUrl, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (claims.size() > 0 && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
Claim resolved = claims.get(0);
Lbry.claimCache.put(key, resolved);
updateFeaturedItemFromResolvedClaim(resolved);
}
}
@Override
public void onError(Exception error) {
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations