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);
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations