mirror of
https://github.com/sparrowwallet/hummingbird.git
synced 2024-12-26 18:16:45 +00:00
add percent complete to legacyurdecoder, bump to 1.5.3
This commit is contained in:
parent
78c29d6eaa
commit
2b24027b16
3 changed files with 20 additions and 2 deletions
|
@ -11,7 +11,7 @@ It contains both the classes to represent a UR, and a UR encoder and decoder to
|
||||||
Hummingbird is hosted in Maven Central and can be added as a dependency with the following:
|
Hummingbird is hosted in Maven Central and can be added as a dependency with the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
implementation('com.sparrowwallet:hummingbird:1.5.2')
|
implementation('com.sparrowwallet:hummingbird:1.5.3')
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
@ -16,7 +16,7 @@ apply plugin: 'com.bmuschko.nexus'
|
||||||
|
|
||||||
archivesBaseName = 'hummingbird'
|
archivesBaseName = 'hummingbird'
|
||||||
group 'com.sparrowwallet'
|
group 'com.sparrowwallet'
|
||||||
version '1.5.2'
|
version '1.5.3'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -27,6 +27,24 @@ public class LegacyURDecoder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getPercentComplete() {
|
||||||
|
if(fragments.isEmpty()) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
|
||||||
|
String fragment = fragments.iterator().next();
|
||||||
|
String[] components = fragment.split("/");
|
||||||
|
if(components.length > 3) {
|
||||||
|
int[] sequence = checkAndGetSequence(components[1]);
|
||||||
|
int total = sequence[1];
|
||||||
|
if(total > 0 && fragments.size() <= total) {
|
||||||
|
return (double)fragments.size() / total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1d;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLegacyURFragment(String fragment) {
|
public static boolean isLegacyURFragment(String fragment) {
|
||||||
String[] components = fragment.split("/");
|
String[] components = fragment.split("/");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue