How to load images with a delay?

Let's say I have a JSON from an HTTP request. The JSON contains several JPG and text links.

For each JPG link and text, I want that they be displayed in a field like that.

And here is the code in the field:

public ProductField extends Field {

    String text;
    Bitmap bmp

    public CustomField(String text, String imageURL){
        bmp = Bitmap.getBitmapResource("blank.png");
    }

    public void paint(Graphics g){
        //....
    }

    public void updateBitmap(String url){
        bitmap = BitmapUtil.loadBitmapFromURL(url);

        // draw the bitmap on XYRect
        dest = new XYRect(0, 0, bitmap.getWidth(), bitmap.getHeight());
        invalidate();
    }
}

I realize that load images takes time, so I don't load them immediately. I have only to load the text and display an empty bitmap in the bitmap field. The actual bitmap will be charged when the updateBitmap() method is called.

And here's how to add these field on the screen (not a 100% valid code, but I hope you will illustrate the idea)

VerticalFieldManager vfm = new VerticalFieldManager

// an array of bitmap URLS, which will be loaded later
final String[] urls = new String[json_array_size];

for (int x = 0; x < json_array.size; x++){
    CustomField field = new CustomField(..);

    // store bitmap URLs in array
    urls[x] = json_array.getJSONObject(x).getString("url");
    vfm.add(field);
    vfm.add(new SeparatorField());
}

Thread t = new Thread( new Runnable() {
    public void run() {
        for(int i = 0; i < len;i += 2) {
            synchronized(UiApplication.getEventLock()) {
                CustomField cf = (CustomField) vfm.getField(i);
                cf.updateBitmap(urls[i]);
           }
            try{
                Thread.sleep(2000);
            }
            catch(Exception e){ }
            }
        }
});

Seems that all the images are loaded simultaneously. What I want is something like:

display bitmap #1-2 seconds of delay - display bitmap #2 - delay 2 sec - display bitmap #3 - delay 2 sec etc..

How to solve this problem?

You can remove the block synchronized as you don't make any changes to the user interface, you read a value of a UI element.
About your son, I can't get started, maybe a start() would help. do not race

Tags: BlackBerry Developers

