Search in sources :

Example 11 with EventDispatcher

use of com.codename1.ui.util.EventDispatcher in project CodenameOne by codenameone.

the class IOSImplementation method captureVideo.

/**
 * Captures a video and notifies with the data when available
 * @param response callback for the resulting video
 */
public void captureVideo(ActionListener response) {
    if (!nativeInstance.checkCameraUsage() || !nativeInstance.checkMicrophoneUsage()) {
        throw new RuntimeException("Please add the ios.NSCameraUsageDescription and ios.NSMicrophoneUsageDescription build hints");
    }
    captureCallback = new EventDispatcher();
    captureCallback.addListener(response);
    nativeInstance.captureCamera(true);
    dropEvents = true;
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 12 with EventDispatcher

use of com.codename1.ui.util.EventDispatcher in project CodenameOne by codenameone.

the class NetworkManager method fireProgressEvent.

void fireProgressEvent(ConnectionRequest c, int type, int length, int sentReceived) {
    // progressListeners might be made null by a separate thread
    EventDispatcher d = progressListeners;
    if (d != null) {
        NetworkEvent n = new NetworkEvent(c, type);
        n.setLength(length);
        n.setSentReceived(sentReceived);
        d.fireActionEvent(n);
    }
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 13 with EventDispatcher

use of com.codename1.ui.util.EventDispatcher in project CodenameOne by codenameone.

the class NetworkManager method addErrorListener.

/**
 * Adds a generic listener to a network error that is invoked before the exception is propagated.
 * Notice that this doesn't apply to server error codes!
 * Consume the event in order to prevent it from propagating further.
 *
 * @param e callback will be invoked with the Exception as the source object
 */
public void addErrorListener(ActionListener<NetworkEvent> e) {
    if (errorListeners == null) {
        errorListeners = new EventDispatcher();
        errorListeners.setBlocking(true);
    }
    errorListeners.addListener(e);
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 14 with EventDispatcher

use of com.codename1.ui.util.EventDispatcher in project CodenameOne by codenameone.

the class AndroidImplementation method openImageGallery.

/**
 * Opens the device image gallery
 *
 * @param response callback for the resulting image
 */
public void openImageGallery(ActionListener response) {
    if (getActivity() == null) {
        throw new RuntimeException("Cannot open image gallery in background mode");
    }
    if (!checkForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, "This is required to browse the photos")) {
        return;
    }
    if (editInProgress()) {
        stopEditing(true);
    }
    callback = new EventDispatcher();
    callback.addListener(response);
    Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    this.getActivity().startActivityForResult(galleryIntent, OPEN_GALLERY);
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 15 with EventDispatcher

use of com.codename1.ui.util.EventDispatcher in project CodenameOne by codenameone.

the class AndroidImplementation method execute.

public void execute(String url, ActionListener response) {
    if (response != null) {
        callback = new EventDispatcher();
        callback.addListener(response);
    }
    try {
        Intent intent = createIntentForURL(url);
        if (intent == null) {
            return;
        }
        if (response != null && getActivity() != null) {
            getActivity().startActivityForResult(intent, IntentResultListener.URI_SCHEME);
        } else {
            getContext().startActivity(intent);
        }
        return;
    } catch (Exception ex) {
        com.codename1.io.Log.e(ex);
    }
    try {
        if (editInProgress()) {
            stopEditing(true);
        }
        getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ParseException(java.text.ParseException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Aggregations

EventDispatcher (com.codename1.ui.util.EventDispatcher)19 IOException (java.io.IOException)4 ActionEvent (com.codename1.ui.events.ActionEvent)3 FileSystemJournalEntry (net.rim.device.api.io.file.FileSystemJournalEntry)3 FileSystemJournalListener (net.rim.device.api.io.file.FileSystemJournalListener)3 Uri (android.net.Uri)2 File (java.io.File)2 RandomAccessFile (java.io.RandomAccessFile)2 ConnectionNotFoundException (javax.microedition.io.ConnectionNotFoundException)2 MediaException (javax.microedition.media.MediaException)2 RecordStoreException (javax.microedition.rms.RecordStoreException)2 CameraArguments (net.rim.blackberry.api.invoke.CameraArguments)2 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Form (com.codename1.ui.Form)1 URISyntaxException (java.net.URISyntaxException)1 ParseException (java.text.ParseException)1 Hashtable (java.util.Hashtable)1 DatabaseIOException (net.rim.device.api.database.DatabaseIOException)1 DatabasePathException (net.rim.device.api.database.DatabasePathException)1 EventInjector (net.rim.device.api.system.EventInjector)1