Typo fixed. Access modifiers changed

This commit is contained in:
Aleksander Nowakowski 2016-09-21 16:25:14 +02:00
parent bc38edc9af
commit 15c7152f94
1 changed files with 22 additions and 22 deletions

View File

@ -33,7 +33,7 @@ import android.support.annotation.NonNull;
private final ProgressListener mListener; private final ProgressListener mListener;
private int progress; private int progress;
private int bytesSent; private int bytesSent;
private int initalBytesSent; private int initialBytesSent;
private int lastBytesSent; private int lastBytesSent;
private int bytesReceived; private int bytesReceived;
private int imageSizeInBytes; private int imageSizeInBytes;
@ -42,11 +42,11 @@ import android.support.annotation.NonNull;
private int totalParts; private int totalParts;
private long timeStart, lastProgressTime; private long timeStart, lastProgressTime;
public DfuProgressInfo(final @NonNull ProgressListener listener) { DfuProgressInfo(final @NonNull ProgressListener listener) {
mListener = listener; mListener = listener;
} }
public DfuProgressInfo init(final int imageSizeInBytes, final int currentPart, final int totalParts) { DfuProgressInfo init(final int imageSizeInBytes, final int currentPart, final int totalParts) {
this.imageSizeInBytes = imageSizeInBytes; this.imageSizeInBytes = imageSizeInBytes;
this.maxObjectSizeInBytes = Integer.MAX_VALUE; // by default the whole firmware will be sent as a single object this.maxObjectSizeInBytes = Integer.MAX_VALUE; // by default the whole firmware will be sent as a single object
this.currentPart = currentPart; this.currentPart = currentPart;
@ -54,7 +54,7 @@ import android.support.annotation.NonNull;
return this; return this;
} }
public DfuProgressInfo setTotalPart(final int totalParts) { DfuProgressInfo setTotalPart(final int totalParts) {
this.totalParts = totalParts; this.totalParts = totalParts;
return this; return this;
} }
@ -64,59 +64,59 @@ import android.support.annotation.NonNull;
mListener.updateProgressNotification(); mListener.updateProgressNotification();
} }
public void setBytesSent(final int bytesSent) { void setBytesSent(final int bytesSent) {
if (timeStart == 0) { if (timeStart == 0) {
timeStart = SystemClock.elapsedRealtime(); timeStart = SystemClock.elapsedRealtime();
initalBytesSent = bytesSent; initialBytesSent = bytesSent;
} }
this.bytesSent = bytesSent; this.bytesSent = bytesSent;
this.progress = (int) (100.0f * bytesSent / imageSizeInBytes); this.progress = (int) (100.0f * bytesSent / imageSizeInBytes);
mListener.updateProgressNotification(); mListener.updateProgressNotification();
} }
public void addBytesSent(final int increment) { void addBytesSent(final int increment) {
setBytesSent(bytesSent + increment); setBytesSent(bytesSent + increment);
} }
public void setBytesReceived(final int bytesReceived) { void setBytesReceived(final int bytesReceived) {
this.bytesReceived = bytesReceived; this.bytesReceived = bytesReceived;
} }
public void setMaxObjectSizeInBytes(final int bytes) { void setMaxObjectSizeInBytes(final int bytes) {
this.maxObjectSizeInBytes = bytes; this.maxObjectSizeInBytes = bytes;
} }
public boolean isComplete() { boolean isComplete() {
return bytesSent == imageSizeInBytes; return bytesSent == imageSizeInBytes;
} }
public boolean isObjectComplete() { boolean isObjectComplete() {
return (bytesSent % maxObjectSizeInBytes) == 0; return (bytesSent % maxObjectSizeInBytes) == 0;
} }
public int getAvailableObjectSizeIsBytes() { int getAvailableObjectSizeIsBytes() {
final int remainingBytes = imageSizeInBytes - bytesSent; final int remainingBytes = imageSizeInBytes - bytesSent;
final int remainingChunk = maxObjectSizeInBytes - (bytesSent % maxObjectSizeInBytes); final int remainingChunk = maxObjectSizeInBytes - (bytesSent % maxObjectSizeInBytes);
return Math.min(remainingBytes, remainingChunk); return Math.min(remainingBytes, remainingChunk);
} }
public int getProgress() { int getProgress() {
return progress; return progress;
} }
public int getBytesSent() { int getBytesSent() {
return bytesSent; return bytesSent;
} }
public int getBytesReceived() { int getBytesReceived() {
return bytesReceived; return bytesReceived;
} }
public int getImageSizeInBytes() { int getImageSizeInBytes() {
return imageSizeInBytes; return imageSizeInBytes;
} }
public float getSpeed() { float getSpeed() {
final long now = SystemClock.elapsedRealtime(); final long now = SystemClock.elapsedRealtime();
final float speed = now - timeStart != 0 ? (float) (bytesSent - lastBytesSent) / (float) (now - lastProgressTime) : 0.0f; final float speed = now - timeStart != 0 ? (float) (bytesSent - lastBytesSent) / (float) (now - lastProgressTime) : 0.0f;
lastProgressTime = now; lastProgressTime = now;
@ -124,20 +124,20 @@ import android.support.annotation.NonNull;
return speed; return speed;
} }
public float getAverageSpeed() { float getAverageSpeed() {
final long now = SystemClock.elapsedRealtime(); final long now = SystemClock.elapsedRealtime();
return now - timeStart != 0 ? (float) (bytesSent - initalBytesSent) / (float) (now - timeStart) : 0.0f; return now - timeStart != 0 ? (float) (bytesSent - initialBytesSent) / (float) (now - timeStart) : 0.0f;
} }
public int getCurrentPart() { int getCurrentPart() {
return currentPart; return currentPart;
} }
public int getTotalParts() { int getTotalParts() {
return totalParts; return totalParts;
} }
public boolean isLastPart() { boolean isLastPart() {
return currentPart == totalParts; return currentPart == totalParts;
} }
} }