Java 类com.amazonaws.mobileconnectors.s3.transferutility.TransferState 实例源码

项目:aws-sdk-android-samples    文件:UploadActivity.java   
/**
 * 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();
}
项目:aws-sdk-android-samples    文件:DownloadActivity.java   
/**
 * 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();
}
项目:PlatePicks-Android    文件:S3TransferHelper.java   
/**
 * 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));
    }
}
项目:PlatePicks-Android    文件:S3TransferHelper.java   
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();
}
项目:ureport-android    文件:TransferListenerAdapter.java   
@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();
    }
}
项目:PerchBroadcast-Android-SDK    文件:S3QueuedUploader.java   
@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;
    }
}
项目:PlatePicks-Android    文件:S3TransferHelper.java   
public boolean isTransferWaiting(final String relativeFilePath) {
    final TransferState xferState = getTransferState(relativeFilePath);
    return WAITING_FOR_CONTENT_STATES.contains(xferState);
}
项目:aws-sdk-android-samples    文件:UploadActivity.java   
@Override
public void onStateChanged(int id, TransferState newState) {
    Log.d(TAG, "onStateChanged: " + id + ", " + newState);
    updateList();
}
项目:aws-sdk-android-samples    文件:DownloadActivity.java   
@Override
public void onStateChanged(int id, TransferState state) {
    Log.d(TAG, "onStateChanged: " + id + ", " + state);
    updateList();
}
项目:Android-Client    文件:NetworkStore.java   
void onStateChanged(String imageId, TransferState state);