Example usage for android.os ResultReceiver send

List of usage examples for android.os ResultReceiver send

Introduction

In this page you can find the example usage for android.os ResultReceiver send.

Prototype

public void send(int resultCode, Bundle resultData) 

Source Link

Document

Deliver a result to this receiver.

Usage

From source file:org.deviceconnect.android.deviceplugin.host.camera.CameraOverlay.java

/**
 * ?????.//w  w w.  j  av  a  2  s .c om
 * @param resultReceiver ????
 */
private void checkCameraCapability(@NonNull final ResultReceiver resultReceiver) {
    PermissionUtility.requestPermissions(mContext, new Handler(), new String[] { Manifest.permission.CAMERA },
            new PermissionUtility.PermissionRequestCallback() {
                @Override
                public void onSuccess() {
                    resultReceiver.send(Activity.RESULT_OK, null);
                }

                @Override
                public void onFail(@NonNull String deniedPermission) {
                    resultReceiver.send(Activity.RESULT_CANCELED, null);
                }
            });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

public void onUbuntuOneFailure(U1Failure failure, ResultReceiver receiver) {
    Log.d(TAG, "onUbuntuOneFailure: " + failure.toString() + ", status code: " + failure.getStatusCode());
    final Bundle resultData = new Bundle();
    resultData.putString(EXTRA_ERROR, failure.getMessage());
    if (receiver != null) {
        receiver.send(Status.ERROR, resultData);
    }//from   w ww.ja v a 2s.  com
}

From source file:com.ubuntuone.android.files.service.MetaService.java

private void deleteNode(final String resourcePath, final ResultReceiver receiver) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);
    api.deleteNode(resourcePath, new U1NodeListener() {
        @Override//from  w  w w  .j a va2s  . c  o  m
        public void onStart() {
            receiver.send(Status.RUNNING, data);
            MetaUtilities.setState(resourcePath, ResourceState.STATE_DELETING);
            MetaUtilities.notifyChange(Nodes.CONTENT_URI);
        }

        @Override
        public void onSuccess(U1Node node) {
            MetaUtilities.deleteByResourcePath(resourcePath);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            MetaUtilities.deleteByResourcePath(resourcePath);
            MetaUtilities.notifyChange(Nodes.CONTENT_URI);
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

public void getVolume(final String resourcePath, final ResultReceiver receiver) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);
    api.getVolume(resourcePath, new U1VolumeListener() {
        @Override/*from w w  w .j av  a2s.c  o  m*/
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, data);
        }

        @Override
        public void onSuccess(U1Volume volume) {
            onGetVolumeSuccess(volume, receiver);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

private void makeDirectory(final String resourcePath, final ResultReceiver receiver) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);
    api.makeDirectory(resourcePath, new U1NodeListener() {
        @Override/*  w w  w.j  av  a 2s.  c o  m*/
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, Bundle.EMPTY);
        }

        @Override
        public void onSuccess(U1Node node) {
            onMakeDirectorySuccess(node);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

private void updateNode(final String resourcePath, final String newPath, final ResultReceiver receiver) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);

    api.moveNode(resourcePath, newPath, new U1NodeListener() {
        @Override//from w  w  w .  j av a  2  s.c o  m
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, data);
        }

        @Override
        public void onSuccess(U1Node node) {
            onUpdateNodeNameSuccess(resourcePath, node);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

private void updateNode(final String resourcePath, Boolean isPublic, final ResultReceiver receiver) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);
    api.setFilePublic(resourcePath, isPublic, new U1NodeListener() {
        @Override//from w  w  w . j a  va 2s. co m
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, Bundle.EMPTY);
        }

        @Override
        public void onSuccess(U1Node node) {
            onUpdateNodeAccessSuccess(node);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

public void getVolumeDelta(String resourcePath, long generation, final ResultReceiver receiver) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);
    api.getVolumeDelta(resourcePath, generation, new U1NodeListener() {
        @Override/*from  w w w  .  ja  v a 2s .c o m*/
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, data);
        }

        @Override
        public void onSuccess(U1Node node) {
            onGetNodeSuccess(node, false);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

public void getNode(final String resourcePath, final ResultReceiver receiver, final boolean getChildren) {
    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);

    api.getNode(resourcePath, new U1NodeListener() {
        @Override/*from   ww w.j  a v  a  2s  .c o m*/
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, data);
        }

        @Override
        public void onSuccess(U1Node node) {
            onGetNodeSuccess(node, getChildren);
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });
}

From source file:com.ubuntuone.android.files.service.MetaService.java

public void getVolumes(final ResultReceiver receiver) {
    // Cached volume node paths.
    final Set<String> cachedNodePaths = MetaUtilities.getUserNodePaths();
    // Fresh volume node paths.
    final List<String> volumeNodePaths = new LinkedList<String>();

    api.getVolumes(new U1VolumeListener() {
        @Override/* w w  w .j  a  va 2 s .  co m*/
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, Bundle.EMPTY);
        }

        @Override
        public void onSuccess(U1Volume volume) {
            onGetVolumeSuccess(volume, receiver);
            volumeNodePaths.add(volume.getNodePath());
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            for (String nodePath : volumeNodePaths) {
                getNode(nodePath, null, false);
                cachedNodePaths.remove(nodePath);
            }
            if (NetworkUtil.isConnected(MetaService.this)) {
                // We are connected, thus left cachedNodePaths are invalid.
                for (String oldNodePath : cachedNodePaths) {
                    MetaUtilities.cleanupTreeByResourcePath(oldNodePath);
                }
            }
            contentResolver.notifyChange(Nodes.CONTENT_URI, null);
            if (receiver != null)
                receiver.send(Status.FINISHED, Bundle.EMPTY);
        }
    });
}