fix publish release time and crash bug on publish form

This commit is contained in:
Akinwale Ariwodola 2020-05-28 03:22:20 +01:00
parent 3283b3a607
commit ddeb209d51
3 changed files with 18 additions and 1 deletions

View file

@ -44,7 +44,7 @@ public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
public int getItemPosition(Claim item) {
for (int i = 0; i < channels.size(); i++) {
Claim channel = channels.get(i);
if (item.getClaimId().equalsIgnoreCase(channel.getClaimId())) {
if (item.getClaimId() != null && item.getClaimId().equalsIgnoreCase(channel.getClaimId())) {
return i;
}
}

View file

@ -73,6 +73,14 @@ public class PublishClaimTask extends AsyncTask<Void, Void, Claim> {
options.put("license_url", metadata.getLicenseUrl());
}
if (metadata.getReleaseTime() > 0) {
options.put("release_time", metadata.getReleaseTime());
} else if (claim.getTimestamp() > 0) {
options.put("release_time", claim.getTimestamp());
} else {
options.put("release_time", Double.valueOf(Math.floor(System.currentTimeMillis() / 1000.0)).intValue());
}
Claim claimResult = null;
try {
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_PUBLISH, options);

View file

@ -1038,6 +1038,15 @@ public class PublishFormFragment extends BaseFragment implements
metadata.setLicenseUrl(selectedLicense.getUrl());
}
// set release time from current claim (on edit)
if (currentClaim != null) {
Claim.StreamMetadata currentMetadata = (Claim.StreamMetadata) currentClaim.getValue();
metadata.setReleaseTime(currentMetadata.getReleaseTime());
if (metadata.getReleaseTime() == 0) {
metadata.setReleaseTime(currentClaim.getTimestamp());
}
}
claim.setValueType(Claim.TYPE_STREAM);
claim.setValue(metadata);