mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-23 21:36:07 +03:00
Only compare major versions of API
This commit is contained in:
parent
e3e8b5614a
commit
071ee8228c
2 changed files with 7 additions and 15 deletions
|
@ -32,16 +32,12 @@ public class ApiVersion implements Comparable<ApiVersion> {
|
|||
return minor;
|
||||
}
|
||||
|
||||
public boolean isGreaterOrEqualTo(ApiVersion v) {
|
||||
return compareTo(v) >= 0;
|
||||
}
|
||||
|
||||
public String getOriginalVersion() {
|
||||
return originalVersion;
|
||||
}
|
||||
|
||||
public static ApiVersion of(String versionString) {
|
||||
int major = 0, minor = 0, micro = 0;
|
||||
int major = 0, minor = 0;
|
||||
if (versionString != null) {
|
||||
String[] split = versionString.split("\\.");
|
||||
if (split.length > 0) {
|
||||
|
@ -64,9 +60,9 @@ public class ApiVersion implements Comparable<ApiVersion> {
|
|||
|
||||
/**
|
||||
* @param compare another version object
|
||||
* @return -1 if the compared version is <strong>higher</strong> than the current version
|
||||
* 0 if the compared version is equal to the current version
|
||||
* 1 if the compared version is <strong>lower</strong> than the current version
|
||||
* @return -1 if the compared major version is <strong>higher</strong> than the current major version
|
||||
* 0 if the compared major version is equal to the current major version
|
||||
* 1 if the compared major version is <strong>lower</strong> than the current major version
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(ApiVersion compare) {
|
||||
|
@ -74,10 +70,6 @@ public class ApiVersion implements Comparable<ApiVersion> {
|
|||
return -1;
|
||||
} else if (compare.getMajor() < getMajor()) {
|
||||
return 1;
|
||||
} else if (compare.getMinor() > getMinor()) {
|
||||
return -1;
|
||||
} else if (compare.getMinor() < getMinor()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ import androidx.annotation.Nullable;
|
|||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import it.niedermann.owncloud.notes.persistence.NotesClient;
|
||||
|
@ -87,12 +87,12 @@ public class LocalAccount {
|
|||
public void setPreferredApiVersion(@Nullable String availableApiVersions) {
|
||||
// TODO move this logic to NotesClient?
|
||||
try {
|
||||
if(availableApiVersions == null) {
|
||||
if (availableApiVersions == null) {
|
||||
this.preferredApiVersion = null;
|
||||
return;
|
||||
}
|
||||
JSONArray versionsArray = new JSONArray(availableApiVersions);
|
||||
Collection<ApiVersion> supportedApiVersions = new ArrayList<>(versionsArray.length());
|
||||
Collection<ApiVersion> supportedApiVersions = new HashSet<>(versionsArray.length());
|
||||
for (int i = 0; i < versionsArray.length(); i++) {
|
||||
ApiVersion parsedApiVersion = ApiVersion.of(versionsArray.getString(i));
|
||||
for (ApiVersion temp : NotesClient.SUPPORTED_API_VERSIONS) {
|
||||
|
|
Loading…
Reference in a new issue