Class ImageDownloadService
- All Implemented Interfaces:
IOProgressListener
-
Nested Class Summary
Nested classes/interfaces inherited from class ConnectionRequest
ConnectionRequest.CachingMode, ConnectionRequest.SSLCertificateModifier and TypeClassDescriptionstatic enumThere are 5 caching modes:static final classEncapsulates an SSL certificate fingerprint. -
Field Summary
Fields inherited from class ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_REDUNDANTModifier and TypeFieldDescriptionstatic final byteA critical priority request will "push" through the queue to the highest point regardless of anything else and ignoring anything that is not in itself of critical priority.static final byteA high priority request is the second highest level, it will act exactly like a critical priority with one difference.static final byteLow priority requests are mostly background tasks that should still be accomplished thoughstatic final byteNormal priority executes as usual on the queuestatic final byteRedundant elements can be discarded from the queue when paused -
Constructor Summary
ConstructorsConstructorDescriptionImageDownloadService(String url, Component targetList, int targetOffset, String targetKey) Constructs an image request that will automatically populate the given list when the response arrives.ImageDownloadService(String url, ActionListener l) Accepts the url to bind to the list renderer, on completion the action listener will be invoked with the image so a list can be updated with the dataImageDownloadService(String url, Label parentLabel) Accepts the url to bind to the label, on completion the label will be updated and revalidated with the new image.ImageDownloadService(String url, List targetList, int targetOffset, String targetKey) Constructs an image request that will automatically populate the given list when the response arrives. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddErrorListener(ActionListener listener) Binds an error listener that will fire an instance of NetworkEvent with an error for a specific fetch operation if applicablestatic voidcreateImageToFileSystem(String url, Component targetList, int targetOffset, String targetKey, String destFile, Dimension toScale, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToFileSystem(String url, Component targetList, int targetOffset, String targetKey, String destFile, Image placeholder, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToFileSystem(String url, Component targetList, ListModel model, int targetOffset, String targetKey, String destFile, Image placeholder, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToFileSystem(String url, ActionListener callback, String destFile) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally.static voidcreateImageToFileSystem(String url, List targetList, int targetOffset, String targetKey, String destFile, Dimension toScale) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToStorage(String url, Component targetList, int targetOffset, String targetKey, String cacheId, Dimension scale, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToStorage(String url, Component targetList, int targetOffset, String targetKey, String cacheId, Image placeholderImage, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToStorage(String url, Component targetList, ListModel model, int targetOffset, String targetKey, String cacheId, Image placeholderImage, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.static voidcreateImageToStorage(String url, ActionListener callback, String cacheId) static voidcreateImageToStorage(String url, ActionListener callback, String cacheId, boolean keep) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally.static voidcreateImageToStorage(String url, Label l, String cacheId, Dimension toScale) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally to the Storagestatic voidcreateImageToStorage(String url, Label l, String cacheId, Dimension toScale, byte priority) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally to the Storagestatic voidcreateImageToStorage(String url, Label l, String cacheId, Image placeholder, byte priority) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally to the Storagestatic voidcreateImageToStorage(String url, List targetList, int targetOffset, String targetKey, String cacheId, Dimension scale) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage.booleanIndicates whether some other object is "equal to" this one.static intIndicates the default timeout to use for image download service, -1 indicates no default is set.Returns the image returned from the server, this method is useful for renderersprotected voidhandleErrorResponseCode(int code, String message) Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)protected voidhandleException(Exception err) Handles an exception thrown when performing a network operation, the default implementation shows a retry dialog.inthashCode()Returns a hash code value for the object.static booleanBy default lists don't revalidate on every change to avoid "jumpiness" when scrollingstatic booleanReturns
booleanDownloads the image to the style objects associated with this component, effectively sets the bgImage property on all the styles for the component instead of invoking setIconstatic booleanFast scaling uses runtime draw scaling rather than the Image scaled method.booleanReturns
protected voidA callback method that's invoked on the EDT after the readResponse() method has finished, this is the place where developers should change their Codename One user interface to avoid race conditions that might be triggered by modifications within readResponse.protected voidreadResponse(InputStream input) Callback for the server response with the input stream from the server.static voidremoveErrorListener(ActionListener listener) Unbinds an error listener that will fire an instance of NetworkEvent with an error for a specific fetch operation if applicablestatic voidsetAlwaysRevalidate(boolean aAlwaysRevalidate) By default lists don't revalidate on every change to avoid "jumpiness" when scrollingstatic voidsetDefaultMaintainAspectRatio(boolean aDefaultMaintainAspectRatio) Parameters
static voidsetDefaultTimeout(int aDefaultTimeout) Indicates the default timeout to use for image download service, -1 indicates no default is set.voidsetDownloadToStyles(boolean downloadToStyles) Downloads the image to the style objects associated with this component, effectively sets the bgImage property on all the styles for the component instead of invoking setIconprotected voidsetEntryInListModel(int offset, Image img) This method is invoked when an image finished downloading and should be set to an offset in the list model.static voidsetFastScale(boolean aFastScale) Fast scaling uses runtime draw scaling rather than the Image scaled method.voidsetMaintainAspectRatio(boolean maintainAspectRatio) Parameters
Methods inherited from class ConnectionRequest
addArgument, addArgument, addArgument, addArgumentArray, addArgumentNoEncoding, addArgumentNoEncoding, addArgumentNoEncodingArray, addArguments, addExceptionListener, addRequestHeader, addResponseCodeListener, addResponseListener, buildRequestBody, cacheUnmodified, canGetSSLCertificates, checkSSLCertificates, cookieReceived, cookieSent, createRequestURL, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, fetchJSON, fetchJSONAsync, fireResponseListener, getCachedData, getCacheMode, getContentLength, getContentType, getCookieHeader, getDefaultCacheMode, getDefaultUserAgent, getDestinationFile, getDestinationStorage, getDisposeOnCompletion, getHeader, getHeaderFieldNames, getHeaders, getHttpMethod, getPriority, getReadTimeout, getRequestBody, getRequestBodyData, getResponseCode, getResponseContentType, getResponseData, getResponseErrorMessage, getResposeCode, getShowOnInit, getSilentRetryCount, getSSLCertificates, getTimeout, getUrl, getUserAgent, getYield, handleIOException, handleRuntimeException, hasResponseListeners, initConnection, initCookieHeader, ioStreamUpdate, isCheckSSLCertificates, isCookiesEnabled, isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported, isFailSilently, isFollowRedirects, isHandleErrorCodesInGlobalErrorHandler, isInsecure, isKilled, isNativeCookieSharingSupported, isPausable, isPaused, isPost, isReadRequest, isReadResponseForErrors, isReadResponseForErrorsDefault, isReadTimeoutSupported, isRedirecting, isWriteRequest, kill, onRedirect, pause, purgeCache, purgeCacheDirectory, readErrorCodeHeaders, readHeaders, removeAllArguments, removeArgument, removeExceptionListener, removeResponseCodeListener, removeResponseListener, resume, retry, setCacheMode, setCheckSSLCertificates, setChunkedStreamingMode, setContentType, setCookieHeader, setCookiesEnabled, setCookiesEnabledDefault, setDefaultCacheMode, setDefaultFollowRedirects, setDefaultUserAgent, setDestinationFile, setDestinationStorage, setDisposeOnCompletion, setDuplicateSupported, setFailSilently, setFollowRedirects, setHandleErrorCodesInGlobalErrorHandler, setHttpMethod, setInsecure, setKilled, setPaused, setPost, setPriority, setReadRequest, setReadResponseForErrors, setReadResponseForErrorsDefault, setReadTimeout, setRequestBody, setRequestBody, setShowOnInit, setSilentRetryCount, setTimeout, setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest, shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop, shouldWriteUTFAsGetBytes, validateModifier and TypeMethodDescriptionvoidaddArgument(String key, byte[] value) Add an argument to the request responsevoidaddArgument(String key, String value) Add an argument to the request responsevoidaddArgument(String key, String[] value) Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same keyvoidaddArgumentArray(String key, String... value) Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same keyvoidaddArgumentNoEncoding(String key, String value) Add an argument to the request response without encoding it, this is useful for arguments which are already encodedvoidaddArgumentNoEncoding(String key, String[] value) Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key, notice that this doesn't implicitly encode the valuevoidaddArgumentNoEncodingArray(String key, String... value) Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key, notice that this doesn't implicitly encode the valuevoidaddArguments(String key, String... value) Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same keyvoidAdds a listener that would be notified on the CodenameOne thread of an exception in this connection requestvoidaddRequestHeader(String key, String value) Adds the given header to the request that will be sentvoidAdds a listener that would be notified on the CodenameOne thread of a response code that is not a 200 (OK) or 301/2 (redirect) response code.voidAdds a listener that would be notified on the CodenameOne thread of a response from the server.protected voidInvoked when send body is true, by default sends the request arguments based on "POST" conventionsprotected voidThis callback is invoked on a 304 server response indicating the data in the server matches the result we currently have in the cache.booleanChecks to see if the platform supports getting SSL certificates.protected voidcheckSSLCertificates(ConnectionRequest.SSLCertificate[] certificates) A callback that can be overridden by subclasses to check the SSL certificates for the server, and kill the connection if they don't pass muster.protected voidCallback invoked for every cookie received from the serverprotected voidcookieSent(Cookie c) Callback invoked for every cookie being sent to the serverprotected StringCreates the request URL mostly for a get requestDownloads an image to the file system asynchronously returning an AsyncResource object that resolves to the loaded image..downloadImageToFileSystem(String file, boolean useCache) Downloads an image to a the file system asynchronously returning an AsyncResource object that resolves to the loaded image..voiddownloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess) Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.voiddownloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, boolean useCache) Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.voiddownloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail) Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.voiddownloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail, boolean useCache) Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.downloadImageToStorage(String storageFile) Downloads an image to a specified storage file asynchronously returning an AsyncResource that resolves to the resulting image..downloadImageToStorage(String storageFile, boolean useCache) Downloads an image to a specified storage file asynchronously returning an AsyncResource that resolves to the resulting image..voiddownloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess) Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.voiddownloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, boolean useCache) Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.voiddownloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail) Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.voiddownloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail, boolean useCache) Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.Utility method that returns a JSON structure or throws an IOException in case of a failure.static AsyncResource<Map<String, Object>> fetchJSONAsync(String url) Fetches JSON asynchronously.protected voidFires the response event to the listeners on this connectionprotected InputStreamThis method should be overriden inCacheMode.MANUALto provide offline caching.There are 5 caching modes:intReturns the content length header valueReturns
static StringWorkaround for https://bugs.php.net/bug.php?id=65633 allowing developers to customize the name of the cookie header to CookieThe default value for the cacheMode property see#getCacheMode()static StringReturns
When set to a none null string saves the response to file system under this file nameWhen set to a none null string saves the response to storage under this file nameA dialog that will be seamlessly disposed once the given request has been completedprotected StringReturns the HTTP header field for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.protected String[]getHeaderFieldNames(Object connection) Returns the HTTP header field names for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.protected String[]getHeaders(Object connection, String header) Returns the HTTP header field for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.Returns the http methodbyteThe priority of this connection based on the constants in this classintGets the read timeout for this connection.The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have argumentsThe request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have argumentsintReturns the response code for this request, this is only relevant after the request completed and might contain a temporary (e.g. redirect) code while the request is in progressReturns the content type from the response headersbyte[]This method will return a valid value for only some of the responses and only after the response was processedReturns error message associated with an error response codeintReturns the response code for this request, this is only relevant after the request completed and might contain a temporary (e.g. redirect) code while the request is in progressThis dialog will be shown when this request enters the network queueintIndicates the number of times to silently retry a connection that failed before promptingGets the server's SSL certificates for this requests.intIndicates the timeout for this connection requestgetUrl()Returns
Returns
protected intgetYield()Returns the amount of time to yield for other processes, this is an implicit method that automatically generates values for lower priority connectionsprotected voidHandles IOException thrown when performing a network operationprotected voidHandles an exception thrown when performing a network operationprotected booleanReturns true if someone is listening to action response events, this is useful so we can decide whether to bother collecting data for an event in some cases since building the event object might be memory/CPU intensive.protected voidinitConnection(Object connection) Invoked to initialize HTTP headers, cookies etc.protected StringinitCookieHeader(String cookie) Allows subclasses to inject cookies into the requestvoidioStreamUpdate(Object source, int bytes) Indicates the number of bytes that were read/written to/from the source streambooleanReturns
booleanReturns
static booleanReturns
static booleanEnables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirectsbooleanIndicates whether this connection request supports duplicate entries in the request queuebooleanIndicates that we are uninterested in error handlingbooleanEnables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirectsstatic booleanWhen set to true (the default), the global error handler inNetworkManagershould receive errors for response code as wellbooleanChecks if the request is insecure (default false).protected booleanisKilled()Returns
static booleanChecks if the platform supports sharing cookies between the native components (e.g. BrowserComponent) and ConnectionRequests.protected booleanReturn true from this method if this connection can be paused and resumed later on.protected booleanisPaused()Returns
booleanisPost()Returns true for a post operation and false for a get operationbooleanReturns
booleanWhen set to true the read response code will happen even for error codes such as 400 and 500static booleanDetermines the default value for#isReadResponseForErrors()static booleanChecks if this platform supports read timeouts.booleanReturns true if this request is been redirected to a different urlbooleanReturns
voidkill()Kills this request if possiblebooleanonRedirect(String url) This is a callback method that been called when there is a redirect.booleanpause()Invoked to pause this opeation, this method will only be invoked if isPausable() returns true (its false by default).voidDeletes the cache file if it exists, notice that this will not work for download filesstatic voidPurges all locally cached filesprotected voidreadErrorCodeHeaders(Object connection) Allows reading the headers from the connection by calling the getHeader() method when a response that isn't 200 OK is sent.protected voidreadHeaders(Object connection) Allows reading the headers from the connection by calling the getHeader() method.voidRemoves all argumentsvoidremoveArgument(String key) Removes the given argument from the requestvoidRemoves the given listenervoidRemoves the given listenervoidRemoves the given listenerbooleanresume()Called when a previously paused operation now has the networking time to resume.voidretry()Retry the current operation in case of an exceptionvoidsetCacheMode(ConnectionRequest.CachingMode cacheMode) There are 5 caching modes:voidsetCheckSSLCertificates(boolean checkSSLCertificates) Parameters
voidsetChunkedStreamingMode(int chunklen) This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance.voidsetContentType(String contentType) Parameters
static voidsetCookieHeader(String aCookieHeader) Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to customize the name of the cookie header to CookievoidsetCookiesEnabled(boolean cookiesEnabled) Parameters
static voidsetCookiesEnabledDefault(boolean aCookiesEnabledDefault) Parameters
static voidsetDefaultCacheMode(ConnectionRequest.CachingMode aDefaultCacheMode) The default value for the cacheMode property see#getCacheMode()static voidsetDefaultFollowRedirects(boolean aDefaultFollowRedirects) Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirectsstatic voidsetDefaultUserAgent(String aDefaultUserAgent) Parameters
voidsetDestinationFile(String destinationFile) When set to a none null string saves the response to file system under this file namevoidsetDestinationStorage(String destinationStorage) When set to a none null string saves the response to storage under this file namevoidsetDisposeOnCompletion(Dialog disposeOnCompletion) A dialog that will be seamlessly disposed once the given request has been completedvoidsetDuplicateSupported(boolean duplicateSupported) Indicates whether this connection request supports duplicate entries in the request queuevoidsetFailSilently(boolean failSilently) Indicates that we are uninterested in error handlingvoidsetFollowRedirects(boolean followRedirects) Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirectsstatic voidsetHandleErrorCodesInGlobalErrorHandler(boolean aHandleErrorCodesInGlobalErrorHandler) When set to true (the default), the global error handler inNetworkManagershould receive errors for response code as wellvoidsetHttpMethod(String httpMethod) Sets the http method for the requestvoidsetInsecure(boolean insecure) Turns off checking to make sure that SSL certificate is valid.protected voidsetKilled(boolean killed) Parameters
protected voidsetPaused(boolean paused) Parameters
voidsetPost(boolean post) Set to true for a post operation and false for a get operation, this will implicitly set the method to post/get respectively (which you can change back by setting the method).voidsetPriority(byte priority) The priority of this connection based on the constants in this classvoidsetReadRequest(boolean readRequest) Parameters
voidsetReadResponseForErrors(boolean readResponseForErrors) When set to true the read response code will happen even for error codes such as 400 and 500static voidsetReadResponseForErrorsDefault(boolean aReadResponseForErrorsDefault) Determines the default value for#setReadResponseForErrors(boolean)voidsetReadTimeout(int timeout) Sets the read timeout for the connection.voidsetRequestBody(Data data) The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments.voidsetRequestBody(String requestBody) The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments.voidsetShowOnInit(Dialog showOnInit) This dialog will be shown when this request enters the network queuevoidsetSilentRetryCount(int silentRetryCount) Indicates the number of times to silently retry a connection that failed before promptingvoidsetTimeout(int timeout) Indicates the timeout for this connection requestvoidParameters
static voidsetUseNativeCookieStore(boolean b) Indicates whether the native Cookie stores should be usedvoidsetUserAgent(String userAgent) Parameters
voidsetWriteRequest(boolean writeRequest) Parameters
protected booleanIndicates whether the response stream should be closed automatically by the framework (defaults to true), this might cause an issue if the stream needs to be passed to a separate thread for reading.protected booleanThis mimics the behavior of browsers that convert post operations to get operations when redirecting a request.protected booleanReturns true if the request is paused or killed, developers should call this method periodically to test whether they should quit the current IO operation immediatelyprotected booleanReturns whether when writing a post body the platform expects something in the form of string.getBytes("UTF-8") or new OutputStreamWriter(os, "UTF-8").protected voidvalidate()Validates that the request has the required information before being added to the queue e.g.Methods inherited from class Object
clone, getClass, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()final ClassgetClass()Returns the runtime class of an object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
ImageDownloadService
Accepts the url to bind to the list renderer, on completion the action listener will be invoked with the image so a list can be updated with the data
Parameters
-
url: the image URL -
l: an action listener callback
-
-
ImageDownloadService
Constructs an image request that will automatically populate the given list when the response arrives. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset
-
-
ImageDownloadService
Constructs an image request that will automatically populate the given list when the response arrives. This assumes the GenericListCellRenderer style of list which relies on a Map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset
-
-
ImageDownloadService
-
-
Method Details
-
isFastScale
public static boolean isFastScale()Fast scaling uses runtime draw scaling rather than the Image scaled method. This works better on smartphones but doesn't work well on feature phones
Returns
the fastScale
-
setFastScale
public static void setFastScale(boolean aFastScale) Fast scaling uses runtime draw scaling rather than the Image scaled method. This works better on smartphones but doesn't work well on feature phones
Parameters
aFastScale: the fastScale to set
-
isAlwaysRevalidate
public static boolean isAlwaysRevalidate()By default lists don't revalidate on every change to avoid "jumpiness" when scrolling
Returns
the alwaysRevalidate
-
setAlwaysRevalidate
public static void setAlwaysRevalidate(boolean aAlwaysRevalidate) By default lists don't revalidate on every change to avoid "jumpiness" when scrolling
Parameters
aAlwaysRevalidate: the alwaysRevalidate to set
-
isDefaultMaintainAspectRatio
public static boolean isDefaultMaintainAspectRatio()Returns
the defaultMaintainAspectRatio
-
setDefaultMaintainAspectRatio
public static void setDefaultMaintainAspectRatio(boolean aDefaultMaintainAspectRatio) Parameters
aDefaultMaintainAspectRatio: the defaultMaintainAspectRatio to set
-
getDefaultTimeout
public static int getDefaultTimeout()Indicates the default timeout to use for image download service, -1 indicates no default is set.
Returns
the defaultTimeout
-
setDefaultTimeout
public static void setDefaultTimeout(int aDefaultTimeout) Indicates the default timeout to use for image download service, -1 indicates no default is set.
Parameters
aDefaultTimeout: the defaultTimeout to set
-
createImageToFileSystem
public static void createImageToFileSystem(String url, List targetList, int targetOffset, String targetKey, String destFile, Dimension toScale) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
destFile: local file to store the data into the given path
-
-
createImageToFileSystem
public static void createImageToFileSystem(String url, Component targetList, int targetOffset, String targetKey, String destFile, Dimension toScale, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
destFile: local file to store the data into the given path
-
-
createImageToFileSystem
public static void createImageToFileSystem(String url, Component targetList, int targetOffset, String targetKey, String destFile, Image placeholder, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
destFile: local file to store the data into the given path
-
-
createImageToFileSystem
public static void createImageToFileSystem(String url, Component targetList, ListModel model, int targetOffset, String targetKey, String destFile, Image placeholder, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
model: the list model -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
destFile: local file to store the data into the given path
-
-
addErrorListener
Binds an error listener that will fire an instance of NetworkEvent with an error for a specific fetch operation if applicable
Parameters
listener: the listener
-
removeErrorListener
Unbinds an error listener that will fire an instance of NetworkEvent with an error for a specific fetch operation if applicable
Parameters
listener: the listener
-
createImageToStorage
public static void createImageToStorage(String url, List targetList, int targetOffset, String targetKey, String cacheId, Dimension scale) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
cacheId: a unique identifier to be used to store the image into storage -
scale: the scale of the image to put in the List or null
-
-
createImageToStorage
public static void createImageToStorage(String url, Component targetList, int targetOffset, String targetKey, String cacheId, Dimension scale, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
cacheId: a unique identifier to be used to store the image into storage -
scale: the scale of the image to put in the List or null
-
-
createImageToStorage
public static void createImageToStorage(String url, Component targetList, int targetOffset, String targetKey, String cacheId, Image placeholderImage, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
cacheId: a unique identifier to be used to store the image into storage -
placeholderImage: the image placeholder
-
-
createImageToStorage
public static void createImageToStorage(String url, Component targetList, ListModel model, int targetOffset, String targetKey, String cacheId, Image placeholderImage, byte priority) Constructs an image request that will automatically populate the given list when the response arrives, it will cache the file locally as a file in the file storage. This assumes the GenericListCellRenderer style of list which relies on a map based model approach.
Parameters
-
url: the image URL -
targetList: the list that should be updated when the data arrives -
model: the model destination -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the map in the target offset -
cacheId: a unique identifier to be used to store the image into storage -
placeholderImage: the image placeholder
-
-
createImageToStorage
Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally to the Storage
Parameters
-
url: the image URL -
l: @param l the Label that should be updated when the data arrives to just use storage and the url as the key -
cacheId: a unique identifier to be used to store the image into storage -
toScale: the scale dimension or null
-
-
createImageToStorage
public static void createImageToStorage(String url, Label l, String cacheId, Dimension toScale, byte priority) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally to the Storage
Parameters
-
url: the image URL -
l: @param l the Label that should be updated when the data arrives to just use storage and the url as the key -
cacheId: a unique identifier to be used to store the image into storage -
toScale: the scale dimension or null -
priority: the priority for the task
-
-
createImageToStorage
public static void createImageToStorage(String url, Label l, String cacheId, Image placeholder, byte priority) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally to the Storage
Parameters
-
url: the image URL -
l: @param l the Label that should be updated when the data arrives to just use storage and the url as the key -
cacheId: a unique identifier to be used to store the image into storage -
placeholder: the image that will appear as a placeholder -
priority: the priority for the task
-
-
createImageToFileSystem
Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally.
Parameters
-
url: the image URL -
callback: the callback that should be updated when the data arrives -
destFile: local file to store the data into the given path
-
-
createImageToStorage
-
createImageToStorage
public static void createImageToStorage(String url, ActionListener callback, String cacheId, boolean keep) Constructs an image request that will automatically populate the given Label when the response arrives, it will cache the file locally.
Parameters
-
url: the image URL -
callback: the callback that should be updated when the data arrives -
cacheId: a unique identifier to be used to store the image into storage -
keep: if set to true keeps the file in RAM once loaded
-
-
setEntryInListModel
This method is invoked when an image finished downloading and should be set to an offset in the list model. This is useful for special cases with complex list model hierarchies or proxies.
Parameters
-
offset: the offset in the list given when creating the service -
img: the image
-
-
handleException
Handles an exception thrown when performing a network operation, the default implementation shows a retry dialog.
Parameters
err: the exception thrown
- Overrides:
handleExceptionin classConnectionRequest
-
handleErrorResponseCode
Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)
Parameters
-
code: the response code from the server -
message: the response message from the server
- Overrides:
handleErrorResponseCodein classConnectionRequest
-
-
postResponse
protected void postResponse()A callback method that's invoked on the EDT after the readResponse() method has finished, this is the place where developers should change their Codename One user interface to avoid race conditions that might be triggered by modifications within readResponse. Notice this method is only invoked on a successful response and will not be invoked in case of a failure.- Overrides:
postResponsein classConnectionRequest
-
readResponse
Callback for the server response with the input stream from the server. This method is invoked on the network thread
Parameters
input: the input stream containing the response
Throws
IOException: when a read input occurs
- Overrides:
readResponsein classConnectionRequest- Throws:
IOException
-
getResult
Returns the image returned from the server, this method is useful for renderers
Returns
the result
-
isDownloadToStyles
public boolean isDownloadToStyles()Downloads the image to the style objects associated with this component, effectively sets the bgImage property on all the styles for the component instead of invoking setIcon
Returns
the downloadToStyles
-
setDownloadToStyles
public void setDownloadToStyles(boolean downloadToStyles) Downloads the image to the style objects associated with this component, effectively sets the bgImage property on all the styles for the component instead of invoking setIcon
Parameters
downloadToStyles: the downloadToStyles to set
-
equals
Indicates whether some other object is "equal to" this one. The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false. The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).- Overrides:
equalsin classConnectionRequest
-
hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables. As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)- Overrides:
hashCodein classConnectionRequest
-
isMaintainAspectRatio
public boolean isMaintainAspectRatio()Returns
the maintainAspectRatio
-
setMaintainAspectRatio
public void setMaintainAspectRatio(boolean maintainAspectRatio) Parameters
maintainAspectRatio: the maintainAspectRatio to set
-