本文整理汇总了Java中com.amazonaws.mobileconnectors.s3.transferutility.TransferState类的典型用法代码示例。如果您正苦于以下问题:Java TransferState类的具体用法?Java TransferState怎么用?Java TransferState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransferState类属于com.amazonaws.mobileconnectors.s3.transferutility包,在下文中一共展示了TransferState类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initData
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
/**
* Gets all relevant transfers from the Transfer Service for populating the
* UI
*/
private void initData() {
transferRecordMaps.clear();
// Use TransferUtility to get all upload transfers.
observers = transferUtility.getTransfersWithType(TransferType.UPLOAD);
TransferListener listener = new UploadListener();
for (TransferObserver observer : observers) {
// For each transfer we will will create an entry in
// transferRecordMaps which will display
// as a single row in the UI
HashMap<String, Object> map = new HashMap<String, Object>();
Util.fillMap(map, observer, false);
transferRecordMaps.add(map);
// Sets listeners to in progress transfers
if (TransferState.WAITING.equals(observer.getState())
|| TransferState.WAITING_FOR_NETWORK.equals(observer.getState())
|| TransferState.IN_PROGRESS.equals(observer.getState())) {
observer.setTransferListener(listener);
}
}
simpleAdapter.notifyDataSetChanged();
}
示例2: initData
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
/**
* Gets all relevant transfers from the Transfer Service for populating the
* UI
*/
private void initData() {
transferRecordMaps.clear();
// Uses TransferUtility to get all previous download records.
observers = transferUtility.getTransfersWithType(TransferType.DOWNLOAD);
TransferListener listener = new DownloadListener();
for (TransferObserver observer : observers) {
HashMap<String, Object> map = new HashMap<String, Object>();
Util.fillMap(map, observer, false);
transferRecordMaps.add(map);
// Sets listeners to in progress transfers
if (TransferState.WAITING.equals(observer.getState())
|| TransferState.WAITING_FOR_NETWORK.equals(observer.getState())
|| TransferState.IN_PROGRESS.equals(observer.getState())) {
observer.setTransferListener(listener);
}
}
simpleAdapter.notifyDataSetChanged();
}
示例3: setProgressListener
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
/**
* Sets the progress listener for a given s3Key being transferred.
* @param relativeFilePath the relative path and file name.
* @param listener the progress listener.
*/
public synchronized void setProgressListener(final String relativeFilePath, final ContentProgressListener listener) {
final Integer transferId = managedFilesToTransfers.get(relativeFilePath);
if (transferId != null) {
if (listener == null) {
progressListeners.remove(transferId);
return;
}
final TransferObserver observer = transfersInProgress.get(transferId);
if (observer != null) {
final ContentProgressListener currentListener = progressListeners.get(transferId);
progressListeners.put(transferId, listener);
if (currentListener != listener) {
observer.refresh();
final TransferState transferState = observer.getState();
if (transferState == TransferState.WAITING ||
transferState == TransferState.WAITING_FOR_NETWORK ||
transferState == TransferState.RESUMED_WAITING) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
onStateChanged(transferId, transferState);
}
});
}
}
}
} else {
Log.w(LOG_TAG, String.format("Attempt to set progress listener for file '%s'," +
" but no transfer is in progress for that file.", relativeFilePath));
}
}
示例4: getTransferState
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
private synchronized TransferState getTransferState(final String relativeFilePath) {
final Integer transferId = managedFilesToTransfers.get(relativeFilePath);
if (transferId == null) {
return null;
}
final TransferObserver observer = transfersInProgress.get(transferId);
observer.refresh();
return observer.getState();
}
示例5: onStateChanged
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
@Override
public final void onStateChanged(int id, TransferState state) {
Log.i(TAG, "onStateChanged: id: " + id + " state: " + state + " filename: " + filename);
if(state == TransferState.COMPLETED) {
Media media = new Media(localMedia);
media.setId(getKey());
media.setUrl(getUrl());
onTransferFinished(media);
} else if(state == TransferState.WAITING_FOR_NETWORK) {
onTransferWaitingNetwork();
} else if (state == TransferState.FAILED) {
onTransferFailed();
}
}
示例6: onStateChanged
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
@Override
public void onStateChanged(int id, TransferState state) {
if (listener == null) return;
ActiveUpload upload = activeUploadMap.get(id);
if (upload == null) {
Timber.w("No ActiveUpload associated with transfer id %d. Cannot notify listener", id);
return;
}
Timber.d("Transfer %s state %s", upload.file.getName(), state.name());
switch (state) {
case IN_PROGRESS:
Timber.d("Marking ActiveUpload start time");
upload.markStartTime();
break;
case COMPLETED:
int bytesPerSecond = (int) (upload.file.length() / (System.currentTimeMillis() - upload.startTimeMs));
listener.onUploadComplete(upload.file, upload.destinationUrl, bytesPerSecond);
activeUploadMap.remove(id);
break;
case CANCELED:
listener.onUploadError(upload.file, upload.destinationUrl, new Exception("Transfer cancelled"));
activeUploadMap.remove(id);
break;
case FAILED:
listener.onUploadError(upload.file, upload.destinationUrl, new Exception("Transfer failed"));
activeUploadMap.remove(id);
break;
}
}
示例7: isTransferWaiting
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
public boolean isTransferWaiting(final String relativeFilePath) {
final TransferState xferState = getTransferState(relativeFilePath);
return WAITING_FOR_CONTENT_STATES.contains(xferState);
}
示例8: onStateChanged
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
@Override
public void onStateChanged(int id, TransferState newState) {
Log.d(TAG, "onStateChanged: " + id + ", " + newState);
updateList();
}
示例9: onStateChanged
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
@Override
public void onStateChanged(int id, TransferState state) {
Log.d(TAG, "onStateChanged: " + id + ", " + state);
updateList();
}
示例10: onStateChanged
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; //导入依赖的package包/类
void onStateChanged(String imageId, TransferState state);