public class TransferObserver extends Object
For example, you can track the progress of an upload as the following:
TransferObserver transfer = transferUtility.upload(bucket, key, file);
transfer.setListener(new TransferListener() {
public onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
// update progress bar
progressBar.setProgress(bytesCurrent);
}
public void onStateChanged(int id, TransferState state) {
}
public void onError(int id, Exception ex) {
}
});
Note that callbacks of a listener will be invoked on the main thread.
| Modifier and Type | Method and Description |
|---|---|
void |
cleanTransferListener()
Cleans the transfer listener.
|
String |
getAbsoluteFilePath()
Gets the absolute path of file to transfer.
|
String |
getBucket()
Gets the bucket name of the record.
|
long |
getBytesTotal()
Gets the total bytes to transfer.
|
long |
getBytesTransferred()
Gets the bytes transferred currently.
|
int |
getId()
Gets the transfer id of the record.
|
String |
getKey()
Gets the key of the record.
|
TransferState |
getState()
Gets the state of the transfer task.
|
void |
refresh()
Refresh fields in the TransferObserver from the running transfer task.
|
void |
setTransferListener(TransferListener listener)
Sets a listener used to receive notification when state or progress
changes.
|
String |
toString() |
protected void |
updateFromDB(android.database.Cursor c)
Update transfer state from the given cursor.
|
public void refresh()
protected void updateFromDB(android.database.Cursor c)
c - a cursor to read the state of the transfer frompublic void setTransferListener(TransferListener listener)
Note that callbacks of the listener will be invoked on the main thread.
listener - A TransferListener used to receive notification.public int getId()
public String getBucket()
public String getKey()
public long getBytesTotal()
public String getAbsoluteFilePath()
public long getBytesTransferred()
public TransferState getState()
public void cleanTransferListener()
Copyright © 2018. All rights reserved.