codenameone

ConnectionRequest pause() and resume()

久未见 提交于 2020-06-26 06:14:23
问题 Are ConnectionRequest methods named pause() and resume() really implemented? Looking at the sources, I imagined that they are "fake", in the sense they actually do nothing, except setting an internal flag: https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/io/ConnectionRequest.java So, my question is if Codename One offers any way to pause and then resume a large download (for example 10MB or 100MB, that could be the size of a video). My idea is to pause the

How to improve the behavior of ConnectionRequest?

落花浮王杯 提交于 2020-06-13 08:13:29
问题 I wrote this code: public static Slider downloadStorageFile(String url, OnComplete<Integer> percentageCallback, OnComplete<String> filesavedCallback) { final String filename = getNewStorageFilename(); ConnectionRequest cr = Rest.get(url).fetchAsBytes(response -> CN.callSerially(() -> filesavedCallback.completed(filename))); cr.setDestinationStorage(filename); Slider slider = new Slider(); slider.addDataChangedListener((int type, int index) -> { CN.callSerially(() -> percentageCallback

Get file size of an URL without download

时光总嘲笑我的痴心妄想 提交于 2020-06-13 06:37:41
问题 To get the file size of an URL without download, I wrote: public static long getFileSizeWithoutDownload(String url) { ConnectionRequest cr = new GZConnectionRequest(); cr.setUrl(url); cr.setPost(false); NetworkManager.getInstance().addProgressListener((NetworkEvent evt) -> { if (cr == evt.getConnectionRequest() && evt.getLength() > 0) { cr.kill(); } }); NetworkManager.getInstance().addToQueueAndWait(cr); return cr.getContentLength(); } It seems to work on Simulator, Android and iOS with a

Get file size of an URL without download

百般思念 提交于 2020-06-13 06:37:30
问题 To get the file size of an URL without download, I wrote: public static long getFileSizeWithoutDownload(String url) { ConnectionRequest cr = new GZConnectionRequest(); cr.setUrl(url); cr.setPost(false); NetworkManager.getInstance().addProgressListener((NetworkEvent evt) -> { if (cr == evt.getConnectionRequest() && evt.getLength() > 0) { cr.kill(); } }); NetworkManager.getInstance().addToQueueAndWait(cr); return cr.getContentLength(); } It seems to work on Simulator, Android and iOS with a

How to get current system DNS resolvers ip-addresses in codename one?

≯℡__Kan透↙ 提交于 2020-02-02 10:08:07
问题 Is there a way to get all current system DNS resolver ip-addresses in codename one? The classes NetworkManager and ConnectionRequest don't provide these information. In general Codename One seems not to provide any way to access a devices communication status information like "Wi-Fi Mac address", "IMEI", "Mobile network type" etc. Am I right? 回答1: Do you mean something like Socket.getHostOrIP() ? There is no standardized explicit DNS lookup API though. Most of these things aren't available

CN1 how to deal with the home indicator (iPhone X and such)

試著忘記壹切 提交于 2020-02-01 05:39:05
问题 When we have to deal with (native) device specific objects on the display (such as the home indicator in iPhone X) in case of having a proper layout of our app (avoiding those objects violate the layout), should I adapt the layout in native code or in CN1 specific code? What would you suggest? 回答1: Most of our effort was around the notch and not so much on the home button but we probably should add support for iOS's safe area API. Although technically it's a pretty horrible API. It might be

Custom action after tapping a video during the playback or when the playback ends

心不动则不痛 提交于 2020-01-23 21:43:45
问题 My use case: I have an image that is the preview of a video. When the user tap the preview, the video should starts a fullscreen playback (I suppose in another Form). When the video ends or when the user tap the video during the playback, the previous Form should be shown. This is the same use case of the question: Codename One landscape oriented Form in a portrait locked app My question: the MediaPlayer class doesn't seem to expose a method to perform a custom action when pressing the video

Custom action after tapping a video during the playback or when the playback ends

爱⌒轻易说出口 提交于 2020-01-23 21:39:08
问题 My use case: I have an image that is the preview of a video. When the user tap the preview, the video should starts a fullscreen playback (I suppose in another Form). When the video ends or when the user tap the video during the playback, the previous Form should be shown. This is the same use case of the question: Codename One landscape oriented Form in a portrait locked app My question: the MediaPlayer class doesn't seem to expose a method to perform a custom action when pressing the video

Saving and loading Images from the Storage in Codename One

丶灬走出姿态 提交于 2020-01-23 17:36:45
问题 It seems that my following code doesn't work as expected. The following class works fine in the Simulator, but on real devices I noted that the app takes too much time to open the images: I mean that there isn't any time advantage after the first load. Instead I expect that this class should require more time to open an image the first time, and then it should be a lot faster next times (because the scaled image is saved to the Storage ). The purpose of the EasyThread is to don't block the

Keep the Toolbar visible when the VKB is open

那年仲夏 提交于 2020-01-23 17:27:25
问题 This question is related to Form with the VKB always open: I would like to keep the VKB open while the Toolbar should remain visible. This should be the normality on Android, but it's not so on iOS. How can I do that with Codename One? Other chatting apps keep the Toolbar (or something that has an UI equivalent to the Toolbar ) open while the VKB is open even in iOS. Thank you Screenshots: Android - VKB closed - Toolbar visible Android - VKB open - Toolbar not visible Android - VKB open -