Search in sources :

Example 1 with EventDispatcher

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

the class LazyValueC method processCommandImpl.

private void processCommandImpl(ActionEvent ev, Command cmd) {
    processCommand(ev, cmd);
    if (ev.isConsumed()) {
        return;
    }
    if (globalCommandListeners != null) {
        globalCommandListeners.fireActionEvent(ev);
        if (ev.isConsumed()) {
            return;
        }
    }
    if (localCommandListeners != null) {
        Form f = Display.getInstance().getCurrent();
        EventDispatcher e = (EventDispatcher) localCommandListeners.get(f.getName());
        if (e != null) {
            e.fireActionEvent(ev);
        }
    }
}
Also used : Form(com.codename1.ui.Form)

Example 2 with EventDispatcher

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

the class ConnectionRequest method addResponseListener.

/**
 * Adds a listener that would be notified on the CodenameOne thread of a response from the server.
 * This event is specific to the connection request type and its firing will change based on
 * how the connection request is read/processed
 *
 * @param a listener
 */
public void addResponseListener(ActionListener<NetworkEvent> a) {
    if (actionListeners == null) {
        actionListeners = new EventDispatcher();
        actionListeners.setBlocking(false);
    }
    actionListeners.addListener(a);
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 3 with EventDispatcher

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

the class ConnectionRequest method addExceptionListener.

/**
 * Adds a listener that would be notified on the CodenameOne thread of an exception
 * in this connection request
 *
 * @param a listener
 */
public void addExceptionListener(ActionListener<NetworkEvent> a) {
    if (exceptionListeners == null) {
        exceptionListeners = new EventDispatcher();
        exceptionListeners.setBlocking(false);
    }
    exceptionListeners.addListener(a);
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 4 with EventDispatcher

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

the class NetworkManager method addProgressListener.

/**
 * Adds a listener to be notified when progress updates
 *
 * @param al action listener
 */
public void addProgressListener(ActionListener<NetworkEvent> al) {
    if (progressListeners == null) {
        progressListeners = new EventDispatcher();
        progressListeners.setBlocking(false);
    }
    progressListeners.addListener(al);
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

Example 5 with EventDispatcher

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

the class AndroidImplementation method openGallery.

public void openGallery(final ActionListener response, int type) {
    if (getActivity() == null) {
        throw new RuntimeException("Cannot open galery in background mode");
    }
    if (!checkForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, "This is required to browse the photos")) {
        return;
    }
    callback = new EventDispatcher();
    callback.addListener(response);
    Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    if (type == Display.GALLERY_VIDEO) {
        galleryIntent.setType("video/*");
    } else if (type == Display.GALLERY_IMAGE) {
        galleryIntent.setType("image/*");
    } else if (type == -9999) {
        galleryIntent = new Intent();
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            galleryIntent.setAction(Intent.ACTION_OPEN_DOCUMENT);
        } else {
            galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
        }
        galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);
        // set MIME type for image
        galleryIntent.setType("*/*");
        galleryIntent.putExtra(Intent.EXTRA_MIME_TYPES, Display.getInstance().getProperty("android.openGallery.accept", "*/*").split(","));
    } else {
        galleryIntent.setType("*/*");
    }
    this.getActivity().startActivityForResult(galleryIntent, OPEN_GALLERY);
}
Also used : EventDispatcher(com.codename1.ui.util.EventDispatcher)

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