Check if releasesList is empty (#2183)
When deserializing with Gson, non-existent blocks are assigned to null https://github.com/google/gson/issues/513
This commit is contained in:
parent
4c6d748be3
commit
993c429f90
|
|
@ -209,9 +209,9 @@ public class RepoLoader {
|
||||||
if (module != null) {
|
if (module != null) {
|
||||||
releases = module.getReleases();
|
releases = module.getReleases();
|
||||||
if (!module.releasesLoaded) {
|
if (!module.releasesLoaded) {
|
||||||
if (channel.equals(channels[1]) && !module.getBetaReleases().isEmpty()) {
|
if (channel.equals(channels[1]) && !(module.getBetaReleases() != null && module.getBetaReleases().isEmpty())) {
|
||||||
releases = module.getBetaReleases();
|
releases = module.getBetaReleases();
|
||||||
} else if (channel.equals(channels[2]) && !module.getSnapshotReleases().isEmpty())
|
} else if (channel.equals(channels[2]) && !(module.getSnapshotReleases() != null && module.getSnapshotReleases().isEmpty()))
|
||||||
releases = module.getSnapshotReleases();
|
releases = module.getSnapshotReleases();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
package org.lsposed.manager.repo.model;
|
package org.lsposed.manager.repo.model;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
|
@ -32,6 +34,7 @@ public class Collaborator {
|
||||||
@Expose
|
@Expose
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getLogin() {
|
public String getLogin() {
|
||||||
return login;
|
return login;
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +43,7 @@ public class Collaborator {
|
||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ public class OnlineModule {
|
||||||
private Integer stargazerCount;
|
private Integer stargazerCount;
|
||||||
public boolean releasesLoaded = false;
|
public boolean releasesLoaded = false;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
@ -112,6 +113,7 @@ public class OnlineModule {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +122,7 @@ public class OnlineModule {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +131,7 @@ public class OnlineModule {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getHomepageUrl() {
|
public String getHomepageUrl() {
|
||||||
return homepageUrl;
|
return homepageUrl;
|
||||||
}
|
}
|
||||||
|
|
@ -136,6 +140,7 @@ public class OnlineModule {
|
||||||
this.homepageUrl = homepageUrl;
|
this.homepageUrl = homepageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<Collaborator> getCollaborators() {
|
public List<Collaborator> getCollaborators() {
|
||||||
return collaborators;
|
return collaborators;
|
||||||
}
|
}
|
||||||
|
|
@ -144,10 +149,12 @@ public class OnlineModule {
|
||||||
this.collaborators = collaborators;
|
this.collaborators = collaborators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<Release> getReleases() {
|
public List<Release> getReleases() {
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getLatestReleaseTime() {
|
public String getLatestReleaseTime() {
|
||||||
return latestReleaseTime;
|
return latestReleaseTime;
|
||||||
}
|
}
|
||||||
|
|
@ -156,6 +163,7 @@ public class OnlineModule {
|
||||||
this.releases = releases;
|
this.releases = releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getReadme() {
|
public String getReadme() {
|
||||||
return readme;
|
return readme;
|
||||||
}
|
}
|
||||||
|
|
@ -164,6 +172,7 @@ public class OnlineModule {
|
||||||
this.readme = readme;
|
this.readme = readme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getReadmeHTML() {
|
public String getReadmeHTML() {
|
||||||
return readmeHTML;
|
return readmeHTML;
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +181,7 @@ public class OnlineModule {
|
||||||
this.readmeHTML = readmeHTML;
|
this.readmeHTML = readmeHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
@ -181,6 +190,7 @@ public class OnlineModule {
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<String> getScope() {
|
public List<String> getScope() {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +199,7 @@ public class OnlineModule {
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getSourceUrl() {
|
public String getSourceUrl() {
|
||||||
return sourceUrl;
|
return sourceUrl;
|
||||||
}
|
}
|
||||||
|
|
@ -205,6 +216,7 @@ public class OnlineModule {
|
||||||
this.hide = hide;
|
this.hide = hide;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<Object> getAdditionalAuthors() {
|
public List<Object> getAdditionalAuthors() {
|
||||||
return additionalAuthors;
|
return additionalAuthors;
|
||||||
}
|
}
|
||||||
|
|
@ -213,6 +225,7 @@ public class OnlineModule {
|
||||||
this.additionalAuthors = additionalAuthors;
|
this.additionalAuthors = additionalAuthors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getUpdatedAt() {
|
public String getUpdatedAt() {
|
||||||
return updatedAt;
|
return updatedAt;
|
||||||
}
|
}
|
||||||
|
|
@ -221,6 +234,7 @@ public class OnlineModule {
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getCreatedAt() {
|
public String getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
@ -229,6 +243,7 @@ public class OnlineModule {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Integer getStargazerCount() {
|
public Integer getStargazerCount() {
|
||||||
return stargazerCount;
|
return stargazerCount;
|
||||||
}
|
}
|
||||||
|
|
@ -237,6 +252,7 @@ public class OnlineModule {
|
||||||
this.stargazerCount = stargazerCount;
|
this.stargazerCount = stargazerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getLatestRelease() {
|
public String getLatestRelease() {
|
||||||
return latestRelease;
|
return latestRelease;
|
||||||
}
|
}
|
||||||
|
|
@ -265,10 +281,12 @@ public class OnlineModule {
|
||||||
return latestSnapshotReleaseTime;
|
return latestSnapshotReleaseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<Release> getBetaReleases() {
|
public List<Release> getBetaReleases() {
|
||||||
return betaReleases;
|
return betaReleases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<Release> getSnapshotReleases() {
|
public List<Release> getSnapshotReleases() {
|
||||||
return snapshotReleases;
|
return snapshotReleases;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
package org.lsposed.manager.repo.model;
|
package org.lsposed.manager.repo.model;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
|
@ -59,6 +61,7 @@ public class Release {
|
||||||
@Expose
|
@Expose
|
||||||
private List<ReleaseAsset> releaseAssets = new ArrayList<>();
|
private List<ReleaseAsset> releaseAssets = new ArrayList<>();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +70,7 @@ public class Release {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +79,7 @@ public class Release {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +88,7 @@ public class Release {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDescriptionHTML() {
|
public String getDescriptionHTML() {
|
||||||
return descriptionHTML;
|
return descriptionHTML;
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +97,7 @@ public class Release {
|
||||||
this.descriptionHTML = descriptionHTML;
|
this.descriptionHTML = descriptionHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getCreatedAt() {
|
public String getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +106,7 @@ public class Release {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getPublishedAt() {
|
public String getPublishedAt() {
|
||||||
return publishedAt;
|
return publishedAt;
|
||||||
}
|
}
|
||||||
|
|
@ -107,6 +115,7 @@ public class Release {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getUpdatedAt() {
|
public String getUpdatedAt() {
|
||||||
return updatedAt;
|
return updatedAt;
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +124,7 @@ public class Release {
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getTagName() {
|
public String getTagName() {
|
||||||
return tagName;
|
return tagName;
|
||||||
}
|
}
|
||||||
|
|
@ -123,6 +133,7 @@ public class Release {
|
||||||
this.tagName = tagName;
|
this.tagName = tagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Boolean getIsPrerelease() {
|
public Boolean getIsPrerelease() {
|
||||||
return isPrerelease;
|
return isPrerelease;
|
||||||
}
|
}
|
||||||
|
|
@ -131,6 +142,7 @@ public class Release {
|
||||||
this.isPrerelease = isPrerelease;
|
this.isPrerelease = isPrerelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public List<ReleaseAsset> getReleaseAssets() {
|
public List<ReleaseAsset> getReleaseAssets() {
|
||||||
return releaseAssets;
|
return releaseAssets;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
package org.lsposed.manager.repo.model;
|
package org.lsposed.manager.repo.model;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
|
@ -35,6 +37,7 @@ public class ReleaseAsset {
|
||||||
@Expose
|
@Expose
|
||||||
private String downloadUrl;
|
private String downloadUrl;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
@ -43,6 +46,7 @@ public class ReleaseAsset {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return contentType;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +55,7 @@ public class ReleaseAsset {
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDownloadUrl() {
|
public String getDownloadUrl() {
|
||||||
return downloadUrl;
|
return downloadUrl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,7 @@ public class RepoFragment extends BaseFragment implements RepoLoader.RepoListene
|
||||||
int sort = App.getPreferences().getInt("repo_sort", 0);
|
int sort = App.getPreferences().getInt("repo_sort", 0);
|
||||||
boolean upgradableFirst = App.getPreferences().getBoolean("upgradable_first", true);
|
boolean upgradableFirst = App.getPreferences().getBoolean("upgradable_first", true);
|
||||||
ConcurrentHashMap<String, Boolean> upgradable = new ConcurrentHashMap<>();
|
ConcurrentHashMap<String, Boolean> upgradable = new ConcurrentHashMap<>();
|
||||||
fullList = modules.parallelStream().filter((onlineModule -> !onlineModule.isHide() && !onlineModule.getReleases().isEmpty()))
|
fullList = modules.parallelStream().filter((onlineModule -> !onlineModule.isHide() && !(onlineModule.getReleases() != null && onlineModule.getReleases().isEmpty())))
|
||||||
.sorted((a, b) -> {
|
.sorted((a, b) -> {
|
||||||
if (upgradableFirst) {
|
if (upgradableFirst) {
|
||||||
var aUpgrade = upgradable.computeIfAbsent(a.getName(), n -> getUpgradableVer(a) != null);
|
var aUpgrade = upgradable.computeIfAbsent(a.getName(), n -> getUpgradableVer(a) != null);
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
|
||||||
if (releaseAdapter != null) {
|
if (releaseAdapter != null) {
|
||||||
runAsync(releaseAdapter::loadItems);
|
runAsync(releaseAdapter::loadItems);
|
||||||
}
|
}
|
||||||
if (module.getReleases().size() == 1) {
|
if ((module.getReleases() != null ? module.getReleases().size() : 1) == 1) {
|
||||||
showHint(R.string.module_release_no_more, true);
|
showHint(R.string.module_release_no_more, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -282,13 +282,16 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
|
||||||
holder.title.setText(R.string.module_information_homepage);
|
holder.title.setText(R.string.module_information_homepage);
|
||||||
holder.description.setText(module.getHomepageUrl());
|
holder.description.setText(module.getHomepageUrl());
|
||||||
} else if (position == collaboratorsRow) {
|
} else if (position == collaboratorsRow) {
|
||||||
holder.title.setText(R.string.module_information_collaborators);
|
|
||||||
List<Collaborator> collaborators = module.getCollaborators();
|
List<Collaborator> collaborators = module.getCollaborators();
|
||||||
|
if (collaborators == null) return;
|
||||||
|
holder.title.setText(R.string.module_information_collaborators);
|
||||||
SpannableStringBuilder sb = new SpannableStringBuilder();
|
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||||
ListIterator<Collaborator> iterator = collaborators.listIterator();
|
ListIterator<Collaborator> iterator = collaborators.listIterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Collaborator collaborator = iterator.next();
|
Collaborator collaborator = iterator.next();
|
||||||
String name = collaborator.getName() == null ? collaborator.getLogin() : collaborator.getName();
|
var collaboratorLogin = collaborator.getLogin();
|
||||||
|
if (collaboratorLogin == null) continue;
|
||||||
|
String name = collaborator.getName() == null ? collaboratorLogin : collaborator.getName();
|
||||||
sb.append(name);
|
sb.append(name);
|
||||||
CustomTabsURLSpan span = new CustomTabsURLSpan(requireActivity(), String.format("https://github.com/%s", collaborator.getLogin()));
|
CustomTabsURLSpan span = new CustomTabsURLSpan(requireActivity(), String.format("https://github.com/%s", collaborator.getLogin()));
|
||||||
sb.setSpan(span, sb.length() - name.length(), sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
sb.setSpan(span, sb.length() - name.length(), sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
|
@ -374,16 +377,16 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
|
||||||
if (releases == null) releases = module.getReleases();
|
if (releases == null) releases = module.getReleases();
|
||||||
List<Release> tmpList;
|
List<Release> tmpList;
|
||||||
if (channel.equals(channels[0])) {
|
if (channel.equals(channels[0])) {
|
||||||
tmpList = releases.parallelStream().filter(t -> {
|
tmpList = releases != null ? releases.parallelStream().filter(t -> {
|
||||||
if (t.getIsPrerelease()) return false;
|
if (Boolean.TRUE.equals(t.getIsPrerelease())) return false;
|
||||||
var name = t.getName().toLowerCase(LocaleDelegate.getDefaultLocale());
|
var name = t.getName() != null ? t.getName().toLowerCase(LocaleDelegate.getDefaultLocale()) : null;
|
||||||
return !name.startsWith("snapshot") && !name.startsWith("nightly");
|
return !(name != null && name.startsWith("snapshot")) && !(name != null && name.startsWith("nightly"));
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList()) : null;
|
||||||
} else if (channel.equals(channels[1])) {
|
} else if (channel.equals(channels[1])) {
|
||||||
tmpList = releases.parallelStream().filter(t -> {
|
tmpList = releases != null ? releases.parallelStream().filter(t -> {
|
||||||
var name = t.getName().toLowerCase(LocaleDelegate.getDefaultLocale());
|
var name = t.getName() != null ? t.getName().toLowerCase(LocaleDelegate.getDefaultLocale()) : null;
|
||||||
return !name.startsWith("snapshot") && !name.startsWith("nightly");
|
return !(name != null && name.startsWith("snapshot")) && !(name != null && name.startsWith("nightly"));
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList()) : null;
|
||||||
} else tmpList = releases;
|
} else tmpList = releases;
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
items = tmpList;
|
items = tmpList;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue