Problem with image extract the content and the tile at the same time show on ListField

My application is Application News get JSON webservice to appear on ListField.

On each line in the list, it will show you the image thumbnail, title and Teaser as below.

_______________________________________

|                |                       Title

|   Thumb  |_______________________________

|_______  |                       Teaser

First of all, I have to get JSON that contains the url of the thumbnail image, title and Teaser.


I managed to view the title and Teaser, but the thumbnail is not. When I Fetch image with the url of the thumbnail image, it returns only bitmap = null for me.

My method is first call httpdispatcher to get the thumbnail image, title and Teaser and then wait and call another httpdispatcher to retrieve the url of the image thumbnail, then added to listfield.

Here is my code

Class helloScreen{

public void requestSucceeded(byte[] result, String contentType)   {      if (contentType.equals("image/png") ||        contentType.equals("image/jpeg") || contentType.equals("image/gif") ||contentType.equals("image/jpg")) {         bitmap_temp = Bitmap.createBitmapFromBytes(result, 0, result.length, 1);                     synchronized (UiApplication.getEventLock()) {

               }         }         else if (contentType.startsWith("text/")) {

              strResult = new String(result);

             try {                     ja = new JSONArray(strResult);

              } catch (JSONException e) {                   // TODO Auto-generated catch block                    e.printStackTrace();              }

           synchronized (UiApplication.getEventLock()) {
                              int temp_int_next=0;
                try {
                    callback.erase();
                     for(int x=0;x<10;x++){

                         j = (JSONObject) ja.get(x);

 String get_htmlOff_first = j.get("teaser").toString().substring(j.get("teaser").toString().indexOf(">")+1);
 final String thumb = replace(j.get("thumb").toString(),"files/","http://www.eng.chula.ac.th/files/");

                                UiApplication.getUiApplication().invokeAndWait(new Runnable() {

                                public void run() {

                       getImageURL(thumb); 

                             }});                      

callback.insert(j.get("title")+" ", ""+get_htmlOff_first.trim(), bitmap_temp , temp_int_next , "Event");                      temp_int_next++;

                  }

                   } catch (JSONException e) {                  // TODO Auto-generated catch block                    e.printStackTrace();              }               

            }         }         else {            synchronized (UiApplication.getEventLock()) {         Dialog.alert("Unknown content type: " + contentType);         }         }


public void getImageURL(String url) {                HttpRequestDispatcher dispatcher2 = new HttpRequestDispatcher(url,                "GET", this);    }

}

httpRequest, class Dispatcher is used to get the data from the url

public HttpRequestDispatcher(String url, String method, helloScreen screen)
{
this.url = url;
this.method = method;
this.screen = screen;

}

public String getType(){

    return type;

}

public void run() {
    try {

        if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
       {
            connection = (HttpConnection)Connector.open(url+";interface=wifi");
     }else{

        String uid = getWap2Uid();
        connection = (HttpConnection)Connector.open(url+";deviceside=true;ConnectionUID=" + uid);

        }

    connection.setRequestMethod(method);

    connection.setRequestProperty("Accept","text/html, image/jpg, image/jpeg, image/,image/gif");

    int responseCode = connection.getResponseCode();
    if (responseCode != HttpConnection.HTTP_OK) {
    screen.requestFailed("Unexpected response code: " + responseCode);
    connection.close();
    return;
    }
    final String contentType = connection.getHeaderField("Content-type");
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream responseData = connection.openInputStream();
    byte[] buffer = new byte[10000];
    int bytesRead = responseData.read(buffer);
    while(bytesRead > 0) {
    baos.write(buffer, 0, bytesRead);
    bytesRead = responseData.read(buffer);
    }
    baos.close();
    connection.close();

              UiApplication.getUiApplication().invokeAndWait(new Runnable() {

                    public void run() {

                        screen.requestSucceeded(baos.toByteArray(), contentType);

                    }

                    });

    } catch (IOException ex) {
    screen.requestFailed(ex.toString());
    }
}

The point here is that I have JSON and get the url of the thumbnail to fetch before add to listfield. The image should be ready in bitmap_temp but it still get null.

UiApplication.getUiApplication().invokeAndWait(new Runnable() {

                               public void run() {

                       getImageURL(thumb); 

                             }});
public void getImageURL(String url) {                HttpRequestDispatcher dispatcher2 = new HttpRequestDispatcher(url,                "GET", this);    }
callback.insert(j.get("title")+" ", ""+get_htmlOff_first.trim(), bitmap_temp , temp_int_next , "Event");

All day trying to fix it but no success, so I need help from you guys.

Thank you

"Is it possible to leave only 1 thread completely pick 10 pictures.

Yes and this is how I would recommend that do you it this way.  So have a Thread that you give a list of things to do and let it work through each.

Tags: BlackBerry Developers

Similar Questions

  • How to open two different images at the same time to work on it together please?

    Please help, I am at a loss to open the two images at the same time to work together on them. can someone help please

    I suspect that, in this point of you familiar with the functionality of Photoshop, you may prefer the following:

    Choose Preferences > Interface > and uncheck open as tabs Documents

    Then, when you open two images they both will appear on the screen.

    At a later time, you may want to work with her alternate: the tabs option.

  • Resizing of the images at the same time

    I have a lot of images I want to resize. The images are all rectangles and same size. I want the images to be smaller and square. Is there a quick way to do it with all the images at the same time?

    If your native images are rectangles and square, you must use the crop tool to get the defined areas. Otherwise, your images will appear distorted.  Unfortunately, batch cropping rarely works well less that all the images are perfectly framed and centered.  From my experience, cropping requires human judgment.

    That said, you can create a crop tool Preset (size & resolution) that can help further your workflow.

    Nancy O.

  • How to display multiple images at the same time in CS6?

    How to display multiple images at the same time in CS6?

    Hello

    If you go to window > reorganize you can choose from several display options. Below, I have chosen two horizontal spaces since I have two images, but you can select other options if you have more than one image.

  • In Acrobat XI, how can I select and move multiple blocks of text/image at the same time on the same page?

    I work with PDF files generated by student requiring all content in a specific range of margin. Occasional tables and figures are indented or otherwise properly spaced so that the content violates the margin requirement. In Acrobat X, I could use the selection tool to draw a selection rectangle around all text and lines of a table for example and just drag the entire table over a little to meet the requirements without referring the PDF to the author for correction. It did not always work, but quite often that I was able to use it on a daily basis.

    Is it possible to select several (but not ALL) blocks of text and image on a page pieces, so they may be submitted at the same time? If I have to select each text block and lines (or each point and in a chart) and move them each individually, it's going to be a nightmare.

    I have Acrobat XI for Mac and Windows, but tend to use the version of Windows more often.

    People have reported what happens when preview of the output (I think) window is open. So you can close.  have not heard of another fix

  • How to hide a control and change a background image at the same TIME

    Hello

    I made a slideshow on LabView VI, who also monitors data in real time to a data logger.

    The program works like this: -.

    Start/Page 1:-bottom pane displays a nice screenshot. A set of indicators displays the data in real time. Switches to Page 2 after 20 seconds.

    Page 2:-background to an another screenshot. Hide indicators in real time and a set of three graphs appear, displaying historical data. Switches after 20 years.

    Page 3 etc:-hide charts and indicators, a 'slide show' appears by changing the history pane. Back to page 1 after the sequence.

    Everything works fine, except for one thing: I can't hide indicators and background to change at once, resulting in a clumsy "discrepancy" between the two.

    I did one VI example to illustrate this. Simply select two separate images to the façade, run the VI and toggle the Boolean control to see what I mean.

    Any idea how to get indicators and background of change at the same time?

    Thanks in advance,

    Hello

    Hi Jin,

    have you tried to "DeferPanelUpdates" when you power on? This is a property of the component...

    So David value = TRUE, do all the switching, to redefine Defer to FALSE!

  • Play video and display an image at the same time

    Hi all

    I'm new to JavaFX and I would like to know if it is possible to read a video simultaneously and display an image above him in the same scene.

    In particular, I want the image to display in a fixed position.

    I tried to use a StackPane layout, but I get an error in the following line:

    sp.getChildren().add(mediaPlayer);
    

    because the mediaPlayer object cannot be considered to be a parameter and a node object is necessary

    I also tried to add the video and the image in the same scene as seen below, without success (the video is playing, but the image is not displayed)

    root.getChildren().add(imageView);
    

    Is what I'm trying to do possible? And if so, what methods should I use?

    Thanks in advance for any answer!

    I tried to use a StackPane layout, but I get an error in the following line:

    1. sp.getChildren () .add (mediaPlayer);

    because the mediaPlayer object cannot be considered to be a parameter and a node object is necessary

    Wrap the mediaPlayer in a MediaView and add the media view to the container. Do not use a group as the component root as in the code example in the example, though.

    I also tried to add the video and the image in the same scene as seen below, without success (the video is playing, but the image is not displayed)

    I think it is because you are using a StackPane, that stacks on top of the other nodes (in the Z-order); so if you add the video first it will be hidden by the image. Use a different presentation pane: VBox is the simplest. The tutorial has a summary of all the components of integrated layout .

    If you are going to do something like this:

    public void start(Stage primaryStage) {
         Media media = new Media(...);
         MediaPlayer player = new MediaPlayer(media);
         MediaView mediaView = new MediaView(player);
    
         Image image = new Image(...);
         ImageView imageView = new ImageView(image);
    
         VBox root = new VBox(5);
         root.getChildren().add(mediaView);
         root.getChildren().add(imageView);
    
         Scene scene = new Scene(root);
         primaryStage.setScene(scene);
         primaryStage.show();
    }
    
  • Animate multiple images at the same time

    I use Photoshop CS5 Extended. I did successfully interpolation when I did only a single object on a layer, but when I want to move more than one object, it does not work.

    Example:

    I have a layer with an object (say, a circle), it is frame one. I copy this image in the animation window. In the second frame, I move the circle. I tween these two frames and everything works fine.

    If I have TWO circles on a single layer, the one frame. I copy this image. In the second frame, I move one or both, circles and it changes circles in the first image as well. Thus, interpolation will not work.

    Is it possible to have multiple images Animate at the same time? So instead of one circle movement from left to right, I could also have a circle moving from top to bottom at the same time? Perhaps executives piled as a timeline? Any ideas?

    Thanks in advance.

    If I have TWO circles on a single layer,

    Not like that. They must be each on separate layers and more, animate you in 'bar' mode and only convert to executives at a later stage (in the interest of efficiency).

    Mylenium

  • FBus Monitor may not work with Configurator at the same time

    I am using NI USB-8486 material and I can get Fbus Configurator work on it. But whenever I run the FBus monitor, the Configurator will go wrong. (Device on the Fbus become invalid)

    I checked the Configuration OR-FBUS Interface utility, I have seen that the use of the port can be either OR-FBUS or Bus-monitor.  Since the USB-8486 only has a port, it means we can only support a single application (Configurator or monitor), instead of two at the same time?

    I'd appreciate any help!

    Hi Steve,.

    That's correct - USB-8486 can function as an interface device or monitor buses at the same time, and the role is configured in intensive care.

    If you want to have two roles at the same time work, you will need two NICs installed.

  • Problems with images after the subclips

    Hey there

    Today I woke up to see all subelements, I made my most recent project. Just today, footage looked more pixelated and blurry.

    What might of happened? When I stop the image the quality is exactly as it was before. But when played his more pixelated.

    Some of the images was shot at a lower resolution, but when I put the size of the screen to the appropriate resolution quality always looks bad.

    Would this have something to do with the manufacture of the subitems? Even go back and see the clips that came the subclips: the film is even more 'pixely '.

    Any help appreciated

    @

    Hi pavalanche11,

    Sorry for the problem. If it is fixed?

    Please consider these points for this problem:

    1. it looks in any case related to subitems.

    2 as you mentioned after a break the clips, they look very good, but not the same case playing; It could be linked to the resolution Pause and play in the monitor Panel.

    You can get these settings, either by clicking the exit button in the lower right of the monitor Panel or by right clicking on the items in the monitor Panel.

    3. you also said that you pulled these clips at a lower resolution. By changing the values in the resolution of reading as suggested above, they may work properly.

    Here is the text of pdf help Prelude:

    Some formats are difficult to display in full motion by reason of their high compression or broadband playback. A lower resolution playback faster but at the expense of the quality of the image. This compromise is particularly visible when you view the other H.264 and AVCHD-based codec of the media. Less than full resolution these formats have turned off error correction, and artifacts are common during playback. These artifacts, however, do not appear in the exported media.

    Use separate reading and resolutions of break to better control the monitoring experience. With images high resolution, resolution of the reading to a lower value (for example, 1/4) for smooth playback and the resolution of the break in full. These settings allow you to check the quality of the details of development or the edge when you stop playing. Cleaning put the monitor resolution of reading, stop no resolution.

    I hope it helps. Customer feedback is important to us. Continue to write in the case of any confusion.

    Thank you

    Mayjain

  • Scanning multiple images at the same time and you want to save everything in a single file, not separately

    I have the HP Envy 4500 model.  I also have a Windows 7 OS, HP.  My problem is that I put for example five images on the glass for scanning and I find myself with five different jpg files when I want all five images on a SINGLE scanned jpg file.  How to achieve this?  Thank you!

    Hello

    Please use the scanner software on your computer.

    Kind regards.

  • 2 problems that occurred at the same time - shift key & problem mouse

    I copied and pasted an email address into a new email.  Now, whenever I press the SHIFT key, it copies the same thing several times in the format of electronic mail and WORD.

    In addition, my mouse now I cannot hold the left key to highlight words.  Nothing happens.

    any suggestions are greatly appreciated.

    Thank you

    Hello


    1. What is the number of brands and models of mouse and keyboard?
    2. were there any changes (hardware or software) to the computer before the show?

    Perform operations by the items listed below and see if the problem persists.
    http://support.Microsoft.com/kb/258826
    http://support.Microsoft.com/kb/303091
     
    Note: Proceed as if you are using a Microsoft Keyboard and mouse.

    Hope this information helps.
  • How to set levels of several images at the same time?

    CS6 user, I scanned recently a few pages of an old black-and-white, Comics who, thanks to the passage of time, are now more black and beige.

    I know how to adjust the levels using the eyedropper tool, but is there a way to apply the same effect to multiple pictures in one go (i.e. adjust the levels of an image, and then apply the same effect to others as a batch of files), rather than by pressing ctrl + alt + l and save each image individually?

    Thank you

    Save the changes in the form of Action and run as a batch process using Image Processor (under the file menu)

  • Resize several Images at the same time?

    Someone told me that in an Adobe product (do not know if his PS) there is a way to resize multiple images simultaneously to the same size. I can't find a way to do this. Anyone has done this before, or is anyone know how?

    Thank you

    chavite wrote:

    I'm sorry! I have CS4.

    Ok

    • Do one of the following
    • Choose file > Scripts > Image Processor (Photoshop)

    • Choose Tools > Photoshop > image processor (bridge)

    Its use is fairly self-explanatory, but help says it all!

    http://help.Adobe.com/en_US/Photoshop/11.0/WSfd1234e1c4b69f30ea53e41001031ab64-7426a.html

  • Move multiple Images at the same time

    I am currently dragging a frame at a time to move between two project files. It would be nice to do several of them at once, as I do with topics in the topics/view tab.

    There is unfortunately no way to do this. You may want to present this as a feature request.

Maybe you are looking for

  • Hard drive Satellite Pro C650 problem

    Hi, a friend of mine's laptop in me to take a look because he wasn't starting. He was going straight to boot from the network map, so a little thought that it's a dead hard drive. Then, I checked the BIOS and as expected not detected HARD drive. Remo

  • HP Pavilion dv6265ca want to install XP

    Hi Pros, Comes to my HP Pavilion dv6265ca comes with Vista everything is OK but I still miss my XP I would install XP on this machine, I go through this forum and got what I need but my question to those who have already tried to install XP on this l

  • Norma 4000 waveform measurement

    Hello I have 4000 Norma connected via rs232 and I want to get the waveform of voltage in labview. Something like DSO. I can do this in NORMA View (which is developed in labview), but when I try to do in labview with lnopa01 v09 pilots it doesent work

  • KKKKK application fails to work even after the update of the latest graphic drivers

    I'm portable Inspiron 15R 7520 (SE) and I installed the kkkkk application that does not work even after updating to the latest drivers from the manufacturer, dell.  I also tried to run this application high performance, but it still does not work. I

  • Failure of Windows 8 install, now the Windows 7 product key is not recognized, because it was an upgrade only.

    After several attempts of downloaded installation windows 8, I ended up with a useless and made desktop resettlement using my windows disc 7. Now, the product key for my windows 7 is recognized as a key to upgrade only and does not have to satisfy to