Similar Questions

  • How to load images into layers or project

    How to load images into layers or projects.  I know how to use open to open a picture, but I was looking for a way load an image to resize to fit in a specific part of a layer or load an image, then one more.

    Yes, a script would be best for what you want to do, but you might be able to do it with an action. I haven't used actions too because I prefer scripting.

  • How to drag images with Dreamweaver CS6?

    How to drag images with Dreamweaver CS6? Please teach me.

    Dreamweaver has no functionality built int to create a slideshow (there no Slide Show behavior for example), then you either have to get the code from a third party source, or write it yourself.

    The simplest script slideshow I met is jQuery Cycle2.

  • How to load images synchronously

    Hi all

    I want a lot of cache images locally with URLLoader and want to know those fails. I can add event listener IOErrorEvent.IO_ERROR.

    A variable can be used to save the filename I want to load the last time. Then in the error handler, I know which file is not loaded correctly.

    However, as the images are loaded asynchronously, i.e. how URLLoader, the first loaded image can not at first filled. This means that the variable contains the wrong file name.

    Is there a better way to approach? I want to just connect the loads of the error.

    Kind regards

    Felix

    If you really want to load synchronously, just load image by image in sequence. In the Event.COMPLETE and image 1 IOErrorEvent.IO_ERROR headphones, put an invocation to load the image 2 and so on. Therefore, you can keep the order of the images.

  • How the loading image in as3 without XML?

    Hey Hi,

    Can someone help me please, I want to load image wihout using XML.

    How can I do this?

    Thank you


    JaxNa

    The only thing you need XML for is to load in a list of images... it isn't as you need. You load images and swf with a Loader object files - and there is a lot of info in the help. In short, if you can simply do:

    var myLoader:Loader = new Loader();

    myLoader.load (new URLRequest ("myimage.jpg"));

    addChild (myLoader);

  • Error "Unable to load image" with iphone app of Lightroom

    I just downloaded the app and when I click on for my camera to import photos from my new collection "iPhone", I get an error "unable to load image". Someone else has had this problem and know how to fix? I could get a single photo to finally take as if by magic, but other 835 photos give this error when I try and select them. Thanks for your help!

    Hi Ryan,

    I have a few questions to understand the question.

    This happens to all your property or only some?

    Does it occur only on a single device (if you have several), what device you are on by knowing this?

    Have you managed to import all of your camera.

    You take the images of a specific album? If so, can you tell us a little of the assets inside the album?

    It helps to look at this image from the Photos app and a new attempt to import?

    Thank you

    Ignacio

  • How to load images dynamically in Flash

    I have a clip on the stage I want to dynamically load images in (constantly changing), how can I get it? Thank you.

    Use the Loader class to load in images.

    Then use addChild to add the class Loader in your MovieClip on the stage.

    That & quot; constantly change & quot; What do you mean by that? You can use setInterval, ther enterFrame event or any other way to trigger a new image to load into the loader instance.

    Finally, you can use the Tween class to create some nice effects for images (fade, blur in the picture mix, masks, etc.)

  • loading image with loadMovie

    Load a picture to a clip (name container) using loadMovie I'm loading the clip image is resized to the size of the loaded image, is there a way to avoid that from happening? I want the clip to its original size.

    Thank you for your help,

    Loaded images or SWFs inherit only position, rotation, and scale. They load
    to their original size well. If you want to resize to fit one
    particular field, you'll need to do it with As first of all, you need to stop
    Use loadMovie instead and use the MovieClipLoader class. You should be
    using it in any case, it's better.

    Simple example that loads an image of my C: drive in a clip named "hold."

    var myLoader = new MovieClipLoader();
    var LIS = new Object();
    lis.onLoadInit = function (targ:MovieClip) {}
    Targ._width = 83;
    Targ._height = 119;
    }
    myLoader.addListener (DSL);
    myLoader.loadClip ("c:/dm_phillips_2005.jpg", hold);

    --
    Dave-
    Developer leader
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.Adobe.com/communities/experts/

  • How to load images into different frames on a movieclip? And the creation of a clip empty?

    I want to be able to load external images into different frames in a movieclip and then to control inside the code. To do this, I need to know how to create a movieclip empty with a quantity of images can I specify in the code and how to put different pictures on different periods of the movieclip. How can I do this?

    When you create a movieclip in actionscript, it contains an image and there is no way to change/increase.

    You can create a movieclip with several images in the authoring environment and do what you want, but I don't know that makes a lot of sense.

  • How to load images into memory

    I want to get the jpg of my webcam

    yesterday thanks to you

    I loaded jpg to the Simulator

    , but it has been imported to res java project

    How can I load the jpg into memory and read from the memory in the bb?

    If you know, or you know some post

    hot please answer T T

    This article will tell you how to read the jpg file in your project in memory.

    How - to add plain text or binary files to an application
    Article number: DB-00148
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To _...

    Then, you must convert the bytes into something that the BlackBerry can handle.  To do this, you use:

    EncodedImage.createEncodedImage (.);

    Now you get to get a Bitmap image, whose form the BlackBerry uses to display images on the screen.  This encodedImage object, you have created in the previous step and be used to get the bitmap image, simply use the

    getBitmap()

    method

    Now, the screen BlackBerry fields on the screen, so you must create a field for display, a BitmapField and tell him to use the bitmap image that you created.  It's easy, you just build a new BitmapField:

    BitmapField (bitmap Bitmap)

    Finally, you add the BitmapField to the screen you are viewing.

    There are shorter ways to do this, if you create a png rather than jpg images.

  • How to load images in the 'People' app that has all my contacts and a lot of white sillouettes. Very frustrating! Rodcliff

    I tried every way I can think to get photos in this app and all the photos that I need are on the same computer, in 'Photos' photography only in that I can put my own photo account. None of the settings or the app command bar downstairs offer me the option. I'm stuck.

    Hello

    Thanks for posting your question on the Forums of community of Microsoft. We are here to help you with all your Windows questions or issues.

    You mentioned that you are unable to load the photos to the App to people with all your contacts in it and it is showing a white figure some of these contacts.

    What exactly are you trying to do? You try to set pictures to your contacts, showing the white figure?

    If you try to put photos of your contacts, showing the white figure in the people App, then I'm sorry to inform you that this can be done with the people App. This is because; the people App does not work like the other application to management of Contact where the contacts are stored in a local file on the computer. In People Soft, contacts are not saved to a local file. It is linked with the online account of that special person that you added to the App people.

    For example, if you add your Facebook account to the people App, all contacts that it will be shown in the people App, but they are not saved locally. It is just linked to your Facebook account. Thus, the image of a particular contact will change unless the account holder he spends his account.

    For more information on the application of people, you can visit these links:

    People soft for Windows: frequently asked questions

     

    http://Windows.Microsoft.com/en-us/Windows-8/people-FAQ

     

    Socialize and stay in touch

     

    http://Windows.Microsoft.com/en-us/Windows-8/people-social

    Hope this information is useful. You can publish all your queries related to Windows on Microsoft Community Forum and we will be happy to help you.

  • How Lightroom handles images with a color profile in fact?

    Since the relevant help page:

    Lightroom simplifies color management by displaying colors using the device independent color spaces. This means that all you need to do before working in Lightroom is to calibrate your monitor. Then, when you're in Lightroom, choose color or color profiles settings when you are ready to output your photos. (In Lightroom color management )

    So. What actually happens? If a picture has, say, a Nikon sRGB profile not LightRoom it converted Adobe RGB (for the library module) and ProPhoto RGB for module progress? This seems to be the implication of the documentation, but it says nothing about a conversion.

    Basically, my question is - it recognizes the supplied profile?

    justinw86398615 wrote:

    Thanks by.

    While SHIPS go as you seem to say that indeed there is no color profile. Lightroom is just reads the raw data and assigns the ProPhotoRGB profile? There is no conversion. Values in only digital pixels?

    Right, there is no color profile. But something must be used to interpret the NAVE while converting from a raw file (just a bunch of values of levels of grey) typical, to become a recognizable RGB image. Read the digital pixel values is not enough without some sort of reference, and an ICC profile does not work on a raw file, so what happens is:

    Lightroom processes the raw numbers thanks to Adobe by default camera profile for your Nikon camera model. A profile of the camera is not the same as an ICC profile. This camera profile determines the initial appearance and the colors of an image raw before other development parameters are changed, so if you don't like the default look, you can choose a different camera (if available) profile or create your own. You can change the profile of the camera in the tab Calibration of the camera at the bottom of the right side of the develop module. Adobe camera profiles produce a look that is close, but not exactly what you would get showing the NEF in Nikon software or the raw file JPEG preview.

    After this initial conversion based on the camera profile, Lightroom will apply other settings default development module. In Lightroom, the result of this exists in the built-in color space Lightroom (ProPhoto RGB with curve of tone as sRGB) and then, finally, you see the end result through your (if all goes well to date) display the ICC profile.

    Thus, how your look of naves in Lightroom before editing it is affected by camera Adobe profile + default develop settings.

  • I downloaded El Capitan. Now how to load images to bridge?

    I had no problem before downloading, and Apple isn't going to help. I got my card from my 6 d and to the bridge it is said it can not read this device and I have no idea how to download the images. Please can you help me?

    Hello

    See Bridge and El Capitan . There are a few known issues with sending images in MAC OS X 10.11.

    Concerning

    Assani

  • How to create images with accents of glitter animation in Photoshop cs6?

    I'm new to photoshop; using paint shop pro 9 for years, however I wanted to accelerate my game to new levels with my creativity.

    I'm also autistic, and while I learn relatively fast, I learn better at a much faster pace through visuals with verbal instructions

    I have've always wanted to learn how to add glitter to text and images as accents. I found a great video on adding glitter animation to text, but I was wondering how I would go about adding accents of glitter to pictures for the pop and give them more life that is unique and special in a way that is easy for me to kiss?

    If anyone has a video tutorial that is clear and concise through each step of the process that you want to share with me, that would be great.

    YouTube has been cut in and out a lot, make my browsers crash so if you have another medium I can look (and even possibly download the tutorial on my desk) for easy access, it would be even better

    Thank you very much

    Hi luna_lysithea,

    Could you please check the below link that might help:

    How to make glitter animated graphics on Photoshop - YouTube

    How to add a glittering in Photoshop effect: 12 steps

    Concerning

    Sarika

  • How to load xml with base64 big element using sqlldr

    Hello
    I'm trying to load xml data into Oracle 10 g 2. I want to use tool standard sqlldr if possible.
    (1) I recorded my schema successfully:
    -Put the 6kbytes schema in a table
    - and
    DECLARE
    schema_txt CLOB.
    BEGIN
    SELECT the text IN schema_txt patterns;
    DBMS_XMLSCHEMA.registerschema ("uddkort.xsd", schema_txt);
    END;
    -Success: I can create table like:
    CREATE TABLE XMLTYPE XmlTest
    XMLSCHEMA 'uddkort.xsd '.
    ELEMENT 'profile '.
    ;
    -USER_XML_TABLES shows:
    XMLSCHEMA, SCHEMA_OWNER, NOM_ELEMENT, TABLE_NAME, STORAGE_TYPE
    "XMLTEST", "uddkort.xsd", "THISE", "profile", "OBJECT-RELATIONAL".

    (2) how can I load XML data into that?
    -An element of the schema is < xs: element name = "billede" type = "xs: base64Binary" minOccurs = "0" / >
    -This data field may be 10kbytes or more

    I tried many control files - search the net but no luck so far.
    Any suggestions?
    / Christmas, DK

    I regret - it seems, Miss me some basic understanding here (XBD is new to me...):

    Reread this part of the documentation on the XML to mappings of SQL types:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14259/xdb05sto.htm#sthref831

    When you save the relational storage schema object, Oracle creates SQL object types to support the underlying structure.
    In particular (see table 5-6 in the link), XS: base64Binary is mapped to a compatible SQL binary data type: RAW (default), or BLOB (if we use the annotation).

    In my example, the generated object type is:

    SQL> desc "image888_T"
     Nom                                       NULL ?   Type
     ----------------------------------------- -------- ----------------------------
     SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
     name                                               VARCHAR2(4000 CHAR)
     content                                            BLOB
    

    I don't understand how this can be (is) done automatically?

    When you load an XML instance in the table, the contents of the string encoded in base64 is automatically converted into format binary original and stored as a BLOB (that's works the mapping).
    Then, when you run:

    select extractvalue(t.object_value, '/image/content') from images_table t;
    

    It follows a BLOB column containing the original image, not the string base64, so you won't need a converter.

Maybe you are looking for